本文整理汇总了C++中NodeRecPtr类的典型用法代码示例。如果您正苦于以下问题:C++ NodeRecPtr类的具体用法?C++ NodeRecPtr怎么用?C++ NodeRecPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeRecPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setName
void AddLightToSceneCommand::execute(void)
{
//Make the Light Beacon node
_CreatedLightBeaconNode = makeCoredNode<Transform>();
setName(_CreatedLightBeaconNode, _LightType.getName() + "_Beacon_Node");
//Make the Light node
LightRecPtr NewLight = dynamic_pointer_cast<Light>(_LightType.createContainer());
NewLight->setBeacon(_CreatedLightBeaconNode);
setName(NewLight, _LightType.getName() + "_NodeCore");
_CreatedLightNode = Node::create();
setName(_CreatedLightNode, _LightType.getName() + "_Node");
_CreatedLightNode->setCore(NewLight);
//Get the Root node
NodeRecPtr RootNode = _RootScene->getPrimaryViewport()->getRoot();
//Move all of the child nodes on the root onto children of the light node
while(RootNode->getNChildren() != 0)
{
_CreatedLightNode->addChild(RootNode->getChild(0));
}
_CreatedLightNode->addChild(_CreatedLightBeaconNode);
//Add the Light node to the root
RootNode->addChild(_CreatedLightNode);
dynamic_cast<ApplicationBuilder*>(MainApplication::the()->getBuilderMode())->getMainWindow()->getSceneComponentTree()->getTreeModel()->lightAdded(dynamic_cast<Light*>(_CreatedLightNode->getCore()));
_HasBeenDone = true;
}
示例2: deepCloneTree
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: 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;
}
示例4: undo
void AddLightToSceneCommand::undo(void)
{
Inherited::undo();
dynamic_cast<ApplicationBuilder*>(MainApplication::the()->getBuilderMode())->getMainWindow()->getSceneComponentTree()->getTreeModel()->lightWillBeRemoved(dynamic_cast<Light*>(_CreatedLightNode->getCore()));
//Get the Root node
NodeRecPtr RootNode = _RootScene->getPrimaryViewport()->getRoot();
//Move all of the child nodes on the root onto children of the light node
while(_CreatedLightNode->getNChildren() != 0)
{
RootNode->addChild(_CreatedLightNode->getChild(0));
}
//Add the Light node to the root
RootNode->subChild(_CreatedLightBeaconNode);
dynamic_cast<ApplicationBuilder*>(MainApplication::the()->getBuilderMode())->getMainWindow()->getSceneComponentTree()->getTreeModel()->lightRemoved(dynamic_cast<Light*>(_CreatedLightNode->getCore()));
}
示例5: createTorus
NodeTransitPtr createTorus(void)
{
// Make Object Nodes
NodeRecPtr ExampleTorusGeo = makeTorus(90, 270, 16, 16);
// Preform transformations on them
Matrix mat;
// On Torus
mat.setTranslate(0.0,100.0,-200.0);
TransformRecPtr TorusTranCore = Transform::create();
TorusTranCore->setMatrix(mat);
NodeRecPtr ExampleTorus = Node::create();
ExampleTorus->setCore(TorusTranCore);
ExampleTorus->addChild(ExampleTorusGeo);
ExampleTorus->setTravMask(0);
return NodeTransitPtr(ExampleTorus);
}
示例6: getGlobal
void
ColladaNode::handleInstanceLight(domInstance_light *instLight)
{
ColladaInstanceLightRefPtr colInstLight =
getUserDataAs<ColladaInstanceLight>(instLight);
if(colInstLight == NULL)
{
colInstLight = dynamic_pointer_cast<ColladaInstanceLight>(
ColladaElementFactory::the()->create(instLight, getGlobal()));
colInstLight->read();
}
//push the Light onto the root
LightUnrecPtr light = colInstLight->process(this);
if(light != NULL)
{
//Append the lights beacon node
GroupUnrecPtr lightBeacon = Group::create();
NodeRecPtr lightBeaconN = Node::create();
lightBeaconN->setCore(lightBeacon);
/*std::string BeaconNodeName(instLight->getName());
BeaconNodeName += "_beacon";
setName(lightBeaconN, BeaconNodeName);*/
//TODO: set beacon name
appendChild(lightBeaconN);
light->setBeacon(lightBeaconN);
NodeRecPtr lightN = Node::create();
lightN->setCore(light);
//setName(lightN,instLight->getName());
//TODO: set light name
_visualScene->pushNodeToRoot(lightN);
}
}
示例7: VRTransform
VRCamera::VRCamera(string name) : VRTransform(name) {
parallaxD = 2;
nearClipPlaneCoeff = 0.1;
//farClipPlaneCoeff = 250000;
farClipPlaneCoeff = 250;
cam_invert_z = true;
cam = PerspectiveCamera::create();
cam->setBeacon(getNode());
cam->setFov(osgDegree2Rad(60));
cam->setNear(parallaxD* nearClipPlaneCoeff);
cam->setFar(parallaxD* farClipPlaneCoeff);
type = "Camera";
doAcceptRoot = true;
camGeo = 0;
TransformRecPtr trans = Transform::create();
NodeRecPtr t = makeNodeFor(trans);
trans->editMatrix().setTranslate(Vec3f(0,0,0.25));
GeometryRecPtr camGeo_ = makeBoxGeo(0.2, 0.2, 0.25, 1, 1, 1);
GeometryRecPtr camGeo2_ = makeCylinderGeo(0.2, 0.07, 16, 1, 1, 1);
camGeo = makeNodeFor(camGeo_);
NodeRecPtr camGeo2 = makeNodeFor(camGeo2_);
camGeo->setTravMask(0);
camGeo_->setMaterial(getCamGeoMat()->getMaterial());
camGeo2_->setMaterial(getCamGeoMat()->getMaterial());
addChild(t);
t->addChild(camGeo);
TransformRecPtr trans2 = Transform::create();
NodeRecPtr t2 = makeNodeFor(trans2);
trans2->editMatrix().setTranslate(Vec3f(0,0,-0.15));
trans2->editMatrix().setRotate(Quaternion(Vec3f(1,0,0), Pi*0.5));
camGeo->addChild(t2);
t2->addChild(camGeo2);
getAll().push_back(this);
VRGuiManager::broadcast("camera_added");
}
示例8: printd
OpenSGEnvironmentSceneGraphAttachment::~OpenSGEnvironmentSceneGraphAttachment() {
if (envGroupeNode->getNChildren() > 0) {
printd(ERROR,
"OpenSGEnvironmentSceneGraphAttachment::destructor(): Environment Group-Node still has children attached! FORCING REMOVE!\n");
for (int i=envGroupeNode->getNChildren()-1; i >= 0 ; i--) {
#if OSG_MAJOR_VERSION >= 2
envGroupeNode->subChild(i);
#else //OpenSG1:
beginEditCP(envGroupeNode);
envGroupeNode->subChild(i);
endEditCP(envGroupeNode);
#endif
} // for
} // if
#if OSG_MAJOR_VERSION >= 2
if (envTransNode->getParent() != NULL) {
printd(ERROR,
"OpenSGEnvironmentSceneGraphAttachment::destructor(): Environment Transformation Node still in SceneGraph! FORCING REMOVE!\n");
NodeRecPtr parentNode = envTransNode->getParent();
parentNode->subChild(envTransNode);
} // if
#else //OpenSG1:
if (envTransNode->getParent() != NullFC) {
printd(ERROR,
"OpenSGEnvironmentSceneGraphAttachment::destructor(): Environment Transformation Node still in SceneGraph! FORCING REMOVE!\n");
NodePtr parentNode = envTransNode->getParent();
beginEditCP(parentNode);
parentNode->subChild(envTransNode);
endEditCP(parentNode);
} // if
subRefCP(envTransNode);
#endif
} // ~OpenSGEnvironmentSceneGraphAttachment
示例9: 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();
}
示例10: 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();
}
示例11: 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();
}
示例12: 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);
}
示例13: 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);
}
示例14: 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);
}
示例15: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
{
// Set up Window
WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
// Create the SimpleSceneManager helper
SimpleSceneManager sceneManager;
TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));
// Tell the Manager what to manage
sceneManager.setWindow(TutorialWindow);
TutorialWindow->connectKeyTyped(boost::bind(keyPressed, _1));
// Make Torus Node (creates Torus in background of scene)
NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRecPtr TutorialGraphics = Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create a Spinner Model. This dictates
how the Spinner functions.
-setMaximum(int): Determine the Maximum
value the Spinner can have.
-setMinimum(int): Determine the Minimum
value the Spinner can have.
-setStepSize(int): Determine the
incremental step size.
-setValue(SharedFieldRecPtr(new SFInt32(int)):
Determine initial starting value
of the Spinner.
Note: the StepSize can be changed
dynamically as done in this
Tutorial with ButtonSelectedListeners.
******************************************************/
//Int32SpinnerModelPtr TheModel(new Int32SpinnerModel());
Int32SpinnerModelPtr TheModel(new Int32SpinnerModel());
TheModel->setMaximum(100);
TheModel->setMinimum(-100);
TheModel->setStepSize(1);
TheModel->setValue(boost::any(Int32(0)));
/******************************************************
Create a Spinner and and assign it a
Model.
******************************************************/
SpinnerRecPtr ExampleSpinner = Spinner::create();
ExampleSpinner->setModel(TheModel);
/******************************************************
Create a RadioButtonPanel to allow
for certain characteristics of the
Spinner to be changed dynamically.
See 14RadioButton for more
information about RadioButtons.
******************************************************/
RadioButtonRecPtr SingleIncrementButton = RadioButton::create();
RadioButtonRecPtr DoubleIncrementButton = RadioButton::create();
SingleIncrementButton->setText("Increment by 1");
SingleIncrementButton->setPreferredSize(Vec2f(100, 50));
SingleIncrementButton->connectButtonSelected(boost::bind(handleSingleIncbuttonSelected, _1,
TheModel));
DoubleIncrementButton->setText("Increment by 2");
DoubleIncrementButton->setPreferredSize(Vec2f(100, 50));
DoubleIncrementButton->connectButtonSelected(boost::bind(handleDoubleIncbuttonSelected, _1,
TheModel));
RadioButtonGroupRecPtr SelectionRadioButtonGroup = RadioButtonGroup::create();
SelectionRadioButtonGroup->addButton(SingleIncrementButton);
SelectionRadioButtonGroup->addButton(DoubleIncrementButton);
SingleIncrementButton->setSelected(true);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
//.........这里部分代码省略.........