コード例 #1
0
void GXMRenderer::bindViewProj(const physx::PxMat44 &eye, const RendererProjection &proj)
{
	m_viewMatrix = eye.inverseRT();
	convertToSce(m_environment.mViewMatrix, m_viewMatrix);
	convertToSce(m_environment.mProjMatrix, proj);

	const PxVec3 &eyePosition  =  eye.getPosition();
	const PxVec3  eyeDirection = -eye.getBasis(2);
	memcpy(m_environment.mEyePosition,  &eyePosition.x,  sizeof(float)*3);
	memcpy(m_environment.mEyeDirection, &eyeDirection.x, sizeof(float)*3);
}
コード例 #2
0
ファイル: GLES2Renderer.cpp プロジェクト: akurt5/AIEShit
void GLES2Renderer::bindViewProj(const physx::PxMat44 &eye, const PxMat44 &proj)
{
		physx::PxMat44 inveye = eye.inverseRT();

		// load the projection matrix...
		PxToGL(m_glProjectionMatrix, proj);

		// load the view matrix...
		m_viewMatrix = inveye;

		m_eyePosition  =  eye.getPosition();
		m_eyeDirection = -eye.getBasis(2);
}
コード例 #3
0
ファイル: GLES2Renderer.cpp プロジェクト: akurt5/AIEShit
void SampleRenderer::PxToGLColumnMajor(GLfloat *gl44, const physx::PxMat44 &mat44)
{
	memcpy(gl44, mat44.front(), 4 * 4 * sizeof (GLfloat));
}
コード例 #4
0
ファイル: GLES2Renderer.cpp プロジェクト: akurt5/AIEShit
void SampleRenderer::PxToGL(GLfloat *gl44, const physx::PxMat44 &mat)
{
	PxMat44 mat44 = mat.getTranspose();
	memcpy(gl44, mat44.front(), 4 * 4 * sizeof (GLfloat));
}
コード例 #5
0
static void ApplyTransformationToApexDestructibleAsset( physx::NxDestructibleAsset& ApexDestructibleAsset, const physx::PxMat44& Transform )
{
	// Get the NxParameterized interface to the asset
	NxParameterized::Interface* AssetParams = const_cast<NxParameterized::Interface*>(ApexDestructibleAsset.getAssetNxParameterized());
	if (AssetParams != NULL)
	{
		// Name buffer used for parameterized array element lookup
		char ArrayElementName[1024];

		/* surfaceTrace default normal */
		physx::PxI32 SurfaceTraceSetCount;
		if (NxParameterized::getParamArraySize(*AssetParams, "surfaceTraceSets", SurfaceTraceSetCount))
		{
			for (physx::PxI32 i = 0; i < SurfaceTraceSetCount; ++i)
			{
				FCStringAnsi::Sprintf( ArrayElementName, "surfaceTraceSets[%d]", i );
				NxParameterized::Interface* SurfaceTraceSetParams;
				if (NxParameterized::getParamRef(*AssetParams, ArrayElementName, SurfaceTraceSetParams))
				{
					if (SurfaceTraceSetParams != NULL)
					{
						physx::PxI32 SurfaceTraceCount;
						if (NxParameterized::getParamArraySize(*SurfaceTraceSetParams, "traces", SurfaceTraceCount))
						{
							for (physx::PxI32 j = 0; j < SurfaceTraceCount; ++j)
							{
								FCStringAnsi::Sprintf( ArrayElementName, "traces[%d].defaultNormal", j );
								NxParameterized::Handle DefaultNormalHandle(*SurfaceTraceSetParams);
								if (NxParameterized::findParam(*SurfaceTraceSetParams, ArrayElementName, DefaultNormalHandle) != NULL)
								{
									physx::PxVec3 DefaultNormal;
									DefaultNormalHandle.getParamVec3( DefaultNormal );
									DefaultNormal = Transform.rotate( DefaultNormal );
									DefaultNormalHandle.setParamVec3( DefaultNormal );
								}
							}
						}
					}
				}
			}
		}

		/* For now, we'll just clear the current cached streams. */
		NxParameterized::Interface* CollisionDataParams;
		if (NxParameterized::getParamRef(*AssetParams, "collisionData", CollisionDataParams))
		{
			if (CollisionDataParams != NULL)
			{
				CollisionDataParams->destroy();
				NxParameterized::setParamRef(*AssetParams, "collisionData", NULL);
			}
		}

		/* chunk surface normal */
		physx::PxI32 AssetChunkCount;
		if (NxParameterized::getParamArraySize(*AssetParams, "chunks", AssetChunkCount))
		{
			for (physx::PxI32 i = 0; i < AssetChunkCount; ++i)
			{
				FCStringAnsi::Sprintf( ArrayElementName, "chunks[%d].surfaceNormal", i );
				NxParameterized::Handle ChunkSurfaceNormalHandle(*AssetParams);
				if (NxParameterized::findParam(*AssetParams, ArrayElementName, ChunkSurfaceNormalHandle) != NULL)
				{
					physx::PxVec3 ChunkSurfaceNormal;
					ChunkSurfaceNormalHandle.getParamVec3( ChunkSurfaceNormal );
					ChunkSurfaceNormal = Transform.rotate( ChunkSurfaceNormal );
					ChunkSurfaceNormalHandle.setParamVec3( ChunkSurfaceNormal );
				}
			}
		}

		/* bounds */
		physx::PxBounds3 Bounds;
		if (NxParameterized::getParamBounds3(*AssetParams, "bounds", Bounds))
		{
			if (!Bounds.isEmpty())
			{
				Bounds = physx::PxBounds3::basisExtent(Transform.transform(Bounds.getCenter()), physx::PxMat33(Transform.column0.getXYZ(), Transform.column1.getXYZ(), Transform.column2.getXYZ()), Bounds.getExtents());
				NxParameterized::setParamBounds3(*AssetParams, "bounds", Bounds);
			}
		}

		/* chunk convex hulls */
		physx::PxI32 ConvexHullCount;
		if (NxParameterized::getParamArraySize(*AssetParams, "chunkConvexHulls", ConvexHullCount))
		{
			for (physx::PxI32 i = 0; i < ConvexHullCount; ++i)
			{
				FCStringAnsi::Sprintf( ArrayElementName, "chunkConvexHulls[%d]", i );
				NxParameterized::Interface* ConvexHullParams;
				if (NxParameterized::getParamRef(*AssetParams, ArrayElementName, ConvexHullParams))
				{
					if (ConvexHullParams != NULL)
					{
						// planes
						physx::PxI32 UniquePlaneCount;
						if (NxParameterized::getParamArraySize(*ConvexHullParams, "uniquePlanes", UniquePlaneCount))
						{
							for (physx::PxI32 j = 0; j < UniquePlaneCount; ++j)
							{
								FCStringAnsi::Sprintf( ArrayElementName, "uniquePlanes[%d].normal", j );
								NxParameterized::Handle PlaneNormalHandle(*ConvexHullParams);
								if (NxParameterized::findParam(*ConvexHullParams, ArrayElementName, PlaneNormalHandle) != NULL)
								{
									physx::PxVec3 PlaneNormal;
									PlaneNormalHandle.getParamVec3( PlaneNormal );
									PlaneNormal = Transform.rotate( PlaneNormal );
									PlaneNormalHandle.setParamVec3( PlaneNormal );
								}
							}
						}

						// vertices
						physx::PxBounds3 HullBounds;
						HullBounds.setEmpty();
						physx::PxI32 HullVertexCount;
						if (NxParameterized::getParamArraySize(*ConvexHullParams, "vertices", HullVertexCount))
						{
							for (physx::PxI32 j = 0; j < HullVertexCount; ++j)
							{
								FCStringAnsi::Sprintf( ArrayElementName, "vertices[%d]", j );
								NxParameterized::Handle HullVertexHandle(*ConvexHullParams);
								if (NxParameterized::findParam(*ConvexHullParams, ArrayElementName, HullVertexHandle) != NULL)
								{
									physx::PxVec3 HullVertex;
									HullVertexHandle.getParamVec3( HullVertex );
									HullVertex = Transform.transform( HullVertex );
									HullVertexHandle.setParamVec3( HullVertex );
									HullBounds.include( HullVertex );
								}
							}
						}
						NxParameterized::setParamBounds3(*ConvexHullParams, "bounds", HullBounds);
					}
				}
			}
		}

		/* render mesh asset (bounding boxes only) */
		const physx::PxMat33 Basis(Transform.getBasis(0), Transform.getBasis(1), Transform.getBasis(2));
		const physx::PxVec3 Offset = Transform.getPosition();
		NxParameterized::Interface* RenderMeshAssetParams;
		if (NxParameterized::getParamRef(*AssetParams, "renderMeshAsset", RenderMeshAssetParams))
		{
			physx::PxI32 PartBoundsCount;
			if (NxParameterized::getParamArraySize(*RenderMeshAssetParams, "partBounds", PartBoundsCount))
			{
				for (physx::PxI32 i = 0; i < PartBoundsCount; ++i)
				{
					FCStringAnsi::Sprintf( ArrayElementName, "partBounds[%d]", i );
					NxParameterized::Handle PartBoundsHandle(*RenderMeshAssetParams);
					if (NxParameterized::findParam(*RenderMeshAssetParams, ArrayElementName, PartBoundsHandle) != NULL)
					{
						physx::PxBounds3 PartBounds;
						PartBoundsHandle.getParamBounds3( PartBounds );
						PartBounds = physx::PxBounds3::transformSafe(Basis, PartBounds);
						PartBounds.minimum += Offset;
						PartBounds.maximum += Offset;
						PartBoundsHandle.setParamBounds3( PartBounds );
					}
				}
			}
		}
	}
}