Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CAMP
campvis-public
Commits
32f1e91d
Commit
32f1e91d
authored
Mar 01, 2017
by
Jakob Weiss
Browse files
Added cylinders to GeometryDataFactory
* minor whitespace fix in mainwindow.cpp
parent
001aeb39
Changes
3
Hide whitespace changes
Inline
Side-by-side
application/gui/mainwindow.cpp
View file @
32f1e91d
...
...
@@ -363,7 +363,7 @@ namespace campvis {
void
MainWindow
::
onBtnShowDataContainerInspectorClicked
()
{
if
(
_selectedPipeline
!=
0
)
{
// if there is no existing inspector window, create one
// if there is no existing inspector window, create one
if
(
_dcInspectorWindow
==
0
)
{
_dcInspectorWindow
=
_mdiArea
->
addWidget
(
_dcInspectorWidget
);
_dcInspectorWindow
->
setWindowTitle
(
tr
(
"Data Container Inspector"
));
...
...
@@ -373,7 +373,7 @@ namespace campvis {
_dcInspectorWindow
->
show
();
_dcInspectorWindow
->
activateWindow
();
//_dcInspectorWindow->detachDockedWindow();
//_dcInspectorWindow->detachDockedWindow();
}
}
...
...
core/datastructures/geometrydatafactory.cpp
View file @
32f1e91d
...
...
@@ -398,4 +398,90 @@ namespace campvis {
return
std
::
unique_ptr
<
MultiIndexedGeometry
>
(
toReturn
);
}
std
::
unique_ptr
<
MultiIndexedGeometry
>
GeometryDataFactory
::
createCylinder
(
uint16_t
numSlices
,
float
cylRadius
)
{
cgtAssert
(
numSlices
>
2
,
"Cylinder must have minimum 3 slices!"
);
std
::
vector
<
cgt
::
vec3
>
vertices
;
std
::
vector
<
cgt
::
vec3
>
normals
;
// add bottom vertex
vertices
.
push_back
(
cgt
::
vec3
(
0.
f
,
0.
f
,
0.
f
));
normals
.
push_back
(
cgt
::
vec3
(
0.
f
,
0.
f
,
-
1.
f
));
// add shaft floor vertices
for
(
int
i
=
0
;
i
<
numSlices
;
++
i
)
{
float
theta
=
static_cast
<
float
>
(
i
)
*
2.
f
*
cgt
::
PIf
/
static_cast
<
float
>
(
numSlices
);
vertices
.
push_back
(
cgt
::
vec3
(
cylRadius
*
cos
(
theta
),
cylRadius
*
sin
(
theta
),
0.
f
));
normals
.
push_back
(
cgt
::
vec3
(
0.
f
,
0.
f
,
-
1.
f
));
}
for
(
int
i
=
0
;
i
<
numSlices
;
++
i
)
{
float
theta
=
static_cast
<
float
>
(
i
)
*
2.
f
*
cgt
::
PIf
/
static_cast
<
float
>
(
numSlices
);
vertices
.
push_back
(
cgt
::
vec3
(
cylRadius
*
cos
(
theta
),
cylRadius
*
sin
(
theta
),
0.
f
));
normals
.
push_back
(
cgt
::
vec3
(
cos
(
theta
),
sin
(
theta
),
0.
f
));
}
// add shaft top vertices
for
(
int
i
=
0
;
i
<
numSlices
;
++
i
)
{
float
theta
=
static_cast
<
float
>
(
i
)
*
2.
f
*
cgt
::
PIf
/
static_cast
<
float
>
(
numSlices
);
vertices
.
push_back
(
cgt
::
vec3
(
cylRadius
*
cos
(
theta
),
cylRadius
*
sin
(
theta
),
1.
f
));
normals
.
push_back
(
cgt
::
vec3
(
cos
(
theta
),
sin
(
theta
),
0.
f
));
}
// add top center vertex
MultiIndexedGeometry
::
index_t
topVertexIndex
=
vertices
.
size
();
vertices
.
push_back
(
cgt
::
vec3
(
0.
f
,
0.
f
,
1.
f
));
normals
.
push_back
(
cgt
::
vec3
(
0.
f
,
0.
f
,
1.
f
));
// add rest of top vertices
for
(
int
i
=
0
;
i
<
numSlices
;
++
i
)
{
float
theta
=
static_cast
<
float
>
(
i
)
*
2.
f
*
cgt
::
PIf
/
static_cast
<
float
>
(
numSlices
);
vertices
.
push_back
(
cgt
::
vec3
(
cylRadius
*
cos
(
theta
),
cylRadius
*
sin
(
theta
),
1.
f
));
normals
.
push_back
(
cgt
::
vec3
(
0.
f
,
0.
f
,
1.
f
));
}
// create geometry
MultiIndexedGeometry
*
toReturn
=
new
MultiIndexedGeometry
(
vertices
,
std
::
vector
<
cgt
::
vec3
>
(),
std
::
vector
<
cgt
::
vec4
>
(),
normals
);
// add indices for primitives to geometry:
{
// cylinder floor
std
::
vector
<
MultiIndexedGeometry
::
index_t
>
indices
;
for
(
MultiIndexedGeometry
::
index_t
j
=
0
;
j
<
numSlices
;
++
j
)
{
indices
.
push_back
(
0
);
indices
.
push_back
(
j
+
1
);
}
indices
.
push_back
(
0
);
indices
.
push_back
(
1
);
toReturn
->
addPrimitive
(
indices
);
}
{
// cylinder shaft
std
::
vector
<
MultiIndexedGeometry
::
index_t
>
indices
;
for
(
MultiIndexedGeometry
::
index_t
j
=
0
;
j
<
numSlices
;
++
j
)
{
indices
.
push_back
(
j
+
1
+
numSlices
);
indices
.
push_back
(
j
+
1
+
numSlices
*
2
);
}
indices
.
push_back
(
1
+
numSlices
);
indices
.
push_back
(
1
+
numSlices
*
2
);
toReturn
->
addPrimitive
(
indices
);
}
{
// cylinder top
std
::
vector
<
MultiIndexedGeometry
::
index_t
>
indices
;
for
(
MultiIndexedGeometry
::
index_t
j
=
0
;
j
<
numSlices
;
++
j
)
{
indices
.
push_back
(
topVertexIndex
);
// the last/top vertex
indices
.
push_back
(
topVertexIndex
+
j
+
1
);
}
indices
.
push_back
(
topVertexIndex
);
// the last/top vertex
indices
.
push_back
(
topVertexIndex
+
1
);
toReturn
->
addPrimitive
(
indices
);
}
return
std
::
unique_ptr
<
MultiIndexedGeometry
>
(
toReturn
);
}
}
\ No newline at end of file
core/datastructures/geometrydatafactory.h
View file @
32f1e91d
...
...
@@ -98,6 +98,14 @@ namespace campvis {
* \return MultiIndexedGeometry storing a unit arrow in Z direction starting from the origin.
*/
static
std
::
unique_ptr
<
MultiIndexedGeometry
>
createArrow
(
uint16_t
numSlices
=
12
,
float
tipLen
=
0.35
,
float
cylRadius
=
0.05
,
float
tipRadius
=
0.15
);
/**
* Creates an MultiIndexedGeometry storing a unit length cylinder in Z direction based on the origin
* \param numSlices Number of slices in the cylinder and cone
* \param cylRadius Radius of the cylinder (arrow shaft)
* \return MultiIndexedGeometry storing a unit arrow in Z direction starting from the origin.
*/
static
std
::
unique_ptr
<
MultiIndexedGeometry
>
createCylinder
(
uint16_t
numSlices
=
12
,
float
cylRadius
=
0.05
);
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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