Exemplo n.º 1
0
void WireframeModel::SetRotation(float x, float y, float z)
{
	rotX = x;
	rotY = y;
	rotZ = z;
	UpdateWorldMatrix();
}
Exemplo n.º 2
0
Object3D::Object3D(ID3D10Device* device, std::string filename, D3DXVECTOR3 position, D3DXVECTOR3 lightPos)
	: mDevice(device), mEffect(NULL), mEffectShadows(NULL), mTechnique(NULL), mTechniqueShadows(NULL),
	  mVertexLayout(NULL), mFont(NULL), mPosition(position), mRotation(0.0f), mLightPosition(lightPos),
	  mVelocity(D3DXVECTOR3(1.2, 0.5, 0.8)), mFXEyePos(NULL), mFXLightPos(NULL), mFXWorld(NULL), 
	  mFXWorldViewProj(NULL), mFXShadowWVP(NULL)
{
	if(!Load(filename))
		return;

	mEffect = CreateEffect("Effect.fx");
	mEffectShadows = CreateEffect("EffectShadows.fx");
	CreateVertexLayout();

	mMatrixWorld = new D3DXMATRIX();
	D3DXMatrixIdentity(mMatrixWorld);

	D3DXVec3Normalize(&mVelocity, &mVelocity);
	mVelocity *= 30;

	UpdateWorldMatrix();

	mFXEyePos = mEffect->GetVariableByName("gEyePos")->AsVector();
	mFXLightPos = mEffect->GetVariableByName("gLightPosition")->AsVector();
	mFXWorld = mEffect->GetVariableByName("gWorld")->AsMatrix();
	mFXWorldViewProj = mEffect->GetVariableByName("gWVP")->AsMatrix();
	mFXShadowWVP = mEffectShadows->GetVariableByName("gWVP")->AsMatrix();
	
	for(std::map<std::string, Group>::iterator it = mGroups.begin(); it != mGroups.end(); ++it)
		it->second.Finalize(mDevice, mEffect);

	mFont = new GameFont(mDevice, "Times New Roman", 18);
}
Exemplo n.º 3
0
void WireframeModel::SetPosition(float x, float y, float z)
{
	posX = x;
	posY = y;
	posZ = z;
	UpdateWorldMatrix();
}
void VsJoint::UpdatePosition()
{	
	Vx::VxReal3 vPos;
	m_vxJoint->getPartAttachmentPosition(0, vPos);

	UpdateWorldMatrix();
	m_lpThisMI->AbsolutePosition(vPos[0], vPos[1], vPos[2]);
}
Exemplo n.º 5
0
void CTourist::YawPitchPos(float yaw,float pitch)
{	
	m_vAngle += D3DXVECTOR3(pitch, yaw, 0);
	ModifyAngle(m_vAngle.x);
	ModifyAngle(m_vAngle.y);

	UpdateWorldMatrix();

}
Exemplo n.º 6
0
void Box::Render(D3D *direct3D)
{
	/*Worldmatrisen uppdateras baserat på position och rotation*/
	UpdateWorldMatrix();

	direct3D->SetShader(m_shader);
	m_shader->SetVariable("worldMatrix", &worldMatrix, sizeof(m4));
	direct3D->ApplyConstantBuffers();
	direct3D->ApplyTexture(m_Texture, 0);

	direct3D->RenderMesh(m_mesh);

	return;
}
Exemplo n.º 7
0
void Obstacle::Render(D3D *direct3D)
{
	//direct3D->SetTexture(blabla)
	UpdateWorldMatrix();

	direct3D->SetShader(m_shader);
	m_shader->SetVariable("worldMatrix", &worldMatrix, sizeof(m4));
	direct3D->ApplyConstantBuffers();
	direct3D->ApplyTexture(m_Texture, 0);

	direct3D->RenderMesh(m_mesh);

	return;
}
Exemplo n.º 8
0
void CTourist::PrepairTour()
{
	m_vAngleVel	= D3DXVECTOR3(0,0,0);
	if ((m_pTourInfo == NULL)||(m_nNowTour < 0)||(m_nNowTour >= m_nNumTour))
		return;
	switch(m_pTourInfo[m_nNowTour].nType)
	{
	case 0x01:		//直线运动
		{
			D3DXVECTOR3 vDistance = m_pTourInfo[m_nNowTour].vTarget - m_vPos;
			m_fTimeTest = m_pTourInfo[m_nNowTour].fTime;
			m_fSpeed = /*(*/D3DXVec3Length(&vDistance)/* - 10)*//m_fTimeTest;
		}

		break;
	case 0x02:		//原地转动
		{
			D3DXVECTOR3 vTemp = m_pTourInfo[m_nNowTour].vTarget;
			D3DXMATRIX inverseOrt;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         		
			D3DXMatrixInverse(&inverseOrt, NULL, &m_mOrientation);
			D3DXVec3TransformCoord(&vTemp, &vTemp, &inverseOrt);
			m_fTimeTest = m_pTourInfo[m_nNowTour].fTime;
			float ang = CaculateYaw(&vTemp);
			ModifyAngle(ang);
			m_vAngleVel.y = ang/m_fTimeTest;
			ang = CaculatePitch(&vTemp);
			ModifyAngle(ang);
			m_vAngleVel.x = ang/m_fTimeTest;
		}
		break;
	case 0x08:		//面向圆心做圆周运动
		{
			D3DXVECTOR3 vTemp = m_pTourInfo[m_nNowTour].vTarget;// - m_vPos;
			D3DXMATRIX inverseOrt;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         		
			D3DXMatrixInverse(&inverseOrt, NULL, &m_mOrientation);
			D3DXVec3TransformCoord(&vTemp, &vTemp, &inverseOrt);
			float ang = CaculateYaw(&vTemp);
			m_vAngle.y += ang;
			ModifyAngle(m_vAngle.y);
			UpdateWorldMatrix();
			m_fTimeTest = m_pTourInfo[m_nNowTour].fTime;
			m_vAngleVel.y = m_pTourInfo[m_nNowTour].fAngle/m_fTimeTest;
		}
		break;
	default:
		break;
	}
}
Exemplo n.º 9
0
RigidBody3::RigidBody3(void) : Object3()
{
	// primary
	linearVelocity = vec3::Zero();
	forces = vec3::Zero();
	
	angularVelocity = vec3::Zero();
	torques = vec3::Zero();

	// constant
	elasticity = 0.8f;
	inverseMass = 1.0f;
	UpdateInertiaTensor();
	
	// derived
	UpdateWorldMatrix();
}
Exemplo n.º 10
0
void CTourist::YawPitchAt(float yaw, float pitch, D3DXVECTOR3 *vCenter)
{
	m_vAngle += D3DXVECTOR3(-pitch, yaw, 0);
	ModifyAngle(m_vAngle.x);
	ModifyAngle(m_vAngle.y);

	D3DXVECTOR3 vRadius = *vCenter - m_vPos;
	D3DXMATRIX mRot, mRotX, mRotY;
	D3DXMatrixRotationX(&mRotX, pitch);
	D3DXMatrixRotationY(&mRotY, yaw);
	D3DXMatrixMultiply(&mRot, &mRotY, &mRotX);
	D3DXVECTOR3 vTemp;
	D3DXVec3TransformCoord(&vTemp, &vRadius, &mRot);
	m_vPos += vRadius - vTemp;

	UpdateWorldMatrix();

}	
Exemplo n.º 11
0
bool Transform3DComponent::OnParentChange(const EventArgs &e)
{
	const EntityParentChangeEvent &event = static_cast<const EntityParentChangeEvent &>(e);

	BaseEntity* pParent = event.getParent();

	if (pParent != nullptr)
	{
		m_pParentTransform = pParent->GetComponentMgr()->GetComponent<Transform3DComponent>();
	}
	else
	{
		m_pParentTransform = nullptr;
	}

	UpdateWorldMatrix();

	return false;
}
Exemplo n.º 12
0
void RigidBody3::Update(real dt)
{
	// linear movement
	vec3 temp = forces * inverseMass * dt;

	linearVelocity = temp + linearVelocity;
	pos = 0.5f * temp * dt + linearVelocity * dt + pos;
	
	// angular movement
	temp = torques * modelMatrix.RotateFromLocalToGlobal(inverseInertiaTensor) * dt;

	angularVelocity = temp + angularVelocity;
	ori =  0.5 * quat(0, 0.5f * temp + angularVelocity) * ori * dt + ori;

	ori.Normalise();
	
	// update derived data
	UpdateWorldMatrix();
}
Exemplo n.º 13
0
void Actor::UpdateMatrix() {
	Entity::UpdateMatrix();
	UpdateWorldMatrix();
}
Exemplo n.º 14
0
types::Matrix44 & Actor::GetWorldMatrix() {
	if ( m_need_world_matrix_update )
		UpdateWorldMatrix();
	return m_actor_matrices.world;
}
void VsJoint::LocalMatrix(osg::Matrix osgLocalMT)
{
	m_osgLocalMatrix = osgLocalMT;
	m_osgFinalMatrix = m_osgLocalMatrix * m_osgChildOffsetMatrix;
	UpdateWorldMatrix();
}
Exemplo n.º 16
0
Matrix4 TransformComponent::GetWorldMatrix() 
{ 
	UpdateWorldMatrix();
	return m_WorldMatrix; 
}