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


C++ NxMat33::setRow方法代码示例

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


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

示例1: InitNx

void InitNx()
{
	// Create a memory allocator
    gAllocator = new UserAllocator;

    // Create the physics SDK
    gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, gAllocator);
    if (!gPhysicsSDK)  return;

	// Set the physics parameters
	gPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.01);

	// Set the debug visualization parameters
	gPhysicsSDK->setParameter(NX_VISUALIZATION_SCALE, 1);
	gPhysicsSDK->setParameter(NX_VISUALIZE_COLLISION_SHAPES, 1);
	gPhysicsSDK->setParameter(NX_VISUALIZE_ACTOR_AXES, 1);
	gPhysicsSDK->setParameter(NX_VISUALIZE_JOINT_LIMITS, 1);
	gPhysicsSDK->setParameter(NX_VISUALIZE_JOINT_LOCAL_AXES, 1);

    // Create the scene
    NxSceneDesc sceneDesc;
    sceneDesc.gravity               = gDefaultGravity;
    sceneDesc.simType				= NX_SIMULATION_HW;
    gScene = gPhysicsSDK->createScene(sceneDesc);	
 if(!gScene){ 
		sceneDesc.simType				= NX_SIMULATION_SW; 
		gScene = gPhysicsSDK->createScene(sceneDesc);  
		if(!gScene) return;
	}

	// Create the default material
	NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.5);
	defaultMaterial->setStaticFriction(0.5);
	defaultMaterial->setDynamicFriction(0.5);

	// Create the objects in the scene
	CreateGroundPlane();

	// Slider Joint
	capsule1 = CreateCapsule(NxVec3(0,5,0), 1, 0.5, 10);
	capsule1->raiseBodyFlag(NX_BF_KINEMATIC);
	capsule2 = CreateCapsule(NxVec3(0,3,0), 1, 0.5, 10);
    capsule2->raiseBodyFlag(NX_BF_DISABLE_GRAVITY);

	NxVec3 globalAnchor = gJointStartPos;
	NxVec3 globalAxis = NxVec3(0,1,0);
	d6Joint = CreateD6Joint(capsule1, capsule2, globalAnchor, globalAxis);

	ball = CreateFollowBall(gBallStartPos,0.25,1);
	ball->raiseBodyFlag(NX_BF_KINEMATIC);

	NxMat33 orient = ball->getGlobalOrientation();
	NxMat33 controlOrient;
	controlOrient.setRow(0, orient.getRow(2));
	controlOrient.setRow(1, orient.getRow(0));
	controlOrient.setRow(2, orient.getRow(1));
	ball->setGlobalOrientation(controlOrient);

	gSelectedActor = ball;
	gForceStrength = 1500;
	gCameraSpeed = 10;

	box = CreateBox(NxVec3(3,0,0), NxVec3(0.5,1,0.5), 20);
	sphere = CreateSphere(NxVec3(0,0,3), 1, 10);
	capsule = CreateCapsule(NxVec3(-3,0,0), 2, 0.5, 10);
	pyramid = CreatePyramid(NxVec3(0,0,-3), NxVec3(0.75,1.5,0.75), 10);

	box->setLinearDamping(0.5);
	sphere->setLinearDamping(0.5);
	capsule->setLinearDamping(0.5);
	pyramid->setLinearDamping(0.5);

	AddUserDataToActors(gScene);

	// Initialize HUD
	InitializeHUD();

	// Get the current time
	getElapsedTime();

	// Start the first frame of the simulation
	if (gScene)  StartPhysics();
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:84,代码来源:Lesson213.cpp

示例2: MatchTarget

void MatchTarget()
{
    NxD6JointDesc d6Desc;

	d6Joint->saveToDesc(d6Desc);

//    d6Desc.xDrive.driveType = NX_D6JOINT_DRIVE_POSITION | NX_D6JOINT_DRIVE_VELOCITY;
    d6Desc.xDrive.driveType = NX_D6JOINT_DRIVE_POSITION;
	d6Desc.xDrive.spring = 200;  // FLT_MAX
	d6Desc.xDrive.damping = 10;
#if 0
	d6Desc.xDrive.driveType = NX_D6JOINT_DRIVE_VELOCITY;
    d6Desc.xDrive.forceLimit = FLT_MAX;
#endif  // 0

//    d6Desc.yDrive.driveType = NX_D6JOINT_DRIVE_POSITION | NX_D6JOINT_DRIVE_VELOCITY;
    d6Desc.yDrive.driveType = NX_D6JOINT_DRIVE_POSITION;
	d6Desc.yDrive.spring = 200;  // FLT_MAX
	d6Desc.yDrive.damping = 10;
#if 0
    d6Desc.yDrive.driveType = NX_D6JOINT_DRIVE_VELOCITY;
    d6Desc.yDrive.forceLimit = FLT_MAX;
#endif  // 0

//    d6Desc.xDrive.driveType = NX_D6JOINT_DRIVE_POSITION | NX_D6JOINT_DRIVE_VELOCITY;
    d6Desc.zDrive.driveType = NX_D6JOINT_DRIVE_POSITION;
	d6Desc.zDrive.spring = 200;  // FLT_MAX
	d6Desc.zDrive.damping = 10;
#if 0
    d6Desc.zDrive.driveType = NX_D6JOINT_DRIVE_VELOCITY;
    d6Desc.zDrive.forceLimit = FLT_MAX;
#endif  // 0

	NxVec3 pos = ball->getGlobalPosition();
	NxVec3 vel = ball->getLinearVelocity();

    NxVec3 controlPos = pos - gBallStartPos;
	controlPos = NxVec3(controlPos.y, controlPos.z, controlPos.x);
	d6Desc.drivePosition.set(controlPos);

//	NxVec3 controlVel = NxVec3(vel.y, vel.z, vel.x);
//	d6Desc.driveLinearVelocity.set(controlVel);

	d6Desc.flags = NX_D6JOINT_SLERP_DRIVE;
//    d6Desc.slerpDrive.driveType = NX_D6JOINT_DRIVE_POSITION | NX_D6JOINT_DRIVE_VELOCITY;
    d6Desc.slerpDrive.driveType = NX_D6JOINT_DRIVE_POSITION;
//    d6Desc.slerpDrive.driveType = NX_D6JOINT_DRIVE_VELOCITY;
//    d6Desc.slerpDrive.forceLimit = FLT_MAX;
	d6Desc.slerpDrive.spring = 200;  // FLT_MAX
	d6Desc.slerpDrive.damping = 10;

	NxMat33 orient = ball->getGlobalOrientation();
	NxMat33 controlOrient;
	controlOrient.setRow(0, orient.getRow(1));
	controlOrient.setRow(1, orient.getRow(2));
	controlOrient.setRow(2, orient.getRow(0));
	NxQuat q(controlOrient);
	d6Desc.driveOrientation = q;

//	NxVec3 angVel = ball->getAngularVelocity();
//	d6Desc.driveAngularVelocity.set(angVel);

	d6Joint->loadFromDesc(d6Desc);
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:64,代码来源:Lesson213.cpp


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