|
楼主 |
发表于 2010-8-25 18:50:47
|
显示全部楼层
5# aya_daxiang 我的链子是画出来的,就是用四个矩形立方体堆出来的,近看或许不太像,远看还是可以的,描画的源码如下:
NxActor* CreateRing(const NxVec3& pos, const NxVec3& boxDim, const NxReal density)
{
NxActorDesc actorDesc;
NxBodyDesc bodyDesc;
NxBoxShapeDesc boxDesc1;
boxDesc1.dimensions.set(boxDim.x/3,boxDim.y/8,(NxReal)0.06);
boxDesc1.localPose.t = NxVec3(0,0.6,-(NxReal)0.1);
actorDesc.shapes.pushBack(&boxDesc1);
NxBoxShapeDesc boxDesc2;
boxDesc2.dimensions.set(boxDim.x/3,boxDim.y/816,(NxReal)0.25);
boxDesc2.dimensions.set(boxDim.x/3,boxDim.y/8,(NxReal)0.06);
boxDesc2.localPose.t = NxVec3(0,-0.6,-(NxReal)0.1);
actorDesc.shapes.pushBack(&boxDesc2);
NxBoxShapeDesc boxDesc3;
boxDesc3.dimensions.set((NxReal)0.05,boxDim.y,(NxReal)0.06);
boxDesc3.localPose.t = NxVec3(boxDim.x/3,0,(NxReal)(0.201-0.25));
actorDesc.shapes.pushBack(&boxDesc3);
NxBoxShapeDesc boxDesc4;
boxDesc4.dimensions.set((NxReal)0.05,boxDim.y,(NxReal)0.06);
boxDesc4.localPose.t = NxVec3(-boxDim.x/3,0,(NxReal)(0.201-0.25));
actorDesc.shapes.pushBack(&boxDesc4);
if (density)
{
actorDesc.body = &bodyDesc;
actorDesc.density = density;
}
else
{
actorDesc.body = NULL;
}
actorDesc.globalPose.t = pos;
return gScene->createActor(actorDesc);
}
void CreateRope(const NxVec3& pos, const NxReal segHeight, const NxReal segRadius, const int nbSegments, const NxReal density)
{
//osg::Group* group = new osg::Group;
//CreateRing(const NxVec3& pos, const NxVec3& boxDim, const NxReal density)
NxI32 i;
ropeSegs = new NxActor*[nbSegments];
ropeLinks = new NxSphericalJoint*[nbSegments-1];
for (i = 0; i < nbSegments; i++)
{
if(i%2==0)
{
ropeSegs = CreateRing(pos + NxVec3(0,i*(2*segRadius+segHeight),0), NxVec3(0.5, 0.7, 0.02), density);
ropeSegs->setGlobalOrientationQuat(AnglesToQuat(NxVec3(0,90,0)));
}
else
{
ropeSegs = CreateRing(pos + NxVec3(0,i*(2*segRadius+segHeight),0), NxVec3(0.5, 0.7, 0.02), density);
}
}
for (i = 0; i < nbSegments - 1; i++)
{//
ropeLinks = CreateRopeSphericalJoint(ropeSegs, ropeSegs[i+1], pos + NxVec3(0,(i+1)*(2*segRadius+segHeight),0), NxVec3(0,1,0));
}
// group->addChild(ropeSegs);
}
你看看能给点建议不?谢谢! |
|