Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
215af8f6
Commit
215af8f6
authored
Apr 13, 2010
by
Alexander Wiebel
Browse files
[CHANGE] make isosurfaces fit for strange coordinate systems
parent
053ff36c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
+19
-11
src/graphicsEngine/WGEUtils.h
src/graphicsEngine/WGEUtils.h
+13
-1
src/modules/marchingCubes/WMMarchingCubes.cpp
src/modules/marchingCubes/WMMarchingCubes.cpp
+6
-10
No files found.
src/graphicsEngine/WGEUtils.h
View file @
215af8f6
...
...
@@ -43,7 +43,7 @@ namespace wge
* \param pos1 First point
* \param pos2 Second point
*/
WColor
getRGBAColorFromDirection
(
const
wmath
::
WPosition
&
pos1
,
const
wmath
::
WPosition
&
pos2
);
WColor
getRGBAColorFromDirection
(
const
wmath
::
WPosition
&
pos1
,
const
wmath
::
WPosition
&
pos2
);
/**
* Converts a WColor to an OSG compatible color
...
...
@@ -78,6 +78,12 @@ namespace wge
* \param camera The matrices of this camera will used for unprojecting.
*/
osg
::
Vec3
unprojectFromScreen
(
const
osg
::
Vec3
screen
,
osg
::
ref_ptr
<
osg
::
Camera
>
camera
);
/**
* Conversion of WVector3D to osg::Vec3
* \param v the vector to convert.
*/
osg
::
Vec3
wv3D2ov3
(
wmath
::
WVector3D
v
);
}
inline
WColor
wge
::
getRGBAColorFromDirection
(
const
wmath
::
WPosition
&
pos1
,
const
wmath
::
WPosition
&
pos2
)
...
...
@@ -96,4 +102,10 @@ inline osg::Vec3 wge::osgVec3( const wmath::WPosition& pos )
{
return
osg
::
Vec3
(
pos
[
0
],
pos
[
1
],
pos
[
2
]
);
}
inline
osg
::
Vec3
wge
::
wv3D2ov3
(
wmath
::
WVector3D
v
)
{
return
osg
::
Vec3
(
v
[
0
],
v
[
1
],
v
[
2
]
);
}
#endif // WGEUTILS_H
src/modules/marchingCubes/WMMarchingCubes.cpp
View file @
215af8f6
...
...
@@ -50,6 +50,7 @@
#include "../../dataHandler/WDataHandler.h"
#include "../../dataHandler/WSubject.h"
#include "../../dataHandler/WDataTexture3D.h"
#include "../../graphicsEngine/WGEUtils.h"
#include "../../kernel/WKernel.h"
#include "WMMarchingCubes.h"
...
...
@@ -298,9 +299,10 @@ template< typename T > void WMMarchingCubes::generateSurface( boost::shared_ptr<
m_grid
=
grid
;
WAssert
(
grid
,
"Grid is not of type WGridRegular3D."
);
m_fCellLengthX
=
grid
->
getOffsetX
();
m_fCellLengthY
=
grid
->
getOffsetY
();
m_fCellLengthZ
=
grid
->
getOffsetZ
();
// We choose the following to be 1 as we transform the positions later.
m_fCellLengthX
=
1
;
m_fCellLengthY
=
1
;
m_fCellLengthZ
=
1
;
m_nCellsX
=
grid
->
getNbCoordsX
()
-
1
;
m_nCellsY
=
grid
->
getNbCoordsY
()
-
1
;
...
...
@@ -649,7 +651,6 @@ void WMMarchingCubes::renderSurface()
// }
}
void
WMMarchingCubes
::
renderMesh
(
boost
::
shared_ptr
<
WTriangleMesh2
>
mesh
)
{
// WKernel::getRunningKernel()->getGraphicsEngine()->getScene()
...
...
@@ -709,16 +710,11 @@ void WMMarchingCubes::renderMesh( boost::shared_ptr< WTriangleMesh2 > mesh )
// ------------------------------------------------
// Shader stuff
// TODO(wiebel): fix texture coords.
double
xext
=
m_grid
->
getOffsetX
()
*
m_grid
->
getNbCoordsX
();
double
yext
=
m_grid
->
getOffsetY
()
*
m_grid
->
getNbCoordsY
();
double
zext
=
m_grid
->
getOffsetZ
()
*
m_grid
->
getNbCoordsZ
();
osg
::
Vec3Array
*
texCoords
=
new
osg
::
Vec3Array
;
for
(
size_t
i
=
0
;
i
<
mesh
->
vertSize
();
++
i
)
{
osg
::
Vec3
vertPos
=
mesh
->
getVertex
(
i
);
texCoords
->
push_back
(
osg
::
Vec3
(
vertPos
[
0
]
/
xext
,
vertPos
[
1
]
/
yext
,
vertPos
[
2
]
/
zext
)
);
texCoords
->
push_back
(
wge
::
wv3D2ov3
(
m_grid
->
worldCoordToTexCoord
(
wmath
::
WPosition
(
vertPos
[
0
],
vertPos
[
1
],
vertPos
[
2
]
)
)
)
);
}
surfaceGeometry
->
setTexCoordArray
(
0
,
texCoords
);
...
...
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