Changeset 2374 for code/branches/physics/src/orxonox/objects/worldentities/collisionshapes/PlaneCollisionShape.cc
- Timestamp:
- Dec 10, 2008, 1:38:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/worldentities/collisionshapes/PlaneCollisionShape.cc
r2323 r2374 21 21 * 22 22 * Author: 23 * Reto Grieder23 * Martin Stypinski 24 24 * Co-authors: 25 25 * ... … … 30 30 #include "PlaneCollisionShape.h" 31 31 32 #include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"33 34 #include "tools/BulletConversions.h"35 32 #include "core/CoreIncludes.h" 36 33 #include "core/XMLPort.h" … … 45 42 RegisterObject(PlaneCollisionShape); 46 43 47 this->planeShape_ = new btStaticPlaneShape(btVector3(1, 1,1), 0);44 this->planeShape_ = new btStaticPlaneShape(btVector3(1, 1, 1), 0); 48 45 this->collisionShape_ = this->planeShape_; 46 this->planeNormal_ = Vector3(1, 1, 1); 47 this->planeOffset_ = 0.0f; 49 48 } 50 49 … … 52 51 { 53 52 if (this->isInitialized()) 54 delete this-> collisionShape_;53 delete this->planeShape_; 55 54 } 56 55 57 void PlaneCollisionShape:: setNormal(const Vector3& normal)56 void PlaneCollisionShape::registerVariables() 58 57 { 59 btScalar offset = this->planeShape_->getPlaneConstant(); 60 delete this->collisionShape_; 61 this->planeShape_ = new btStaticPlaneShape(omni_cast<btVector3>(normal), offset); 62 this->collisionShape_ = this->planeShape_; 63 } 64 65 void PlaneCollisionShape::setOffset(float offset) 66 { 67 btVector3 normal = this->planeShape_->getPlaneNormal(); 68 delete this->collisionShape_; 69 this->planeShape_ = new btStaticPlaneShape(normal, offset); 70 this->collisionShape_ = this ->planeShape_; 58 REGISTERDATA(this->planeNormal_, network::direction::toclient, new network::NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::planeNormalChanged)); 59 REGISTERDATA(this->planeOffset_, network::direction::toclient, new network::NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::planeOffsetChanged)); 71 60 } 72 61 … … 75 64 SUPER(PlaneCollisionShape, XMLPort, xmlelement, mode); 76 65 77 XMLPortParam(PlaneCollisionShape, " normal", setNormal, getNormal, xmlelement, mode);78 XMLPortParam(PlaneCollisionShape, " offset", setOffset, getOffset, xmlelement, mode);66 XMLPortParam(PlaneCollisionShape, "planeNormal", setNormal, getNormal, xmlelement, mode); 67 XMLPortParam(PlaneCollisionShape, "planeOffset", setOffset, getOffset, xmlelement, mode); 79 68 } 80 69 81 btVector3 PlaneCollisionShape::getTotalScaling()70 void PlaneCollisionShape::setNormal(const Vector3& normal) 82 71 { 83 return omni_cast<btVector3>(this->node_->getScale()); //* this->radius_; 72 delete this->planeShape_; 73 this->planeNormal_ = normal; 74 this->planeShape_ = new btStaticPlaneShape(omni_cast<btVector3>(normal), this->planeOffset_); 75 this->collisionShape_ = this->planeShape_; 76 } 77 78 void PlaneCollisionShape::setOffset(float offset) 79 { 80 delete this->planeShape_; 81 this->planeOffset_ = offset; 82 this->planeShape_ = new btStaticPlaneShape(omni_cast<btVector3>(this->planeNormal_), offset); 83 this->collisionShape_ = this->planeShape_; 84 84 } 85 85 }
Note: See TracChangeset
for help on using the changeset viewer.