本文整理汇总了C++中NodeUnrecPtr::getCore方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeUnrecPtr::getCore方法的具体用法?C++ NodeUnrecPtr::getCore怎么用?C++ NodeUnrecPtr::getCore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeUnrecPtr
的用法示例。
在下文中一共展示了NodeUnrecPtr::getCore方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTreeComponent
ComponentTransitPtr SceneNodeTreeComponentGenerator::getTreeComponent(Tree* const Parent,
const boost::any& Value,
bool IsSelected,
bool Expanded,
bool Leaf,
UInt32 Row,
bool HasFocus)
{
NodeUnrecPtr TheNode;
try
{
TheNode = boost::any_cast<NodeUnrecPtr>(Value);
}
catch (boost::bad_any_cast &)
{
//Could not convert to FieldContinerFieldPath
return ComponentTransitPtr(NULL);
}
//Get the text for the label
std::string LabelText("");
if(TheNode != NULL)
{
const Char8* name(getName(TheNode));
if(name)
{
LabelText += std::string(name) + " ";
}
if(TheNode->getCore() != NULL)
{
LabelText += std::string("[") + TheNode->getCore()->getType().getCName() + "]";
}
else
{
LabelText += "[NULL core]";
}
}
else
{
LabelText += "NULL";
}
ComponentRecPtr GenComp = getTreeComponentText(Parent, LabelText, IsSelected, Expanded, Leaf, Row, HasFocus);
if(TheNode != NULL &&
!(TheNode->getTravMask() & getTravMask()))
{
GenComp->setEnabled(false);
}
return ComponentTransitPtr(GenComp);
}
示例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)
{
//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)
{
//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);
}
}
//Switch animation
if(e->getKey() == KeyEvent::KEY_1)
{
TheCurrentAnimation = TheJointAnimation;
}
else if(e->getKey() == KeyEvent::KEY_2)
{
TheCurrentAnimation = TheChildJointAnimation;
}
}
示例3: buildBox
PhysicsBodyUnrecPtr buildBox(const Pnt3f& Position,
const Vec3f& Dimensions,
const Color3f& Color,
Node* const spaceGroupNode,
PhysicsWorld* const physicsWorld,
PhysicsHashSpace* const physicsSpace)
{
Matrix m;
//create OpenSG mesh
GeometryUnrecPtr box;
NodeUnrecPtr boxNode = makeBox(Dimensions.x(), Dimensions.y(), Dimensions.z(), 1, 1, 1);
box = dynamic_cast<Geometry*>(boxNode->getCore());
SimpleMaterialUnrecPtr box_mat = SimpleMaterial::create();
box_mat->setAmbient(Color3f(0.0,0.0,0.0));
box_mat->setDiffuse(Color);
box->setMaterial(box_mat);
TransformUnrecPtr boxTrans;
NodeUnrecPtr boxTransNode = makeCoredNode<Transform>(&boxTrans);
m.setIdentity();
m.setTranslate(Position);
boxTrans->setMatrix(m);
//create ODE data
PhysicsBodyUnrecPtr boxBody = PhysicsBody::create(physicsWorld);
boxBody->setPosition(Vec3f(Position));
boxBody->setBoxMass(1.0,Dimensions.x(), Dimensions.y(), Dimensions.z());
boxBody->setLinearDamping(0.0001);
boxBody->setAngularDamping(0.0001);
PhysicsBoxGeomUnrecPtr boxGeom = PhysicsBoxGeom::create();
boxGeom->setBody(boxBody);
boxGeom->setSpace(physicsSpace);
boxGeom->setLengths(Dimensions);
//add attachments
boxNode->addAttachment(boxGeom);
boxTransNode->addAttachment(boxBody);
boxTransNode->addChild(boxNode);
//add to SceneGraph
spaceGroupNode->addChild(boxTransNode);
return boxBody;
}
示例4: buildSphere
//////////////////////////////////////////////////////////////////////////
//! build a sphere
//////////////////////////////////////////////////////////////////////////
PhysicsBodyUnrecPtr buildSphere(void)
{
Real32 Radius((Real32)(rand()%2)*0.5+0.5);
Matrix m;
//create OpenSG mesh
GeometryUnrecPtr sphere;
NodeUnrecPtr sphereNode = makeSphere(2, Radius);
sphere = dynamic_cast<Geometry*>(sphereNode->getCore());
SimpleMaterialUnrecPtr sphere_mat = SimpleMaterial::create();
sphere_mat->setAmbient(Color3f(0.0,0.0,0.0));
sphere_mat->setDiffuse(Color3f(0.0,0.0,1.0));
sphere->setMaterial(sphere_mat);
TransformUnrecPtr sphereTrans;
NodeUnrecPtr sphereTransNode = makeCoredNode<Transform>(&sphereTrans);
m.setIdentity();
Real32 randX = (Real32)(rand()%10)-5.0;
Real32 randY = (Real32)(rand()%10)-5.0;
m.setTranslate(randX, randY, 10.0);
sphereTrans->setMatrix(m);
//create ODE data
PhysicsBodyUnrecPtr sphereBody = PhysicsBody::create(physicsWorld);
sphereBody->setPosition(Vec3f(randX, randY, 10.0));
sphereBody->setLinearDamping(0.0001);
sphereBody->setAngularDamping(0.0001);
sphereBody->setSphereMass(1.0,Radius);
PhysicsSphereGeomUnrecPtr sphereGeom = PhysicsSphereGeom::create();
sphereGeom->setBody(sphereBody);
sphereGeom->setSpace(physicsSpace);
sphereGeom->setRadius(Radius);
//add attachments
sphereNode->addAttachment(sphereGeom);
sphereTransNode->addAttachment(sphereBody);
sphereTransNode->addChild(sphereNode);
//add to SceneGraph
spaceGroupNode->addChild(sphereTransNode);
commitChanges();
return sphereBody;
}
示例5: buildBox
//////////////////////////////////////////////////////////////////////////
//! build a box
//////////////////////////////////////////////////////////////////////////
PhysicsBodyUnrecPtr buildBox(void)
{
Vec3f Lengths((Real32)(rand()%2)+1.0, (Real32)(rand()%2)+1.0, (Real32)(rand()%2)+1.0);
Matrix m;
//create OpenSG mesh
GeometryUnrecPtr box;
NodeUnrecPtr boxNode = makeBox(Lengths.x(), Lengths.y(), Lengths.z(), 1, 1, 1);
box = dynamic_cast<Geometry*>(boxNode->getCore());
SimpleMaterialUnrecPtr box_mat = SimpleMaterial::create();
box_mat->setAmbient(Color3f(0.0,0.0,0.0));
box_mat->setDiffuse(Color3f(0.0,1.0 ,0.0));
box->setMaterial(box_mat);
TransformUnrecPtr boxTrans;
NodeUnrecPtr boxTransNode = makeCoredNode<Transform>(&boxTrans);
m.setIdentity();
Real32 randX = (Real32)(rand()%10)-5.0;
Real32 randY = (Real32)(rand()%10)-5.0;
m.setTranslate(randX, randY, 10.0);
boxTrans->setMatrix(m);
//create ODE data
PhysicsBodyUnrecPtr boxBody = PhysicsBody::create(physicsWorld);
boxBody->setPosition(Vec3f(randX, randY, 10.0));
boxBody->setBoxMass(1.0, Lengths.x(), Lengths.y(), Lengths.z());
PhysicsBoxGeomUnrecPtr boxGeom = PhysicsBoxGeom::create();
boxGeom->setBody(boxBody);
boxGeom->setSpace(physicsSpace);
boxGeom->setLengths(Lengths);
//add attachments
boxNode->addAttachment(boxGeom);
boxTransNode->addAttachment(boxBody);
boxTransNode->addChild(boxNode);
//add to SceneGraph
spaceGroupNode->addChild(boxTransNode);
commitChanges();
return boxBody;
}
示例6: 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);
}
}
}
}
示例7: 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);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//Make Torus Node
NodeUnrecPtr TorusNode = makeTorus(.5, 2, 32, 32);
//Make Main Scene Node
NodeUnrecPtr scene = makeCoredNode<Group>();
setName(scene, "scene");
rootNode = Node::create();
setName(rootNode, "rootNode");
ComponentTransformUnrecPtr Trans;
Trans = ComponentTransform::create();
rootNode->setCore(Trans);
// add the torus as a child
rootNode->addChild(scene);
//Setup Physics Scene
physicsWorld = PhysicsWorld::create();
physicsWorld->setWorldContactSurfaceLayer(0.005);
physicsWorld->setAutoDisableFlag(1);
physicsWorld->setAutoDisableTime(0.75);
physicsWorld->setWorldContactMaxCorrectingVel(100.0);
physicsWorld->setGravity(Vec3f(0.0, 0.0, -9.81));
//physicsSpace = PhysicsSimpleSpace::create();
//physicsSpace = PhysicsQuadTreeSpace::create();
//physicsSpace = PhysicsHashSpace::create();
physicsSpace = PhysicsSweepAndPruneSpace::create();
CollisionContactParametersUnrecPtr DefaultCollisionParams = CollisionContactParameters::createEmpty();
DefaultCollisionParams->setMode(dContactApprox1 | dContactBounce);
DefaultCollisionParams->setMu(0.3);
DefaultCollisionParams->setMu2(0.0);
DefaultCollisionParams->setBounce(0.2);
DefaultCollisionParams->setBounceSpeedThreshold(0.1);
DefaultCollisionParams->setSoftCFM(0.1);
DefaultCollisionParams->setSoftERP(0.2);
DefaultCollisionParams->setMotion1(0.0);
DefaultCollisionParams->setMotion2(0.0);
DefaultCollisionParams->setMotionN(0.0);
DefaultCollisionParams->setSlip1(0.0);
DefaultCollisionParams->setSlip2(0.0);
physicsSpace->setDefaultCollisionParameters(DefaultCollisionParams);
physHandler = PhysicsHandler::create();
physHandler->setWorld(physicsWorld);
physHandler->pushToSpaces(physicsSpace);
physHandler->setUpdateNode(rootNode);
physHandler->attachUpdateProducer(TutorialWindow->editEventProducer());
rootNode->addAttachment(physHandler);
rootNode->addAttachment(physicsWorld);
rootNode->addAttachment(physicsSpace);
/************************************************************************/
/* create spaces, geoms and bodys */
/************************************************************************/
//create a group for our space
GroupUnrecPtr spaceGroup;
spaceGroupNode = makeCoredNode<Group>(&spaceGroup);
//create the ground plane
GeometryUnrecPtr plane;
NodeUnrecPtr planeNode = makeBox(30.0, 30.0, 1.0, 1, 1, 1);
plane = dynamic_cast<Geometry*>(planeNode->getCore());
//and its Material
SimpleMaterialUnrecPtr plane_mat = SimpleMaterial::create();
plane_mat->setAmbient(Color3f(0.7,0.7,0.7));
plane_mat->setDiffuse(Color3f(0.9,0.6,1.0));
plane->setMaterial(plane_mat);
//.........这里部分代码省略.........