Hi Robin.
Robin Steinke wrote:
Matrix oldPos;
oldPos = dot1->getToWorld();
where dot1 is declared as NodePtr dot1 = makeSphere(3,.5); and is a
Child Node. What i get is a memory violation. Am i on the right way, or
did i get it totaly wrong?
I fear that my quick'n'dirty ICQ-Help wasn't that helpful. So here we go
again with some more details:
Example:
NodePtr torus = makeTorus(.5, 2, 16, 16);
ComponentTransformPtr trans1=ComponentTransform::create();
beginEditCP(trans1);
trans1->setTranslation(Vec3f(5,3,0));
endEditCP(trans1);
NodePtr scene=Node::create();
beginEditCP(scene);
scene->setCore(trans1);
scene->addChild(torus);
endEditCP(scene);
Matrix m=torus->getToWorld();
cout<<m<<endl;
Output is (as expected):
[EMAIL PROTECTED]:~$ ./01hello
1.000 0.000 0.000 5.000
0.000 1.000 0.000 3.000
0.000 0.000 1.000 0.000
0.000 0.000 0.000 1.000
But, regarding the segfault, I think your error is somewhere else.
I send you the modified 01hello tutorial off the list.
Regards,
Dominik
// OpenSG Tutorial Example: Hello World
//
// Minimalistic OpenSG program
//
// This is the shortest useful OpenSG program
// (if you remove all the comments ;)
//
// It shows how to use OpenSG together with GLUT to create a little
// interactive scene viewer.
//
// GLUT is used for window handling
#include <OpenSG/OSGGLUT.h>
// General OpenSG configuration, needed everywhere
#include <OpenSG/OSGConfig.h>
// Methods to create simple geometry: boxes, spheres, tori etc.
#include <OpenSG/OSGSimpleGeometry.h>
// The GLUT-OpenSG connection class
#include <OpenSG/OSGGLUTWindow.h>
#include <OpenSG/OSGComponentTransform.h>
// A little helper to simplify scene management and interaction
#include <OpenSG/OSGSimpleSceneManager.h>
#include <iostream>
// Activate the OpenSG namespace
// This is not strictly necessary, you can also prefix all OpenSG symbols
// with OSG::, but that would be a bit tedious for this example
OSG_USING_NAMESPACE
using namespace std;
// The SimpleSceneManager to manage simple applications
SimpleSceneManager *mgr;
// forward declaration so we can have the interesting stuff upfront
int setupGLUT( int *argc, char *argv[] );
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// GLUT init
int winid = setupGLUT(&argc, argv);
// the connection between GLUT and OpenSG
GLUTWindowPtr gwin= GLUTWindow::create();
gwin->setId(winid);
gwin->init();
// create the scene
NodePtr torus = makeTorus(.5, 2, 16, 16);
ComponentTransformPtr trans1=ComponentTransform::create();
beginEditCP(trans1);
trans1->setTranslation(Vec3f(5,3,0));
endEditCP(trans1);
NodePtr scene=Node::create();
beginEditCP(scene);
scene->setCore(trans1);
scene->addChild(torus);
endEditCP(scene);
Matrix m=torus->getToWorld();
cout<<m<<endl;
// create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// tell the manager what to manage
mgr->setWindow(gwin );
mgr->setRoot (scene);
// show the whole scene
mgr->showAll();
// GLUT main loop
glutMainLoop();
return 0;
}
//
// GLUT callback functions
//
// redraw the window
void display(void)
{
mgr->redraw();
}
// react to size changes
void reshape(int w, int h)
{
mgr->resize(w, h);
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 mouse motions with pressed buttons
void motion(int x, int y)
{
mgr->mouseMove(x, y);
glutPostRedisplay();
}
// react to keys
void keyboard(unsigned char k, int x, int y)
{
switch(k)
{
case 27:
{
OSG::osgExit();
exit(0);
}
break;
}
}
// setup the GLUT library which handles the windows for us
int setupGLUT(int *argc, char *argv[])
{
glutInit(argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
int winid = glutCreateWindow("OpenSG");
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutKeyboardFunc(keyboard);
return winid;
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users