当前位置: 首页>>代码示例>>C++>>正文


C++ Mat4x4类代码示例

本文整理汇总了C++中Mat4x4的典型用法代码示例。如果您正苦于以下问题:C++ Mat4x4类的具体用法?C++ Mat4x4怎么用?C++ Mat4x4使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Mat4x4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PxMatrixToMat4x4

void PhysXPhysics::VSyncVisibleScene()
{
	for (ActorIdToPysXRigidBodyTable::const_iterator it = m_actorRigidBodyMap.begin(); it != m_actorRigidBodyMap.end(); it++)
	{
		ActorId const id = it->first;

		PxTransform pxLoc = it->second->getGlobalPose();
		Mat4x4 loc;
		PxMatrixToMat4x4(PxMat44(pxLoc), &loc);
		
		Actor* pActor = g_pApp->m_pGame->VGetActor(id);
		if (pActor)
		{
			TransformComponent* pTransformComponent = pActor->GetComponent<TransformComponent>(TransformComponent::g_Name);

			if (pTransformComponent)
			{
				if (pTransformComponent->GetTransform() != loc)
				{
					Vec3 rot = loc.GetYawPitchRoll();
					pTransformComponent->SetPosition(loc.GetPosition());
					pTransformComponent->SetRotation(Vec3(XMConvertToDegrees(rot.x), XMConvertToDegrees(rot.y), XMConvertToDegrees(rot.z)));
					EventDataPtr pEvent(BE_NEW EvtData_Move_Actor(id, loc));
					IEventManager::Get()->VQueueEvent(pEvent);
				}
			}
		}
	}
}
开发者ID:jel-massih,项目名称:BombastEngine,代码行数:29,代码来源:PhysXPhysics.cpp

示例2: setTransform

void SNSpatialComponent::setTransform( Vec3D const& pos , Quat const& q )
{
	Mat4x4 trans;
	trans.setTransform( pos , q );
	mSceneNode->setWorldTransform( trans );
	updatePhyicalCompTransform( trans );
}
开发者ID:uvbs,项目名称:GameProject,代码行数:7,代码来源:SpatialComponent.cpp

示例3: CreateBuffers

	void SquareObject::OnCreate() {

		CreateBuffers(m_Scale.x, m_Scale.y);

		//行列の定義
		Mat4x4 World;
		World.affineTransformation(
			m_Scale,
			Vec3(0, 0, 0),
			m_Qt,
			m_Pos
		);

		auto TexPtr = App::GetApp()->GetResource<TextureResource>(m_TextureResName);
		auto NormTexPtr = App::GetApp()->GetResource<TextureResource>(m_NormalTextureResName);

		m_PtrObj = make_shared<BcDrawObject>();
		m_PtrObj->m_MeshRes = m_SquareMesh;
		m_PtrObj->m_TextureRes = TexPtr;
		m_PtrObj->m_NormalTextureRes = NormTexPtr;
		m_PtrObj->m_WorldMatrix = World;
		m_PtrObj->m_Camera = GetStage<Stage>()->GetCamera();
		m_PtrObj->m_OwnShadowmapActive = true;
		m_PtrObj->m_SamplerState = SamplerState::LinearWrap;
		m_PtrObj->m_ShadowmapUse = false;
		m_PtrObj->m_FogEnabled = true;
		//フォグはきつめに
		m_PtrObj->m_FogColor = Col4(0.3f, 0.3f, 0.3f, 1.0f);
		m_PtrObj->m_FogStart = -10.0f;
		m_PtrObj->m_FogEnd = -30.0f;


	}
开发者ID:WiZFramework,项目名称:BaseCross,代码行数:33,代码来源:Character.cpp

示例4: MakeStrongPtr

void BulletPhysics::CreateTrigger(WeakGameObjectPtr pGameObject, const Vec3& position, const float dim)
{
	StrongGameObjectPtr pStrongObject = MakeStrongPtr(pGameObject);
	if (!pStrongObject)
	{
		CB_ERROR("Must attach a game object to the trigger");
		return;
	}

	// create the collision body
	btBoxShape* boxShape = new btBoxShape(Vec3_to_btVector3(Vec3(dim, dim, dim)));

	// 0 mass, this trigger is not moveable
	const btScalar mass = 0;

	// set the initial position of the trigger from the object
	Mat4x4 triggerTransform = Mat4x4::Identity;
	triggerTransform.SetPosition(position);
	ObjectMotionState* motionState = CB_NEW ObjectMotionState(triggerTransform);

	// create the rigid body
	btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, motionState, boxShape, btVector3(0, 0, 0));
	btRigidBody* body = new btRigidBody(rbInfo);

	// add the body to the world
	m_DynamicsWorld->addRigidBody(body);

	// mark the body as a trigger so it does not physically collide with object
	body->setCollisionFlags(body->getCollisionFlags() | btRigidBody::CF_NO_CONTACT_RESPONSE);
	
	// update the maps
	m_ObjectIdToRigidBody[pStrongObject->GetId()] = body;
	m_RigidBodyToObjectId[body] = pStrongObject->GetId();
}
开发者ID:deanmarsinelli,项目名称:City-Protectors,代码行数:34,代码来源:Physics.cpp

示例5: setOrientation

void SNSpatialComponent::setOrientation( Quat const& q )
{
	Mat4x4 trans;
	trans.setTransform( mSceneNode->getWorldPosition() , q );
	mSceneNode->setWorldTransform( trans );
	updatePhyicalCompTransform( trans );
}
开发者ID:uvbs,项目名称:GameProject,代码行数:7,代码来源:SpatialComponent.cpp

示例6: Vec3

	//初期化
	void BcStaticChara::OnCreate() {

		//Rigidbodyの初期化
		auto PtrGameStage = GetStage<GameStage>();
		Rigidbody body;
		body.m_Owner = GetThis<GameObject>();
		body.m_Mass = 1.0f;
		body.m_Scale = m_Scale;
		body.m_Quat = m_Qt;
		body.m_Pos = m_Pos;
		body.m_CollType = CollType::typeCAPSULE;
		body.m_IsFixed = true;
//		body.m_IsDrawActive = true;
		body.SetToBefore();
		PtrGameStage->AddRigidbody(body);

		//メッシュとトランスフォームの差分の設定
		m_MeshToTransformMatrix.affineTransformation(
			Vec3(1.0f, 1.0f, 1.0f),
			Vec3(0.0f, 0.0f, 0.0f),
			Vec3(0.0f, 0.0f, 0.0f),
			Vec3(0.0f, -1.0f, 0.0f)
		);
		//行列の定義
		Mat4x4 World;
		World.affineTransformation(
			m_Scale,
			Vec3(0, 0, 0),
			m_Qt,
			m_Pos
		);
		//差分を計算
		World = m_MeshToTransformMatrix * World;
		auto MeshPtr = App::GetApp()->GetResource<MeshResource>(L"MODEL_MESH");
		//描画データの構築
		m_PtrObj = make_shared<BcDrawObject>();
		m_PtrObj->m_OwnShadowmapActive = m_OwnShadowActive;
		m_PtrObj->m_UsedModelColor = false;
		m_PtrObj->m_UsedModelTextre = true;
		m_PtrObj->m_ShadowmapUse = true;
		m_PtrObj->m_FogEnabled = true;
		//フォグは黄色っぽく
		m_PtrObj->m_FogColor = Col4(0.5f, 0.5f, 0.1f, 1.0f);
		m_PtrObj->m_FogStart = -10.0f;
		m_PtrObj->m_FogEnd = -30.0f;
		m_PtrObj->m_MeshRes = MeshPtr;
		m_PtrObj->m_WorldMatrix = World;
		m_PtrObj->m_Camera = GetStage<Stage>()->GetCamera();

		//シャドウマップ描画データの構築
		m_PtrShadowmapObj = make_shared<ShadowmapObject>();
		m_PtrShadowmapObj->m_MeshRes = MeshPtr;
		//描画データの行列をコピー
		m_PtrShadowmapObj->m_WorldMatrix = World;
		m_PtrShadowmapObj->m_Camera = GetStage<Stage>()->GetCamera();


	}
开发者ID:WiZFramework,项目名称:BaseCross,代码行数:59,代码来源:Character.cpp

示例7: CreateOrthoProjectionLH

///////////////////////////////////////////////
//Motion Blur
///////////////////////////////////////////////
AVOID DeferredRenderer::VGenerateVelocityMap(CameraPtr pCamera, Renderer* pRenderer, const Mat4x4 & viewproj)
{
	//set screen-aligned quad
	m_pVertices->Set(0, 0);

	//set shaders
	m_pVelocityMapShaders->VBind();

	//set shader resources
	m_gbuffer.BindPositionTex(0, ST_Pixel);

	//set render target
	m_pVelocityRTV->Set();

	//set constant buffers

	//bind matrix constant buffer to the pipeline
	Mat4x4 trans;
	//trans.CreateTranslation(pCamera->GetLookAt() + 10000 * pCamera->GetDir());
	trans.CreateTranslation(pCamera->GetPosition() + 500* pCamera->GetDir());

	Mat4x4 rot;
	rot = rot.CreateRollPitchYaw(pCamera->GetRoll(), pCamera->GetPitch(), pCamera->GetYaw());

	Mat4x4 WVP = rot * trans * pCamera->GetView() * CreateOrthoProjectionLH(SCREEN_WIDTH, SCREEN_HEIGHT, 1.0f, 1000.0f);
	WVP.Transpose();
	m_pMatrixBuffer->UpdateSubresource(0, NULL, &WVP, 0, 0);
	m_pMatrixBuffer->Set(0, ST_Vertex);

	//set previous frame view-projection transform
	Mat4x4 currViewProj = viewproj;
	Mat4x4 prevViewProj = pCamera->GetPrevView() * pCamera->GetPrevProjection();
	//prevViewProj = pCamera->GetView() * pCamera->GetProjection();
	//prevViewProj = pCamera->GetProjection();
	currViewProj.Transpose();
	prevViewProj.Transpose();
	//m_pcbPrevViewProj->UpdateSubresource(0, NULL, &prevViewProj, 0, 0);
	//m_pcbPrevViewProj->Set(0, ST_Pixel);

	struct TwoMatrices
	{
		Mat4x4 prevViewProj;
		Mat4x4 currViewProj;
	};
	TwoMatrices temp;
	temp.prevViewProj =prevViewProj;
	temp.currViewProj = currViewProj;

	m_pcbWorldPlusWVP->UpdateSubresource(0, nullptr, &temp, 0, 0);
	m_pcbWorldPlusWVP->Set(0, ST_Pixel);

	//Finally render velocity map
	Draw(6, 0);

	//unbind views
	UnbindShaderResourceViews(0, 1, ST_Pixel);
	UnbindRenderTargetViews(1);
}
开发者ID:jjiezheng,项目名称:Anubis-Engine,代码行数:61,代码来源:DeferredRenderer.cpp

示例8: int

//
// TeapotWarsGame::VOnUpdate			- Chapter 19, page 709
//
void CometConquestGame::VOnUpdate(float time, float elapsedTime)
{
	int deltaMilliseconds = int(elapsedTime * 1000.0f);
	m_Lifetime += elapsedTime;
	unsigned int currentTime = timeGetTime();
	BaseGameLogic::VOnUpdate(time, elapsedTime);

	if (m_bProxy)
		return;

	switch(m_State)
	{
	case BGS_LoadingGameEnvironment:
		break;

	case BGS_MainMenu:
		break;

	case BGS_WaitingForPlayers:
		if (m_ExpectedPlayers + m_ExpectedRemotePlayers == m_HumanPlayersAttached ) 
		{
			VChangeState(BGS_LoadingGameEnvironment);
		}
		break;

	case BGS_Running:
		if(currentTime > (m_data.m_lastCometTime + 5000))
		{
			Vec4 at = -g_Right4 * 2.0f;
			Vec4 atWorld = Mat4x4::g_Identity.Xform(at);
			int randVertical = m_random.Random(115) + 1 - 60;
			Vec3 normalDir(atWorld);
			normalDir.Normalize();
			Mat4x4 temp = Mat4x4::g_Identity;
			temp.SetPosition(Vec3(110,10,randVertical));
			CometParams cp;
			cp.m_Pos = temp.GetPosition() + Vec3(atWorld);
			cp.m_Radius = 6.0f;
			cp.m_Color = g_Cyan;
			cp.m_NormalDir = normalDir;
			cp.m_Force = 40000.0f;

			const EvtData_Request_New_Actor cannonBallEvt( &cp );
			safeTriggerEvent( cannonBallEvt );
			m_data.m_lastCometTime = currentTime;
		}
		break;
	default:
		assert(0 && _T("Unrecognized state."));
	}

	// look in Chapter 15, page 563 for more on this bit of code
	if(m_pPhysics)
	{
		m_pPhysics->VOnUpdate(elapsedTime);
		m_pPhysics->VSyncVisibleScene();
	}
}
开发者ID:jmazar,项目名称:CometConquest,代码行数:61,代码来源:CometConquest.cpp

示例9: VPreRender

//
// SkyNode::VPreRender				- Chapter 14, page 502
//
HRESULT SkyNode::VPreRender(Scene *pScene)
{
	Vec3 cameraPos = m_camera->VGet()->ToWorld().GetPosition();
	Mat4x4 mat = m_Props.ToWorld();
	mat.SetPosition(cameraPos);
	VSetTransform(&mat);

	return SceneNode::VPreRender(pScene);
}
开发者ID:JDHDEV,项目名称:AlphaEngine,代码行数:12,代码来源:Sky.cpp

示例10: GetLookAt

Vec Camera::GetLookAt() const
{
	Mat4x4 rot;
	rot = rot.CreateRollPitchYaw(m_roll, m_pitch, m_yaw);

	Vec lookAt;
	lookAt = m_pos + m_dir * rot;

	return lookAt;
}
开发者ID:Solidstatewater,项目名称:Anubis-Engine,代码行数:10,代码来源:Camera.cpp

示例11: SetDepthStencilView

AVOID Light::VPrepareToGenerateShadowMap(const Mat4x4 & world, Renderer * pRenderer)
{
	//Set depth stencil view
	if (pRenderer->m_bVarianceShadows)
	{
		m_pVarianceShadowRTV->Set(*m_pShadowMapDSV);
		//m_pVarianceShadowRTV->Set();
	}
	else
	{
		SetDepthStencilView(m_pShadowMapDSV);
	}
	//GetRenderTargetView()->Set(*m_pShadowMapDSV);

	//set constant buffer with orthographic projection
	Vec pos = m_pData->m_pos * m_worldTransform;
	Vec dir = Vector(m_pData->m_dir.x, m_pData->m_dir.y, m_pData->m_dir.z, 0.0f);
	Mat4x4 view = CreateViewMatrixLH(pos, dir, Vector(0.0f, 1.0f, 0.0f, 0.0f));
	Mat4x4 ortho = CreateOrthoProjectionLH(m_iShadowMapWidth * 1.5f, m_iShadowMapHeight * 1.5f, 0.5f, m_r32Range);
	//Mat4x4 ortho = CreateOrthoProjectionLH(m_iShadowMapWidth, m_iShadowMapHeight, 2.0f, 60.0f);
	//Mat4x4 ortho = CreatePerspectiveProjectionLH( 0.25f * 3.14f, (AREAL)SCREEN_WIDTH / (AREAL)SCREEN_HEIGHT, 0.5f, 30.0f);
	
	m_view = view;
	m_viewProjection = view * ortho;

	Mat4x4 WVP = world * m_viewProjection;
	WVP.Transpose();

	if (pRenderer->m_bVarianceShadows)
	{
		Mat4x4 WorldView = world * view;
		WorldView.Transpose();

		struct MatrixBuffer
		{
			Mat4x4 WorldView;
			Mat4x4 WVP;
		};
		MatrixBuffer buffer;
		buffer.WorldView = WorldView;
		buffer.WVP = WVP;
		pRenderer->m_pcbWorldPlusWVP->UpdateSubresource(0, NULL, &buffer, 0, 0);
		pRenderer->m_pcbWorldPlusWVP->Set(0, ST_Vertex);
	}
	else
	{
		pRenderer->m_pcbWVP->UpdateSubresource(0, NULL, &WVP, 0, 0);
		pRenderer->m_pcbWVP->Set(0, ST_Vertex);
	}

	//Actually stores length of light frustum
	Vec frustumSize = Vector(m_r32Range - 0.5, m_r32Range -0.5, m_r32Range - 0.5, m_r32Range - 0.5 );
	pRenderer->m_pcbCameraPos->UpdateSubresource(0, NULL, &frustumSize, 0, 0);
	pRenderer->m_pcbCameraPos->Set(0, ST_Pixel);
}
开发者ID:jjiezheng,项目名称:Anubis-Engine,代码行数:55,代码来源:Light.cpp

示例12: OnCreate

	//初期化
	void BcBoxObject::OnCreate() {

		//Rigidbodyの初期化
		auto PtrGameStage = GetStage<GameStage>();
		Rigidbody body;
		body.m_Owner = GetThis<GameObject>();
		body.m_Mass = 1.0f;
		body.m_Scale = m_Scale;
		body.m_Quat = m_Qt;
		body.m_Pos = m_Pos;
		body.m_CollType = CollType::typeOBB;
		body.m_IsFixed = true;
//		body.m_IsDrawActive = true;
		body.SetToBefore();
		PtrGameStage->AddRigidbody(body);


		//行列の定義
		Mat4x4 World;
		World.affineTransformation(
			body.m_Scale,
			Vec3(0, 0, 0),
			body.m_Quat,
			body.m_Pos
		);
		auto TexPtr = App::GetApp()->GetResource<TextureResource>(m_TextureResName);
		auto NormTexPtr = App::GetApp()->GetResource<TextureResource>(m_NormalTextureResName);
		//メッシュの取得
		auto MeshPtr = App::GetApp()->GetResource<MeshResource>(L"NORMAL_BOX");

		//描画データの構築
		m_PtrObj = make_shared<BcDrawObject>();
		m_PtrObj->m_MeshRes = MeshPtr;
		m_PtrObj->m_TextureRes = TexPtr;
		m_PtrObj->m_NormalTextureRes = NormTexPtr;
		m_PtrObj->m_WorldMatrix = World;
		m_PtrObj->m_Camera = GetStage<Stage>()->GetCamera();
		m_PtrObj->m_OwnShadowmapActive = true;
		m_PtrObj->m_ShadowmapUse = true;
		m_PtrObj->m_FogEnabled = true;
		//フォグは黄色っぽく
		m_PtrObj->m_FogColor = Col4(0.5f, 0.5f, 0.1f, 1.0f);
		m_PtrObj->m_FogStart = -10.0f;
		m_PtrObj->m_FogEnd = -30.0f;

		//シャドウマップ描画データの構築
		m_PtrShadowmapObj = make_shared<ShadowmapObject>();
		m_PtrShadowmapObj->m_MeshRes = MeshPtr;
		//描画データの行列をコピー
		m_PtrShadowmapObj->m_WorldMatrix = World;
		m_PtrShadowmapObj->m_Camera = GetStage<Stage>()->GetCamera();


	}
开发者ID:WiZFramework,项目名称:BaseCross,代码行数:55,代码来源:Character.cpp

示例13: CreateOrthoProjectionLH

Mat4x4 Anubis::CreateOrthoProjectionLH(	const AREAL width, const AREAL height,
										const AREAL nearZ,	const AREAL farZ)
{
	Mat4x4 mat;

	mat.Init(	Vector( 2.0f / width,			0,					0,					 0),
				Vector( 0,				 2.0f / height,				0,					 0),
				Vector( 0,						0,			1.0f / (farZ - nearZ),		 0),
				Vector( 0,						0,			nearZ / (nearZ - farZ),		 1) );

	return mat;
}
开发者ID:Solidstatewater,项目名称:Engine,代码行数:12,代码来源:Math.cpp

示例14: OnDrawShadowmap

	void Player::OnDrawShadowmap() {
		auto PtrGameStage = GetStage<GameStage>();
		//ワールド行列の決定
		Mat4x4 World;
		World.affineTransformation(m_Scale, Vec3(0, 0, 0),
			m_Qt, m_Pos);
		auto shptr = PtrGameStage->FindTagGameObject<ShadowmapDrawObject>(L"ShadowmapDrawObject");
		shptr->AddDrawMesh(
			m_SphereMesh,
			World
		);
	}
开发者ID:WiZFramework,项目名称:BaseCross,代码行数:12,代码来源:Player.cpp

示例15: BE_ASSERT

void PhysXPhysics::AddShape(Actor* pActor, PxGeometry* geometry, float density, const std::string& physicsMaterial, bool gravityEnabled, float linearDamping, float angularDamping, const std::string& bodyType)
{
	BE_ASSERT(pActor);
	ActorId actorId = pActor->GetId();
	BE_ASSERTf(m_actorRigidBodyMap.find(actorId) == m_actorRigidBodyMap.end(), "Actor with more than one rigidbody");

	Mat4x4 transform = Mat4x4::g_Identity;
	
	TransformComponent* pTransformComponent = pActor->GetComponent<TransformComponent>(TransformComponent::g_Name);

	if (pTransformComponent)
	{
		transform = pTransformComponent->GetTransform();
	}
	else 
	{
		//Doesnt work without transform
		BE_ERROR("Actor %s PhysicsComponent requires Shape to have Transform Component: %d", actorId);
		return;
	}

	PhysicsMaterialData material(LookupMaterialData(physicsMaterial));
	PxMaterial* mat = m_pPhysicsSdk->createMaterial(material.m_friction, material.m_friction, material.m_restitution);

	Vec3 translation, scale;
	Quaternion rotation;
	
	bool ok = transform.Decompose(translation, rotation, scale);
	PxQuat pxRot;
	PxVec3 pxLoc;
	Vec3ToPxVec(translation, &pxLoc);
	QuaternionToPxQuat(rotation, &pxRot);
	PxTransform t(pxLoc, pxRot);

	if (bodyType == "Dynamic")
	{
		PxRigidDynamic* body = PxCreateDynamic(*m_pPhysicsSdk, t, *geometry, *mat, density);
		body->setActorFlag(PxActorFlag::eDISABLE_GRAVITY, !gravityEnabled);
		PxRigidBodyExt::updateMassAndInertia(*body, density);
		body->setLinearDamping(linearDamping);
		body->setAngularDamping(angularDamping);
		m_pScene->addActor(*body);

		m_actorRigidBodyMap[actorId] = body;
		m_rigidBodyActorMap[body] = actorId;
	}
	else
	{
		BE_ERROR("[Physics] BodyType not supported: %s", bodyType.c_str());
		return;
	}
}
开发者ID:jel-massih,项目名称:BombastEngine,代码行数:52,代码来源:PhysXPhysics.cpp


注:本文中的Mat4x4类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。