1 / 14

Dojo/G3D Help Session

Dojo/G3D Help Session. CS196-2 Sunday 1/29. What is Dojo?. Game engine Graphics: G3D http://g3d-cpp.sourceforge.net/html/ Physics: ODE http://www.ode.org/. Getting Started. Work in Windows, MS Visual Studio 2005 Use MSLab, or work at home (recommended)

avak
Download Presentation

Dojo/G3D Help Session

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dojo/G3D Help Session CS196-2 Sunday 1/29

  2. What is Dojo? • Game engine • Graphics: G3D • http://g3d-cpp.sourceforge.net/html/ • Physics: ODE • http://www.ode.org/

  3. Getting Started • Work in Windows, MS Visual Studio 2005 • Use MSLab, or work at home (recommended) • Get Visual Studio 2005 Professional CD from CIS Help Desk • Or download Visual C++ 2005 Express Edition at http://msdn.microsoft.com/vstudio/express/visualc/download/ • Copy files from Y:/course/cs196-2/asgn/0/dojo/ • Copy Dojo to a local directory (on the C:/ drive) when working, otherwise compiling will take forever. Note: in the MSLab, the desktop is NOT a local directory. • Open dojo.sln with Visual Studio.

  4. Visual Studio • Set up path to Dojo’s library files. • Select Tools->Options->Projects and Solutions->VC++ Directories, and in the top right corner of the window, select “Library files” • Add the path “Y:/course/cs196-2/libraries/win32-vc8-lib” to the list. • If you’re working at home, you’ll need to copy the contents of that directory to your PC, and set the appropriate path.

  5. Visual Studio (cont.) • In the Solution Explorer on the left hand side of the Visual Studio window, right click on the line “Solution ‘dojo’ (3 projects).” • In the dialog that comes up, select “Single startup project” and select “scratch” from the drop-down list. • Use the Solution Explorer to select the files you want to edit. • Can add new files to a project by right clicking on the project name and selecting Add->New Item. • Compile using Build->Build Solution (F7) • Run using Debug->Start Debugging (F5) • If you’ve made any changes since last compiling, this option will compile for you as well.

  6. scratch/main.cpp #include "dojo/dojo.h“ #include "ui/ui.h" #include "dojo/physicsunits.h" #include "App.h" int main(int argc, char** argv) { GAppSettings settings; … dojo::app = new App(settings); dojo::app->run(); delete dojo::app; dojo::app = NULL; return 0; } ← G3D class; use it to set a number of settings for your application App is your game application (see next slide). dojo::app is a global pointer to the application. Call run() to start your game. ←

  7. scratch/App.h • Subclass of Dojo’s DApp • DApp::main() • Called by DApp::run() • Override this to perform any initializations you need • Specifically, need to instantiate a DApplet and once you’re ready to begin the game, call its run() method.

  8. scratch/Demo.h • Subclass of Dojo’s DApplet • A DApp can contain multiple DApplets • Only 1 DApplet can be running at any time • Create a separate DApplet for each portion of your game (e.g. one for the actual game and one for the initial menu screen). • DApplet::run() begins execution of the game loop.

  9. scratch/Demo.h (cont.) • The DApplet game loop: • onInit() • Called once, before the game loop begins. • Perform any necessary initializations here. • onGraphics() • Render the current frame and perform any other drawing operations. • onNetwork() • Perform network message polling.

  10. scratch/Demo.h (cont.) • onUserInput() • Process any keyboard/mouse/gamepad events. • onSimulation() • Advance the state of your game objects from the previous frame (e.g. using a physics simulator). • onCleanup() • Called only once, at the end of a run() call. • Perform any necessary cleanup operations here.

  11. dojo::Entity • The base class for all graphical/physical objects in Dojo. • create() • Static method used to create new Entities. • Use instead of constructor. • Returns a reference-counted pointer – don’t delete. • See Ball, Helicopter, Crate classes for examples.

  12. dojo::World • Handles rendering/physics. • Insert Entities into World: EntityRef ball = Ball::create("Basketball"); World::world()->insert(ball, CoordinateFrame()); • CoordinateFrame is a G3D class used to specify an object’s position and orientation in 3-space. • World::world() • Returns the global World instance. The first time you call this method in your program a new World is created. • Have to initialize it with a subsequent call to World::world()->init()

  13. dojo::World (cont.) • Rendering • The World renders all the Entities that you insert into it: void Demo::onGraphics(RenderDevice* rd) { World::world()->activeCamera = &app->debugCamera; rd->setProjectionAndCameraMatrix(*World::world()->activeCamera); World::world()->onGraphics(rd); DApplet::onGraphics(rd); }

  14. dojo::World (cont.) • Physics • The World also handles physics on all inserted Entities for you: void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) { DApplet::onSimulation(rdt, sdt, idt); }

More Related