Commit 4bedc2f8 by Christian Schulte zu Berge

### Added exponents argument to GeometryDataFactory::createSphere for creating a supersphere.

parent 35c0f343
 ... ... @@ -160,9 +160,10 @@ namespace campvis { return toReturn; } MultiIndexedGeometry* GeometryDataFactory::createSphere(uint16_t numStacks /*= 6*/, uint16_t numSlices /*= 12*/) { MultiIndexedGeometry* GeometryDataFactory::createSphere(uint16_t numStacks /*= 6*/, uint16_t numSlices /*= 12*/, const cgt::vec3& exponents /*= cgt::vec3(1.f)*/) { cgtAssert(numStacks > 1 && numSlices > 2, "Sphere must have minimum 2 stacks and 3 slices!"); std::vector vertices; std::vector vertices2; std::vector textureCoordinates; // add top vertex ... ... @@ -175,7 +176,17 @@ namespace campvis { for (int j = 0; j < numSlices; ++j) { float theta = static_cast(j) * 2.f*cgt::PIf / static_cast(numSlices); vertices.push_back(cgt::vec3(cos(theta) * sin(phi), sin(theta) * sin(phi), cos(phi))); // apply exponents for supersphere cgt::vec3 theVertex(cos(theta) * sin(phi), sin(theta) * sin(phi), cos(phi)); for (size_t e = 0; e < 3; ++e) { if (theVertex[e] < 0) theVertex[e] = -pow(-theVertex[e], exponents[e]); else theVertex[e] = pow(theVertex[e], exponents[e]); } vertices.push_back(theVertex); textureCoordinates.push_back(cgt::vec3(theta / (2.f * cgt::PIf), phi / cgt::PIf, 0.f)); } } ... ...
 ... ... @@ -68,22 +68,23 @@ namespace campvis { /** * Creates an MultiIndexedGeometry storing a unit sphere around the origin. * \param numStacks Number of stacks in the sphere * \param numSlices Number of slices in the sphere * \param numStacks Number of stacks in the sphere * \param numSlices Number of slices in the sphere * \param exponents Exponent for each dimension to define a supersphere (defines the roundness) * \return MultiIndexedGeometry storing a unit sphere around the origin. */ static MultiIndexedGeometry* createSphere(uint16_t numStacks = 6, uint16_t numSlices = 12); static MultiIndexedGeometry* createSphere(uint16_t numStacks = 6, uint16_t numSlices = 12, const cgt::vec3& exponents = cgt::vec3(1.f)); /** * Creates an MultiIndexedGeometry storing a unit length arrow in Z direction starting from the origin. * \param numSlices Number of slices in the cylinder and cone * \param tipLen Length of arrow tip (between 0 and 1) * \param tipLen Length of arrow tip (between 0 and 1) * \param cylRadius Radius of the cylinder (arrow shaft) * \param tipRadius Radius of the bottom of the arrow tip * \param tipRadius Radius of the bottom of the arrow tip * \return MultiIndexedGeometry storing a unit arrow in Z direction starting from the origin. */ static MultiIndexedGeometry* createArrow(uint16_t numSlices = 12, float tipLen = 0.35, float cylRadius = 0.05, float tipRadius = 0.15); static MultiIndexedGeometry* createArrow(uint16_t numSlices = 12, float tipLen = 0.35, float cylRadius = 0.05, float tipRadius = 0.15); }; } ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!