本文整理汇总了C++中NodeUnrecPtr::setTravMask方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeUnrecPtr::setTravMask方法的具体用法?C++ NodeUnrecPtr::setTravMask怎么用?C++ NodeUnrecPtr::setTravMask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeUnrecPtr
的用法示例。
在下文中一共展示了NodeUnrecPtr::setTravMask方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressed
virtual void keyPressed(const KeyEventUnrecPtr e)
{
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_CONTROL)
{
TutorialWindow->closeWindow();
}
switch(e->getKey())
{
case KeyEvent::KEY_B:
buildBox(Vec3f(10.0,10.0,10.0), Pnt3f((Real32)(rand()%100)-50.0,(Real32)(rand()%100)-50.0,25.0));
break;
case KeyEvent::KEY_UP:
_IsUpKeyDown = true;
break;
case KeyEvent::KEY_DOWN:
_IsDownKeyDown = true;
break;
case KeyEvent::KEY_LEFT:
_IsLeftKeyDown = true;
break;
case KeyEvent::KEY_RIGHT:
_IsRightKeyDown = true;
break;
case KeyEvent::KEY_D:
{
if(PhysDrawableNode->getTravMask())
{
PhysDrawableNode->setTravMask(TypeTraits<UInt32>::getMin());
}
else
{
PhysDrawableNode->setTravMask(TypeTraits<UInt32>::getMax());
}
}
break;
}
}
示例2: keyPressed
virtual void keyPressed(const KeyEventUnrecPtr e)
{
//Exit
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_COMMAND)
{
TutorialWindow->closeWindow();
}
//Toggle animation
if(e->getKey() == KeyEvent::KEY_SPACE)
{
if(animationPaused)
animationPaused = false;
else
animationPaused = true;
}
//Toggle bind pose
if(e->getKey() == KeyEvent::KEY_B)
{
if(e->getModifiers() & KeyEvent::KEY_MODIFIER_SHIFT)
{
//Toggle mesh
if(UnboundGeometry->getTravMask() == 0)
{
UnboundGeometry->setTravMask(1);
}
else
{
UnboundGeometry->setTravMask(0);
}
}
else
{
//Toggle skeleton
if(dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->getDrawBindPose() == false)
{
dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->setDrawBindPose(true);
}
else
{
dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->setDrawBindPose(false);
}
}
}
//Toggle current pose
if(e->getKey() == KeyEvent::KEY_P)
{
if(e->getModifiers() & KeyEvent::KEY_MODIFIER_SHIFT)
{
//Toggle mesh
if(MeshNode->getTravMask() == 0)
{
MeshNode->setTravMask(1);
}
else
{
MeshNode->setTravMask(0);
}
}
else
{
//Toggle skeleton
if(dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->getDrawPose() == false)
{
dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->setDrawPose(true);
}
else
{
dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->setDrawPose(false);
}
}
}
}
示例3: main
// Initialize GLUT & OpenSG and set up the rootNode
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
TutorialUpdateListener TheTutorialUpdateListener;
TutorialWindow->addUpdateListener(&TheTutorialUpdateListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//Make Main Scene Node
NodeRefPtr scene = makeCoredNode<Group>();
setName(scene, "scene");
rootNode = Node::create();
setName(rootNode, "rootNode");
ComponentTransformRefPtr Trans;
Trans = ComponentTransform::create();
{
rootNode->setCore(Trans);
// add the torus as a child
rootNode->addChild(scene);
}
//Make The Physics Characteristics Node
PhysicsCharacteristicsDrawableUnrecPtr PhysDrawable = PhysicsCharacteristicsDrawable::create();
PhysDrawable->setRoot(rootNode);
PhysDrawableNode = Node::create();
PhysDrawableNode->setCore(PhysDrawable);
PhysDrawableNode->setTravMask(TypeTraits<UInt32>::getMin());
rootNode->addChild(PhysDrawableNode);
//Light Beacon
NodeRefPtr TutorialLightBeacon = makeCoredNode<Transform>();
//Light Node
DirectionalLightRefPtr TutorialLight = DirectionalLight::create();
TutorialLight->setDirection(0.0,0.0,-1.0);
TutorialLight->setBeacon(TutorialLightBeacon);
NodeRefPtr TutorialLightNode = Node::create();
TutorialLightNode->setCore(TutorialLight);
scene->addChild(TutorialLightNode);
scene->addChild(TutorialLightBeacon);
//Setup Physics Scene
physicsWorld = PhysicsWorld::create();
physicsWorld->setWorldContactSurfaceLayer(0.01);
physicsWorld->setAutoDisableFlag(1);
physicsWorld->setAutoDisableTime(0.75);
physicsWorld->setWorldContactMaxCorrectingVel(1.0);
//physicsWorld->setGravity(Vec3f(0.0, 0.0, -9.81));
//physicsWorld->setCfm(0.001);
//physicsWorld->setErp(0.2);
hashSpace = PhysicsHashSpace::create();
physHandler = PhysicsHandler::create();
physHandler->setWorld(physicsWorld);
physHandler->pushToSpaces(hashSpace);
physHandler->setUpdateNode(rootNode);
physHandler->attachUpdateProducer(TutorialWindow->editEventProducer());
rootNode->addAttachment(physHandler);
rootNode->addAttachment(physicsWorld);
rootNode->addAttachment(hashSpace);
/************************************************************************/
/* create spaces, geoms and bodys */
/************************************************************************/
//create a group for our space
GroupRefPtr spaceGroup;
spaceGroupNode = makeCoredNode<Group>(&spaceGroup);
//add Attachments to nodes...
//.........这里部分代码省略.........
示例4: main
//.........这里部分代码省略.........
norms->push_back(Vec3f( 0.0,0.0,1.0));
//Right Femur
norms->push_back(Vec3f( 0.0,0.0,1.0));
norms->push_back(Vec3f( 0.0,0.0,1.0));
norms->push_back(Vec3f( 0.0,0.0,1.0));
norms->push_back(Vec3f( 0.0,0.0,1.0));
//Right Tibia
norms->push_back(Vec3f( 0.0,0.0,1.0));
norms->push_back(Vec3f( 0.0,0.0,1.0));
norms->push_back(Vec3f( 0.0,0.0,1.0));
norms->push_back(Vec3f( 0.0,0.0,1.0));
//Right Foot
norms->push_back(Vec3f( 0.0,1.0,0.0));
norms->push_back(Vec3f( 0.0,1.0,0.0));
norms->push_back(Vec3f( 0.0,1.0,0.0));
norms->push_back(Vec3f( 0.0,1.0,0.0));
//Tell the geometry (geo) to use the points and normals we just defined
geo->setTypes (type);
geo->setLengths (lens);
geo->setPositions(pnts);
geo->setNormals(norms);
// assign a material to the geometry to make it visible. The details
// of materials are defined later.
geo->setMaterial(getDefaultMaterial());
//Create unbound geometry node (for displaying mesh in its bind pose)
UnboundGeometry = Node::create();
UnboundGeometry->setCore(geo);
UnboundGeometry->setTravMask(0); //By default, we won't show the mesh's bind pose
//SkeletonDrawer
SkeletonDrawableUnrecPtr ExampleSkeletonDrawable = SkeletonDrawable::create();
ExampleSkeletonDrawable->setSkeleton(ExampleSkeleton);
ExampleSkeletonDrawable->setMaterial(ExampleMaterial);
ExampleSkeletonDrawable->setDrawBindPose(false); //By default, we don't draw the skeleton's bind pose
ExampleSkeletonDrawable->setBindPoseColor(Color4f(0.0, 1.0, 0.0, 1.0)); //When drawn, the skeleton's bind pose renders green
ExampleSkeletonDrawable->setDrawPose(true); //By default, we do draw the skeleton's current pose
ExampleSkeletonDrawable->setPoseColor(Color4f(0.0, 0.0, 1.0, 1.0)); //The skeleton's current pose renders blue
//Skeleton Node
SkeletonNode = Node::create();
SkeletonNode->setCore(ExampleSkeletonDrawable);
// Skeleton Blended Geometry
// Here we are attaching the "skin" to the skeleton so that when the skeleton is animated, the skin moves with it
ExampleSkeleton->setBaseGeometry(geo);
//Back
ExampleSkeleton->addJointBlending(0,Pelvis,1.0f);
ExampleSkeleton->addJointBlending(1,Pelvis,1.0f);
ExampleSkeleton->addJointBlending(2,Clavicle,1.0f);
ExampleSkeleton->addJointBlending(3,Clavicle,1.0f);
//Head
ExampleSkeleton->addJointBlending(4,Clavicle,1.0f);
ExampleSkeleton->addJointBlending(5,Clavicle,1.0f);