【发布时间】:2013-01-01 18:43:22
【问题描述】:
我目前正在尝试在一个角色上制作两条手臂并使用 NxRevoluteJoint 进行移动。我让这些在另一个作为示例给出的程序中完美运行,并且我在这个新项目中使用了相同的代码,但是我收到了一个错误(标题中的那个),我正在努力解决它。我知道指针在某个地方引用了 NULL,但我看不到如何对其进行排序。
变量是全局设置的:
NxRevoluteJoint* playerLeftJoint= 0;
NxRevoluteJoint* playerRightJoint= 0;
这是将播放器构建为复合对象的单独函数中的代码:
NxVec3 globalAnchor(0,1,0);
NxVec3 globalAxis(0,0,1);
playerLeftJoint= CreateRevoluteJoint(0,actor2,globalAnchor,globalAxis);
playerRightJoint= CreateRevoluteJoint(0,actor2,globalAnchor,globalAxis);
//set joint limits
NxJointLimitPairDesc limit1;
limit1.low.value = -0.3f;
limit1.high.value = 0.0f;
playerLeftJoint->setLimits(limit1);
NxJointLimitPairDesc limit2;
limit2.low.value = 0.0f;
limit2.high.value = 0.3f;
playerRightJoint->setLimits(limit2);
NxMotorDesc motorDesc1;
motorDesc1.velTarget = 0.15;
motorDesc1.maxForce = 1000;
motorDesc1.freeSpin = true;
playerLeftJoint->setMotor(motorDesc1);
NxMotorDesc motorDesc2;
motorDesc2.velTarget = -0.15;
motorDesc2.maxForce = 1000;
motorDesc2.freeSpin = true;
playerRightJoint->setMotor(motorDesc2);
我收到错误的行是playerLeftJoint->setLimits(limit1);
【问题讨论】:
-
NxRevoluteJoint* playerLeftJoint= 0;你正在取消引用一个空指针。 -
如何才能不取消引用它?
-
在使用之前使其指向现有的
NxRevoluteJoint。右侧关节类似。 -
好吧,我已经让它指向
NxRevoluteJointCreateRevoluteJoint是NxRevoluteJoint函数 -
那一定是返回了
NULL。该错误清楚地表明您正在尝试读取地址 0。
标签: c++ visual-studio-2010 nvidia