rem: */
context: int main (int argc, char **argv){	OSG::osgInit(argc,argv);	// GLUT init	glutInit(&argc, argv);	glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);	int winid = glutCreateWindow("OpenSG");	glutKeyboardFunc(key);	glutVisibilityFunc(vis);	glutReshapeFunc(reshape);	glutDisplayFunc(display);       	glutMouseFunc(mouse);   	glutMotionFunc(motion); 		glutIdleFunc(display);		// glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );		glEnable( GL_DEPTH_TEST );	glEnable( GL_LIGHTING );	glEnable( GL_LIGHT0 );    glEnable( GL_NORMALIZE );	// OSG	// create the graph	// beacon for camera and light	    OSG::NodePtr b1n = OSG::Node::create();    OSG::GroupPtr b1 = OSG::Group::create();	OSG::beginEditCP(b1n);	b1n->setCore( b1 );	OSG::endEditCP(b1n);	// transformation    OSG::NodePtr t1n = OSG::Node::create();    OSG::TransformPtr t1 = OSG::Transform::create();	OSG::beginEditCP(t1n);	t1n->setCore( t1 );	t1n->addChild( b1n );	OSG::endEditCP(t1n);	cam_trans = t1;	// light		OSG::NodePtr dlight = OSG::Node::create();	dl = OSG::DirectionalLight::create();	OSG::beginEditCP(dlight);	dlight->setCore( dl );	OSG::endEditCP(dlight);		OSG::beginEditCP(dl);	dl->setAmbient( .3, .3, .3, 1 );	dl->setDiffuse( 1, 1, 1, 1 );	dl->setDirection(0,0,1);	dl->setBeacon( b1n);	OSG::endEditCP(dl);	// root    root = OSG::Node::create();    OSG::GroupPtr gr1 = OSG::Group::create();	OSG::beginEditCP(root);	root->setCore( gr1 );	root->addChild( t1n );	root->addChild( dlight );	OSG::endEditCP(root);	// Load the file    OSG::beginEditCP(dlight);    for(OSG::UInt32 numFiles = 1; numFiles < argc; numFiles++)    {        if(argv[numFiles][0] == '-')        {            loadMesh(&(argv[numFiles][1]), dlight);        }        else        {            file =                 OSG::SceneFileHandler::the().readTopNodes(                    argv[numFiles],                     OSG::VRMLFile::StripeGeometry |                    OSG::VRMLFile::CreateNormals);            /*			file = OSG::SceneFileHandler::the().read(argv[numFiles],										OSG::VRMLFile::StripeGeometry |                   		 				OSG::VRMLFile::CreateNormals);			*/			for(OSG::UInt32 i=0; i<file.size(); ++i)			{				dlight->addChild(file[i]);			}		}    }        dlight->invalidateVolume();    OSG::endEditCP(dlight);        dlight->updateVolume();    // should check first. ok for now.    const OSG::BoxVolume *vol = (OSG::BoxVolume *)&dlight->getVolume();            OSG::Vec3f min,max;    OSG::Vec3f size;    OSG::Pnt3f center;    vol->getBounds(min, max);	vol->getCenter(center);    size = max - min;    cout << "Volume: from " << min << " to " << max << endl;//	cerr << "Tree: " << endl;//    root->print();	// Camera	OSG::PerspectiveCameraPtr cam = OSG::PerspectiveCamera::create();	cam->setBeacon( b1n );	cam->setFov( OSG::deg2rad( 60 ) );	cam->setNear( 1 );	cam->setFar( 5000 );	// Solid Background	OSG::SolidBackgroundPtr bkgnd = OSG::SolidBackground::create();	bkgnd->setColor( OSG::Color3f(0,0,1) );	// Viewport	OSG::ViewportPtr vp = OSG::Viewport::create();	vp->setCamera( cam );	vp->setBackground( bkgnd );	vp->setRoot( root );	vp->setSize( 0,0, 1,1 );	// Window	cout << "GLUT winid: " << winid << endl;	OSG::GLUTWindowPtr gwin;	GLint glvp[4];	glGetIntegerv( GL_VIEWPORT, glvp );	gwin = OSG::GLUTWindow::create();	gwin->setWinID(winid);	gwin->setSize( glvp[2], glvp[3] );	win = gwin;	win->addPort( vp );	// Action		ract = OSG::DrawAction::create();	cerr << "Calculating normals...";		// Task 1: Cal Vertex Normals	ract->registerEnterFunction( OSG::Geometry::getClassType(),									OSG::osgFunctionFunctor2( calcVNormal ) );	//	ract->apply( dlight );	cerr << "done." << endl;		// Task 2: draw wireframe bbox, if wanted	ract->registerEnterFunction( OSG::Geometry::getClassType(),									OSG::osgFunctionFunctor2( wireDraw ) );										// tball        OSG::Vec3f pos(min[0] + ((max[0] - min[0]) * 0.5),                    min[1] + ((max[1] - min[1]) * 0.5),                    max[2] + ( max[2] - min[2] ) * 1.5 );        float scale = (max[2] - min[2] + max[1] - min[1] + max[0] - min[0]) / 6;	tball.setMode( OSG::Trackball::OSGObject );	tball.setStartPosition( pos, true );	tball.setSum( true );	tball.setTranslationMode( OSG::Trackball::OSGFree );    tball.setTranslationScale(scale);    tball.setRotationCenter(center);    tball.setTranslationGen(OSG::Trackball::OSGAbsoluteTranslation);	// run...#if 0	cam->setFar(size.length() * 4.5);    if((size.length() * 4.5) > 1000.)    {        cam->setNear( 1 );    }    else if((size.length()) < 100.)    {        cam->setNear(0.01);    }    else    {        cam->setNear(0.1);    }#endif		glutMainLoop();	    return 0;}