Planet
navi homeaboutscreenshotsdownloaddevelopmentforum

WorldEntity

ArchivePage?

A WorldEntity is an extension ParentNode, that can be displayed, and interact in the wonderful Worlds of orxonox

source:/trunk/src/world_entities/world_entity.h#HEAD
Dependecies:

usage

  void loadParams(const TiXmlElement* root);
  void loadModel(const char* fileName, float scaling = 1.0f);
  bool buildObbTree(unsigned int depth);
  void setVisibiliy (bool visibility) { this->bVisible = visibility; };

  virtual void postSpawn ();
  virtual void leftWorld ();

  virtual void tick (float time);
  virtual void draw () const;
  virtual void collidesWith (WorldEntity* entity, const Vector& location);

Initailisation-Phase:

  • loadParams: Loads Parameters on the WorldEntity - level
  • loadModel: loads a new Model onto the WorldEntity (this is coppled with the ResourceManager, so you don't have to care about the pointer anymore)
  • buildObbTree: If you want collisions to happen onto this WorldEntity, then you have to call this function, to create a Collision-Cluster. This is normally called upon a call to loadModel, but maybe you want something more.
  • setVisibility: Tells the ENGINE if this WorldEntity must be drawn, or not

Runtime

  • tick: Tells this WorldEntity, to step around a little timestep (dt) into the future (or past if (dt < 0)). All derived Classes should reimplement this function, to describe the behaviour of the WorldEntity over time.
  • draw: Tells this WorldEntity to draw itself. This function should be reimplemented virtually by all derived classes. Most Classes are drawn differently. The default drawing function is quite good, but maybe not, what you are looking for.
  • collidesWith: If a Collision has happened, this function is called. Here you get the Entity that collided with this one, and the location, where the hit occured.

other functions All the other functions to be read about in the Source-Documentation

Howto Create a new WorldEntity

If you want to create a new WorldEntity, you first have to know the concept of

  • ClassID, BaseObject (for nice integration into our project)
  • LoadParam / Factory (for automatic Loading)

Then it would be a good idea to look at an other WorldEntity, like Player/NPC/PowerUp.

Creation Process:

  1. Copy src/proto/proto_world_entity.[cc,h] to src world_entities/you_entity.[cc,h]
  2. Rename all the ProtoWorldEntities to YourOwnName (look at all cases, PROTO_WORLD_ENTITY, proto_world_entity.h)
  3. add your new ClassID to src/defs/class_id.h → write a mail to orxonox-dev-mailingList, if you have problems with this
  4. Peek at some the other WorldEntities, to get the hang of the functionality
  5. be creative :)
Last modified 9 years ago Last modified on Nov 28, 2007, 12:19:28 AM