diff options
author | Stijn Buys <ingar@osirion.org> | 2008-04-27 13:08:12 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-04-27 13:08:12 +0000 |
commit | a4b36e6d1e20b5036d1ed7cf9f61a48dbbf77812 (patch) | |
tree | 7efd0048fd8c10b1f04d427c78e3ac8da402f059 /src/core/entity.cc | |
parent | fe95954f9d17c9dade1827fe5d4cf8cffffddbce (diff) |
3D flight
Diffstat (limited to 'src/core/entity.cc')
-rw-r--r-- | src/core/entity.cc | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc index 1e90b2a..b3d58a3 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -91,7 +91,6 @@ Entity::Entity(unsigned int flags) : entity_moduletypeid = 0; entity_radius = 1.0f; - entity_direction = 0; entity_shape = Diamond; entity_created = true; @@ -118,7 +117,7 @@ Entity::Entity(std::istream & is) is >> entity_color; is >> s; // shape is >> entity_radius; - is >> entity_direction; + is >> entity_axis; entity_shape = (Shape) s ; char c; @@ -155,7 +154,7 @@ void Entity::serialize(std::ostream & os) const << entity_color << " " << entity_shape << " " << entity_radius << " " - << entity_direction << " " + << entity_axis << " " << "\"" << entity_name << "\" " << "\"" << entity_modelname << "\""; } @@ -207,9 +206,8 @@ void EntityDynamic::frame(float seconds) if (entity_speed == 0) return; - // location avoid sin/cos calculations - entity_location.x += cosf(entity_direction * M_PI / 180) * entity_speed * seconds; - entity_location.y += sinf(entity_direction * M_PI / 180) * entity_speed * seconds; + entity_location += entity_axis.forward() * entity_speed * seconds; + entity_dirty = true; } @@ -229,13 +227,13 @@ void EntityDynamic::recieve_client_update(std::istream &is) void EntityDynamic::serialize_server_update(std::ostream & os) const { - os << entity_location << " " << entity_direction << " " << entity_speed; + os << entity_location << " " << entity_axis << " " << entity_speed; } void EntityDynamic::recieve_server_update(std::istream &is) { is >> entity_location; - is >> entity_direction; + is >> entity_axis; is >> entity_speed; } @@ -335,6 +333,18 @@ void EntityControlable::set_direction(float direction) } } +void EntityControlable::set_pitch(float pitch) +{ + if ((flags() & Static) == Static) + return; + + if (target_pitch != pitch) { + target_pitch = pitch; + entity_dirty = true; + } +} + + /*----- EntityGlobe ------------------------------------------------ */ EntityGlobe::EntityGlobe(unsigned int flags) : |