DojoG3D Help Session - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

DojoG3D Help Session

Description:

Advance the state of your game objects from the previous frame (e.g. using a physics simulator) ... See Ball, Helicopter, Crate classes for examples. dojo: ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 15
Provided by: pawelw
Learn more at: https://cs.brown.edu
Category:

less

Transcript and Presenter's Notes

Title: DojoG3D Help Session


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 Dojos library files.
  • Select Tools-gtOptions-gtProjects and
    Solutions-gtVC Directories, and in the top right
    corner of the window, select Library files
  • Add the path Y/course/cs196-2/libraries/win32-vc
    8-lib to the list.
  • If youre working at home, youll 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-gtNew Item.
  • Compile using Build-gtBuild Solution (F7)
  • Run using Debug-gtStart Debugging (F5)
  • If youve 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
  • dojoapp new App(settings)
  • dojoapp-gtrun()
  • delete dojoapp
  • dojoapp NULL
  • return 0

G3D class use it to set a number of settings for
your application
?
App is your game application (see next slide).
dojoapp is a global pointer to the application.
Call run() to start your game.
?
7
scratch/App.h
  • Subclass of Dojos DApp
  • DAppmain()
  • Called by DApprun()
  • Override this to perform any initializations you
    need
  • Specifically, need to instantiate a DApplet and
    once youre ready to begin the game, call its
    run() method.

8
scratch/Demo.h
  • Subclass of Dojos 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).
  • DAppletrun() 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
dojoEntity
  • 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 dont
    delete.
  • See Ball, Helicopter, Crate classes for examples.

12
dojoWorld
  • Handles rendering/physics.
  • Insert Entities into World
  • EntityRef ball Ballcreate("Basketball")
  • Worldworld()-gtinsert(ball, CoordinateFrame())
  • CoordinateFrame is a G3D class used to specify an
    objects position and orientation in 3-space.
  • Worldworld()
  • 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
  • Worldworld()-gtinit()

13
dojoWorld (cont.)
  • Rendering
  • The World renders all the Entities that you
    insert into it
  • void DemoonGraphics(RenderDevice rd)
  • Worldworld()-gtactiveCamera
    app-gtdebugCamera
  • rd-gtsetProjectionAndCameraMatrix(Worldworld()-
    gtactiveCamera)
  • Worldworld()-gtonGraphics(rd)
  • DAppletonGraphics(rd)

14
dojoWorld (cont.)
  • Physics
  • The World also handles physics on all inserted
    Entities for you
  • void DemoonSimulation(RealTime rdt, SimTime
    sdt, SimTime idt)
  • DAppletonSimulation(rdt, sdt, idt)
Write a Comment
User Comments (0)
About PowerShow.com