Hello,

I am attaching a small snippet of code showing one of the probable usage
of FieldContainer that is taken from the starter guide.


But i am getting error


Could you point out my mistake as the error script saying as follows:

firstOSG.cpp: In function ‘int main(int, char**)’:
firstOSG.cpp:94: error: ‘class osg::Node’ has no member named ‘getChildren’
firstOSG.cpp:96: error: ‘class osg::Node’ has no member named ‘getChildren’
firstOSG.cpp:99: error: ‘class osg::Node’ has no member named ‘getChildren’
make: *** [firstOSG.o] Error 1


i m just copying the code from the guide, and need to understand what is
it doing?



Sajjad


// File : 01firstapp.cpp
//what follows here is the smallest OpenSG programm possible
//most things used here are explained now or on the next few pages, so don’t
//worry if not everything is clear right at the beginning...
//Some needed include files - these will become more, believe me ;)
#include "OpenSG/OSGConfig.h"
#include "OpenSG/OSGGLUT.h"
#include "OpenSG/OSGSimpleGeometry.h"
#include "OpenSG/OSGGLUTWindow.h"
#include "OpenSG/OSGSimpleSceneManager.h"
#include "OpenSG/OSGSimpleAttachments.h"
#include <iostream>
//In most cases it is useful to add this line, otherwise every OpenSG command
//must be preceeded by an extra OSG::
OSG_USING_NAMESPACE

using namespace std;

//The SimpleSceneManager is a useful class which helps us to
//manage simple configurations. It will be discussed in detail later on
SimpleSceneManager *mgr;


//create a transformation core as a global variable
TransformPtr transCore;


//we have a forward declaration here, just to have a better order
//of codepieces
int setupGLUT( int *argc, char *argv[] );


int main(int argc, char **argv)
{
    // Init the OpenSG subsystem
    osgInit(argc,argv);
    // We create a GLUT Window (that is almost the same for most applications)
    int winid = setupGLUT(&argc, argv);

    GLUTWindowPtr gwin = GLUTWindow::create();

    gwin->setId(winid);
    gwin->init();


    // This will be our whole scene for now : an incredible torus
    /*
    NodePtr torus  = makeTorus(.5, 2, 160, 160);
    NodePtr transNode = makeCoredNode<Transform>(&transCore);

    Matrix m;

   //now provide some data
   m.setIdentity();

   beginEditCP(transNode);
        //add the torus that have created by  the high-level command
        //to  the node as a children
        transNode->addChild(torus);
   endEditCP(transNode);
   */


    //
    //Instead of the torus we are now adding the grandpa hierrarchies
    
    NodePtr grandpa = Node::create();
    NodePtr aunt = Node::create();
    NodePtr mother = Node::create();
    NodePtr me = Node::create();


    setName(grandpa, "Grandpa");
    setName(aunt, "Aunt");
    setName(mother, "Mother");
    setName(me, "Me");

    //now i create the hierrarchies
    //start with the root as grandpa
    beginEditCP(grandpa);
      grandpa->addChild(aunt);
      grandpa->addChild(mother);
    endEditCP(grandpa);

    beginEditCP(mother);
      mother->addChild(me);
    endEditCP(mother);

    NodePtr n;

    n = me->getParent()->getParent();


    cout << "Grandpa has " << grandpa->getChildren().size() << " children.";

    n = grandpa->getChildren()[0];
   
    //cout << "Now i get my " << n->getName() << endl;
    n = grandpa->getChildren().getValue(1);

    //cout << "Now i get my " << n->getName() << endl;
    

    //some test stuff....nothing to rener down here
    TransformPtr trans = Transform::create();
    const Char8 *c = trans->getTypeName();
    cout << "Typename : " << c << endl;

    const UInt32 id = trans->getTypeId();
    cout << "Type ID : " << id << endl;



    // Create and setup our little friend - the SSM
    mgr = new SimpleSceneManager;
    mgr->setWindow(gwin);
    mgr->setRoot(grandpa);
    mgr->showAll();
    // Give Control to the GLUT Main Loop
    glutMainLoop();




    return 0;
}

//react the mouse motions with pressed buttons
void motion(int x, int y)
{
	mgr->mouseMove(x,y);
	glutPostRedisplay();
}

//react to mouse button presses
void mouse(int button,int state, int x,int y)
{
	if(state)
		mgr->mouseButtonRelease(button,x,y);
	else
		mgr->mouseButtonPress(button,x,y);

	glutPostRedisplay();
}



// react to size changes
void reshape(int w, int h)
{
    mgr->resize(w, h);
    glutPostRedisplay();
}
// just redraw our scene if this GLUT callback is invoked
void display(void)
{
    /*
    Matrix m;


    //get  the elapsed time since the application started
    Real32 time = glutGet(GLUT_ELAPSED_TIME);

    //set  the rotation
    m.setRotate(Quaternion(Vec3f(0,1,0),time/1000.f));

    //apply the matrix to  the transformation core
    beginEditCP(transCore);
       transCore->setMatrix(m);       
    endEditCP(transCore);
   
    */

    mgr->redraw();
}
//The GLUT subsystem is set up here. This is very similar to other GLUT
//applications. If you have worked with GLUT before, you may have the
//feeling of meeting old friends again, if you have not used GLUT before
//that is no problem. GLUT will be introduced briefly on the next section
int setupGLUT(int *argc, char *argv[])
{
    glutInit(argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    int winid = glutCreateWindow("OpenSG First Application");

    // register the GLUT callback functions
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutReshapeFunc(reshape);
    glutMotionFunc(motion);
    glutMouseFunc(mouse);
    return winid;

}

Attachment: Makefile
Description: Binary data

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to