I've been toying around with setting custom game object types for gathering.
So for now I have a list of:
Code:
Game::ObjMemx<<NewObj> Trees;
The trees class is the one from the tutorial file on custom classes.
Then I set it here:
Code:
Game::World.init ( )
.setObjType(Players, OBJ_PLAYER)
.setObjType(Trees, OBJ_TREE)
.setObjType(Statics, OBJ_STATIC)
.setObjType(ObjLightPoints, OBJ_LIGHT_POINT)
.New (ChrData.world()->worldDir());
But it doesn't actually seem to do anything with the list of trees. I've also tried making it just a Game::Static list but it also doesn't seem to want to work.
I should clarify i can't find them with a Physhit and there draw overrides aren't actually drawing any objects.
I should post the NewObj struct as well
Header section:
Code:
STRUCT(NewObj , Game::Obj) // extend Game Object
//{
Vec position; // the class will contain only position
MeshPtr mesh ; // and mesh
Str gather;
Str produce;
// provide necessary methods required by Game::Obj :
virtual void create(Game::ObjParams &obj); // extend default creation
virtual Vec pos( ) {return position ;} // get position
virtual void pos(C Vec &pos) { T.position=pos;} // set position
virtual Str Gather() { return gather;}
virtual void Gather(C Str <) { T.gather = lt; }
virtual Str Produce(){ return produce;}
virtual void Produce(C Str &ls) { T.produce = ls; }
virtual Matrix matrix( ) {return position ;} // get matrix
virtual void matrix(C Matrix &matrix) { T.position=matrix.pos;} // set matrix
virtual Bool update () {return true;} // object update
virtual UInt drawPrepare(); // object draw prepare
virtual void drawShadow (); // object draw shadow
// io methods
virtual void save(File &f);
virtual Bool load(File &f);
// constructor
NewObj();
};
cpp stuff:
Code:
NewObj::NewObj() // initialize values in constructor
{
position.zero();
}
void NewObj::create(Game::ObjParams &obj_params)
{
// now setup custom parameters from 'obj_params'
position=obj_params.matrixFinal().pos; // obtain our 'position' member from 'obj_params'
mesh =obj_params.mesh () ; // set 'mesh'
Produce(obj_params.findParam("Produce")->asText());
Gather(obj_params.findParam("Gather")->asText());
}
/******************************************************************************/
UInt NewObj::drawPrepare()
{
if(mesh && Frustum(mesh->box,matrix()))mesh->draw(matrix());
return 0; // return 0 because no additional rendering modes are required
}
void NewObj::drawShadow()
{
if(mesh && Frustum(mesh->box, matrix()))mesh->drawShadow(matrix());
}
/******************************************************************************/
void NewObj::save(File &f)
{
super::save(f); // default save
f<<position; // save custom parameters
f.putStr(mesh.name()); // save mesh path
}
Bool NewObj::load(File &f)
{
if(super::load(f)) // if default load was successful
{
f>>position; // load custom parameters
mesh.require(f.getStr()); // load mesh
return true; // return success
}
return false; // return failure
}