Hello everyone, i hope you have fun in OF !!!
Because, i’m turning crazy now!
I’m working on a big project: creating a 3D software for my holographic pyramid, with a Leap Motion
the problem is: because it is big, i put the leap in an other class (to clean the ofApp), i try to put it in ofApp too…
BUT, the leap is detected, and the int are not changing !
This is my sketch…a little bit empty because, really, i was on it all day: HERE
or if you want, here is the ofApp (i think, the Leap is not the problem), i hope you can help me, it is really important to me (my first big project).
Thank you and enjoy coding
Vincent
PS, here is the ofApp.cpp (VERY LONG) :
UPDATED !
#include “ofApp.h”
//--------------------------------------------------------------
void testApp::setup() {
Model.loadModel("sydney.3ds", true);
MenuVerr = 0;
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
ofAddListener(recognizer.speechRecognizedEvent, this, &testApp::speechRecognized);
recognizer.initRecognizer();
recognizer.loadDictionaryFromFile("dictionary.txt");
recognizer.startListening();
synthesizer.initSynthesizer("Virginie");
ofBackground(0);
ofSetFrameRate(60);
//fbo
fbo1.allocate(ofGetWidth(), ofGetHeight(), GL_RGB);
fbo2.allocate(ofGetWidth(), ofGetHeight(), GL_RGB);
Mainfbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGB);
//first triangle in the mesh //OK
mesh2.addTexCoord(ofVec2f(0,0));//T1
mesh2.addVertex(ofVec3f(0,0,0));//v1
mesh2.addTexCoord(ofVec2f(fbo1.getWidth()/2, 0));//T2
mesh2.addVertex(ofVec3f(ofGetWidth()/2.0, 0, 0));//v2
mesh2.addTexCoord(ofVec2f(0, fbo1.getHeight()));//T3
mesh2.addVertex(ofVec3f(0, ofGetHeight(), 0));//v3
//Second triangle in the mesh //OK
mesh1.addTexCoord(ofVec2f(fbo2.getWidth(),0));//T1
mesh1.addVertex(ofVec3f(ofGetWidth(),0,0));//v1
mesh1.addTexCoord(ofVec2f(fbo2.getWidth()/2, 0));//T2
mesh1.addVertex(ofVec3f(ofGetWidth()/2.0, 0, 0));//v2
mesh1.addTexCoord(ofVec2f(fbo2.getWidth(), fbo2.getHeight()));//T3
mesh1.addVertex(ofVec3f(ofGetWidth(), ofGetHeight(), 0));//v3*/
//Main triangle in the mesh // OK
MainMesh.addTexCoord(ofVec2f(Mainfbo.getWidth()/2, 0));//T3
MainMesh.addVertex(ofVec3f(ofGetWidth()/2, 0, 0));//v3
MainMesh.addTexCoord(ofVec2f(0,Mainfbo.getHeight()));//T1
MainMesh.addVertex(ofVec3f(ofGetWidth(), ofGetHeight(), 0));//v2
MainMesh.addTexCoord(ofVec2f(Mainfbo.getWidth(), Mainfbo.getHeight()));//T2
MainMesh.addVertex(ofVec3f(0,ofGetHeight(),0));//v1
}
//--------------------------------------------------------------
void testApp::update() {
// CLASSES YOUHOU:
leap.update();
Nav.update();
Draw.update();
Act.update();
//mainCam.setNearClip(50);
mainCam.setDistance(1500 + Nav.Zoom);
// Droite
cam1.setDistance(550 + Nav.Zoom);
cam1.setPosition(-2500,-2500 ,5000);
// Gauche
cam2.setDistance(550 + Nav.Zoom);
cam2.setPosition(2500,-2500 ,5000);
//Dessin des fbo
fbo1.begin();
drawFbo1();
fbo1.end();
fbo2.begin();
drawFbo2();
fbo2.end();
Mainfbo.begin();
drawMainFbo();
Mainfbo.end();
Model.update();
Act.update();
}
//-------------------------- FBO 1 -----------------------------
void testApp::drawFbo1(){
cam1.begin();
//écran clair
ofClear(0,0,0);
ofPushMatrix();
ofRotateZ(-90);
ofRotateX(180);
ofRotateY(90);
Draw3dWorld();
ofPopMatrix();
cam1.end();
cam1.disableMouseInput();
}
//-------------------------- FBO 2 -----------------------------
void testApp::drawFbo2(){
cam2.begin();
//écran clair
ofClear(0,0,0);
///GAUCHE
ofPushMatrix();
ofRotateZ(90);
ofRotateX(-180);
ofRotateY(-90);
Draw3dWorld();
ofPopMatrix();
cam2.end();
cam2.disableMouseInput();
}
//------------------------- MAIN FBO ---------------------------
void testApp::drawMainFbo(){
mainCam.begin();
//écran clair
ofClear(0,0,0);
ofPushMatrix();
ofTranslate(0, -1000);
Draw3dWorld();
ofPopMatrix();
mainCam.end();
mainCam.disableMouseInput();
}
//--------------------- ENVIRRONEMENT 3D -----------------------
void testApp::Draw3dWorld(){
ofPushMatrix();
leap.draw(vitesse);
//World :
if (MenuVerr == 0){
Act.msgPrincipal = "Menu principal";
Act.msg1 = "1_Volumes";
Act.msg2 = "2_Dessin";
Act.msg3 = "3_FreeForm";
Act.msg4 = "4_Navigation";
Act.msg5 = "5_Fichiers";
switch (leap.Finger) {
case 1:
Menu = 1;
break;
case 2:
Menu = 2;
break;
case 3:
Menu = 3;
break;
case 4:
Menu = 4;
break;
case 5:
Menu = 0;
break;
}
}
switch (Menu) {
case 1:
MenuVerr = 1;
Menu = 0;
break;
case 2:
MenuVerr = 2;
Menu = 0;
break;
case 3:
MenuVerr = 3;
Menu = 0;
break;
case 4:
MenuVerr = 4;
Menu = 0;
break;
case 5:
MenuVerr = 0;
Menu = 0;
break;
}
cout << " Menu = "<< Menu << " / MenuVerr = "<< MenuVerr << " / FINGER = "<< leap.Finger << endl;
if (MenuVerr == 1) {
MSG = "Volumes actives";
Act.msgPrincipal = "Volumes";
Act.msg1 = "1_";
Act.msg2 = "2_";
Act.msg3 = "3_";
Act.msg4 = "4_Navigation";
Act.msg5 = "5_Retour";
} else { }
if (MenuVerr == 2) {
MSG = "Dessin active";
Act.msgPrincipal = "Dessin";
Act.msg1 = "1_Changer mode";
Act.msg2 = "2_Changer mode";
Act.msg3 = "3_Dessiner";
Act.msg4 = "4_Options";
Act.msg5 = "5_Retour";
switch (Finger) {
case 1:
Mode -1;
break;
case 2:
Mode +1;
break;
case 3:
Dessin = 1;
break;
case 4:
Dessin = 2;
break;
case 5:
MenuVerr = 0;
break;
default:
break;
}
if (Dessin == 1) {
vitesse = 25;
leap.LeapCoord = true;
MSG = "Dessin GO GO GO";
Act.msgPrincipal = Act.msg6;
Act.msg1 = "1_Cliquer";
Act.msg2 = "2_";
Act.msg3 = "3_";
Act.msg4 = "4_Navigation";
Act.msg5 = "5_Retour";
Draw.Drawing(leap.leapX, leap.leapY, leap.leapZ, leap.Finger, Mode, vueFilaire, curve, Menu);
switch (Menu) {
case 4:
MenuVerr = 4;
break;
case 5:
Dessin = 0;
break;
default:
break;
}
}
switch (Mode) {
case 1:
Act.msg6 = "TRIANGLES";
break;
case 2:
Act.msg6 = "STRIP";
break;
case 3:
Act.msg6 = "SURFACE";
break;
case 4:
Act.msg6 = "POLYLIGNE";
break;
case 5:
Act.msg6 = "COURBES";
break;
default:
Mode = 1;
break;
}
}
if (MenuVerr == 3) {
Act.msgPrincipal = "Freeform";
Act.msg1 = "1_Dessin";
Act.msg2 = "2_";
Act.msg3 = "3_Options";
Act.msg4 = "4_Navigation";
Act.msg5 = "5_Retour";
Nav.Navigate(Finger, Gesture, Menu);
} else { }
if (MenuVerr == 4) {
MSG = "Navigation activee";
Act.msgPrincipal = "Navigation";
Act.msg1 = "1_";
Act.msg2 = "2_Translation";
Act.msg3 = "3_Rotation";
Act.msg4 = "4_";
Act.msg5 = "5_Retour";
} else { }
if (MenuVerr == 5) {
MSG = "Menu acitve";
Act.msgPrincipal = "Fichiers";
Act.msg1 = "1_Save";
Act.msg2 = "2_Load";
Act.msg3 = "3_";
Act.msg4 = "4_Gants sensitifs";
Act.msg5 = "5_Retour menu principal";
} else { }
if (Ortho){
Act.OrthoG;
}
cout << "Commande = "<< MSG << endl;
ofPopMatrix();
ofBox(100);
ofRotateX(Nav.RotX);
ofRotateY(Nav.RotY);
ofTranslate(Nav.TransX, Nav.TransY, Nav.TransZ);
}
//--------------------------------------------------------------
void testApp::draw() {
ofPushMatrix();
//changement écran;
if (interface) {
ofRotateZ(180);
ofRotateX(180);
ofRotateY(0);
ofTranslate(-ofGetWidth(), 0, 0);
}
//Classes
Act.draw();
//// Commandes basiques
fbo1.getTextureReference().bind();
mesh1.draw();
fbo1.getTextureReference().unbind();
fbo2.getTextureReference().bind();
mesh2.draw();
fbo2.getTextureReference().unbind();
Mainfbo.getTextureReference().bind();
MainMesh.draw();
Mainfbo.getTextureReference().unbind();
}
//--------------------------------------------------------------
void testApp::keyPressed(int key) {
if (key == 'm'){
synthesizer.speakPhrase("Menu principal");
cout << "RETOUR"<< endl;
MenuVerr = 5;
}
if (key == 'n'){
synthesizer.speakPhrase("Navigation");
cout << " NAVIGATION "<< endl;
MenuVerr = 4;
}
if (key == 'p'){
synthesizer.speakPhrase("Dessin");
cout << " Dessin "<< endl;
MenuVerr = 2;
}
}
//--------------------------------------------------------------
void testApp::keyReleased(int key) {
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h) {
}
//--------------------------------------------------------------
void testApp::speechRecognized(string & wordRecognized)
{
cout << wordRecognized << endl; // taper les mots reconnus dans la console
if(wordRecognized == "back")// condition et mot reconnus
{
synthesizer.speakPhrase("Menu principal");
}
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg) {
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo) {
}
//--------------------------Charger le Model en mémoire-----------------------------
void testApp::processOpenFileSelection(ofFileDialogResult Model){
}