本文整理汇总了C++中NodeRecPtr::getCore方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeRecPtr::getCore方法的具体用法?C++ NodeRecPtr::getCore怎么用?C++ NodeRecPtr::getCore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeRecPtr
的用法示例。
在下文中一共展示了NodeRecPtr::getCore方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VRIntersect_computeTexel
Vec2f VRIntersect_computeTexel(VRIntersection& ins, NodeRecPtr node) {
if (!ins.hit) return Vec2f(0,0);
if (node == 0) return Vec2f(0,0);
GeometryRefPtr geo = dynamic_cast<Geometry*>( node->getCore() );
if (geo == 0) return Vec2f(0,0);
auto texcoords = geo->getTexCoords();
if (texcoords == 0) return Vec2f(0,0);
TriangleIterator iter = geo->beginTriangles(); iter.seek( ins.triangle );
Matrix m = node->getToWorld();
m.invert();
Pnt3f local_pnt; m.mult(ins.point, local_pnt);
Pnt3f p0 = iter.getPosition(0);
Pnt3f p1 = iter.getPosition(1);
Pnt3f p2 = iter.getPosition(2);
Vec3f cr = (p1 - p0).cross(p2 - p0);
Vec3f n = cr; n.normalize();
float areaABC = n.dot(cr);
float areaPBC = n.dot((p1 - local_pnt).cross(p2 - local_pnt));
float areaPCA = n.dot((p2 - local_pnt).cross(p0 - local_pnt));
float a = areaPBC / areaABC;
float b = areaPCA / areaABC;
float c = 1.0f - a - b;
return iter.getTexCoords(0) * a + iter.getTexCoords(1) * b + iter.getTexCoords(2) * c;
}
示例2: createNodeGeo
NodeTransitPtr OctreeVisualization::createNodeGeo(OctreePtr,
const Octree::OTNodePtr node,
Material* GeoMaterial,
const Node* BaseGeo)
{
//Make the Geoemtry
NodeRecPtr box = deepCloneTree(BaseGeo);
dynamic_cast<Geometry*>(box->getCore())->setMaterial(GeoMaterial);
Matrix m;
TransformRecPtr box_trans;
NodeRecPtr trans_node = makeCoredNode<Transform>(&box_trans);
Pnt3f Center;
node->getVolume().getCenter(Center);
m.setTranslate( Center.x(), Center.y(), Center.z());
const Real32 Offset(0.0f);
Vec3f Size;
node->getVolume().getSize(Size);
m.setScale(Size.x()-(Size.x()*Offset), Size.y()-(Size.y()*Offset), Size.z()-(Size.z()*Offset));
box_trans->setMatrix(m);
trans_node->addChild(box);
return NodeTransitPtr(trans_node);
}
示例3: buildBox
//////////////////////////////////////////////////////////////////////////
//! build a box
//////////////////////////////////////////////////////////////////////////
void buildBox(Node* const spaceGroupNode, PhysicsWorld* const physicsWorld, PhysicsHashSpace* const physicsSpace)
{
Vec3f Lengths((Real32)(rand()%2)+1.0, (Real32)(rand()%2)+1.0, (Real32)(rand()%2)+1.0);
Matrix m;
//create OpenSG mesh
GeometryRecPtr box;
NodeRecPtr boxNode = makeBox(Lengths.x(), Lengths.y(), Lengths.z(), 1, 1, 1);
box = dynamic_cast<Geometry*>(boxNode->getCore());
SimpleMaterialRecPtr 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);
TransformRecPtr boxTrans;
NodeRecPtr 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
PhysicsBodyRecPtr boxBody = PhysicsBody::create(physicsWorld);
boxBody->setPosition(Vec3f(randX, randY, 10.0));
boxBody->setBoxMass(1.0, Lengths.x(), Lengths.y(), Lengths.z());
//std::cout << "mass: " << boxBody->getMass() << std::endl
//<< "massCenterOfGravity: " << boxBody->getMassCenterOfGravity().x() << ", " << boxBody->getMassCenterOfGravity().y() << ", " << boxBody->getMassCenterOfGravity().z() << std::endl
//<< "massInertiaTensor: " << std::endl
//<< boxBody->getMassInertiaTensor()[0][0] << " "<< boxBody->getMassInertiaTensor()[0][1] << " "<< boxBody->getMassInertiaTensor()[0][2] << " " << boxBody->getMassInertiaTensor()[0][3] << std::endl
//<< boxBody->getMassInertiaTensor()[1][0] << " "<< boxBody->getMassInertiaTensor()[1][1] << " "<< boxBody->getMassInertiaTensor()[1][2] << " " << boxBody->getMassInertiaTensor()[1][3] << std::endl
//<< boxBody->getMassInertiaTensor()[2][0] << " "<< boxBody->getMassInertiaTensor()[2][1] << " "<< boxBody->getMassInertiaTensor()[2][2] << " " << boxBody->getMassInertiaTensor()[2][3] << std::endl
//<< boxBody->getMassInertiaTensor()[3][0] << " "<< boxBody->getMassInertiaTensor()[3][1] << " "<< boxBody->getMassInertiaTensor()[3][2] << " " << boxBody->getMassInertiaTensor()[3][3] << std::endl
//<< std::endl;
PhysicsBoxGeomRecPtr 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();
}
示例4: buildTriMesh
//////////////////////////////////////////////////////////////////////////
//! trimesh defined by filenode will be loaded
//////////////////////////////////////////////////////////////////////////
void buildTriMesh(Node* const TriGeometryBase, Node* const spaceGroupNode, PhysicsWorld* const physicsWorld, PhysicsHashSpace* const physicsSpace)
{
NodeRecPtr tri = cloneTree(TriGeometryBase);
if(tri!=NULL)
{
GeometryRecPtr triGeo = dynamic_cast<Geometry*>(tri->getCore());
Matrix m;
SimpleMaterialRecPtr tri_mat = SimpleMaterial::create();
tri_mat->setAmbient(Color3f(0.1,0.1,0.2));
tri_mat->setDiffuse(Color3f(1.0,0.1,0.7));
triGeo->setMaterial(tri_mat);
TransformRecPtr triTrans;
NodeRecPtr triTransNode = makeCoredNode<Transform>(&triTrans);
m.setIdentity();
Real32 randX = (Real32)(rand()%10)-5.0;
Real32 randY = (Real32)(rand()%10)-5.0;
m.setTranslate(randX, randY, 18.0);
triTrans->setMatrix(m);
//create ODE data
Vec3f GeometryBounds(calcMinGeometryBounds(triGeo));
PhysicsBodyRecPtr triBody = PhysicsBody::create(physicsWorld);
triBody->setPosition(Vec3f(randX, randY, 18.0));
triBody->setLinearDamping(0.0001);
triBody->setAngularDamping(0.0001);
triBody->setBoxMass(1.0,GeometryBounds.x(), GeometryBounds.y(), GeometryBounds.z());
PhysicsGeomRecPtr triGeom;
if(true)
{
triGeom = PhysicsTriMeshGeom::create();
triGeom->setBody(triBody);
//add geom to space for collision
triGeom->setSpace(physicsSpace);
//set the geometryNode to fill the ode-triMesh
NodeRecPtr TorusGeometryNode(makeTorus(0.55, 1.05, 6, 6));
dynamic_pointer_cast<PhysicsTriMeshGeom>(triGeom)->setGeometryNode(TorusGeometryNode);
}
//add attachments
tri->addAttachment(triGeom);
triTransNode->addAttachment(triBody);
//add to SceneGraph
triTransNode->addChild(tri);
spaceGroupNode->addChild(triTransNode);
}
else
{
SLOG << "Could not read MeshData!" << endLog;
}
commitChanges();
}
示例5: buildSphere
//////////////////////////////////////////////////////////////////////////
//! build a sphere
//////////////////////////////////////////////////////////////////////////
void buildSphere(Node* const spaceGroupNode, PhysicsWorld* const physicsWorld, PhysicsHashSpace* const physicsSpace)
{
Real32 Radius((Real32)(rand()%2)*0.5+0.5);
Matrix m;
//create OpenSG mesh
GeometryRecPtr sphere;
NodeRecPtr sphereNode = makeSphere(2, Radius);
sphere = dynamic_cast<Geometry*>(sphereNode->getCore());
SimpleMaterialRecPtr 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);
TransformRecPtr sphereTrans;
NodeRecPtr 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
PhysicsBodyRecPtr sphereBody = PhysicsBody::create(physicsWorld);
sphereBody->setPosition(Vec3f(randX, randY, 10.0));
sphereBody->setAngularDamping(0.0001);
sphereBody->setSphereMass(1.0,Radius);
PhysicsSphereGeomRecPtr 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();
}
示例6: createBox
NodeTransitPtr createBox(void)
{
// Make Object Nodes
NodeRecPtr ExampleBoxGeo = makeBox(100, 100, 100, 1, 1, 1);
MaterialRecPtr GreenMaterial = createMaterial(Color4f(0.0f,1.0f,0.0f,1.0f));
dynamic_cast<Geometry*>(ExampleBoxGeo->getCore())->setMaterial(GreenMaterial);
Matrix mat;
mat.setTranslate(250.0,250.0,0.0);
TransformRecPtr ExampleBoxTranCore = Transform::create();
ExampleBoxTranCore->setMatrix(mat);
NodeRecPtr ExampleBox = Node::create();
ExampleBox->setCore(ExampleBoxTranCore);
ExampleBox->addChild(ExampleBoxGeo);
ExampleBox->setTravMask(0);
return NodeTransitPtr(ExampleBox);
}
示例7: createSphere
NodeTransitPtr createSphere(void)
{
// Make Object Nodes
NodeRecPtr ExampleSphereGeo = makeSphere(4, 100);
MaterialRecPtr RedMaterial = createMaterial(Color4f(1.0f,0.0f,0.0f,1.0f));
dynamic_cast<Geometry*>(ExampleSphereGeo->getCore())->setMaterial(RedMaterial);
Matrix mat;
mat.setTranslate(250.0,0.0,0.0);
TransformRecPtr SphereTranCore = Transform::create();
SphereTranCore->setMatrix(mat);
NodeRecPtr ExampleSphere = Node::create();
ExampleSphere->setCore(SphereTranCore);
ExampleSphere->addChild(ExampleSphereGeo);
ExampleSphere->setTravMask(0);
return NodeTransitPtr(ExampleSphere);
}
示例8: createNodeDistanceLOD
NodeTransitPtr OctreeVisualization::createNodeDistanceLOD(OctreePtr,
const Octree::OTNodePtr node,
Material* GeoMaterial,
const Node* BaseGeo,
Real32 Range
)
{
NodeRecPtr box = deepCloneTree(BaseGeo);
dynamic_cast<Geometry*>(box->getCore())->setMaterial(GeoMaterial);
//DistanceLOD node
DistanceLODRecPtr LOD = DistanceLOD::create();
LOD->editMFRange()->push_back(10.0);
NodeRecPtr LODNode = makeNodeFor(LOD);
LODNode->addChild(box);
LODNode->addChild(makeCoredNode<Group>());
Matrix m;
TransformRecPtr box_trans;
NodeRecPtr trans_node = makeCoredNode<Transform>(&box_trans);
Pnt3f Center;
node->getVolume().getCenter(Center);
m.setTranslate(Center.x(),
Center.y(),
Center.z());
const Real32 Offset(0.0f);
Vec3f Size;
node->getVolume().getSize(Size);
m.setScale(Size.x()-(Size.x()*Offset),
Size.y()-(Size.y()*Offset),
Size.z()-(Size.z()*Offset));
box_trans->setMatrix(m);
trans_node->addChild(LODNode);
return NodeTransitPtr(trans_node);
}
示例9: createCone
NodeTransitPtr createCone(void)
{
// Make Object Nodes
NodeRecPtr ExampleConeGeo = makeCone(150, 50, 16, true, true);
MaterialRecPtr BlueMaterial = createMaterial(Color4f(0.0f,0.0f,1.0f,1.0f));
dynamic_cast<Geometry*>(ExampleConeGeo->getCore())->setMaterial(BlueMaterial);
// Preform transformations on them
Matrix mat;
// On Cone
mat.setTranslate(0.0,0.0,-250.0);
TransformRecPtr ConeTranCore = Transform::create();
ConeTranCore->setMatrix(mat);
NodeRecPtr ExampleCone = Node::create();
ExampleCone->setCore(ConeTranCore);
ExampleCone->addChild(ExampleConeGeo);
ExampleCone->setTravMask(0);
return NodeTransitPtr(ExampleCone);
}
示例10: makeUnique
void VRGeometry::makeUnique() {
if (mesh_node == 0) return;
NodeRecPtr clone = deepCloneTree( mesh_node );
setMesh( dynamic_cast<Geometry*>( clone->getCore() ), source );
}
示例11: selectedNodeChanged
void selectedNodeChanged(void)
{
_mgr->setHighlight(_SelectedNode);
//Update Details Panel
if(_SelectedNode == NULL)
{
_NodeNameValueLabel->setText("");
_NodeCoreTypeValueLabel->setText("");
_NodeMinValueLabel->setText("");
_NodeMaxValueLabel->setText("");
_NodeCenterValueLabel->setText("");
_NodeTriCountValueLabel->setText("");
_NodeTravMaskValueLabel->setText("");
}
else
{
const Char8 *NodeName = getName(_SelectedNode);
if(NodeName == NULL)
{
_NodeNameValueLabel->setText("Unnamed Node");
}
else
{
_NodeNameValueLabel->setText(NodeName);
}
_NodeCoreTypeValueLabel->setText(_SelectedNode->getCore()->getType().getCName());
BoxVolume DyVol;
_SelectedNode->getWorldVolume(DyVol);
Pnt3f Min,Max,Center;
DyVol.getBounds(Min,Max);
DyVol.getCenter(Center);
std::string TempText("");
TempText = boost::lexical_cast<std::string>(Min.x())
+ ", " +boost::lexical_cast<std::string>(Min.x())
+ ", " + boost::lexical_cast<std::string>(Min.x());
_NodeMinValueLabel->setText(TempText);
TempText = boost::lexical_cast<std::string>(Max.x())
+ ", " +boost::lexical_cast<std::string>(Max.x())
+ ", " + boost::lexical_cast<std::string>(Max.x());
_NodeMaxValueLabel->setText(TempText);
TempText = boost::lexical_cast<std::string>(Center.x())
+ ", " +boost::lexical_cast<std::string>(Center.x())
+ ", " + boost::lexical_cast<std::string>(Center.x());
_NodeCenterValueLabel->setText(TempText);
_NodeTravMaskValueLabel->setText(boost::lexical_cast<std::string>(_SelectedNode->getTravMask()));
//Tri Cound
TriCountGraphOpRefPtr TheTriGraphOp = TriCountGraphOp::create();
TheTriGraphOp->traverse(_SelectedNode);
_NodeTriCountValueLabel->setText(boost::lexical_cast<std::string>(TheTriGraphOp->getNumTri()));
}
}
示例12: main
// Initialize GLUT & OpenSG and set up the rootNode
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
{
// Set up Window
WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
SimpleSceneManager sceneManager;
TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));
//Attach to events
TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
TutorialWindow->connectMouseMoved(boost::bind(mouseMoved, _1, &sceneManager));
TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
// Tell the Manager what to manage
sceneManager.setWindow(TutorialWindow);
//Make Base Geometry Node
NodeRecPtr TriGeometryBase = makeTorus(0.5, 1.0, 24, 24);
//Make Main Scene Node
NodeRecPtr scene = makeCoredNode<Group>();
setName(scene, "scene");
NodeRecPtr rootNode = Node::create();
setName(rootNode, "rootNode");
ComponentTransformRecPtr Trans;
Trans = ComponentTransform::create();
rootNode->setCore(Trans);
// add the torus as a child
rootNode->addChild(scene);
//Make The Physics Characteristics Node
PhysicsCharacteristicsDrawableRecPtr PhysDrawable = PhysicsCharacteristicsDrawable::create();
PhysDrawable->setRoot(rootNode);
NodeRecPtr PhysDrawableNode = Node::create();
PhysDrawableNode->setCore(PhysDrawable);
PhysDrawableNode->setTravMask(TypeTraits<UInt32>::getMin());
rootNode->addChild(PhysDrawableNode);
//Setup Physics Scene
PhysicsWorldRecPtr 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));
PhysicsHashSpaceRecPtr physicsSpace = PhysicsHashSpace::create();
PhysicsHandlerRecPtr physHandler = PhysicsHandler::create();
physHandler->setWorld(physicsWorld);
physHandler->pushToSpaces(physicsSpace);
physHandler->setUpdateNode(rootNode);
physHandler->attachUpdateProducer(TutorialWindow);
/************************************************************************/
/* create spaces, geoms and bodys */
/************************************************************************/
//create a group for our space
GroupRecPtr spaceGroup;
NodeRecPtr spaceGroupNode = makeCoredNode<Group>(&spaceGroup);
//create the ground plane
GeometryRecPtr plane;
NodeRecPtr planeNode = makeBox(30.0, 30.0, 1.0, 1, 1, 1);
plane = dynamic_cast<Geometry*>(planeNode->getCore());
//and its Material
SimpleMaterialRecPtr 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);
//create Physical Attachments
PhysicsBoxGeomRecPtr planeGeom = PhysicsBoxGeom::create();
planeGeom->setLengths(Vec3f(30.0, 30.0, 1.0));
//add geoms to space for collision
planeGeom->setSpace(physicsSpace);
//add Attachments to nodes...
spaceGroupNode->addAttachment(physicsSpace);
spaceGroupNode->addAttachment(physHandler);
spaceGroupNode->addAttachment(physicsWorld);
spaceGroupNode->addChild(planeNode);
//.........这里部分代码省略.........