00001 #include "SIGEL_Visualisation/SIG_VisualSceneObject.h" 00002 00003 namespace SIGEL_Visualisation 00004 { 00005 SIG_VisualSceneObject::SIG_VisualSceneObject(int number, 00006 QString name, 00007 DL_vector position, 00008 DL_matrix rotation, 00009 DL_vector color) 00010 : SIG_SceneObject(number, position, rotation), 00011 name(name), 00012 color(color), 00013 transformationInternal(16), 00014 colorInternal(3), 00015 visible(true), 00016 floatingText(0) 00017 { 00018 for (int j=0; j<3; j++) 00019 transformationInternal[ (j * 4) + 3 ] = 0; 00020 transformationInternal[ 15 ] = 1; 00021 00022 updatePositionInternal(); 00023 updateRotationInternal(); 00024 updateColorInternal(); 00025 }; 00026 00027 int SIG_VisualSceneObject::getNumber() 00028 { 00029 return number; 00030 }; 00031 00032 void SIG_VisualSceneObject::setPosition(DL_vector newPosition) 00033 { 00034 position = newPosition; 00035 updatePositionInternal(); 00036 }; 00037 00038 DL_vector SIG_VisualSceneObject::getPosition() const 00039 { 00040 return position; 00041 }; 00042 00043 void SIG_VisualSceneObject::setRotation(DL_matrix newRotation) 00044 { 00045 rotation = newRotation; 00046 updateRotationInternal(); 00047 }; 00048 00049 DL_matrix SIG_VisualSceneObject::getRotation() const 00050 { 00051 return rotation; 00052 }; 00053 00054 void SIG_VisualSceneObject::setColor(DL_vector newColor) 00055 { 00056 color = newColor; 00057 updateColorInternal(); 00058 }; 00059 00060 DL_vector SIG_VisualSceneObject::getColor() const 00061 { 00062 return color; 00063 }; 00064 00065 void SIG_VisualSceneObject::applyTransformation() 00066 { 00067 glMultMatrixd(transformationInternal.data()); 00068 }; 00069 00070 void SIG_VisualSceneObject::applyColor() 00071 { 00072 glColor3dv(colorInternal.data()); 00073 }; 00074 00075 void SIG_VisualSceneObject::updatePositionInternal() 00076 { 00077 for (int i=0; i<3; i++) 00078 transformationInternal[ 12 + i ] = static_cast<GLdouble>(position.get(i)); 00079 }; 00080 00081 void SIG_VisualSceneObject::updateRotationInternal() 00082 { 00083 for (int i=0; i<3; i++) 00084 for (int j=0; j<3; j++) 00085 transformationInternal[ i + (4 * j) ] = static_cast<GLdouble>(rotation.get(i,j)); 00086 }; 00087 00088 void SIG_VisualSceneObject::updateColorInternal() 00089 { 00090 for (int i=0; i<3; i++) 00091 colorInternal[ i ] = static_cast<GLdouble>(color.get(i)); 00092 }; 00093 00094 void SIG_VisualSceneObject::setVisible( bool newVisible ) 00095 { 00096 visible = newVisible; 00097 }; 00098 00099 bool SIG_VisualSceneObject::getVisible() 00100 { 00101 return visible; 00102 }; 00103 00104 void SIG_VisualSceneObject::setFloatingText( SIG_FloatingText *newFloatingText ) 00105 { 00106 floatingText = newFloatingText; 00107 }; 00108 00109 SIG_FloatingText *SIG_VisualSceneObject::getFloatingText() 00110 { 00111 return floatingText; 00112 }; 00113 00114 }