Hello Michael,
On 09/30/2014 04:46 PM, Michael Raab wrote:
thanks for your explanation. I followed your hint and tried implement a
Stage similar to DepthPeelingStage but the rendering looks broken.
The geometry to highlight looks like it is rendered unlit. I'm attaching
the source code, maybe someone has some minutes to look at.
in your case I don't think you want to disable the default partition,
that is intended for Stages that want to take over rendering entirely [1].
You can also avoid having to copy the viewport and camera settings, by
changing the pushPartition call to:
this->pushPartition(a, RenderPartition::CopyAll);
I think it would also be better to set the override material on the
partition that should use it, instead of the parent partition and have
it inherited.
I'm thinking something like the attached (completely untested).
Cheers,
Carsten
[1] and probably only makes sense for stages that are used very near the
root of the scene - otherwise I think that is likely to skip rendering
of objects (namely those that have already been added to the default
partition).
/*---------------------------------------------------------------------------*\
* OpenSG *
* *
* *
* Copyright (C) 2000-2013 by the OpenSG Forum *
* *
* www.opensg.org *
* *
* contact: Michael Raab *
* *
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
* License *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Library General Public License as published *
* by the Free Software Foundation, version 2. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* *
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
* Changes *
* *
* *
* *
* *
* *
* *
\*---------------------------------------------------------------------------*/
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <cstdlib>
#include <cstdio>
#define OSG_COMPILEEXTLIB
#include "OpenSG/OSGConfig.h"
#include "OpenSG/OSGRenderAction.h"
#include "OpenSG/OSGFrameBufferObject.h"
#include "OpenSG/OSGCamera.h"
#include "OSGVDTHighlightStage.h"
OSG_BEGIN_NAMESPACE
// Documentation for this class is emitted in the
// OSGVDTHighlightStageBase.cpp file.
// To modify it, please change the .fcd file (OSGVDTHighlightStage.fcd) and
// regenerate the base file.
/***************************************************************************\
* Class variables *
\***************************************************************************/
/***************************************************************************\
* Class methods *
\***************************************************************************/
void VDTHighlightStage::initMethod(InitPhase ePhase)
{
Inherited::initMethod(ePhase);
if(ePhase == TypeObject::SystemPost)
{
RenderAction::registerEnterDefault(
VDTHighlightStage::getClassType(),
reinterpret_cast<Action::Callback>(&VDTHighlightStage::renderEnter));
RenderAction::registerLeaveDefault(
VDTHighlightStage::getClassType(),
reinterpret_cast<Action::Callback>(&VDTHighlightStage::renderLeave));
}
}
/***************************************************************************\
* Instance methods *
\***************************************************************************/
/*-------------------------------------------------------------------------*\
- private -
\*-------------------------------------------------------------------------*/
/*----------------------- constructors & destructors ----------------------*/
VDTHighlightStage::VDTHighlightStage(void) :
Inherited()
{
}
VDTHighlightStage::VDTHighlightStage(const VDTHighlightStage &source) :
Inherited(source)
{
}
VDTHighlightStage::~VDTHighlightStage(void)
{
}
/*-------------------------------------------------------------------------*/
/* Draw */
Action::ResultE VDTHighlightStage::renderEnter(Action *action)
{
RenderAction *pAction = dynamic_cast<RenderAction *>(action);
Int32 iVPWidth = pAction->getActivePartition()->getViewportWidth ();
Int32 iVPHeight = pAction->getActivePartition()->getViewportHeight();
this->beginPartitionGroup(pAction);
{
// RenderPartition (1) -> Render SubTree using 'normal' materials..
setupRenderScene(pAction, iVPWidth, iVPHeight, false);
// RenderPartition (2) -> Render SubTree using 'highlight' material
setupRenderScene(pAction, iVPWidth, iVPHeight, true);
}
this->endPartitionGroup(pAction);
return Action::Skip;
}
Action::ResultE VDTHighlightStage::renderLeave(Action *action)
{
return Action::Skip;
}
void
VDTHighlightStage::setupRenderScene(RenderAction* a,
Int32 iVPWidth,
Int32 iVPHeight,
bool useOverride)
{
this->pushPartition(a, RenderPartition::CopyAll);
{
RenderPartition *pPart = a->getActivePartition();
pPart->pushState();
if(useOverride)
{
pPart->overrideMaterial(getHighlightMaterial(), a->getActNode());
}
this->recurseFromThis(a);
a->useNodeList(false);
if(useOverride)
{
pPart->overrideMaterial(NULL, a->getActNode());
}
pPart->popState();
}
this->popPartition(a);
}
/*----------------------------- class specific ----------------------------*/
void VDTHighlightStage::changed(ConstFieldMaskArg whichField,
UInt32 origin,
BitVector details)
{
Inherited::changed(whichField, origin, details);
}
void VDTHighlightStage::dump( UInt32 ,
const BitVector ) const
{
SLOG << "Dump VDTHighlightStage NI" << std::endl;
}
OSG_END_NAMESPACE
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users