Ejemplo n.º 1
0
void CMagicMissile::Create(const Vec3f & aeSrc, const Anglef & angles)
{
	SetDuration(ulDuration);
	
	eCurPos = eSrc = aeSrc;

	Vec3f e = eSrc;

	int i = 40;
	e.x -= std::sin(glm::radians(angles.getPitch())) * 50 * i;
	e.y += std::sin(glm::radians(MAKEANGLE(angles.getYaw()))) * 50 * i;
	e.z += std::cos(glm::radians(angles.getPitch())) * 50 * i;

	pathways[0].p = eSrc;
	pathways[5].p = e;
	Split(pathways, 0, 5, 50, 0.5f);

	for(i = 0; i < 6; i++) {
		if(pathways[i].p.y >= eSrc.y + 150) {
			pathways[i].p.y = eSrc.y + 150;
		}
	}

	fTrail = 0;

	iLength = 50;
	iBezierPrecision = BEZIERPrecision;
	fOneOnBezierPrecision = 1.0f / (float) iBezierPrecision;
	bExplo = false;
	bMove = true;

	ARX_SOUND_PlaySFX(SND_SPELL_MM_CREATE, &eCurPos);
	ARX_SOUND_PlaySFX(SND_SPELL_MM_LAUNCH, &eCurPos);
	snd_loop = ARX_SOUND_PlaySFX(SND_SPELL_MM_LOOP, &eCurPos, 1.0F, ARX_SOUND_PLAY_LOOPED);
}
Ejemplo n.º 2
0
void ARXDRAW_DrawEyeBall() {
	if(eyeball.exist == 0 || !eyeballobj)
		return;

	float d;

	if(eyeball.exist < 0) {
		d = (float)(-eyeball.exist)*( 1.0f / 100 );
		eyeball.exist++;
	} else if(eyeball.exist > 2) {
		d = (float)(eyeball.exist)*( 1.0f / 100 );
	}
	else
		return;

	Anglef angle = eyeball.angle;
	angle.setPitch(MAKEANGLE(180.f - angle.getPitch()));

	Vec3f pos = eyeball.pos;
	pos.y += eyeball.floating;

	Vec3f scale = Vec3f(d);
	Color3f rgb = Color3f::gray(d);
	
	RenderMaterial mat;
	mat.setDepthTest(true);
	mat.setBlendType(RenderMaterial::Additive);
	
	Draw3DObject(eyeballobj, angle, pos, scale, rgb, mat);
}
Ejemplo n.º 3
0
void CMagicMissile::Create(const Vec3f & startPos, const Anglef & angles)
{
	SetDuration(ulDuration);
	
	eCurPos = startPos;
	
	short i = 40.f;
	Vec3f endPos = startPos;
	endPos += angleToVectorXZ(angles.getPitch()) * (50.f * i);
	endPos.y += std::sin(glm::radians(MAKEANGLE(angles.getYaw()))) * (50.f * i);
	
	pathways[0] = startPos;
	pathways[5] = endPos;
	Split(pathways, 0, 5, 50, 0.5f);

	for(i = 0; i < 6; i++) {
		if(pathways[i].y >= startPos.y + 150) {
			pathways[i].y = startPos.y + 150;
		}
	}

	fTrail = 0;

	iLength = 50;
	iBezierPrecision = BEZIERPrecision;
	bExplo = false;
	bMove = true;

	ARX_SOUND_PlaySFX(SND_SPELL_MM_CREATE, &eCurPos);
	ARX_SOUND_PlaySFX(SND_SPELL_MM_LAUNCH, &eCurPos);
	snd_loop = ARX_SOUND_PlaySFX(SND_SPELL_MM_LOOP, &eCurPos, 1.0F, ARX_SOUND_PLAY_LOOPED);
}
Ejemplo n.º 4
0
glm::quat angleToQuatForExtraRotation(const Anglef & angle) {
	Anglef vt1;
	vt1.setYaw(angle.getRoll());
	vt1.setPitch(angle.getPitch());
	vt1.setRoll(angle.getYaw());
	
	return QuatFromAngles(vt1);
}
Ejemplo n.º 5
0
glm::mat4 toRotationMatrix(const Anglef & angle) {
	float yaw = glm::radians(angle.getYaw());
	float pitch = glm::radians(angle.getPitch());
	float roll = glm::radians(angle.getRoll());
	glm::mat4 rotateX = glm::eulerAngleX(yaw);
	glm::mat4 rotateY = glm::eulerAngleY(pitch);
	glm::mat4 rotateZ = glm::eulerAngleZ(-roll);
	return rotateZ * rotateX * rotateY;
}
Ejemplo n.º 6
0
Vec3f angleToVector(const Anglef & angle) {
	Vec3f cam_vector = angleToVectorXZ(angle.getPitch());
	
	float yaw = glm::radians(angle.getYaw());
	cam_vector.x *= std::cos(yaw);
	cam_vector.y = std::sin(yaw);
	cam_vector.z *= std::cos(yaw);
	
	return cam_vector;
}
Ejemplo n.º 7
0
void EERIE_TRANSFORM::updateFromAngle(const Anglef &angle) {
	float pitch = glm::radians(angle.getPitch());
	xcos = std::cos(pitch);
	xsin = std::sin(pitch);
	float yaw = glm::radians(angle.getYaw());
	ycos = std::cos(yaw);
	ysin = std::sin(yaw);
	float roll = glm::radians(angle.getRoll());
	zcos = std::cos(roll);
	zsin = std::sin(roll);
	
	glm::mat4 translation = glm::translate(glm::mat4(1), -pos);
	worldToView = toRotationMatrix(angle) * translation;
}
Ejemplo n.º 8
0
glm::quat angleToQuatForArrow(const Anglef & angle) {
	float aa = angle.getYaw();
	float ab = 90 - angle.getPitch();
	
	Vec3f front(0,0,1);
	Vec3f up(0,-1,0);
	
	front = VRotateZ(front, aa);
	front = VRotateY(front, ab);
	up = VRotateZ(up, aa);
	up = VRotateY(up, ab);
	
	glm::mat4x4 tmat;
	MatrixSetByVectors(tmat, front, up);
	return glm::toQuat(tmat);
}
Ejemplo n.º 9
0
//*************************************************************************************
// Converts euler angles to a unit quaternion.
//*************************************************************************************
glm::quat QuatFromAngles(const Anglef & angle) {
	float A, B;
	A = glm::radians(angle.getYaw()) * ( 1.0f / 2 );
	B = glm::radians(angle.getPitch()) * ( 1.0f / 2 );

	float fSinYaw   = glm::sin(A);
	float fCosYaw   = glm::cos(A);
	float fSinPitch = glm::sin(B);
	float fCosPitch = glm::cos(B);
	A = glm::radians(angle.getRoll()) * ( 1.0f / 2 );
	float fSinRoll  = glm::sin(A);
	float fCosRoll  = glm::cos(A);
	A = fCosRoll * fCosPitch;
	B = fSinRoll * fSinPitch;
	
	glm::quat q;
	q.x = fSinRoll * fCosPitch * fCosYaw - fCosRoll * fSinPitch * fSinYaw;
	q.y = fCosRoll * fSinPitch * fCosYaw + fSinRoll * fCosPitch * fSinYaw;
	q.z = A * fSinYaw - B * fCosYaw;
	q.w = A * fCosYaw + B * fSinYaw;
	return q;
}
Ejemplo n.º 10
0
bool Manage3DCursor(Entity * io, bool simulate) {
	
	arx_assert(io);
	
	if(BLOCK_PLAYER_CONTROLS)
		return false;

	float ag = player.angle.getYaw();

	if(ag > 180)
		ag = ag - 360;

	float drop_miny = (float)(g_size.center().y) - g_size.center().y * (ag * (1.f/70));

	if(DANAEMouse.y < drop_miny)
		return false;
	
	Anglef temp = Anglef::ZERO;

	if(io->ioflags & IO_INVERTED) {
		temp.setYaw(180.f);
		temp.setPitch(-MAKEANGLE(270.f - io->angle.getPitch() - (player.angle.getPitch() - STARTED_ANGLE)));
	} else {
		temp.setPitch(MAKEANGLE(270.f - io->angle.getPitch() - (player.angle.getPitch() - STARTED_ANGLE)));
	}
	
	EERIE_3D_BBOX bbox;
	for(size_t i = 0; i < io->obj->vertexlist.size(); i++) {
		bbox.add(io->obj->vertexlist[i].v);
	}
	
	Vec3f mvectx = angleToVectorXZ(player.angle.getPitch() - 90.f);
	
	Vec2f mod = Vec2f(Vec2i(DANAEMouse) - g_size.center()) / Vec2f(g_size.center()) * Vec2f(160.f, 220.f);
	mvectx *= mod.x;
	Vec3f mvecty(0, mod.y, 0);

	Vec3f orgn = player.pos;
	orgn += angleToVector(player.angle) * 50.f;
	orgn += mvectx;
	orgn.y += mvecty.y;

	Vec3f dest = player.pos;
	dest += angleToVector(player.angle) * 10000.f;
	dest += mvectx;
	dest.y += mvecty.y * 5.f;
	
	Vec3f pos = orgn;

	Vec3f movev = glm::normalize(dest - orgn);

	float lastanything = 0.f;
	float height = -(bbox.max.y - bbox.min.y);

	if(height > -30.f)
		height = -30.f;
	
	Vec3f objcenter = bbox.min + (bbox.max - bbox.min) * Vec3f(0.5f);
	
	Vec3f collidpos = Vec3f_ZERO;
	bool collidpos_ok = false;
	
	{
	float maxdist = 0.f;
	
	for(size_t i = 0; i < io->obj->vertexlist.size(); i++) {
		const EERIE_VERTEX & vert = io->obj->vertexlist[i];
		
		float dist = glm::distance(Vec2f(objcenter.x, objcenter.z), Vec2f(vert.v.x, vert.v.z)) - 4.f;
		maxdist = std::max(maxdist, dist);
	}

	if(io->obj->pbox) {
		Vec2f tmpVert(io->obj->pbox->vert[0].initpos.x, io->obj->pbox->vert[0].initpos.z);
		
		for(int i = 1; i < io->obj->pbox->nb_physvert; i++) {
			const PHYSVERT & physVert = io->obj->pbox->vert[i];
			
			float dist = glm::distance(tmpVert, Vec2f(physVert.initpos.x, physVert.initpos.z)) + 14.f;
			maxdist = std::max(maxdist, dist);
		}
	}
	
	Cylinder cyl2;
	const float inc = 10.f;
	long iterating = 40;

	cyl2.height = std::min(-30.f, height);
	cyl2.radius = glm::clamp(maxdist, 20.f, 150.f);
	
	while(iterating > 0) {
		cyl2.origin = pos + movev * inc + Vec3f(0.f, bbox.max.y, 0.f);

		float anything = CheckAnythingInCylinder(cyl2, io, CFLAG_JUST_TEST | CFLAG_COLLIDE_NOCOL | CFLAG_NO_NPC_COLLIDE);

		if(anything < 0.f) {
			if(iterating == 40) {
				CANNOT_PUT_IT_HERE = 1;
				// TODO is this correct ?
				return true;
			}

			iterating = 0;

			collidpos = cyl2.origin;

			if(lastanything < 0.f) {
				pos.y += lastanything;
				collidpos.y += lastanything;
			}
		} else {
			pos = cyl2.origin;
			lastanything = anything;
		}

		iterating--;
	}
	collidpos_ok = iterating == -1;
	
	}
	
	objcenter = VRotateY(objcenter, temp.getPitch());
	
	collidpos.x -= objcenter.x;
	collidpos.z -= objcenter.z;

	pos.x -= objcenter.x;
	pos.z -= objcenter.z;

	if(!collidpos_ok) {
		CANNOT_PUT_IT_HERE = 1;
		return false;
	}

	if(collidpos_ok && closerThan(player.pos, pos, 300.f)) {
		if(simulate) {
			ARX_INTERACTIVE_Teleport(io, pos, true);

			io->gameFlags &= ~GFLAG_NOCOMPUTATION;
			
			glm::quat rotation = glm::toQuat(toRotationMatrix(temp));
			
			if(SPECIAL_DRAGINTER_RENDER) {
			if(glm::abs(lastanything) > glm::abs(height)) {
				TransformInfo t(collidpos, rotation, io->scale);

				static const float invisibility = 0.5f;

				DrawEERIEInter(io->obj, t, io, false, invisibility);
			} else {
				TransformInfo t(pos, rotation, io->scale);

				float invisibility = Cedric_GetInvisibility(io);

				DrawEERIEInter(io->obj, t, io, false, invisibility);
			}
			}
		} else {
			if(glm::abs(lastanything) > std::min(glm::abs(height), 12.0f)) {
				Entity * io = DRAGINTER;
				ARX_PLAYER_Remove_Invisibility();
				io->obj->pbox->active = 1;
				io->obj->pbox->stopcount = 0;
				io->pos = collidpos;
				io->velocity = Vec3f_ZERO;

				io->stopped = 1;

				movev.x *= 0.0001f;
				movev.y = 0.1f;
				movev.z *= 0.0001f;
				Vec3f viewvector = movev;

				Anglef angle = temp;
				io->soundtime = 0;
				io->soundcount = 0;
				EERIE_PHYSICS_BOX_Launch(io->obj, io->pos, angle, viewvector);
				ARX_SOUND_PlaySFX(SND_WHOOSH, &pos);
				io->show = SHOW_FLAG_IN_SCENE;
				Set_DragInter(NULL);
			} else {
				ARX_PLAYER_Remove_Invisibility();
				ARX_SOUND_PlayInterface(SND_INVSTD);
				ARX_INTERACTIVE_Teleport(io, pos, true);

				io->angle.setYaw(temp.getYaw());
				io->angle.setPitch(270.f - temp.getPitch());
				io->angle.setRoll(temp.getRoll());

				io->stopped = 0;
				io->show = SHOW_FLAG_IN_SCENE;
				io->obj->pbox->active = 0;
				Set_DragInter(NULL);
			}
		}

		GRenderer->SetCulling(Renderer::CullNone);
		return true;
	} else {
		CANNOT_PUT_IT_HERE=-1;
	}

	return false;
}
Ejemplo n.º 11
0
	void add(std::string key, const Anglef value) {
		m_maxKeyLen = std::max(m_maxKeyLen, key.length());
		std::string valueStr = boost::str(boost::format("%4.2f %4.2f %4.2f") % value.getYaw() % value.getPitch() % value.getRoll());
		m_elements.push_back(std::pair<std::string, std::string>(key, valueStr));
	}
Ejemplo n.º 12
0
void CBless::Set_Angle(const Anglef & angle)
{
	m_yaw = angle.getPitch();
}