int main(int argc, char** argv) { // Construct our main loop Gtk::Main kit(argc, argv); // Initialize OpenGL Gtk::GL::init(argc, argv); std::string filename = "puppet.lua"; if (argc >= 2) { filename = argv[1]; } // This is how you might import a scene. SceneNode* root = import_lua(filename); if (!root) { std::cerr << "Could not open " << filename << std::endl; return 1; } // Construct our (only) window AppWindow window; // Set the root node for the viewer window.getViewer().setSceneRoot(root); // And run the application! Gtk::Main::run(window); }
int main( int argc, char *argv[] ) { QApplication app( argc, argv ); // verifies if OpenGL is supported by this system if( !QGLFormat::hasOpenGL() ){ qWarning("This system has no OpenGL support. Exiting. "); return(-1); } // Read default file a3mark.lua if no other name is given as input. std::string filename = "scene.lua"; if( argc >= 2 ){ filename = argv[1]; } // This is how you might import a scene SceneNode* root = import_lua( filename ); if( !root ){ std::cerr << "Could not open file " << filename << std::endl; return 1; } // Construct the main window MainWindow window; // Version 3. Set the scene */ window.setScene( root ); // And run the application window.show(); return app.exec(); }
Track::Track() : mFileName("data/track.lua") { mRoot = import_lua(mFileName); if (!mRoot) { cerr << "ERROR: Track - Could not load " << mFileName << endl; return; } // set up display list mDisplayList = glGenLists(1); glNewList(mDisplayList, GL_COMPILE); mRoot->WalkGl(false); glEndList(); }
Viewer::Viewer(std::string filename) { Glib::RefPtr<Gdk::GL::Config> glconfig; // Ask for an OpenGL Setup with // - red, green and blue component colour // - a depth buffer to avoid things overlapping wrongly // - double-buffered rendering to avoid tearing/flickering glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB | Gdk::GL::MODE_DEPTH | Gdk::GL::MODE_DOUBLE); if (glconfig == 0) { // If we can't get this configuration, die std::cerr << "Unable to setup OpenGL Configuration!" << std::endl; abort(); } // Accept the configuration set_gl_capability(glconfig); // Register the fact that we want to receive these events add_events(Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK | Gdk::BUTTON3_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::VISIBILITY_NOTIFY_MASK); root = import_lua(filename); if (!root) { std::cerr << "Could not open " << filename << std::endl; } currMode = MODEL_TRANSLATE; mb1 = false; mb2 = false; mb3 = false; translateX = 0; translateY = 0; translateZ = 0; pickedObj = NULL; frontFaceCull = false; backFaceCull= false; zBufferCull= false; drawTrackballCircle= false; }
int main(int argc, char** argv) { // Construct our main loop Gtk::Main kit(argc, argv); // Initialize OpenGL Gtk::GL::init(argc, argv); std::string pcf = "pc.lua"; SceneNode* pc = import_lua(pcf); // Construct our (only) window AppWindow window; window.m_game->pc.scene = pc; window.run(); // And run the application! Gtk::Main::run(window); }
Buoy::Buoy( Point3D pos ) : mFileName( "data/buoy.lua" ), mBobHeight( 0.05 ), mBobAmount( 0.0 ) { mRoot = import_lua( mFileName ); if ( !mRoot ) { cerr << "ERROR: Buoy - Could not load " << mFileName << endl; return; } // initial min and max point //mMinPoint = mPosition - Vector3D(2.0, 0.0, 2.0); //mMaxPoint = mPosition + Vector3D(2.0, 0.0, 2.0); // initial transformation mRoot->Translate( Vector3D( pos[0], pos[1], pos[2] ) ); mTrans = mRoot->GetTransform(); mPosition = Point3D( mTrans[0][3], mTrans[1][3], mTrans[2][3] ); mNormal = mTrans * mNormal; mNormal.normalize(); }
Player::Player( Point3D pos ) : mFileName( "data/boat.lua" ), mVelocity( Vector3D(0.0, 0.0, -40.0) ), mWidth( 2.5 ), mLength( 5.7 ), mHeight( 7.0 ) { mRoot = import_lua( mFileName ); if ( !mRoot ) { cerr << "ERROR: Player - Could not load " << mFileName << endl; return; } // initial min and max point mBoundingBox = OBB3D( mPosition, mPosition + Vector3D( 1.5, 1.0, 5.0 ) ); // set up display list mDisplayList = glGenLists( 1 ); glNewList( mDisplayList, GL_COMPILE ); mRoot->WalkGl( false ); glEndList(); // set normal to be facing into the screen for player mNormal = Vector3D( 0.0, 0.0, -1.0 ); // initial tranformation mRoot->Translate( Vector3D( pos[0], pos[1], pos[2] ) ); mRoot->Rotate( 'y', 90 ); mTrans = mRoot->GetTransform(); mLastTrans = mTrans; mPosition = Point3D( mTrans[0][3], mTrans[1][3], mTrans[2][3] ); mLastPosition = mPosition; mNormal = mTrans * mNormal; mNormal.normalize(); mLastNormal = mNormal; }