![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 * Copyright (c) 2012 MAK Technologies, Inc. 00003 * All rights reserved. 00004 *****************************************************************************/ 00005 00009 00010 #pragma once 00011 00012 #include <vrvOsg/vrvOsg.h> 00013 00014 #include <vrvOsg/DtOsgModelInstance.h> 00015 00016 #include <osg/MatrixTransform> 00017 #include <osg/Geometry> 00018 00019 namespace makVrv 00020 { 00021 00024 class DT_DLL_VRVOSG DtAttachableEllipsoidArcModelInstance : public DtOsgModelInstance 00025 { 00026 public: 00027 00030 00034 DtAttachableEllipsoidArcModelInstance( DtDe& de ); 00035 00038 virtual ~DtAttachableEllipsoidArcModelInstance(); 00039 00042 virtual void addToConnector( DtOsgSceneConnector* connector ); 00043 00046 virtual bool removeFromConnector( DtOsgSceneConnector* connector ); 00047 00050 virtual bool realize( DtModelDefinition& definition ); 00051 00054 virtual void setVisible( bool isVisible ) {} 00055 00057 00060 00066 virtual void setRelativePosition( double x, double y, double z ); 00067 00073 virtual void setOrientation( double yaw, double pitch, double roll ); 00074 00080 virtual void setDimensions( double x, double y, double z ); 00081 00088 virtual void setColor( float r, float g, float b, float a ); 00089 00098 virtual void setInsideColor( float r, float g, float b, float a ); 00099 00106 virtual void setOutsideColor( float r, float g, float b, float a ); 00107 00112 virtual void setAzimuthRange( float azimuthCenter, float azimuthSweep ); 00113 00118 virtual void setElevationRange( float elevationCenter, float elevationSweep ); 00119 00124 virtual void setMaxAngleSegment( float angleSegmentMax ); 00125 00130 virtual void setShowLines( bool showLines ); 00131 00136 virtual void setLinesHaveAlpha( bool lineAlpha ); 00137 00145 virtual void setLockUpdates( bool lock ); 00146 00148 00149 protected: 00150 00153 00159 virtual void updateGeometry(); 00160 00166 virtual void updateGeometryColors(); 00167 00171 virtual void updateGeometryWireframeState(); 00172 00177 virtual void updateGeometryTransforms(); 00178 00180 00181 protected: 00182 00185 00188 struct SphericalVertex { 00189 00195 SphericalVertex( double _inclination, double _azimuth, double _radius ); 00196 00200 SphericalVertex( const osg::Vec3& cartesian ); 00201 00207 bool operator < ( const SphericalVertex& rhs ) const; 00208 00212 osg::Vec3 toCartesian() const; 00213 00215 double myInclination; 00216 00218 double myAzimuth; 00219 00221 double myRadius; 00222 00223 }; 00224 00227 struct VertexCache 00228 { 00229 00236 VertexCache( osg::Vec3Array* vertices, osg::Vec3Array* normals ); 00237 00245 int getIndex( const SphericalVertex& vertex ); 00246 00248 typedef std::map<SphericalVertex, int> SphericalToIndexMap; 00249 00251 SphericalToIndexMap mySphericalToIndexMap; 00252 00254 osg::Vec3Array* myVertices; 00255 00257 osg::Vec3Array* myNormals; 00258 00260 int myNextIndex; 00261 00262 }; 00263 00266 struct SphericalQuad 00267 { 00268 00275 SphericalQuad( SphericalVertex _topLeft, SphericalVertex _topRight, 00276 SphericalVertex _bottomLeft, SphericalVertex _bottomRight ); 00277 00278 SphericalVertex topLeft; 00279 SphericalVertex topRight; 00280 SphericalVertex bottomLeft; 00281 SphericalVertex bottomRight; 00282 00283 }; 00284 00287 struct Triangle { 00288 00294 Triangle( SphericalVertex _v1, SphericalVertex _v2, SphericalVertex _v3 ); 00295 00296 SphericalVertex v1; 00297 SphericalVertex v2; 00298 SphericalVertex v3; 00299 00300 }; 00301 00307 double angularDistance( double from, double to ); 00308 00310 struct EllipsoidArcRange { 00311 00313 EllipsoidArcRange() 00314 : center(0) 00315 , sweep(0) 00316 {} 00317 00319 EllipsoidArcRange( float _center, float _sweep ) 00320 { 00321 set( _center, _sweep ); 00322 } 00323 00325 inline void set( float _center, float _sweep ) 00326 { 00327 center = _center; 00328 sweep = _sweep; 00329 } 00330 00331 float center; 00332 float sweep; 00333 00334 }; 00335 00337 00338 protected: 00339 00341 osg::ref_ptr<osg::MatrixTransform> myTransform; 00342 00344 osg::ref_ptr<osg::Group> myBlendNode; 00345 00347 osg::ref_ptr<osg::Group> myWireNode; 00348 00350 osg::ref_ptr<osg::Geometry> myGeometry; 00351 00353 osg::ref_ptr<osg::Geode> myFrontGeode; 00354 00356 osg::ref_ptr<osg::Geode> myBackGeode; 00357 00358 int myCenterVertexIndex; 00359 00361 bool myLockUpdates; 00362 00364 bool myDirtyGeometry; 00365 00367 bool myDirtyColors; 00368 00370 osg::Vec3d myRelativePosition; 00371 00373 osg::Quat myRelativeOrientation; 00374 00376 osg::Vec3d myDimensions; 00377 00379 EllipsoidArcRange myAzimuthRange; 00380 00382 EllipsoidArcRange myElevationRange; 00383 00385 osg::Vec4 myInsideColor; 00386 00388 osg::Vec4 myOutsideColor; 00389 00391 bool myShowLines; 00392 00394 bool myLineAlphaFlag; 00395 00397 float myAngleSegmentMax; 00398 00400 bool myFlashing; 00401 00402 }; 00403 00404 00407 class DT_DLL_VRVOSG DtAttachableEllipsoidArcModelInstanceCreator : public DtModelInstanceCreator 00408 { 00409 public: 00410 00413 virtual ~DtAttachableEllipsoidArcModelInstanceCreator(); 00414 00418 static void registerCreator( DtDe& de ); 00419 00423 virtual DtModelInstance* create( DtDe& de ); 00424 00425 protected: 00426 00429 DtAttachableEllipsoidArcModelInstanceCreator(); 00430 00431 }; 00432 00433 }