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


C++ NxQuat::zero方法代码示例

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


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

示例1: sizeof

HeightmapActor::HeightmapActor(NxPhysicsSDK &sdk_, NxScene &scene, const unsigned short *buffer, int samplesX, int samplesY, const VC3 &size)
:	sdk(sdk_),
	heightField(0)
{
	NxHeightFieldDesc heightDesc;
	heightDesc.nbColumns = samplesX;
	heightDesc.nbRows = samplesY;
	heightDesc.verticalExtent = -1000;
	heightDesc.convexEdgeThreshold = 0;
	heightDesc.samples = new NxU32[samplesX * samplesY];
	heightDesc.sampleStride = sizeof(NxU32);

    NxU8 *currentByte = (NxU8 *) heightDesc.samples;
	for(int row = 0; row < samplesY; ++row)
	for(int column = 0; column < samplesX; ++column)
	{            
		NxHeightFieldSample *currentSample = (NxHeightFieldSample *) currentByte;

		//int sample = buffer[row * samplesX + column];
		//int sample = buffer[column * samplesY + row];
		int sample = buffer[(samplesY - row - 1) * samplesX + column];
		//int sample = buffer[column * samplesX + row];
		sample -= 32768;

		currentSample->height = sample;
		currentSample->materialIndex0 = 0;
		currentSample->materialIndex1 = 0;
		currentSample->tessFlag = 0;
		currentByte += heightDesc.sampleStride;
	}

	heightField = sdk.createHeightField(heightDesc);
	delete[] (NxU32 *) heightDesc.samples;

	if(heightField)
	{
		float scaleX = size.x / samplesX;
		float scaleY = 1.f / 65536.f * size.y;
		float scaleZ = size.z / samplesY;

		NxHeightFieldShapeDesc shapeDesc;
		shapeDesc.heightField = heightField;
		shapeDesc.heightScale = scaleY;
		shapeDesc.rowScale = scaleZ;
		shapeDesc.columnScale = scaleX;
		shapeDesc.materialIndexHighBits = 0;
		shapeDesc.holeMaterial = 2;    

		NxVec3 pos;
		pos.x = -size.x * 0.5f;
		pos.y = size.y * 0.5f;
		pos.z = (size.z * 0.5f) - scaleZ;

		NxQuat quat;
		quat.zero();
		quat.fromAngleAxis(90, NxVec3(0, 1, 0));

		NxActorDesc actorDesc;
		actorDesc.shapes.pushBack(&shapeDesc);
		actorDesc.globalPose.t = pos;
		actorDesc.globalPose.M = quat;

		actor = scene.createActor(actorDesc);
	}

	this->scene = &scene;
	init();
}
开发者ID:sopyer,项目名称:Shadowgrounds,代码行数:68,代码来源:heightmap_actor.cpp


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