00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "axes.h"
00031 #include "shape.h"
00032
00033 #include <OGRE/OgreSceneManager.h>
00034 #include <OGRE/OgreSceneNode.h>
00035 #include <OGRE/OgreVector3.h>
00036 #include <OGRE/OgreQuaternion.h>
00037
00038 #include <sstream>
00039
00040 namespace ogre_tools
00041 {
00042
00043 Axes::Axes( Ogre::SceneManager* scene_manager, Ogre::SceneNode* parent_node, float length, float radius )
00044 : Object( scene_manager )
00045 {
00046 if ( !parent_node )
00047 {
00048 parent_node = scene_manager_->getRootSceneNode();
00049 }
00050
00051 scene_node_ = parent_node->createChildSceneNode();
00052
00053 x_axis_ = new Shape( Shape::Cylinder, scene_manager_, scene_node_ );
00054 y_axis_ = new Shape( Shape::Cylinder, scene_manager_, scene_node_ );
00055 z_axis_ = new Shape( Shape::Cylinder, scene_manager_, scene_node_ );
00056
00057 set( length, radius );
00058 }
00059
00060 Axes::~Axes()
00061 {
00062 delete x_axis_;
00063 delete y_axis_;
00064 delete z_axis_;
00065
00066 scene_manager_->destroySceneNode( scene_node_->getName() );
00067 }
00068
00069 void Axes::set( float length, float radius )
00070 {
00071 x_axis_->setScale(Ogre::Vector3( radius, length, radius ));
00072 y_axis_->setScale(Ogre::Vector3( radius, length, radius ));
00073 z_axis_->setScale(Ogre::Vector3( radius, length, radius ));
00074
00075 x_axis_->setPosition( Ogre::Vector3( length/2.0f, 0.0f, 0.0f ) );
00076 x_axis_->setOrientation( Ogre::Quaternion( Ogre::Degree( -90 ), Ogre::Vector3::UNIT_Z ) );
00077 y_axis_->setPosition( Ogre::Vector3( 0.0f, length/2.0f, 0.0f ) );
00078 z_axis_->setPosition( Ogre::Vector3( 0.0, 0.0f, length/2.0f ) );
00079 z_axis_->setOrientation( Ogre::Quaternion( Ogre::Degree( 90 ), Ogre::Vector3::UNIT_X ) );
00080
00081 setToDefaultColors();
00082 }
00083
00084 void Axes::setPosition( const Ogre::Vector3& position )
00085 {
00086 scene_node_->setPosition( position );
00087 }
00088
00089 void Axes::setOrientation( const Ogre::Quaternion& orientation )
00090 {
00091 scene_node_->setOrientation( orientation );
00092 }
00093
00094 void Axes::setScale( const Ogre::Vector3& scale )
00095 {
00096 scene_node_->setScale( scale );
00097 }
00098
00099 void Axes::setColor( float r, float g, float b, float a )
00100 {
00101
00103 }
00104
00105 const Ogre::Vector3& Axes::getPosition()
00106 {
00107 return scene_node_->getPosition();
00108 }
00109
00110 const Ogre::Quaternion& Axes::getOrientation()
00111 {
00112 return scene_node_->getOrientation();
00113 }
00114
00115 void Axes::setUserData( const Ogre::Any& data )
00116 {
00117 x_axis_->setUserData( data );
00118 y_axis_->setUserData( data );
00119 z_axis_->setUserData( data );
00120 }
00121
00122 void Axes::setXColor(const Ogre::ColourValue& col)
00123 {
00124 x_axis_->setColor(col.r, col.g, col.b, col.a);
00125 }
00126
00127 void Axes::setYColor(const Ogre::ColourValue& col)
00128 {
00129 y_axis_->setColor(col.r, col.g, col.b, col.a);
00130 }
00131
00132 void Axes::setZColor(const Ogre::ColourValue& col)
00133 {
00134 z_axis_->setColor(col.r, col.g, col.b, col.a);
00135 }
00136
00137 void Axes::setToDefaultColors()
00138 {
00139 x_axis_->setColor( 1.0f, 0.0f, 0.0f, 1.0f );
00140 y_axis_->setColor( 0.0f, 1.0f, 0.0f, 1.0f );
00141 z_axis_->setColor( 0.0f, 0.0f, 1.0f, 1.0f );
00142 }
00143
00144 const Ogre::ColourValue& Axes::getDefaultXColor()
00145 {
00146 return Ogre::ColourValue(1.0f, 0.0f, 0.0f, 1.0f);
00147 }
00148
00149 const Ogre::ColourValue& Axes::getDefaultYColor()
00150 {
00151 return Ogre::ColourValue(0.0f, 1.0f, 0.0f, 1.0f);
00152 }
00153
00154 const Ogre::ColourValue& Axes::getDefaultZColor()
00155 {
00156 return Ogre::ColourValue(0.0f, 0.0f, 1.0f, 1.0f);
00157 }
00158
00159 }
00160