Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
CAMP
campvis-public
Commits
4bedc2f8
Commit
4bedc2f8
authored
Feb 06, 2015
by
Christian Schulte zu Berge
Browse files
Added exponents argument to GeometryDataFactory::createSphere for creating a supersphere.
parent
35c0f343
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/datastructures/geometrydatafactory.cpp
View file @
4bedc2f8
...
...
@@ -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
<
cgt
::
vec3
>
vertices
;
std
::
vector
<
cgt
::
vec3
>
vertices2
;
std
::
vector
<
cgt
::
vec3
>
textureCoordinates
;
// add top vertex
...
...
@@ -175,7 +176,17 @@ namespace campvis {
for
(
int
j
=
0
;
j
<
numSlices
;
++
j
)
{
float
theta
=
static_cast
<
float
>
(
j
)
*
2.
f
*
cgt
::
PIf
/
static_cast
<
float
>
(
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
));
}
}
...
...
core/datastructures/geometrydatafactory.h
View file @
4bedc2f8
...
...
@@ -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
);
};
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment