; dojo
Learning Center
Plans & pricing Sign in
Sign Out



  • pg 1
									Dojo/G3D Help Session

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)
        Get Visual Studio 2005 Professional CD from CIS Help Desk

        Or download Visual C++ 2005 Express Edition at
   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.
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.
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.
#include "dojo/dojo.h“
#include "ui/ui.h"
#include "dojo/physicsunits.h"
#include "App.h"

int main(int argc, char** argv) {
     GAppSettings settings;          ← G3D class; use it to set a number of settings
     …                                 for your application
    dojo::app = new App(settings);    ← App is your game application (see next
    dojo::app->run();                   slide). dojo::app is a global pointer to the
    delete dojo::app;
                                        application. Call run() to start your game.
    dojo::app = NULL;

    return 0;
 Subclass of Dojo‟s DApp
 DApp::main()
     Called by DApp::run()
     Override this to perform any initializations you
          Specifically, need to instantiate a DApplet and
           once you‟re ready to begin the game, call its run()
 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.
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.
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.
   The base class for all graphical/physical objects
    in Dojo.
   create()
     Staticmethod used to create new Entities.
     Use instead of constructor.
     Returns a reference-counted pointer – don‟t delete.

   See Ball, Helicopter, Crate classes for
   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
          Have to initialize it with a subsequent call to
dojo::World (cont.)
   Rendering
     TheWorld renders all the Entities that you
     insert into it:
      void Demo::onGraphics(RenderDevice* rd) {
        World::world()->activeCamera = &app->debugCamera;
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);

To top