I've made a lot of headway...
Although I've not made a start yet on particle generation, nor even movement, it's looking okay. The creation of objects and setting up rotation, movement, etc. I'll transfer those into simpler setting up commands.
If there's a way of altering the code so that I don't have to use a temporary myObj inside the main code I'm sure I'll find it soon.
Is ObjFactory another library that's out there?
#include "DarkGDK.h"
#include <list>
using namespace std;
#include "objectclass.h"
#include "mycam.h"
void DarkGDK ( void )
{
myObj temp;
myCam cam;
dbSyncOn ( );
dbSyncRate ( 60 );
temp.make(myObj_Cube,100);
temp.rotatexyz(1,1,1);
dbGhostObjectOn(temp.object);
dbColorObject(temp.object,0xff0000);
myObjList.push_back(temp);
temp.make(myObj_Cube,100);
temp.rotatexyz(1,0.9,1.1);
dbGhostObjectOn(temp.object);
dbColorObject(temp.object,0x00ff00);
myObjList.push_back(temp);
temp.make(myObj_Plain, 100);
temp.rotatexyz(0.5,0.5,0);
myObjList.push_back(temp);
temp.make(myObj_Cylinder, 50);
temp.rotatey=1;
temp.movesp=1;
dbColorObject(temp.object, 0xffff00);
myObjList.push_back(temp);
while ( LoopGDK ( ) )
{
temp.update();
cam.update();
dbSync ( );
}
return;
}
"objectclass.h"
#define myObj_Sphere 1
#define myObj_Cube 2
#define myObj_Plain 3
#define myObj_Cylinder 4
class myObj {
public:
//VARS
int object;
float movesp;
float positionx, positiony, positionz;
float rotatex, rotatey, rotatez;
public:
// FUNCTIONS
int make(int type, float size) {
object=findblankobject();
switch ( type ) {
case myObj_Sphere:
dbMakeObjectSphere (object, size);
break;
case myObj_Cube:
dbMakeObjectCube (object, size);
break;
case myObj_Plain:
dbMakeObjectPlain (object, size, size);
break;
case myObj_Cylinder:
dbMakeObjectCylinder(object, size);
break;
default:
object=0;
break;
}
movesp = rotatex = rotatey = rotatez =
positionx = positiony = positionz = 0;
return object;
}
int findblankobject() {
int curr=1;
while ( dbObjectExist(curr) == 1 ) {
curr++;
}
return curr;
}
int getobject() {
return object;
}
// DEFAULT constructor
myObj() {
movesp = rotatex = rotatey = rotatez = object = 0;
}
void rotatexyz(float x, float y, float z) {
rotatex=x;
rotatey=y;
rotatez=z;
}
void update();
};
// GLOBAL object list
list<myObj> myObjList;
list<myObj>::iterator myObjPtr;
// EXTERNAL function for CLASS myObj
void myObj::update() {
for (myObjPtr = myObjList.begin();
myObjPtr != myObjList.end();
++ myObjPtr) {
if (myObjPtr->rotatey) {
dbTurnObjectRight (myObjPtr->object, myObjPtr->rotatey);
}
if (myObjPtr->rotatex) {
dbPitchObjectUp (myObjPtr->object, myObjPtr->rotatex);
}
if (myObjPtr->rotatez) {
dbRollObjectRight (myObjPtr->object, myObjPtr->rotatez);
}
if (myObjPtr->movesp) {
dbMoveObject(myObjPtr->object, myObjPtr->movesp);
}
}
}
"mycam.h"
class myCam {
float movesp;
public:
myCam() {
movesp=0;
}
// MOUSE & Keyboard control
// Up & Down arrow keys
void update() {
int mc=dbMouseClick();
if (movesp<10 && (dbUpKey() || mc==1)) { movesp++; }
if (movesp>-10 && (dbDownKey() || mc==2)) { movesp--; }
dbYRotateCamera(dbCameraAngleY()+(float)dbMouseMoveX()/2);
dbXRotateCamera(dbCameraAngleX()+(float)dbMouseMoveY()/2);
dbZRotateCamera(0);
dbMoveCamera(movesp);
if (movesp<0) {movesp+=0.5;}
if (movesp>0) {movesp-=0.5;}
}
};
Warning! May contain Nuts!