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.
- data/Gemfile +4 -0
- data/README.md +29 -0
- data/Rakefile +65 -0
- data/bindings/procedural/interface/ProceduralBoxGenerator.i +12 -0
- data/bindings/procedural/interface/ProceduralCapsuleGenerator.i +12 -0
- data/bindings/procedural/interface/ProceduralConeGenerator.i +12 -0
- data/bindings/procedural/interface/ProceduralCylinderGenerator.i +12 -0
- data/bindings/procedural/interface/ProceduralExtruder.i +8 -0
- data/bindings/procedural/interface/ProceduralGeometryHelpers.i +15 -0
- data/bindings/procedural/interface/ProceduralHeader.i +8 -0
- data/bindings/procedural/interface/ProceduralIcoSphereGenerator.i +12 -0
- data/bindings/procedural/interface/ProceduralLathe.i +8 -0
- data/bindings/procedural/interface/ProceduralMeshGenerator.i +9 -0
- data/bindings/procedural/interface/ProceduralMultiShape.i +8 -0
- data/bindings/procedural/interface/ProceduralPath.i +8 -0
- data/bindings/procedural/interface/ProceduralPathGenerators.i +10 -0
- data/bindings/procedural/interface/ProceduralPlaneGenerator.i +12 -0
- data/bindings/procedural/interface/ProceduralPlatform.i +8 -0
- data/bindings/procedural/interface/ProceduralRoot.i +23 -0
- data/bindings/procedural/interface/ProceduralRoundedBoxGenerator.i +12 -0
- data/bindings/procedural/interface/ProceduralShape.i +8 -0
- data/bindings/procedural/interface/ProceduralShapeGenerators.i +10 -0
- data/bindings/procedural/interface/ProceduralSphereGenerator.i +11 -0
- data/bindings/procedural/interface/ProceduralSplines.i +8 -0
- data/bindings/procedural/interface/ProceduralStableHeaders.i +8 -0
- data/bindings/procedural/interface/ProceduralTorusGenerator.i +12 -0
- data/bindings/procedural/interface/ProceduralTorusKnotGenerator.i +12 -0
- data/bindings/procedural/interface/ProceduralTrack.i +8 -0
- data/bindings/procedural/interface/ProceduralTriangleBuffer.i +13 -0
- data/bindings/procedural/interface/ProceduralTriangulator.i +8 -0
- data/bindings/procedural/interface/ProceduralTubeGenerator.i +12 -0
- data/bindings/procedural/interface/ProceduralUtils.i +8 -0
- data/bindings/procedural/interface/Rakefile +22 -0
- data/bindings/procedural/interface/procedural.i +41 -0
- data/bindings/procedural/interface/procedural_wrap.cpp +36079 -0
- data/bindings/procedural/interface/procedural_wrap.h +19 -0
- data/bindings/procedural/interface/procedural_wrap.o +0 -0
- data/deps/include/OgreProcedural/Procedural.h +54 -0
- data/deps/include/OgreProcedural/ProceduralBoxGenerator.h +110 -0
- data/deps/include/OgreProcedural/ProceduralCapsuleGenerator.h +103 -0
- data/deps/include/OgreProcedural/ProceduralConeGenerator.h +90 -0
- data/deps/include/OgreProcedural/ProceduralCylinderGenerator.h +99 -0
- data/deps/include/OgreProcedural/ProceduralExtruder.h +131 -0
- data/deps/include/OgreProcedural/ProceduralGeometryHelpers.h +171 -0
- data/deps/include/OgreProcedural/ProceduralIcoSphereGenerator.h +76 -0
- data/deps/include/OgreProcedural/ProceduralLathe.h +129 -0
- data/deps/include/OgreProcedural/ProceduralMeshGenerator.h +286 -0
- data/deps/include/OgreProcedural/ProceduralMultiShape.h +126 -0
- data/deps/include/OgreProcedural/ProceduralPath.h +322 -0
- data/deps/include/OgreProcedural/ProceduralPathGenerators.h +281 -0
- data/deps/include/OgreProcedural/ProceduralPlaneGenerator.h +93 -0
- data/deps/include/OgreProcedural/ProceduralPlatform.h +54 -0
- data/deps/include/OgreProcedural/ProceduralRoot.h +65 -0
- data/deps/include/OgreProcedural/ProceduralRoundedBoxGenerator.h +118 -0
- data/deps/include/OgreProcedural/ProceduralShape.h +532 -0
- data/deps/include/OgreProcedural/ProceduralShapeGenerators.h +362 -0
- data/deps/include/OgreProcedural/ProceduralSphereGenerator.h +80 -0
- data/deps/include/OgreProcedural/ProceduralSplines.h +168 -0
- data/deps/include/OgreProcedural/ProceduralStableHeaders.h +28 -0
- data/deps/include/OgreProcedural/ProceduralTorusGenerator.h +88 -0
- data/deps/include/OgreProcedural/ProceduralTorusKnotGenerator.h +106 -0
- data/deps/include/OgreProcedural/ProceduralTrack.h +122 -0
- data/deps/include/OgreProcedural/ProceduralTriangleBuffer.h +328 -0
- data/deps/include/OgreProcedural/ProceduralTriangulator.h +173 -0
- data/deps/include/OgreProcedural/ProceduralTubeGenerator.h +96 -0
- data/deps/include/OgreProcedural/ProceduralUtils.h +185 -0
- data/deps/lib/libOgreProcedural.so +0 -0
- data/lib/procedural.so +0 -0
- data/lib/ruby-procedural/version.rb +5 -0
- data/lib/ruby-procedural.rb +27 -0
- data/ruby-procedural.gemspec +33 -0
- metadata +138 -0
@@ -0,0 +1,131 @@
|
|
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_EXTRUDER_INCLUDED
|
29
|
+
#define PROCEDURAL_EXTRUDER_INCLUDED
|
30
|
+
|
31
|
+
#include "ProceduralShape.h"
|
32
|
+
#include "ProceduralPath.h"
|
33
|
+
#include "ProceduralPlatform.h"
|
34
|
+
#include "ProceduralMeshGenerator.h"
|
35
|
+
#include "ProceduralMultiShape.h"
|
36
|
+
#include "ProceduralTrack.h"
|
37
|
+
|
38
|
+
namespace Procedural
|
39
|
+
{
|
40
|
+
/// Extrudes a 2D shape along a path to build an extruded mesh.
|
41
|
+
/// Can be used to build things such as pipelines, roads...
|
42
|
+
///
|
43
|
+
/// Note : Concerning UV texCoords, U is along the path and V along the shape.
|
44
|
+
class _ProceduralExport Extruder : public MeshGenerator<Extruder>
|
45
|
+
{
|
46
|
+
Shape* mShapeToExtrude;
|
47
|
+
MultiShape* mMultiShapeToExtrude;
|
48
|
+
Path* mExtrusionPath;
|
49
|
+
bool mCapped;
|
50
|
+
Track* mRotationTrack;
|
51
|
+
Track* mScaleTrack;
|
52
|
+
Track* mShapeTextureTrack;
|
53
|
+
Track* mPathTextureTrack;
|
54
|
+
|
55
|
+
void _extrudeBodyImpl(TriangleBuffer& buffer, const Shape* shapeToExtrude) const;
|
56
|
+
|
57
|
+
void _extrudeCapImpl(TriangleBuffer& buffer) const;
|
58
|
+
|
59
|
+
public:
|
60
|
+
/// Default constructor
|
61
|
+
Extruder() : mShapeToExtrude(0), mExtrusionPath(0), mCapped(true), mRotationTrack(0), mScaleTrack(0), mShapeTextureTrack(0), mPathTextureTrack(0)
|
62
|
+
{}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Builds the mesh into the given TriangleBuffer
|
66
|
+
* @param buffer The TriangleBuffer on where to append the mesh.
|
67
|
+
*/
|
68
|
+
void addToTriangleBuffer(TriangleBuffer& buffer) const;
|
69
|
+
|
70
|
+
/** Sets the shape to extrude. Mutually exclusive with setMultiShapeToExtrude. */
|
71
|
+
inline Extruder & setShapeToExtrude(Shape* shapeToExtrude)
|
72
|
+
{
|
73
|
+
mMultiShapeToExtrude = 0;
|
74
|
+
mShapeToExtrude = shapeToExtrude;
|
75
|
+
return *this;
|
76
|
+
}
|
77
|
+
|
78
|
+
/** Sets the multishape to extrude. Mutually exclusive with setShapeToExtrude. */
|
79
|
+
inline Extruder & setMultiShapeToExtrude(MultiShape* multiShapeToExtrude)
|
80
|
+
{
|
81
|
+
mShapeToExtrude = 0;
|
82
|
+
mMultiShapeToExtrude = multiShapeToExtrude;
|
83
|
+
return *this;
|
84
|
+
}
|
85
|
+
|
86
|
+
/** Sets the extrusion path */
|
87
|
+
inline Extruder & setExtrusionPath(Path* extrusionPath)
|
88
|
+
{
|
89
|
+
mExtrusionPath = extrusionPath;
|
90
|
+
return *this;
|
91
|
+
}
|
92
|
+
|
93
|
+
/** Sets the rotation track (optional) */
|
94
|
+
inline Extruder& setRotationTrack(Track* rotationTrack)
|
95
|
+
{
|
96
|
+
mRotationTrack = rotationTrack;
|
97
|
+
return *this;
|
98
|
+
}
|
99
|
+
|
100
|
+
/** Sets the scale track (optional) */
|
101
|
+
inline Extruder& setScaleTrack(Track* scaleTrack)
|
102
|
+
{
|
103
|
+
mScaleTrack = scaleTrack;
|
104
|
+
return *this;
|
105
|
+
}
|
106
|
+
|
107
|
+
/// Sets the track that maps shape points to V texture coords (optional).
|
108
|
+
/// Warning : if used with multishape, all shapes will have the same track.
|
109
|
+
inline Extruder& setShapeTextureTrack(Track* shapeTextureTrack)
|
110
|
+
{
|
111
|
+
mShapeTextureTrack = shapeTextureTrack;
|
112
|
+
return *this;
|
113
|
+
}
|
114
|
+
|
115
|
+
/// Sets the track that maps path points to V texture coord (optional).
|
116
|
+
inline Extruder& setPathTextureTrack(Track* pathTextureTrack)
|
117
|
+
{
|
118
|
+
mPathTextureTrack = pathTextureTrack;
|
119
|
+
return *this;
|
120
|
+
}
|
121
|
+
|
122
|
+
/** Sets whether caps are added to the extremities or not (not closed paths only) */
|
123
|
+
inline Extruder & setCapped(bool capped)
|
124
|
+
{
|
125
|
+
mCapped = capped;
|
126
|
+
return *this;
|
127
|
+
}
|
128
|
+
};
|
129
|
+
}
|
130
|
+
|
131
|
+
#endif
|
@@ -0,0 +1,171 @@
|
|
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_GEOMETRYHELPERS_INCLUDED
|
29
|
+
#define PROCEDURAL_GEOMETRYHELPERS_INCLUDED
|
30
|
+
|
31
|
+
#include "OgrePlane.h"
|
32
|
+
#include "OgreVector2.h"
|
33
|
+
#include "OgreVector3.h"
|
34
|
+
|
35
|
+
namespace Procedural
|
36
|
+
{
|
37
|
+
class Line;
|
38
|
+
//-----------------------------------------------------------------------
|
39
|
+
/// Represents a 2D circle
|
40
|
+
class Circle
|
41
|
+
{
|
42
|
+
private:
|
43
|
+
Ogre::Vector2 mCenter;
|
44
|
+
Ogre::Real mRadius;
|
45
|
+
|
46
|
+
public:
|
47
|
+
|
48
|
+
Circle() {}
|
49
|
+
|
50
|
+
/// Contructor with arguments
|
51
|
+
Circle(Ogre::Vector2 center, Ogre::Real radius) : mCenter(center), mRadius(radius)
|
52
|
+
{}
|
53
|
+
|
54
|
+
/// Contructor with arguments
|
55
|
+
Circle(Ogre::Vector2 p1, Ogre::Vector2 p2, Ogre::Vector2 p3);
|
56
|
+
|
57
|
+
/// Tells whether that point is inside the circle or not
|
58
|
+
bool isPointInside(const Ogre::Vector2& p) const
|
59
|
+
{
|
60
|
+
return (p-mCenter).length() < mRadius;
|
61
|
+
}
|
62
|
+
};
|
63
|
+
//-----------------------------------------------------------------------
|
64
|
+
/// Extends the Ogre::Plane class to be able to compute the intersection between 2 planes
|
65
|
+
class Plane : public Ogre::Plane
|
66
|
+
{
|
67
|
+
public:
|
68
|
+
Plane() : Ogre::Plane() {}
|
69
|
+
|
70
|
+
/// Contructor with arguments
|
71
|
+
Plane(const Ogre::Vector3& normal, const Ogre::Vector3& pos) : Ogre::Plane(normal, pos) {}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Checks whether 2 planes intersect and compute intersecting line if it is the case.
|
75
|
+
* @arg other the other plane with which to check for intersection
|
76
|
+
* @arg outputLine the intersecting line, if planes actually intersect
|
77
|
+
* @returns true if planes intersect, false otherwise
|
78
|
+
*/
|
79
|
+
bool intersect(const Plane& other, Line& outputLine) const;
|
80
|
+
};
|
81
|
+
//-----------------------------------------------------------------------
|
82
|
+
/// Represents a line in 3D
|
83
|
+
class Line
|
84
|
+
{
|
85
|
+
Ogre::Vector3 mPoint;
|
86
|
+
Ogre::Vector3 mDirection;
|
87
|
+
|
88
|
+
public:
|
89
|
+
Line() {}
|
90
|
+
|
91
|
+
/// Contructor with arguments
|
92
|
+
/// @arg point a point on the line
|
93
|
+
/// @arg direction a normalized vector representing the direction of that line
|
94
|
+
Line(Ogre::Vector3 point, Ogre::Vector3 direction) : mPoint(point), mDirection(direction.normalisedCopy()) {}
|
95
|
+
|
96
|
+
/// Builds the line between 2 points
|
97
|
+
void setFrom2Points(const Ogre::Vector3& a, const Ogre::Vector3& b)
|
98
|
+
{
|
99
|
+
mPoint = a;
|
100
|
+
mDirection = (b-a).normalisedCopy();
|
101
|
+
}
|
102
|
+
|
103
|
+
/// Finds the shortest vector between that line and a point
|
104
|
+
Ogre::Vector3 shortestPathToPoint(const Ogre::Vector3& point) const;
|
105
|
+
};
|
106
|
+
//-----------------------------------------------------------------------
|
107
|
+
/// Represents a line in 2D
|
108
|
+
class Line2D
|
109
|
+
{
|
110
|
+
Ogre::Vector2 mPoint;
|
111
|
+
Ogre::Vector2 mDirection;
|
112
|
+
|
113
|
+
public:
|
114
|
+
Line2D() {}
|
115
|
+
|
116
|
+
/// Contructor with arguments
|
117
|
+
/// @arg point a point on the line
|
118
|
+
/// @arg direction a normalized vector representing the direction of that line
|
119
|
+
Line2D(Ogre::Vector2 point, Ogre::Vector2 direction) : mPoint(point), mDirection(direction.normalisedCopy()) {}
|
120
|
+
|
121
|
+
/// Builds the line between 2 points
|
122
|
+
void setFrom2Points(const Ogre::Vector2& a, const Ogre::Vector2& b)
|
123
|
+
{
|
124
|
+
mPoint = a;
|
125
|
+
mDirection = (b-a).normalisedCopy();
|
126
|
+
}
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Computes the interesction between current segment and another segment
|
130
|
+
* @arg the other segment
|
131
|
+
* @arg intersection the point of intersection if outputed there if it exists
|
132
|
+
* @return true if segments intersect, false otherwise
|
133
|
+
*/
|
134
|
+
bool findIntersect(const Line2D& other, Ogre::Vector2& intersection) const;
|
135
|
+
};
|
136
|
+
//-----------------------------------------------------------------------
|
137
|
+
/// Represents a 2D segment
|
138
|
+
class Segment2D
|
139
|
+
{
|
140
|
+
Ogre::Vector2 mA;
|
141
|
+
Ogre::Vector2 mB;
|
142
|
+
public:
|
143
|
+
|
144
|
+
/// Contructor with arguments
|
145
|
+
Segment2D(Ogre::Vector2 a, Ogre::Vector2 b) : mA(a), mB(b) {}
|
146
|
+
|
147
|
+
/// Returns point A
|
148
|
+
Ogre::Vector2 getA()
|
149
|
+
{
|
150
|
+
return mA;
|
151
|
+
}
|
152
|
+
|
153
|
+
/// Returns point B
|
154
|
+
Ogre::Vector2 getB()
|
155
|
+
{
|
156
|
+
return mB;
|
157
|
+
}
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Computes the interesction between current segment and another segment
|
161
|
+
* @arg the other segment
|
162
|
+
* @arg intersection the point of intersection if outputed there if it exists
|
163
|
+
* @return true if segments intersect, false otherwise
|
164
|
+
*/
|
165
|
+
bool findIntersect(const Segment2D& other, Ogre::Vector2& intersection) const;
|
166
|
+
|
167
|
+
/// Tells whether this segments intersects the other segment
|
168
|
+
bool intersects(const Segment2D& other) const;
|
169
|
+
};
|
170
|
+
}
|
171
|
+
#endif
|
@@ -0,0 +1,76 @@
|
|
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_ICOSPHERE_GENERATOR_INCLUDED
|
29
|
+
#define PROCEDURAL_ICOSPHERE_GENERATOR_INCLUDED
|
30
|
+
|
31
|
+
#include "ProceduralMeshGenerator.h"
|
32
|
+
#include "ProceduralPlatform.h"
|
33
|
+
|
34
|
+
namespace Procedural
|
35
|
+
{
|
36
|
+
/** Builds an icosphere mesh, ie a sphere built with equally sized triangles
|
37
|
+
*/
|
38
|
+
class _ProceduralExport IcoSphereGenerator : public MeshGenerator<IcoSphereGenerator>
|
39
|
+
{
|
40
|
+
Ogre::Real mRadius;
|
41
|
+
unsigned int mNumIterations;
|
42
|
+
|
43
|
+
public:
|
44
|
+
/// Contructor with arguments
|
45
|
+
IcoSphereGenerator(Ogre::Real radius = 1.f, unsigned int numIterations = 2) :
|
46
|
+
mRadius(radius),
|
47
|
+
mNumIterations(numIterations)
|
48
|
+
{}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Builds the mesh into the given TriangleBuffer
|
52
|
+
* @param buffer The TriangleBuffer on where to append the mesh.
|
53
|
+
*/
|
54
|
+
void addToTriangleBuffer(TriangleBuffer& buffer) const;
|
55
|
+
|
56
|
+
/** Sets the radius of the sphere (default=1) */
|
57
|
+
inline IcoSphereGenerator & setRadius(Ogre::Real radius)
|
58
|
+
{
|
59
|
+
mRadius = radius;
|
60
|
+
return *this;
|
61
|
+
}
|
62
|
+
|
63
|
+
/** Sets the number of iterations needed to build the sphere mesh.
|
64
|
+
First iteration corresponds to a 20 face sphere.
|
65
|
+
Each iteration has 3 more faces than the previous.
|
66
|
+
(default=2)
|
67
|
+
*/
|
68
|
+
inline IcoSphereGenerator & setNumIterations(unsigned int numIterations)
|
69
|
+
{
|
70
|
+
mNumIterations = numIterations;
|
71
|
+
return *this;
|
72
|
+
}
|
73
|
+
|
74
|
+
};
|
75
|
+
}
|
76
|
+
#endif
|
@@ -0,0 +1,129 @@
|
|
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_LATHE_INCLUDED
|
29
|
+
#define PROCEDURAL_LATHE_INCLUDED
|
30
|
+
|
31
|
+
#include "ProceduralShape.h"
|
32
|
+
#include "ProceduralPlatform.h"
|
33
|
+
#include "ProceduralMeshGenerator.h"
|
34
|
+
|
35
|
+
namespace Procedural
|
36
|
+
{
|
37
|
+
/** Builds a mesh by rotating a shape 360� around Y-axis.
|
38
|
+
* The shape is assumed to be defined in the X>=0 half-plane
|
39
|
+
*/
|
40
|
+
class _ProceduralExport Lathe : public MeshGenerator<Lathe>
|
41
|
+
{
|
42
|
+
Shape* mShapeToExtrude;
|
43
|
+
MultiShape* mMultiShapeToExtrude;
|
44
|
+
int mNumSeg;
|
45
|
+
Ogre::Radian mAngleBegin;
|
46
|
+
Ogre::Radian mAngleEnd;
|
47
|
+
bool mClosed;
|
48
|
+
bool mCapped;
|
49
|
+
|
50
|
+
void _latheCapImpl(TriangleBuffer& buffer) const;
|
51
|
+
void _latheBodyImpl(TriangleBuffer& buffer, const Shape* shapeToExtrude) const;
|
52
|
+
|
53
|
+
public:
|
54
|
+
/// Contructor with arguments
|
55
|
+
Lathe(Shape* shapeToExtrude = 0, int numSeg = 16) : mShapeToExtrude(shapeToExtrude), mMultiShapeToExtrude(0),
|
56
|
+
mNumSeg(numSeg), mAngleBegin(0), mAngleEnd((Ogre::Radian)Ogre::Math::TWO_PI), mClosed(true), mCapped(true)
|
57
|
+
{}
|
58
|
+
|
59
|
+
/** Sets the number of segments when rotating around the axis (default=16)*/
|
60
|
+
inline Lathe& setNumSeg(int numSeg)
|
61
|
+
{
|
62
|
+
mNumSeg = numSeg;
|
63
|
+
return *this;
|
64
|
+
}
|
65
|
+
|
66
|
+
/// Sets the angle to begin lathe with (default=0)
|
67
|
+
/// Automatically makes the lathe not closed
|
68
|
+
inline Lathe& setAngleBegin(Ogre::Radian angleBegin)
|
69
|
+
{
|
70
|
+
mAngleBegin = angleBegin;
|
71
|
+
mClosed = false;
|
72
|
+
return *this;
|
73
|
+
}
|
74
|
+
|
75
|
+
/// Sets the angle to end lathe with (default=2PI)
|
76
|
+
/// Automatically makes the lathe not closed
|
77
|
+
inline Lathe& setAngleEnd(Ogre::Radian angleEnd)
|
78
|
+
{
|
79
|
+
mAngleEnd = angleEnd;
|
80
|
+
mClosed = false;
|
81
|
+
return *this;
|
82
|
+
}
|
83
|
+
|
84
|
+
/// Sets whether the lathe is closed or not
|
85
|
+
inline Lathe& setClosed(bool closed)
|
86
|
+
{
|
87
|
+
mClosed = closed;
|
88
|
+
return *this;
|
89
|
+
}
|
90
|
+
|
91
|
+
/// Sets whether the lathe is capped or not (default=true)
|
92
|
+
/// Only makes sense if the lathe is not closed.
|
93
|
+
inline Lathe& setCapped(bool capped)
|
94
|
+
{
|
95
|
+
mCapped = capped;
|
96
|
+
return *this;
|
97
|
+
}
|
98
|
+
|
99
|
+
/** Sets the shape to extrude
|
100
|
+
* If a multishape is already defined, auto-disables it
|
101
|
+
* The shape is assumed to be defined in the X>=0 half-plane
|
102
|
+
*/
|
103
|
+
inline Lathe& setShapeToExtrude(Shape* shapeToExtrude)
|
104
|
+
{
|
105
|
+
mShapeToExtrude = shapeToExtrude;
|
106
|
+
mMultiShapeToExtrude = 0;
|
107
|
+
return *this;
|
108
|
+
}
|
109
|
+
|
110
|
+
/** Sets the multiShape to extrude
|
111
|
+
* If a shape is already defined, auto-disables it
|
112
|
+
* The shapes in this multi-shape are assumed to be defined in the X>=0 half-plane
|
113
|
+
*/
|
114
|
+
inline Lathe& setMultiShapeToExtrude(MultiShape* multiShapeToExtrude)
|
115
|
+
{
|
116
|
+
mMultiShapeToExtrude = multiShapeToExtrude;
|
117
|
+
mShapeToExtrude = 0;
|
118
|
+
return *this;
|
119
|
+
}
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Builds the mesh into the given TriangleBuffer
|
123
|
+
* @param buffer The TriangleBuffer on where to append the mesh.
|
124
|
+
*/
|
125
|
+
void addToTriangleBuffer(TriangleBuffer& buffer) const;
|
126
|
+
};
|
127
|
+
}
|
128
|
+
|
129
|
+
#endif
|