Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
cef18f4e
Commit
cef18f4e
authored
5 years ago
by
Fabian Paus
Browse files
Options
Downloads
Patches
Plain Diff
Optimize mesh visualizer
parent
12ca0ca9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/components/ArViz/Coin/VisualizerMesh.h
+26
-14
26 additions, 14 deletions
source/RobotAPI/components/ArViz/Coin/VisualizerMesh.h
with
26 additions
and
14 deletions
source/RobotAPI/components/ArViz/Coin/VisualizerMesh.h
+
26
−
14
View file @
cef18f4e
...
...
@@ -40,6 +40,13 @@ namespace armarx::viz::coin
SoMaterial
*
materials
;
SoCoordinate3
*
coords
;
SoIndexedFaceSet
*
faceSet
;
std
::
vector
<
SbColor
>
matAmb
;
std
::
vector
<
SbColor
>
matDif
;
std
::
vector
<
float
>
transp
;
std
::
vector
<
SbVec3f
>
vertexPositions
;
std
::
vector
<
int32_t
>
faces
;
std
::
vector
<
int32_t
>
matInx
;
};
struct
VisualizerMesh
:
TypedElementVisualizer
<
VisualizerMesh
,
ElementMesh
,
VisuDataMesh
>
...
...
@@ -52,10 +59,12 @@ namespace armarx::viz::coin
{
colorSize
=
1
;
}
// TODO: Optimize these temporary arrays away
std
::
vector
<
SbColor
>
matAmb
(
colorSize
);
std
::
vector
<
SbColor
>
matDif
(
colorSize
);
std
::
vector
<
float
>
transp
(
colorSize
);
auto
&
matAmb
=
data
->
matAmb
;
auto
&
matDif
=
data
->
matDif
;
auto
&
transp
=
data
->
transp
;
matAmb
.
resize
(
colorSize
);
matDif
.
resize
(
colorSize
);
transp
.
resize
(
colorSize
);
const
float
conv
=
1.0
f
/
255.0
f
;
if
(
noColorsArray
)
...
...
@@ -85,14 +94,15 @@ namespace armarx::viz::coin
}
// Define colors for the faces
SoMaterial
*
m
yM
aterials
=
data
->
materials
;
m
yM
aterials
->
diffuseColor
.
setValues
(
0
,
colorSize
,
matDif
.
data
());
m
yM
aterials
->
ambientColor
.
setValues
(
0
,
colorSize
,
matAmb
.
data
());
m
yM
aterials
->
transparency
.
setValues
(
0
,
colorSize
,
transp
.
data
());
SoMaterial
*
materials
=
data
->
materials
;
materials
->
diffuseColor
.
setValues
Pointer
(
colorSize
,
matDif
.
data
());
materials
->
ambientColor
.
setValues
Pointer
(
colorSize
,
matAmb
.
data
());
materials
->
transparency
.
setValues
Pointer
(
colorSize
,
transp
.
data
());
// define vertex array
int
vertexSize
=
(
int
)
element
.
vertices
.
size
();
std
::
vector
<
SbVec3f
>
vertexPositions
(
vertexSize
);
auto
&
vertexPositions
=
data
->
vertexPositions
;
vertexPositions
.
resize
(
vertexSize
);
for
(
int
i
=
0
;
i
<
vertexSize
;
i
++
)
{
auto
v
=
element
.
vertices
[
i
];
...
...
@@ -100,11 +110,13 @@ namespace armarx::viz::coin
}
// Define coordinates for vertices
data
->
coords
->
point
.
setValues
(
0
,
vertexSize
,
vertexPositions
.
data
());
data
->
coords
->
point
.
setValues
Pointer
(
vertexSize
,
vertexPositions
.
data
());
int
facesSize
=
(
int
)
element
.
faces
.
size
();
std
::
vector
<
int32_t
>
faces
(
facesSize
*
4
);
std
::
vector
<
int32_t
>
matInx
(
facesSize
*
4
);
auto
&
faces
=
data
->
faces
;
faces
.
resize
(
facesSize
*
4
);
auto
&
matInx
=
data
->
matInx
;
matInx
.
resize
(
facesSize
*
4
);
for
(
int
i
=
0
;
i
<
facesSize
;
i
++
)
{
...
...
@@ -122,8 +134,8 @@ namespace armarx::viz::coin
}
SoIndexedFaceSet
*
myFaceSet
=
data
->
faceSet
;
myFaceSet
->
coordIndex
.
setValues
(
0
,
faces
.
size
(),
faces
.
data
());
myFaceSet
->
materialIndex
.
setValues
(
0
,
matInx
.
size
(),
matInx
.
data
());
myFaceSet
->
coordIndex
.
setValues
Pointer
(
faces
.
size
(),
faces
.
data
());
myFaceSet
->
materialIndex
.
setValues
Pointer
(
matInx
.
size
(),
matInx
.
data
());
}
};
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment