ruby-procedural 0.0.1-x86-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. data/Gemfile +4 -0
  2. data/README.md +29 -0
  3. data/Rakefile +65 -0
  4. data/bindings/procedural/interface/ProceduralBoxGenerator.i +12 -0
  5. data/bindings/procedural/interface/ProceduralCapsuleGenerator.i +12 -0
  6. data/bindings/procedural/interface/ProceduralConeGenerator.i +12 -0
  7. data/bindings/procedural/interface/ProceduralCylinderGenerator.i +12 -0
  8. data/bindings/procedural/interface/ProceduralExtruder.i +8 -0
  9. data/bindings/procedural/interface/ProceduralGeometryHelpers.i +15 -0
  10. data/bindings/procedural/interface/ProceduralHeader.i +8 -0
  11. data/bindings/procedural/interface/ProceduralIcoSphereGenerator.i +12 -0
  12. data/bindings/procedural/interface/ProceduralLathe.i +8 -0
  13. data/bindings/procedural/interface/ProceduralMeshGenerator.i +9 -0
  14. data/bindings/procedural/interface/ProceduralMultiShape.i +8 -0
  15. data/bindings/procedural/interface/ProceduralPath.i +8 -0
  16. data/bindings/procedural/interface/ProceduralPathGenerators.i +10 -0
  17. data/bindings/procedural/interface/ProceduralPlaneGenerator.i +12 -0
  18. data/bindings/procedural/interface/ProceduralPlatform.i +8 -0
  19. data/bindings/procedural/interface/ProceduralRoot.i +23 -0
  20. data/bindings/procedural/interface/ProceduralRoundedBoxGenerator.i +12 -0
  21. data/bindings/procedural/interface/ProceduralShape.i +8 -0
  22. data/bindings/procedural/interface/ProceduralShapeGenerators.i +10 -0
  23. data/bindings/procedural/interface/ProceduralSphereGenerator.i +11 -0
  24. data/bindings/procedural/interface/ProceduralSplines.i +8 -0
  25. data/bindings/procedural/interface/ProceduralStableHeaders.i +8 -0
  26. data/bindings/procedural/interface/ProceduralTorusGenerator.i +12 -0
  27. data/bindings/procedural/interface/ProceduralTorusKnotGenerator.i +12 -0
  28. data/bindings/procedural/interface/ProceduralTrack.i +8 -0
  29. data/bindings/procedural/interface/ProceduralTriangleBuffer.i +13 -0
  30. data/bindings/procedural/interface/ProceduralTriangulator.i +8 -0
  31. data/bindings/procedural/interface/ProceduralTubeGenerator.i +12 -0
  32. data/bindings/procedural/interface/ProceduralUtils.i +8 -0
  33. data/bindings/procedural/interface/Rakefile +22 -0
  34. data/bindings/procedural/interface/procedural.i +41 -0
  35. data/bindings/procedural/interface/procedural_wrap.cpp +36079 -0
  36. data/bindings/procedural/interface/procedural_wrap.h +19 -0
  37. data/bindings/procedural/interface/procedural_wrap.o +0 -0
  38. data/deps/include/OgreProcedural/Procedural.h +54 -0
  39. data/deps/include/OgreProcedural/ProceduralBoxGenerator.h +110 -0
  40. data/deps/include/OgreProcedural/ProceduralCapsuleGenerator.h +103 -0
  41. data/deps/include/OgreProcedural/ProceduralConeGenerator.h +90 -0
  42. data/deps/include/OgreProcedural/ProceduralCylinderGenerator.h +99 -0
  43. data/deps/include/OgreProcedural/ProceduralExtruder.h +131 -0
  44. data/deps/include/OgreProcedural/ProceduralGeometryHelpers.h +171 -0
  45. data/deps/include/OgreProcedural/ProceduralIcoSphereGenerator.h +76 -0
  46. data/deps/include/OgreProcedural/ProceduralLathe.h +129 -0
  47. data/deps/include/OgreProcedural/ProceduralMeshGenerator.h +286 -0
  48. data/deps/include/OgreProcedural/ProceduralMultiShape.h +126 -0
  49. data/deps/include/OgreProcedural/ProceduralPath.h +322 -0
  50. data/deps/include/OgreProcedural/ProceduralPathGenerators.h +281 -0
  51. data/deps/include/OgreProcedural/ProceduralPlaneGenerator.h +93 -0
  52. data/deps/include/OgreProcedural/ProceduralPlatform.h +54 -0
  53. data/deps/include/OgreProcedural/ProceduralRoot.h +65 -0
  54. data/deps/include/OgreProcedural/ProceduralRoundedBoxGenerator.h +118 -0
  55. data/deps/include/OgreProcedural/ProceduralShape.h +532 -0
  56. data/deps/include/OgreProcedural/ProceduralShapeGenerators.h +362 -0
  57. data/deps/include/OgreProcedural/ProceduralSphereGenerator.h +80 -0
  58. data/deps/include/OgreProcedural/ProceduralSplines.h +168 -0
  59. data/deps/include/OgreProcedural/ProceduralStableHeaders.h +28 -0
  60. data/deps/include/OgreProcedural/ProceduralTorusGenerator.h +88 -0
  61. data/deps/include/OgreProcedural/ProceduralTorusKnotGenerator.h +106 -0
  62. data/deps/include/OgreProcedural/ProceduralTrack.h +122 -0
  63. data/deps/include/OgreProcedural/ProceduralTriangleBuffer.h +328 -0
  64. data/deps/include/OgreProcedural/ProceduralTriangulator.h +173 -0
  65. data/deps/include/OgreProcedural/ProceduralTubeGenerator.h +96 -0
  66. data/deps/include/OgreProcedural/ProceduralUtils.h +185 -0
  67. data/deps/lib/libOgreProcedural.so +0 -0
  68. data/lib/procedural.so +0 -0
  69. data/lib/ruby-procedural/version.rb +5 -0
  70. data/lib/ruby-procedural.rb +27 -0
  71. data/ruby-procedural.gemspec +33 -0
  72. metadata +138 -0
@@ -0,0 +1,173 @@
1
+ /*
2
+ -----------------------------------------------------------------------------
3
+ This source file is part of ogre-procedural
4
+
5
+ For the latest info, see http://code.google.com/p/ogre-procedural/
6
+
7
+ Copyright (c) 2010 Michael Broutin
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in
17
+ all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ THE SOFTWARE.
26
+ -----------------------------------------------------------------------------
27
+ */
28
+ #ifndef PROCEDURAL_TRIANGULATOR_INCLUDED
29
+ #define PROCEDURAL_TRIANGULATOR_INCLUDED
30
+
31
+ #include "ProceduralTriangleBuffer.h"
32
+ #include "ProceduralShape.h"
33
+ #include "OgreVector3.h"
34
+ #include "OgreMatrix4.h"
35
+ #include "ProceduralUtils.h"
36
+ #include "ProceduralMultiShape.h"
37
+ #include "ProceduralMeshGenerator.h"
38
+
39
+ namespace Procedural
40
+ {
41
+ typedef std::vector<Ogre::Vector2> PointList;
42
+
43
+ /** Implements a Delaunay Triangulation algorithm.
44
+ * It works on Shapes to build Triangle Buffers
45
+ */
46
+ class _ProceduralExport Triangulator : public MeshGenerator<Triangulator>
47
+ {
48
+ struct Triangle;
49
+ struct DelaunaySegment;
50
+ typedef std::list<Triangle> DelaunayTriangleBuffer;
51
+
52
+ //-----------------------------------------------------------------------
53
+ struct DelaunaySegment
54
+ {
55
+ int i1, i2;
56
+ DelaunaySegment(int _i1, int _i2) : i1(_i1), i2(_i2) {}
57
+ bool operator<(const DelaunaySegment& other) const
58
+ {
59
+ if (i1!=other.i1)
60
+ return i1<other.i1;
61
+ else
62
+ return i2<other.i2;
63
+ }
64
+ DelaunaySegment inverse()
65
+ {
66
+ return DelaunaySegment(i2, i1);
67
+ }
68
+ };
69
+
70
+ //-----------------------------------------------------------------------
71
+ struct Triangle
72
+ {
73
+ const PointList* pl;
74
+ int i[3];
75
+ Triangle(const PointList* pl)
76
+ { this->pl = pl;
77
+ }
78
+
79
+ inline Ogre::Vector2 p(int k) const
80
+ {
81
+ return (*pl)[i[k]];
82
+ }
83
+
84
+ bool operator==(const Triangle& other) const
85
+ {
86
+ return i[0]==other.i[0] && i[1]==other.i[1] && i[2]==other.i[2];
87
+ }
88
+
89
+ inline Ogre::Vector2 getMidPoint() const
90
+ {
91
+ return 1.f/3.f * (p(0)+p(1)+p(2));
92
+ }
93
+
94
+ void setVertices(int i0, int i1, int i2);
95
+
96
+ int findSegNumber(int i0, int i1) const;
97
+
98
+ bool isPointInside(const Ogre::Vector2& point);
99
+
100
+ bool containsSegment(int i0, int i1) const
101
+ {
102
+ return ((i0==i[0] || i0==i[1] || i0==i[2])&&(i1==i[0] || i1==i[1] || i1==i[2]));
103
+ }
104
+
105
+ enum InsideType
106
+ {
107
+ IT_INSIDE, IT_OUTSIDE, IT_BORDERLINEOUTSIDE
108
+ };
109
+
110
+ InsideType isPointInsideCircumcircle(const Ogre::Vector2& point);
111
+
112
+ void makeDirectIfNeeded()
113
+ {
114
+ if ((p(1)-p(0)).crossProduct(p(2)-p(0))<0)
115
+ {
116
+ std::swap(i[0], i[1]);
117
+ }
118
+ }
119
+ };
120
+ //-----------------------------------------------------------------------
121
+ struct TouchSuperTriangle
122
+ {
123
+ int i0,i1,i2;
124
+ TouchSuperTriangle(int i, int j, int k) : i0(i), i1(j), i2(k) {}
125
+ bool operator()(const Triangulator::Triangle& tri)
126
+ {
127
+ for (int k=0;k<3;k++) if (tri.i[k]==i0 || tri.i[k]==i1 ||tri.i[k]==i2) return true;
128
+ return false;
129
+ }
130
+ };
131
+
132
+ Shape* mShapeToTriangulate;
133
+ MultiShape* mMultiShapeToTriangulate;
134
+
135
+ void delaunay(PointList& pointList, DelaunayTriangleBuffer& tbuffer) const;
136
+ void addConstraints(const MultiShape& multiShape, DelaunayTriangleBuffer& tbuffer, const PointList& pl) const;
137
+ void _recursiveTriangulatePolygon(const DelaunaySegment& cuttingSeg, std::vector<int> inputPoints, DelaunayTriangleBuffer& tbuffer, const PointList& pl) const;
138
+
139
+ public:
140
+
141
+ /// Default ctor
142
+ Triangulator() : mShapeToTriangulate(0), mMultiShapeToTriangulate(0) {}
143
+
144
+ /// Sets shape to triangulate
145
+ Triangulator& setShapeToTriangulate(Shape* shape)
146
+ {
147
+ mShapeToTriangulate = shape;
148
+ mMultiShapeToTriangulate = 0;
149
+ return *this;
150
+ }
151
+
152
+ /// Sets multi shape to triangulate
153
+ Triangulator& setMultiShapeToTriangulate(MultiShape* multiShape)
154
+ {
155
+ mMultiShapeToTriangulate = multiShape;
156
+ return *this;
157
+ }
158
+
159
+ /**
160
+ * Executes the Constrained Delaunay Triangulation algorithm
161
+ * @arg ouput A vector of index where is outputed the resulting triangle indexes
162
+ */
163
+ void triangulate(std::vector<int>& output, PointList& outputVertices) const;
164
+
165
+ /**
166
+ * Builds the mesh into the given TriangleBuffer
167
+ * @param buffer The TriangleBuffer on where to append the mesh.
168
+ */
169
+ void addToTriangleBuffer(TriangleBuffer& buffer) const;
170
+ };
171
+
172
+ }
173
+ #endif
@@ -0,0 +1,96 @@
1
+ /*
2
+ -----------------------------------------------------------------------------
3
+ This source file is part of ogre-procedural
4
+
5
+ For the latest info, see http://code.google.com/p/ogre-procedural/
6
+
7
+ Copyright (c) 2010 Michael Broutin
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in
17
+ all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ THE SOFTWARE.
26
+ -----------------------------------------------------------------------------
27
+ */
28
+ #ifndef PROCEDURAL_TUBE_GENERATOR_INCLUDED
29
+ #define PROCEDURAL_TUBE_GENERATOR_INCLUDED
30
+
31
+ #include "ProceduralMeshGenerator.h"
32
+ #include "ProceduralPlatform.h"
33
+
34
+ namespace Procedural
35
+ {
36
+ /// Builds an Y-axis tube mesh, i.e. an emptied cylinder
37
+ class _ProceduralExport TubeGenerator : public MeshGenerator<TubeGenerator>
38
+ {
39
+ int mNumSegBase;
40
+ int mNumSegHeight;
41
+ Ogre::Real mOuterRadius;
42
+ Ogre::Real mInnerRadius;
43
+ Ogre::Real mHeight;
44
+
45
+ public:
46
+ /// Constructor with arguments
47
+ TubeGenerator(Ogre::Real outerRadius=2.f, Ogre::Real innerRadius=1.f, Ogre::Real height=1.f, int numSegBase=16, int numSegHeight=1) :
48
+ mNumSegBase(numSegBase),
49
+ mNumSegHeight(numSegHeight),
50
+ mOuterRadius(outerRadius),
51
+ mInnerRadius(innerRadius),
52
+ mHeight(height) {}
53
+
54
+ /**
55
+ * Builds the mesh into the given TriangleBuffer
56
+ * @param buffer The TriangleBuffer on where to append the mesh.
57
+ */
58
+ void addToTriangleBuffer(TriangleBuffer& buffer) const;
59
+
60
+ /** Sets the number of segments when rotating around the tube's axis (default=16) */
61
+ inline TubeGenerator & setNumSegBase(int numSegBase)
62
+ {
63
+ mNumSegBase = numSegBase;
64
+ return *this;
65
+ }
66
+
67
+ /** Sets the number of segments along the height of the cylinder (default=1) */
68
+ inline TubeGenerator & setNumSegHeight(int numSegHeight)
69
+ {
70
+ mNumSegHeight = numSegHeight;
71
+ return *this;
72
+ }
73
+
74
+ /** Sets the outer radius of the tube (default=2)*/
75
+ inline TubeGenerator & setOuterRadius(Ogre::Real outerRadius)
76
+ {
77
+ mOuterRadius = outerRadius;
78
+ return *this;
79
+ }
80
+
81
+ /** Sets the inner radius of the tube (default=1)*/
82
+ inline TubeGenerator & setInnerRadius(Ogre::Real innerRadius)
83
+ {
84
+ mInnerRadius = innerRadius;
85
+ return *this;
86
+ }
87
+
88
+ /** Sets the height of the tube (default=1) */
89
+ inline TubeGenerator & setHeight(Ogre::Real height)
90
+ {
91
+ mHeight = height;
92
+ return *this;
93
+ }
94
+ };
95
+ }
96
+ #endif
@@ -0,0 +1,185 @@
1
+ /*
2
+ -----------------------------------------------------------------------------
3
+ This source file is part of ogre-procedural
4
+
5
+ For the latest info, see http://code.google.com/p/ogre-procedural/
6
+
7
+ Copyright (c) 2010 Michael Broutin
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in
17
+ all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ THE SOFTWARE.
26
+ -----------------------------------------------------------------------------
27
+ */
28
+ #ifndef PROCEDURAL_UTILS_INCLUDED
29
+ #define PROCEDURAL_UTILS_INCLUDED
30
+ #include "OgreVector3.h"
31
+ #include "OgreAxisAlignedBox.h"
32
+ #include "ProceduralPlatform.h"
33
+
34
+ namespace Procedural
35
+ {
36
+ /// Holds a bunch of static utility functions
37
+ class _ProceduralExport Utils
38
+ {
39
+ static int counter;
40
+ public:
41
+ /// Outputs something to the ogre log, with a [PROCEDURAL] prefix
42
+ static void log(const Ogre::String& st)
43
+ {
44
+ Ogre::LogManager::getSingleton().logMessage("[PROCEDURAL] " + st);
45
+ #if (PROCEDURAL_PLATFORM == PROCEDURAL_PLATFORM_WIN32)
46
+ #ifdef UNICODE
47
+ std::basic_ostringstream<TCHAR> buf;
48
+ buf << st.c_str();
49
+ std::wstring wst = buf.str();
50
+ OutputDebugString( wst.c_str() );
51
+ #else
52
+ OutputDebugString( (st + "\n").c_str() );
53
+ #endif
54
+ #endif
55
+ }
56
+
57
+ /// Gets the min of the coordinates between 2 vectors
58
+ static Ogre::Vector3 min(const Ogre::Vector3& v1, const Ogre::Vector3& v2)
59
+ {
60
+ return Ogre::Vector3(std::min(v1.x, v2.x), std::min(v1.y, v2.y), std::min(v1.z, v2.z));
61
+ }
62
+
63
+ /// Gets the max of the coordinates between 2 vectors
64
+ static Ogre::Vector3 max(const Ogre::Vector3& v1, const Ogre::Vector3& v2)
65
+ {
66
+ return Ogre::Vector3(std::max(v1.x, v2.x), std::max(v1.y, v2.y), std::max(v1.z, v2.z));
67
+ }
68
+
69
+ /// Gets the min of the coordinates between 2 vectors
70
+ static Ogre::Vector2 min(const Ogre::Vector2& v1, const Ogre::Vector2& v2)
71
+ {
72
+ return Ogre::Vector2(std::min(v1.x, v2.x), std::min(v1.y, v2.y));
73
+ }
74
+
75
+ /// Gets the max of the coordinates between 2 vectors
76
+ static Ogre::Vector2 max(const Ogre::Vector2& v1, const Ogre::Vector2& v2)
77
+ {
78
+ return Ogre::Vector2(std::max(v1.x, v2.x), std::max(v1.y, v2.y));
79
+ }
80
+
81
+ /// Builds an AABB from a list of points
82
+ static Ogre::AxisAlignedBox AABBfromPoints(std::vector<Ogre::Vector3> points)
83
+ {
84
+ Ogre::AxisAlignedBox aabb;
85
+ if (points.size() == 0)
86
+ return aabb;
87
+ aabb.setMinimum(points[0]);
88
+ aabb.setMaximum(points[0]);
89
+ for (std::vector<Ogre::Vector3>::iterator it = points.begin(); it!=points.end();it++)
90
+ {
91
+ aabb.setMinimum(min(aabb.getMinimum(), *it));
92
+ aabb.setMaximum(max(aabb.getMaximum(), *it));
93
+ }
94
+
95
+ return aabb;
96
+ }
97
+
98
+ /// Generate a name from a prefix and a counter
99
+ static std::string getName(const std::string& prefix= "default");
100
+
101
+ /// Shifts the components of the vector to the right
102
+ static Ogre::Vector3 vectorPermute(const Ogre::Vector3& in)
103
+ {
104
+ return Ogre::Vector3(in.z, in.x, in.y);
105
+ }
106
+
107
+ /// Shifts the components of the vector to the left
108
+ static Ogre::Vector3 vectorAntiPermute(const Ogre::Vector3& in)
109
+ {
110
+ return Ogre::Vector3(in.y, in.z, in.x);
111
+ }
112
+
113
+ // Rotates a Vector2 by a given oriented angle
114
+ static inline Ogre::Vector2 rotateVector2(const Ogre::Vector2& in, Ogre::Radian angle)
115
+ {
116
+ return Ogre::Vector2(in.x* Ogre::Math::Cos(angle) - in.y * Ogre::Math::Sin(angle),
117
+ in.x * Ogre::Math::Sin(angle) + in.y * Ogre::Math::Cos(angle));
118
+ }
119
+
120
+ /// Caps n between min and max
121
+ static int cap(int n, int min, int max)
122
+ {
123
+ return std::max(std::min(n,max),min);
124
+ }
125
+
126
+ /**
127
+ * An extend version of the standard modulo, in that int values are "wrapped"
128
+ * in both directions, whereas with standard modulo, (-1)%2 == -1
129
+ * Always return an int between 0 and cap-1
130
+ */
131
+ static int modulo(int n, int cap)
132
+ {
133
+ if (n>=0)
134
+ return n%cap;
135
+ return (cap-1)-((1+n)%cap);
136
+ }
137
+
138
+ /**
139
+ * Equivalent of Ogre::Vector3::angleBetween, applied to Ogre::Vector2
140
+ */
141
+ static inline Ogre::Radian angleBetween(const Ogre::Vector2& v1, const Ogre::Vector2& v2)
142
+ {
143
+ Ogre::Real lenProduct = v1.length() * v2.length();
144
+ // Divide by zero check
145
+ if(lenProduct < 1e-6f)
146
+ lenProduct = 1e-6f;
147
+
148
+ Ogre::Real f = v1.dotProduct(v2) / lenProduct;
149
+
150
+ f = Ogre::Math::Clamp(f, (Ogre::Real)-1.0, (Ogre::Real)1.0);
151
+ return Ogre::Math::ACos(f);
152
+ }
153
+
154
+ /**
155
+ * Gives the oriented angle from v1 to v2
156
+ */
157
+ static inline Ogre::Radian angleTo(const Ogre::Vector2& v1, const Ogre::Vector2& v2)
158
+ {
159
+ Ogre::Radian angle = angleBetween(v1, v2);
160
+
161
+ if (v1.crossProduct(v2)<0)
162
+ {
163
+ angle = (Ogre::Radian)Ogre::Math::TWO_PI - angle;
164
+ }
165
+
166
+ return angle;
167
+ }
168
+
169
+ /**
170
+ * Computes a quaternion between UNIT_Z and direction.
171
+ * It keeps the "up" vector to UNIT_Y
172
+ */
173
+ static Ogre::Quaternion _computeQuaternion(const Ogre::Vector3& direction, const Ogre::Vector3& upVector = Ogre::Vector3::UNIT_Y);
174
+
175
+ /**
176
+ * Maps a vector2 to vector3, with Y=0
177
+ */
178
+ static inline Ogre::Vector3 vec2ToVec3Y(const Ogre::Vector2& pos)
179
+ {
180
+ return Ogre::Vector3(pos.x, 0, pos.y);
181
+ }
182
+
183
+ };
184
+ }
185
+ #endif