33 #include <OgreSceneManager.h> 34 #include <OgreSceneNode.h> 35 #include <OgreVector3.h> 36 #include <OgreQuaternion.h> 43 Ogre::SceneNode* parent_node,
61 set(shaft_length, shaft_diameter, head_length, head_diameter);
74 void Arrow::set(
float shaft_length,
float shaft_diameter,
float head_length,
float head_diameter)
76 shaft_->
setScale(Ogre::Vector3(shaft_diameter, shaft_length, shaft_diameter));
79 head_->
setScale(Ogre::Vector3(head_diameter, head_length, head_diameter));
91 setColor(Ogre::ColourValue(r, g, b, a));
123 scene_node_->setOrientation(orientation * Ogre::Quaternion(Ogre::Degree(-90), Ogre::Vector3::UNIT_X));
128 if (!direction.isZeroLength())
130 setOrientation(Ogre::Vector3::NEGATIVE_UNIT_Z.getRotationTo(direction));
137 scene_node_->setScale(Ogre::Vector3(scale.z, scale.x, scale.y));
Ogre::SceneNode * scene_node_
const Ogre::Vector3 & getPosition() override
Get the local position of this object.
void setScale(const Ogre::Vector3 &scale) override
Set the scale of the object. Always relative to the identity orientation of the object.
void setDirection(const Ogre::Vector3 &direction)
Set the direction of the arrow.
void setPosition(const Ogre::Vector3 &position) override
Set the position of the base of the arrow.
Arrow(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node=nullptr, float shaft_length=1.0f, float shaft_diameter=0.1f, float head_length=0.3f, float head_diameter=0.2f)
Constructor.
void setUserData(const Ogre::Any &data) override
Sets user data on all ogre objects we own.
void set(float shaft_length, float shaft_diameter, float head_length, float head_diameter)
Set the parameters for this arrow.
void setColor(float r, float g, float b, float a) override
Set the color of the object. Values are in the range [0, 1].
Base class for visible objects, providing a minimal generic interface.
Shape * head_
Cone used for the head of the arrow.
const Ogre::Quaternion & getOrientation() override
Get the local orientation of this object.
void setShaftColor(float r, float g, float b, float a=1.0f)
Set the color of the arrow's shaft. Values are in the range [0, 1].
void setScale(const Ogre::Vector3 &scale) override
Set the scale of the object. Always relative to the identity orientation of the object.
void setPosition(const Ogre::Vector3 &position) override
Set the position of this object.
void setUserData(const Ogre::Any &data) override
Sets user data on all ogre objects we own.
void setOrientation(const Ogre::Quaternion &orientation) override
Set the orientation.
Ogre::SceneManager * scene_manager_
Ogre scene manager this object is part of.
void setColor(float r, float g, float b, float a) override
Set the color of this arrow. Sets both the head and shaft color to the same value. Values are in the range [0, 1].
void setOffset(const Ogre::Vector3 &offset)
Set the offset for this shape.
void setHeadColor(float r, float g, float b, float a=1.0f)
Set the color of the arrow's head. Values are in the range [0, 1].
Shape * shaft_
Cylinder used for the shaft of the arrow.