Added ClipNode::set/getReferenceFrame();
This commit is contained in:
parent
f4fe462b28
commit
0ea6cdeb96
@ -34,10 +34,31 @@ class OSG_EXPORT ClipNode : public Group
|
|||||||
|
|
||||||
META_Node(osg, ClipNode);
|
META_Node(osg, ClipNode);
|
||||||
|
|
||||||
|
enum ReferenceFrame
|
||||||
|
{
|
||||||
|
RELATIVE_RF,
|
||||||
|
ABSOLUTE_RF
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Set the light sources's ReferenceFrame, either to be relative to its
|
||||||
|
* parent reference frame, or relative to an absolute coordinate
|
||||||
|
* frame. RELATIVE_RF is the default.
|
||||||
|
* Note: setting the ReferenceFrame to be ABSOLUTE_RF will
|
||||||
|
* also set the CullingActive flag on the light source, and hence all
|
||||||
|
* of its parents, to false, thereby disabling culling of it and
|
||||||
|
* all its parents. This is necessary to prevent inappropriate
|
||||||
|
* culling, but may impact cull times if the absolute light source is
|
||||||
|
* deep in the scene graph. It is therefore recommended to only use
|
||||||
|
* absolute light source at the top of the scene.
|
||||||
|
*/
|
||||||
|
void setReferenceFrame(ReferenceFrame rf);
|
||||||
|
|
||||||
|
ReferenceFrame getReferenceFrame() const { return _referenceFrame; }
|
||||||
|
|
||||||
|
|
||||||
/** Creates six clip planes corresponding to the given BoundingBox. */
|
/** Creates six clip planes corresponding to the given BoundingBox. */
|
||||||
void createClipBox(const BoundingBox& bb,unsigned int clipPlaneNumberBase=0);
|
void createClipBox(const BoundingBox& bb,unsigned int clipPlaneNumberBase=0);
|
||||||
|
|
||||||
|
|
||||||
/** Adds the clipplane. Returns true on success, and false if the plane
|
/** Adds the clipplane. Returns true on success, and false if the plane
|
||||||
* has already been added, or if clipplane is NULL. */
|
* has already been added, or if clipplane is NULL. */
|
||||||
bool addClipPlane(ClipPlane* clipplane);
|
bool addClipPlane(ClipPlane* clipplane);
|
||||||
@ -81,8 +102,10 @@ class OSG_EXPORT ClipNode : public Group
|
|||||||
|
|
||||||
virtual ~ClipNode();
|
virtual ~ClipNode();
|
||||||
|
|
||||||
StateAttribute::GLModeValue _value;
|
StateAttribute::GLModeValue _value;
|
||||||
ClipPlaneList _planes;
|
ClipPlaneList _planes;
|
||||||
|
|
||||||
|
ReferenceFrame _referenceFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
using namespace osg;
|
using namespace osg;
|
||||||
|
|
||||||
ClipNode::ClipNode():
|
ClipNode::ClipNode():
|
||||||
_value(StateAttribute::ON)
|
_value(StateAttribute::ON),
|
||||||
|
_referenceFrame(RELATIVE_RF)
|
||||||
{
|
{
|
||||||
setStateSet(new StateSet);
|
setStateSet(new StateSet);
|
||||||
}
|
}
|
||||||
@ -43,6 +44,12 @@ ClipNode::~ClipNode()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ClipNode::setReferenceFrame(ReferenceFrame rf)
|
||||||
|
{
|
||||||
|
_referenceFrame = rf;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a 6 clip planes to create a clip box.
|
// Create a 6 clip planes to create a clip box.
|
||||||
void ClipNode::createClipBox(const BoundingBox& bb,unsigned int clipPlaneNumberBase)
|
void ClipNode::createClipBox(const BoundingBox& bb,unsigned int clipPlaneNumberBase)
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,11 @@ void ClipNode::write(DataOutputStream* out){
|
|||||||
throw Exception("ClipNode::write(): Could not cast this osg::ClipNode to an osg::Group.");
|
throw Exception("ClipNode::write(): Could not cast this osg::ClipNode to an osg::Group.");
|
||||||
// Write ClipNode's properties.
|
// Write ClipNode's properties.
|
||||||
|
|
||||||
|
if ( out->getVersion() >= VERSION_0037 )
|
||||||
|
{
|
||||||
|
out->writeInt((int)getReferenceFrame());
|
||||||
|
}
|
||||||
|
|
||||||
out->writeUInt(getNumClipPlanes());
|
out->writeUInt(getNumClipPlanes());
|
||||||
|
|
||||||
for (unsigned int i=0;i<getNumClipPlanes();++i)
|
for (unsigned int i=0;i<getNumClipPlanes();++i)
|
||||||
@ -56,6 +61,11 @@ void ClipNode::read(DataInputStream* in){
|
|||||||
throw Exception("ClipNode::read(): Could not cast this osg::ClipNode to an osg::Object.");
|
throw Exception("ClipNode::read(): Could not cast this osg::ClipNode to an osg::Object.");
|
||||||
// Read ClipNode's properties
|
// Read ClipNode's properties
|
||||||
|
|
||||||
|
if ( in->getVersion() >= VERSION_0037 )
|
||||||
|
{
|
||||||
|
setReferenceFrame((osg::ClipNode::ReferenceFrame) in->readInt());
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int numClipPlanes = in->readUInt();
|
unsigned int numClipPlanes = in->readUInt();
|
||||||
|
|
||||||
for (unsigned int i=0;i<numClipPlanes;++i)
|
for (unsigned int i=0;i<numClipPlanes;++i)
|
||||||
|
@ -45,8 +45,9 @@
|
|||||||
#define VERSION_0034 34
|
#define VERSION_0034 34
|
||||||
#define VERSION_0035 35
|
#define VERSION_0035 35
|
||||||
#define VERSION_0036 36
|
#define VERSION_0036 36
|
||||||
|
#define VERSION_0037 37
|
||||||
|
|
||||||
#define VERSION VERSION_0036
|
#define VERSION VERSION_0037
|
||||||
|
|
||||||
/* The BYTE_SEX tag is used to check the endian
|
/* The BYTE_SEX tag is used to check the endian
|
||||||
of the IVE file being read in. The IVE format
|
of the IVE file being read in. The IVE format
|
||||||
|
@ -27,6 +27,22 @@ bool ClipNode_readLocalData(Object& obj, Input& fr)
|
|||||||
|
|
||||||
ClipNode& clipnode = static_cast<ClipNode&>(obj);
|
ClipNode& clipnode = static_cast<ClipNode&>(obj);
|
||||||
|
|
||||||
|
if (fr[0].matchWord("referenceFrame"))
|
||||||
|
{
|
||||||
|
if (fr[1].matchWord("ABSOLUTE"))
|
||||||
|
{
|
||||||
|
clipnode.setReferenceFrame(ClipNode::ABSOLUTE_RF);
|
||||||
|
fr += 2;
|
||||||
|
iteratorAdvanced = true;
|
||||||
|
}
|
||||||
|
if (fr[1].matchWord("RELATIVE"))
|
||||||
|
{
|
||||||
|
clipnode.setReferenceFrame(ClipNode::RELATIVE_RF);
|
||||||
|
fr += 2;
|
||||||
|
iteratorAdvanced = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
osg::ref_ptr<StateAttribute> sa=0;
|
osg::ref_ptr<StateAttribute> sa=0;
|
||||||
while((sa=fr.readStateAttribute())!=0)
|
while((sa=fr.readStateAttribute())!=0)
|
||||||
{
|
{
|
||||||
@ -43,6 +59,17 @@ bool ClipNode_writeLocalData(const Object& obj, Output& fw)
|
|||||||
{
|
{
|
||||||
const ClipNode& clipnode = static_cast<const ClipNode&>(obj);
|
const ClipNode& clipnode = static_cast<const ClipNode&>(obj);
|
||||||
|
|
||||||
|
fw.indent() << "referenceFrame ";
|
||||||
|
switch (clipnode.getReferenceFrame())
|
||||||
|
{
|
||||||
|
case ClipNode::ABSOLUTE_RF:
|
||||||
|
fw << "ABSOLUTE\n";
|
||||||
|
break;
|
||||||
|
case ClipNode::RELATIVE_RF:
|
||||||
|
default:
|
||||||
|
fw << "RELATIVE\n";
|
||||||
|
};
|
||||||
|
|
||||||
for(unsigned int i=0;i<clipnode.getNumClipPlanes();++i)
|
for(unsigned int i=0;i<clipnode.getNumClipPlanes();++i)
|
||||||
{
|
{
|
||||||
fw.writeObject(*clipnode.getClipPlane(i));
|
fw.writeObject(*clipnode.getClipPlane(i));
|
||||||
|
@ -953,7 +953,14 @@ void CullVisitor::apply(ClipNode& node)
|
|||||||
itr!=planes.end();
|
itr!=planes.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
addPositionedAttribute(&matrix,itr->get());
|
if (node.getReferenceFrame()==osg::ClipNode::RELATIVE_RF)
|
||||||
|
{
|
||||||
|
addPositionedAttribute(&matrix,itr->get());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addPositionedAttribute(0,itr->get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_cull_callbacks_and_traverse(node);
|
handle_cull_callbacks_and_traverse(node);
|
||||||
|
@ -30,6 +30,12 @@
|
|||||||
|
|
||||||
TYPE_NAME_ALIAS(std::vector< osg::ref_ptr< osg::ClipPlane > >, osg::ClipNode::ClipPlaneList)
|
TYPE_NAME_ALIAS(std::vector< osg::ref_ptr< osg::ClipPlane > >, osg::ClipNode::ClipPlaneList)
|
||||||
|
|
||||||
|
BEGIN_ENUM_REFLECTOR(osg::ClipNode::ReferenceFrame)
|
||||||
|
I_DeclaringFile("osg/ClipNode");
|
||||||
|
I_EnumLabel(osg::ClipNode::RELATIVE_RF);
|
||||||
|
I_EnumLabel(osg::ClipNode::ABSOLUTE_RF);
|
||||||
|
END_REFLECTOR
|
||||||
|
|
||||||
BEGIN_OBJECT_REFLECTOR(osg::ClipNode)
|
BEGIN_OBJECT_REFLECTOR(osg::ClipNode)
|
||||||
I_DeclaringFile("osg/ClipNode");
|
I_DeclaringFile("osg/ClipNode");
|
||||||
I_BaseType(osg::Group);
|
I_BaseType(osg::Group);
|
||||||
@ -70,6 +76,16 @@ BEGIN_OBJECT_REFLECTOR(osg::ClipNode)
|
|||||||
__void__accept__osg_NodeVisitor_R1,
|
__void__accept__osg_NodeVisitor_R1,
|
||||||
"Visitor Pattern : calls the apply method of a NodeVisitor with this node's type. ",
|
"Visitor Pattern : calls the apply method of a NodeVisitor with this node's type. ",
|
||||||
"");
|
"");
|
||||||
|
I_Method1(void, setReferenceFrame, IN, osg::ClipNode::ReferenceFrame, rf,
|
||||||
|
Properties::NON_VIRTUAL,
|
||||||
|
__void__setReferenceFrame__ReferenceFrame,
|
||||||
|
"Set the light sources's ReferenceFrame, either to be relative to its parent reference frame, or relative to an absolute coordinate frame. ",
|
||||||
|
"RELATIVE_RF is the default. Note: setting the ReferenceFrame to be ABSOLUTE_RF will also set the CullingActive flag on the light source, and hence all of its parents, to false, thereby disabling culling of it and all its parents. This is necessary to prevent inappropriate culling, but may impact cull times if the absolute light source is deep in the scene graph. It is therefore recommended to only use absolute light source at the top of the scene. ");
|
||||||
|
I_Method0(osg::ClipNode::ReferenceFrame, getReferenceFrame,
|
||||||
|
Properties::NON_VIRTUAL,
|
||||||
|
__ReferenceFrame__getReferenceFrame,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
I_MethodWithDefaults2(void, createClipBox, IN, const osg::BoundingBox &, bb, , IN, unsigned int, clipPlaneNumberBase, 0,
|
I_MethodWithDefaults2(void, createClipBox, IN, const osg::BoundingBox &, bb, , IN, unsigned int, clipPlaneNumberBase, 0,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__void__createClipBox__C5_BoundingBox_R1__unsigned_int,
|
__void__createClipBox__C5_BoundingBox_R1__unsigned_int,
|
||||||
@ -148,6 +164,9 @@ BEGIN_OBJECT_REFLECTOR(osg::ClipNode)
|
|||||||
I_SimpleProperty(osg::StateAttribute::GLModeValue, LocalStateSetModes,
|
I_SimpleProperty(osg::StateAttribute::GLModeValue, LocalStateSetModes,
|
||||||
0,
|
0,
|
||||||
__void__setLocalStateSetModes__StateAttribute_GLModeValue);
|
__void__setLocalStateSetModes__StateAttribute_GLModeValue);
|
||||||
|
I_SimpleProperty(osg::ClipNode::ReferenceFrame, ReferenceFrame,
|
||||||
|
__ReferenceFrame__getReferenceFrame,
|
||||||
|
__void__setReferenceFrame__ReferenceFrame);
|
||||||
END_REFLECTOR
|
END_REFLECTOR
|
||||||
|
|
||||||
BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osg::ClipPlane >)
|
BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osg::ClipPlane >)
|
||||||
|
Loading…
Reference in New Issue
Block a user