int main(int, char **argv)
{
	// Initialize Inventor. This returns a main window to use.
	// If unsuccessful, exit.
	HWND myWindow = SoWin::init("A red cone."); // pass the app name
	if (myWindow == NULL) exit(1);
	// Make a scene containing a red cone
	SoSeparator *root = new SoSeparator;
	root->ref();
	SoMaterial *myMaterial = new SoMaterial;
	myMaterial->diffuseColor.setValue(1.0, 0.0, 0.0);
	root->addChild(myMaterial);
	root->addChild(new SoCone);
	// Set up viewer:
	SoWinExaminerViewer *myViewer =new SoWinExaminerViewer(myWindow);
	myViewer->setSceneGraph(root);
	myViewer->setTitle("Examiner Viewer");
	myViewer->show(); 
	
	SoWin::show(myWindow); // Display main window
	SoWin::mainLoop(); // Main Inventor event loop
	
	root->unref();
	return 0;
}
Example #2
0
int main(int, char **argv)
{
	// Initialize Inventor. This returns a main window to use.
	// If unsuccessful, exit.
	HWND myWindow = SoWin::init("A red cone."); // pass the app name
	if (myWindow == NULL) exit(1);
	// Make a scene containing a red cone
	SoSeparator *root = new SoSeparator;
	SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
	SoMaterial *myMaterial = new SoMaterial;
	root->ref();
	root->addChild(myCamera);
	root->addChild(new SoDirectionalLight);
	myMaterial->diffuseColor.setValue(1.0, 1.0, 0.0); // Red
	root->addChild(myMaterial);

	root->addChild(new SoCone);
	// Create a renderArea in which to see our scene graph.
	// The render area will appear within the main window.
	SoWinExaminerViewer *myRenderArea = new SoWinExaminerViewer(myWindow);
	// Make myCamera see everything.
	myCamera->viewAll(root, myRenderArea->getViewportRegion());
	// Put our scene in myRenderArea, change the title
	myRenderArea->setSceneGraph(root);
	myRenderArea->setTitle("A red cone");
	myRenderArea->show();
	SoWin::show(myWindow); // Display main window
	SoWin::mainLoop(); // Main Inventor event loop
	delete myRenderArea;
	root->unref();
	return 0;
}
Example #3
0
int main(int, char **argv)
{
	// Initialize Inventor. This returns a main window to use.
	// If unsuccessful, exit.
	HWND myWindow = SoWin::init("Water molecule"); // pass the app name
	if (myWindow == NULL) exit(1);
	// Make a scene containing a red cone
	SoGroup *waterMolecule = new SoGroup; // water molecule
	SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
	SoGroup *oxygen = new SoGroup; // oxygen atom
	SoMaterial *redPlastic = new SoMaterial;
	SoSphere *sphere1 = new SoSphere;
	SoGroup *hydrogen1 = new SoGroup; // hydrogen atoms
	SoGroup *hydrogen2 = new SoGroup;
	SoTransform *hydrogenXform1 = new SoTransform;
	SoTransform *hydrogenXform2 = new SoTransform;
	SoMaterial *whitePlastic = new SoMaterial;
	SoSphere *sphere2 = new SoSphere;
	SoSphere *sphere3 = new SoSphere;
	// Set all field values for the oxygen atom
	redPlastic->ambientColor.setValue(1.0, 0.0, 0.0);
	redPlastic->diffuseColor.setValue(1.0, 0.0, 0.0);
	redPlastic->specularColor.setValue(0.5, 0.5, 0.5);
	redPlastic->shininess = 0.5;
	// Set all field values for the hydrogen atoms
	hydrogenXform1->scaleFactor.setValue(0.75, 0.75, 0.75);
	hydrogenXform1->translation.setValue(0.1, 1.2, 1.0);
	hydrogenXform2->translation.setValue(0.0, -3.2, 0.0);
	whitePlastic->ambientColor.setValue(1.0, 1.0, 1.0);
	whitePlastic->diffuseColor.setValue(1.0, 1.0, 1.0);
	whitePlastic->specularColor.setValue(0.5, 0.5, 0.5);
	whitePlastic->shininess = 0.5;
	// Create a hierarchy
	waterMolecule->ref();
	waterMolecule->addChild(oxygen);
	waterMolecule->addChild(hydrogen1);
	waterMolecule->addChild(hydrogen2);
	oxygen->addChild(redPlastic);
	oxygen->addChild(sphere1);
	hydrogen1->addChild(hydrogenXform1);
	hydrogen1->addChild(whitePlastic);
	hydrogen1->addChild(sphere2);
	hydrogen2->addChild(hydrogenXform2);
	hydrogen2->addChild(sphere3);
	SoWinExaminerViewer *myRenderArea = new SoWinExaminerViewer(myWindow);
	// Make myCamera see everything.
	myCamera->viewAll(waterMolecule, myRenderArea->getViewportRegion());
	// Put our scene in myRenderArea, change the title
	myRenderArea->setSceneGraph(waterMolecule);
	myRenderArea->setTitle("Water molecule");
	myRenderArea->show();
	SoWin::show(myWindow); // Display main window
	SoWin::mainLoop(); // Main Inventor event loop
	delete myRenderArea;
	waterMolecule->unref();
	return 0;
}
Example #4
0
File: main.cpp Project: geha/GriS
int main (int argc, char** argv) {

    // Initialize Inventor and Win
    HWND myWindow = SoWin::init(argv[0]);
    if (myWindow == NULL) exit(1);

    // Knoten zum Selektieren der angehängten Objekte
    rootSelection = new SoSelection;
    rootSelection->ref();
    rootSelection->addSelectionCallback(selectionCallback, NULL);
    rootSelection->addDeselectionCallback(deselectionCallback, NULL);

    SoSeparator *root = new SoSeparator;
    rootSelection->addChild(root);

    // This function contains our code fragment.
    root->addChild(make_brett());

    SoWrapperKit *myWrapperKit = new SoWrapperKit;

    // Figur mit Wrapper verbinden
    root->addChild(myWrapperKit);
    myWrapperKit->setPart("contents", (make_brett()));
    myWrapperKit->set((char *)"transform { translation 0 0 0 }");

    // create the manipulators
    SoHandleBoxManip *myHandleBox = new SoHandleBoxManip;
    myHandleBox->ref();
    SoTranslate2Dragger *myTranslater = new SoTranslate2Dragger;

    // Get the draggers and add callbacks to them. Note
    // that you don't put callbacks on manipulators. You put
    // them on the draggers which handle events for them. 
    SoDragger *myDragger;
    myDragger = myHandleBox->getDragger();
    myDragger->addStartCallback(dragStartCallback);
    myDragger->addFinishCallback(dragFinishCallback);

    SoWinExaminerViewer *myViewer = new SoWinExaminerViewer(myWindow);
    myViewer->setSceneGraph(rootSelection);
    myViewer->setGLRenderAction(new SoBoxHighlightRenderAction);
    myViewer->setTitle("Schachbrett");
    myViewer->show();
    myViewer->viewAll();

    SoWin::show(myWindow);
    SoWin::mainLoop();

    return 0;
}
Example #5
0
int main(int, char ** argv)
{
	
	HWND window = SoWin::init("Oil Well");
	if (window == NULL) exit(1);
	SoWinExaminerViewer * viewer = new SoWinExaminerViewer(window);
	viewer->setDecoration(false);
	viewer->setSize(SbVec2s(800, 600));
	SoSeparator *root = new SoSeparator;
	root->ref();
	SoSeparator *obelisk = new SoSeparator();

	// Define the normals used:
	SoNormal *myNormals = new SoNormal;
	myNormals->vector.setValues(0, 8, norms);
	obelisk->addChild(myNormals);
	SoNormalBinding *myNormalBinding = new SoNormalBinding;
	myNormalBinding->value = SoNormalBinding::PER_FACE;
	obelisk->addChild(myNormalBinding);
	// Define material for obelisk
	SoMaterial *myMaterial = new SoMaterial;
	myMaterial->diffuseColor.setValue(.4, .4, .4);
	obelisk->addChild(myMaterial);
	// Define coordinates for vertices
	SoCoordinate3 *myCoords = new SoCoordinate3;
	myCoords->point.setValues(0, 28, vertices);
	obelisk->addChild(myCoords);
	// Define the FaceSet
	SoFaceSet *myFaceSet = new SoFaceSet;
	myFaceSet->numVertices.setValues(0, 8, numvertices);
	obelisk->addChild(myFaceSet);

	root->addChild(obelisk);

	viewer->setSceneGraph(root);
	viewer->setTitle("Oil Well");
	viewer->show();
	SoWin::show(window);
	SoWin::mainLoop();
	delete viewer;
	root->unref();
	return 0;
}
Example #6
0
int main(int argc, char** argv)
{

	// init Inventor
	HWND w = SoWin::init(argv[0]);
	SoWinExaminerViewer * v = new SoWinExaminerViewer(w);
	
	//Preguntar donde iria
	SoViewportRegion::initClass();

	// Iniciamos la escena
	SoSeparator *root = new SoSeparator;
	root->ref();
	root->addChild(new SoUnits);


	Pointers * mypointers= new Pointers();

	//De este separador colgará la escena que se carga de 
	//fichero, así como las cámaras y luces encargadas de 
	//mostrarla
	SoSeparator *ojo_izq= new SoSeparator;
	
	
    //Partimos la pantalla
    SoViewportRegion *vp1 = new SoViewportRegion();
    vp1->height=0.4f;
    vp1->width=0.2f;
	vp1->y_pos=0.6f;
    vp1->x_pos=0.0f;
    vp1->onTop=TRUE; 
    
    ojo_izq->addChild(vp1);
    
	//Introducimos una nueva cámara. Esta cámara pintará
	//los draggers siempre en la misma posición 
	SoFrustumCamera *cam = new SoFrustumCamera();	
	ojo_izq->addChild(cam);

	

	

	SoSeparator * escena = new SoSeparator;
	LightControl * luces;
	luces = new LightControl(escena);
	CheckStick * mystickcontrol;

	mypointers->lights=luces;
	
	mypointers->viewer=v;
	

	SoSeparator *habitacion=new SoSeparator;
	SoTransform * centrar = new SoTransform;

	//centrar->translation.setValue(60.0f,-60.0f,60.0f);
	centrar->translation.setValue(0,-1.f,0.5f);
	//centrar->scaleFactor.setValue(0.0001f,0.0001f,0.0001f);//bateria wena
	//centrar->scaleFactor.setValue(3.f,3.f,3.f);

	habitacion->addChild(centrar);
	//Desplazamiento de la pantalla 

	 // model
	  SoFile *model = new SoFile;
	  if (argc > 1) model->name.setValue(argv[1]);
	  else model->name.setValue("drumconparedes.wrl");
	  habitacion->addChild(model);

	escena->addChild(habitacion);

	SoSeparator * esqueleto= new SoSeparator;

	DrawCoin::CrearEsqueleto(esqueleto);

	mystickcontrol=new CheckStick(DrawCoin::t_cabeza,DrawCoin::t_mano_izq,DrawCoin::t_mano_der);
	mypointers->sticks=mystickcontrol;

	escena->addChild(esqueleto);

	ojo_izq->addChild (escena);
	//Colocamos la camara de modo que pueda ver toda la escena
	cam->viewAll(escena,vp1->getViewportRegion());

	//cam->position.setValue(0.0f,10.0f,-10.f);
	//cam->orientation.setValue(SbVec3f(0.0f,-1.f,1.f),0);
	//De este separador colgará la escena que se carga de 
	//fichero, así como las cámaras y luces encargadas de 
	//mostrarla
	SoSeparator *ojo_der= new SoSeparator;
	root->addChild (ojo_der);
	root->addChild (ojo_izq);
    //Partimos la pantalla
    SoViewportRegion *vp2 = new SoViewportRegion();
    vp2->height=1.0f;
    vp2->width=1.0f;
    vp2->x_pos=0.0f;
    vp2->onTop=FALSE; 
    
    ojo_der->addChild(vp2);
    
	//Introducimos una nueva cámara. Esta cámara pintará
	//los draggers siempre en la misma posición 
	SoFrustumCamera * cam2;

	cam2 = new SoFrustumCamera();	
	mypointers->camera2=cam2;
	//cam2->farDistance = 3.f;

	ojo_der->addChild(cam2);
	SoTransform * cabeza;
	SoRotation * rotacion;

	cabeza=DrawCoin::Get_Cabeza_Pos();
	rotacion=DrawCoin::Get_Cabeza_Rot();
	cam2->position.connectFrom(&cabeza->translation);
	cam2->orientation.connectFrom(&rotacion->rotation);
	
	ojo_der->addChild (escena);

	//Colocamos la camara de modo que pueda ver toda la escena
	cam2->viewAll(escena,vp2->getViewportRegion());
	cam2->viewportMapping = SoCamera::LEAVE_ALONE;
	cam2->position.setValue(0.0f,0.0f,0.0f);
	
	int Data_Of_Thread = 1;
    HANDLE Handle_Of_Thread;

	Handle_Of_Thread = CreateThread( NULL, 0, Thread, &Data_Of_Thread, 0, NULL);  
    if ( Handle_Of_Thread == NULL) ExitProcess(Data_Of_Thread);



	//Creamos un sensor encargado del render
	SoTimerSensor*   rendertimer = new SoTimerSensor(renderCallback,(void *)mypointers);
	rendertimer->setInterval(FPS); 
	rendertimer->schedule();


	SoEventCallback *eventCB = new SoEventCallback;
	eventCB->addEventCallback(SoKeyboardEvent::getClassTypeId(),handle_keyboard,(void*)mypointers);
	root->addChild(eventCB);
	
	
	v->setBackgroundColor(SbColor(0.0f, 0.2f, 0.3f));
	v->setFeedbackVisibility(TRUE);
	v->setSceneGraph(root);
	//v->setViewing(FALSE);
	v->setTitle("Kinect Tracking");
	v->setAutoRedraw(FALSE);
	///v->setDecoration(FALSE);

	
	SoWin::show(w);
	SoWin::mainLoop();


	root->unref();
	delete v;
	
	
	
	
	return 0;
}
Example #7
0
void
SoWinExaminerViewerP::cameraButtonProc(SoWinBitmapButton * b, void * userdata)
{
  SoWinExaminerViewer * that = (SoWinExaminerViewer *)userdata;
  if (that->getCamera()) that->toggleCameraType();
}