Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3236 in orxonox.OLD for orxonox/trunk/src/world.h


Ignore:
Timestamp:
Dec 20, 2004, 1:39:51 AM (19 years ago)
Author:
patrick
Message:

/orxonox/trunk: unstable - problems getting collision to compile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world.h

    r3226 r3236  
    8585};
    8686
    87 /**
    88     \brief spawn a new WorldEntity at a Location
    89     \param loc: the Location where the Entity should be spawned
    90     \param owner: a pointer to the parent of the Entity
    91     \return a pointer to the new WorldEntity or NULL if there was an error
    92    
    93     You can use this function to spawn any derivation of WorldEntity you want, just specify the desired
    94     class within the template specification brackets. Do not attempt to spawn any classes that have NOT been
    95     derived from WorldEntity, you won't even be able to compile the code. Note that this version of spawn()
    96     works with both free and bound WorldEntities.
    97 */
    98 template<typename T> T* World::spawn(Location* loc = NULL, WorldEntity* owner = NULL)
    99 {
    100   Location zeroloc;
    101   T* entity = new T();
    102   entities->add ((WorldEntity*)entity, LIST_ADD_NEXT);
    103   if( loc == NULL)
    104     {
    105       zeroloc.dist = 0;
    106       zeroloc.part = 0;
    107       zeroloc.pos = Vector();
    108       zeroloc.rot = Quaternion();
    109       loc = &zeroloc;
    110     }
    111   entity->init (loc, owner);
    112   if (entity->bFree)
    113     {
    114       track[loc->part].map_coords( loc, entity->get_placement());
    115     }
    116   entity->post_spawn ();
    117   return entity;
    118 }
    119 
    120 /**
    121     \brief spawn a new WorldEntity at a Placement
    122     \param lplc: the placement where the Entity should be spawned
    123     \param owner: a pointer to the parent of the Entity
    124     \return a pointer to the new WorldEntity or NULL if there was an error
    125    
    126     You can use this function to spawn any FREE derivation of WorldEntity you want, just specify the desired
    127     class within the template specification brackets. Do not attempt to spawn any classes that have NOT been
    128     derived from WorldEntity, you won't even be able to compile the code. Note that this version of spawn()
    129     works with free WorldEntities only, you will provoke an error message if you try to spawn a bound Entity with
    130     a Placement.
    131 */
    132 template<typename T> T* World::spawn(Placement* plc, WorldEntity* owner = NULL)
    133 {
    134   T* entity = new T();
    135   entities->add ((WorldEntity*)entity, LIST_ADD_NEXT);
    136   entity->init (plc, owner);
    137   if (!entity->bFree)
    138     {
    139       printf("Can't spawn unfree entity with placement\n");
    140       entities->remove( (WorldEntity*)entity, LIST_FIND_FW);
    141       return NULL;
    142     }
    143   entity->post_spawn ();
    144   return entity;
    145 }
    146 
    14787#endif /* _WORLD_H */
Note: See TracChangeset for help on using the changeset viewer.