Changeset 13041 for OpenSceneGraph/trunk/include/osgParticle/DomainOperator
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgParticle/DomainOperator
r12139 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 45 45 DISK_DOMAIN 46 46 }; 47 47 48 48 Domain( Type t ) : r1(0.0f), r2(0.0f), type(t) {} 49 49 osg::Plane plane; … … 57 57 Type type; 58 58 }; 59 59 60 60 DomainOperator() 61 61 : Operator() 62 62 {} 63 63 64 64 DomainOperator( const DomainOperator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY ) 65 65 : Operator(copy, copyop), _domains(copy._domains), _backupDomains(copy._backupDomains) 66 66 {} 67 67 68 68 META_Object( osgParticle, DomainOperator ); 69 69 70 70 /// Add a point domain 71 71 inline void addPointDomain( const osg::Vec3& p ); 72 72 73 73 /// Add a line segment domain 74 74 inline void addLineSegmentDomain( const osg::Vec3& v1, const osg::Vec3& v2 ); 75 75 76 76 /// Add a triangle domain 77 77 inline void addTriangleDomain( const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3 ); 78 78 79 79 /// Add a rectangle domain 80 80 inline void addRectangleDomain( const osg::Vec3& corner, const osg::Vec3& w, const osg::Vec3& h ); 81 81 82 82 /// Add a plane domain 83 83 inline void addPlaneDomain( const osg::Plane& plane ); 84 84 85 85 /// Add a sphere domain 86 86 inline void addSphereDomain( const osg::Vec3& c, float r ); 87 87 88 88 /// Add a box domain 89 89 inline void addBoxDomain( const osg::Vec3& min, const osg::Vec3& max ); 90 90 91 91 /// Add a disk domain 92 92 inline void addDiskDomain( const osg::Vec3& c, const osg::Vec3& n, float r1, float r2=0.0f ); 93 93 94 94 /// Add a domain object directly, used by the .osg wrappers and serializers. 95 95 void addDomain( const Domain& domain ) { _domains.push_back(domain); } 96 96 97 97 /// Get a domain object directly, used by the .osg wrappers and serializers. 98 98 const Domain& getDomain( unsigned int i ) const { return _domains[i]; } 99 99 100 100 /// Remove a domain at specific index 101 101 void removeDomain( unsigned int i ) 102 102 { if (i<_domains.size()) _domains.erase(_domains.begin() + i); } 103 103 104 104 /// Remove all existing domains 105 105 void removeAllDomains() { _domains.clear(); } 106 106 107 107 /// Get number of domains 108 108 unsigned int getNumDomains() const { return _domains.size(); } 109 109 110 110 /// Apply the acceleration to a particle. Do not call this method manually. 111 111 void operate( Particle* P, double dt ); 112 112 113 113 /// Perform some initializations. Do not call this method manually. 114 114 void beginOperate( Program* prg ); 115 115 116 116 /// Perform some post-operations. Do not call this method manually. 117 117 void endOperate(); 118 118 119 119 protected: 120 120 virtual ~DomainOperator() {} 121 121 DomainOperator& operator=( const DomainOperator& ) { return *this; } 122 122 123 123 virtual void handlePoint( const Domain& domain, Particle* P, double dt ) { ignore("Point"); } 124 124 virtual void handleLineSegment( const Domain& domain, Particle* P, double dt ) { ignore("LineSegment"); } … … 129 129 virtual void handleBox( const Domain& domain, Particle* P, double dt ) { ignore("Box"); } 130 130 virtual void handleDisk( const Domain& domain, Particle* P, double dt ) { ignore("Disk"); } 131 131 132 132 inline void computeNewBasis( const osg::Vec3&, const osg::Vec3&, osg::Vec3&, osg::Vec3& ); 133 133 inline void ignore( const std::string& func ); 134 134 135 135 std::vector<Domain> _domains; 136 136 std::vector<Domain> _backupDomains; … … 218 218 u.x()*v.z()*w.y() + v.z()*w.x()*u.y() + u.z()*v.x()*w.y(); 219 219 det = 1.0f / det; 220 220 221 221 s1.set( v.y()*w.z() - v.z()*w.y(), v.z()*w.x() - v.x()*w.z(), v.x()*w.y() - v.y()*w.x() ); 222 222 s1 = s1 * det;
