Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Modules
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Modules
Commits
3792f163
Commit
3792f163
authored
Aug 22, 2017
by
Alexander Wiebel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CHANGE] reactivated code according to issue #28 in core OpenWalnut
parent
131e15d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
50 deletions
+48
-50
Unmaintained/src/sliceContext/WTransparentLinesDrawable.cpp
Unmaintained/src/sliceContext/WTransparentLinesDrawable.cpp
+48
-50
No files found.
Unmaintained/src/sliceContext/WTransparentLinesDrawable.cpp
View file @
3792f163
...
...
@@ -30,62 +30,60 @@
#include "core/graphicsEngine/WGraphicsEngine.h"
#include "WTransparentLinesDrawable.h"
//
namespace
//
{
//
double depth( osg::Vec3f pos, WPosition viewDir )
//
{
//
WVector3d tmp = pos - WPosition();
//
double result = dot( tmp, viewDir );
//
return result;
//
}
namespace
{
double
depth
(
osg
::
Vec3f
pos
,
WPosition
viewDir
)
{
WVector3d
tmp
=
pos
-
WPosition
();
double
result
=
dot
(
tmp
,
viewDir
);
return
result
;
}
//
class MySorting
//
{
//
public:
//
int operator()( std::pair< double, size_t > p1 , std::pair< double, size_t > p2 )
//
{
//
return ( p1.first < p2.first );
//
}
//
};
//
}
class
MySorting
{
public:
int
operator
()(
std
::
pair
<
double
,
size_t
>
p1
,
std
::
pair
<
double
,
size_t
>
p2
)
{
return
(
p1
.
first
<
p2
.
first
);
}
};
}
void
WTransparentLinesDrawable
::
drawImplementation
(
osg
::
RenderInfo
&
/*renderInfo*/
)
const
//NOLINT
void
WTransparentLinesDrawable
::
drawImplementation
(
osg
::
RenderInfo
&
renderInfo
)
const
//NOLINT
{
// TODO(wiebel): reactivate this and above if build server has osg100
// boost::shared_ptr< WGraphicsEngine > ge = WGraphicsEngine::getGraphicsEngine();
// boost::shared_ptr< WGEViewer > viewer; //!< Stores reference to the main viewer
// viewer = ge->getViewerByName( "Main View" );
// WPosition endPos = WPosition( wge::unprojectFromScreen( osg::Vec3( 0.0, 0.0, 1.0 ), viewer->getCamera() ) );
// WPosition startPos = WPosition( wge::unprojectFromScreen( osg::Vec3(), viewer->getCamera() ) );
// WPosition viewDir = normalize( endPos - startPos );
boost
::
shared_ptr
<
WGraphicsEngine
>
ge
=
WGraphicsEngine
::
getGraphicsEngine
();
boost
::
shared_ptr
<
WGEViewer
>
viewer
;
//!< Stores reference to the main viewer
viewer
=
ge
->
getViewerByName
(
"Main View"
);
WPosition
endPos
=
WPosition
(
wge
::
unprojectFromScreen
(
osg
::
Vec3
(
0.0
,
0.0
,
1.0
),
viewer
->
getCamera
()
)
);
WPosition
startPos
=
WPosition
(
wge
::
unprojectFromScreen
(
osg
::
Vec3
(),
viewer
->
getCamera
()
)
);
WPosition
viewDir
=
normalize
(
endPos
-
startPos
);
//
std::vector< std::pair< double, size_t > > depthVals( _vertexArray->getNumElements() );
//
for( size_t i = 0; i < _vertexArray->getNumElements(); i += 2 )
//
{
//
double myDepth = -1 * depth( ( *( dynamic_cast< osg::Vec3Array* >( _vertexArray.get() ) ) )[i], viewDir );
//
// TODO(wiebel): improve this unidication of values
//
depthVals[i] = std::make_pair( myDepth, i );
//
depthVals[i+1] = std::make_pair( myDepth, i+1 );
//
}
std
::
vector
<
std
::
pair
<
double
,
size_t
>
>
depthVals
(
_vertexArray
->
getNumElements
()
);
for
(
size_t
i
=
0
;
i
<
_vertexArray
->
getNumElements
();
i
+=
2
)
{
double
myDepth
=
-
1
*
depth
(
(
*
(
dynamic_cast
<
osg
::
Vec3Array
*
>
(
_vertexArray
.
get
()
)
)
)[
i
],
viewDir
);
// TODO(wiebel): improve this unidication of values
depthVals
[
i
]
=
std
::
make_pair
(
myDepth
,
i
);
depthVals
[
i
+
1
]
=
std
::
make_pair
(
myDepth
,
i
+
1
);
}
//
std::stable_sort( depthVals.begin(), depthVals.end(), MySorting() );
std
::
stable_sort
(
depthVals
.
begin
(),
depthVals
.
end
(),
MySorting
()
);
//
//
osg::ref_ptr< osg::Vec3Array > tmp( new osg::Vec3Array( _vertexArray->getNumElements() ) );
//
osg::ref_ptr< osg::Vec3Array > oldVec =
//
new osg::Vec3Array( *dynamic_cast<osg::Vec3Array*>( _vertexArray.get() ), osg::CopyOp::DEEP_COPY_ALL );
//
osg::Vec3Array* oldVec2 = oldVec.get();
//
osg::Vec3Array* tmpVec = const_cast< osg::Vec3Array* >( ( dynamic_cast< const osg::Vec3Array*>( _vertexArray.get() ) ) );
//
osg::ref_ptr< osg::Vec3Array > oldTexCoords =
//
new osg::Vec3Array( *dynamic_cast<osg::Vec3Array*>( _texCoordList[0].get() ), osg::CopyOp::DEEP_COPY_ALL );
//
osg::Vec3Array* oldTexCoords2 = oldTexCoords.get();
//
osg::Vec3Array* tmpTexCoords = const_cast< osg::Vec3Array* >( ( dynamic_cast< const osg::Vec3Array*>( _texCoordList[0].get() ) ) );
//
for( size_t i = 0; i < _vertexArray->getNumElements(); ++i )
//
{
//
( *tmpTexCoords )[i] = ( *oldTexCoords2 )[ depthVals[i].second ];
//
( *tmpVec )[i] = ( *oldVec2 )[ depthVals[i].second ];
//
}
// osg::ref_ptr< osg::Vec3Array > tmp( new osg::Vec3Array( _vertexArray->getNumElements() ) );
osg
::
ref_ptr
<
osg
::
Vec3Array
>
oldVec
=
new
osg
::
Vec3Array
(
*
dynamic_cast
<
osg
::
Vec3Array
*>
(
_vertexArray
.
get
()
),
osg
::
CopyOp
::
DEEP_COPY_ALL
);
osg
::
Vec3Array
*
oldVec2
=
oldVec
.
get
();
osg
::
Vec3Array
*
tmpVec
=
const_cast
<
osg
::
Vec3Array
*
>
(
(
dynamic_cast
<
const
osg
::
Vec3Array
*>
(
_vertexArray
.
get
()
)
)
);
osg
::
ref_ptr
<
osg
::
Vec3Array
>
oldTexCoords
=
new
osg
::
Vec3Array
(
*
dynamic_cast
<
osg
::
Vec3Array
*>
(
_texCoordList
[
0
].
get
()
),
osg
::
CopyOp
::
DEEP_COPY_ALL
);
osg
::
Vec3Array
*
oldTexCoords2
=
oldTexCoords
.
get
();
osg
::
Vec3Array
*
tmpTexCoords
=
const_cast
<
osg
::
Vec3Array
*
>
(
(
dynamic_cast
<
const
osg
::
Vec3Array
*>
(
_texCoordList
[
0
].
get
()
)
)
);
for
(
size_t
i
=
0
;
i
<
_vertexArray
->
getNumElements
();
++
i
)
{
(
*
tmpTexCoords
)[
i
]
=
(
*
oldTexCoords2
)[
depthVals
[
i
].
second
];
(
*
tmpVec
)[
i
]
=
(
*
oldVec2
)[
depthVals
[
i
].
second
];
}
//
osg::Geometry::drawImplementation( renderInfo );
osg
::
Geometry
::
drawImplementation
(
renderInfo
);
}
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