Quote:Original post by cypherx
* Why "with-init"/"with-engine" and not "init"/"engine"?
Good points, the current names do not make sense. I'll change these.
Quote:Original post by cypherx
* What is the null list passed as the first argument to sdl::with-init?
sdl::wih-init can takes several parameters to initialize the various SDL subsystems. A null list means that SDL should be initialized using the default sdl::SDL-INIT-VIDEO which initializes the video subsystem. If I wanted to initialize both video and audio then I would do this: (sdl:with-init (sdl::SDL-INIT-VIDEO sdl::SDL-INIT-AUDIO) (STUFF-HERE))
Quote:Original post by cypherx
* Where are 'root-node and 'actor defined?
root-node is the root node of the scene graph and is implicitly defined by RM:WITH-ENGINE. The scene graph root node must be bound to a variable that the programmer can refer to as it is used to define camera pointing etc. In this code RM:WITH-ENGINE binds the root node to 'root-node', but this variable can be named anything (e.g. top-node, node etc.)
ACTOR is is little more complicated, as it is defined as a side effect of DEFSCRIPT.
DEFSCRIPT does five things:
1) It creates a new class, for example (DEFSCRIPT (SIN-BOUNCE) (STUFF-HERE))
2) It creates the object initializer function
3) It creates the UPDATE function that the engine calls every frame to update the state of the script.
4) It creates a new instance of the class and returns that.
5) It uses symbol-macrolet to create references to all members of the class; things like ACTOR, TRIGGER, TIMESCALE, CURRENT-FRAME are all implicitly defined. See below for an example of a slightly more complicated rotate script [1].
Quote:Original post by cypherx
* What's the point of calling "primtives" and "script" in add-actor?
:primitives; OpenRM allows many different types of primitives to be added to a single node; cubes, cylinders, quads, and triangle meshes can all be added to a single node. So, for example 1000 cube primitives can be added to a single node allowing all 1000 cubes to be translated or rotated using a single OpenGL command.
:script; The engine will execute the contents of :script once every frame.
Thanks for the comments.
[1] This script will rotate an object around an axis by x degrees a second:
(defscript (rotate) (init ((dx 1.0) (dy 0.0) (dz 0.0))) (rotate-actor actor dx dy dz))
To create a new rotate script and override the defaults, just do the following:
(NEW-ROTATE :DX 0.0 :DY 1.0)
The DEFSCRIPT macro actually expands into the following:
(PROGN (DEFCLASS ROTATE (SCRIPT) ((DX :ACCESSOR DX :INITFORM 1.0 :INITARG :DX) (DY :ACCESSOR DY :INITFORM 0.0 :INITARG :DY) (DZ :ACCESSOR DZ :INITFORM 0.0 :INITARG :DZ))) (DEFUN NEW-ROTATE (&KEY (DX 1.0) (DY 0.0) (DZ 0.0)) (MAKE-INSTANCE 'ROTATE :DX DX :DY DY :DZ DZ)) (DEFMETHOD UPDATE-ACTOR ((ACTOR ACTOR) (SCRIPT ROTATE) ENGINE::TIMESCALE ENGINE::TRIGGER) (SYMBOL-MACROLET ((ENGINE::CURRENT-TIME (ENGINE::CURRENT-TIME SCRIPT)) (DX (DX SCRIPT)) (DY (DY SCRIPT)) (DZ (DZ SCRIPT))) (ROTATE-ACTOR ACTOR DX DY DZ))) (NEW-ROTATE))