- Timestamp:
- Nov 28, 2008, 1:25:16 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/worldentities/LinearEntity.cc
r2192 r2292 74 74 if (this->isActive()) 75 75 { 76 this->velocity_ += (dt * this->acceleration_); 77 this->node_->translate(dt * this->velocity_); 76 if (!this->isDynamic()) 77 { 78 // we have to do 'physics' ourselves. 79 this->velocity_ += (dt * this->acceleration_); 80 this->node_->translate(dt * this->velocity_); 78 81 79 this->rotationRate_ += (dt * this->momentum_); 80 this->node_->rotate(this->rotationAxis_, this->rotationRate_ * dt); 82 this->rotationRate_ += (dt * this->momentum_); 83 this->node_->rotate(this->rotationAxis_, this->rotationRate_ * dt); 84 } 81 85 } 82 86 } … … 123 127 } 124 128 125 void LinearEntity:: setPosition(const Vector3& position)129 void LinearEntity::positionChanged() 126 130 { 127 this->node_->setPosition(position); 128 this->overwrite_position_ = this->node_->getPosition(); 131 this->overwrite_position_ = this->node_->getPosition(); 129 132 } 130 133 131 void LinearEntity:: translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)134 void LinearEntity::orientationChanged() 132 135 { 133 this->node_->translate(distance, relativeTo); 134 this->overwrite_position_ = this->node_->getPosition(); 136 this->overwrite_orientation_ = this->node_->getOrientation(); 135 137 } 136 138 137 void LinearEntity::set Orientation(const Quaternion& orientation)139 void LinearEntity::setVelocity(const Vector3& velocity) 138 140 { 139 this->node_->setOrientation(orientation); 140 this->overwrite_orientation_ = this->node_->getOrientation(); 141 } 142 143 void LinearEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo) 144 { 145 this->node_->rotate(rotation, relativeTo); 146 this->overwrite_orientation_ = this->node_->getOrientation(); 147 } 148 149 void LinearEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo) 150 { 151 this->node_->yaw(angle, relativeTo); 152 this->overwrite_orientation_ = this->node_->getOrientation(); 153 } 154 155 void LinearEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo) 156 { 157 this->node_->pitch(angle, relativeTo); 158 this->overwrite_orientation_ = this->node_->getOrientation(); 159 } 160 161 void LinearEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo) 162 { 163 this->node_->roll(angle, relativeTo); 164 this->overwrite_orientation_ = this->node_->getOrientation(); 165 } 166 167 void LinearEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector) 168 { 169 this->node_->lookAt(target, relativeTo, localDirectionVector); 170 this->overwrite_orientation_ = this->node_->getOrientation(); 171 } 172 173 void LinearEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector) 174 { 175 this->node_->setDirection(direction, relativeTo, localDirectionVector); 176 this->overwrite_orientation_ = this->node_->getOrientation(); 141 if (!this->isDynamic()) 142 { 143 // no physics, we do it ourselves 144 internalSetVelocity(velocity); 145 } 146 else 147 { 148 this->physicalBody_->setLinearVelocity(btVector3(velocity.x, velocity.y, velocity.z)); 149 } 177 150 } 178 151 }
Note: See TracChangeset
for help on using the changeset viewer.