1 // BEGIN_COPYRIGHT -*- glean -*-
3 // Copyright (C) 1999,2000 Allen Akin All Rights Reserved.
5 // Permission is hereby granted, free of charge, to any person
6 // obtaining a copy of this software and associated documentation
7 // files (the "Software"), to deal in the Software without
8 // restriction, including without limitation the rights to use,
9 // copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 // KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 // DEALINGS IN THE SOFTWARE.
32 // geomutil.h: frequently-used geometric operations
34 #ifndef __geomutil_h__
35 #define __geomutil_h__
41 class RandomDouble
; // Forward reference.
47 RandomMesh2D(float minX
, float maxX
, int xPoints
,
48 float minY
, float maxY
, int yPoints
,
51 inline float* operator() (int y
, int x
)
52 { return m
+ 2 * (y
* rowLength
+ x
); }
58 SpiralStrip2D(int nPoints
, float minX
, float maxX
,
59 float minY
, float maxY
);
61 inline float* operator() (int i
)
68 SpiralTri2D(int nTris
, float minX
, float maxX
,
69 float minY
, float maxY
);
71 inline float* operator() (int i
)
76 std::vector
<float> vertices
;
77 std::vector
<float> normals
;
79 std::vector
<unsigned int> indices
;
82 Sphere3D(float radius
, int slices
, int stacks
);
84 // This returns the vertices: 3 floats per vertex in a tightly packed array (no padding between vertices).
85 const float* getVertices() const;
86 int getNumVertices() const;
88 // This returns the normals; same data format as the vertices. And of course the number of normals is
89 // the same as the number of vertices.
90 const float* getNormals() const;
92 // This returns a series of vertices that form triangles from the vertices (the indices specify loose
93 // triangles, not tristrips or fans or whatnot. So each triplet of indices is an individual triangle.)
94 const unsigned int* getIndices() const;
95 int getNumIndices() const;
100 #endif // __geomutil_h__