+ fixes #0002222: Number of normals in exported VRML is wrong
This commit is contained in:
parent
694c409caf
commit
c135ca40a5
|
@ -211,6 +211,7 @@ const std::string& Gui::SoFCDB::writeNodesToString(SoNode * root)
|
||||||
bool Gui::SoFCDB::writeToVRML(SoNode* node, const char* filename, bool binary)
|
bool Gui::SoFCDB::writeToVRML(SoNode* node, const char* filename, bool binary)
|
||||||
{
|
{
|
||||||
SoVRMLAction vrml2;
|
SoVRMLAction vrml2;
|
||||||
|
vrml2.setOverrideMode(true);
|
||||||
vrml2.apply(node);
|
vrml2.apply(node);
|
||||||
SoToVRML2Action tovrml2;
|
SoToVRML2Action tovrml2;
|
||||||
tovrml2.apply(node);
|
tovrml2.apply(node);
|
||||||
|
@ -219,6 +220,10 @@ bool Gui::SoFCDB::writeToVRML(SoNode* node, const char* filename, bool binary)
|
||||||
std::string buffer = SoFCDB::writeNodesToString(vrmlRoot);
|
std::string buffer = SoFCDB::writeNodesToString(vrmlRoot);
|
||||||
vrmlRoot->unref(); // release the memory as soon as possible
|
vrmlRoot->unref(); // release the memory as soon as possible
|
||||||
|
|
||||||
|
// restore old settings
|
||||||
|
vrml2.setOverrideMode(false);
|
||||||
|
vrml2.apply(node);
|
||||||
|
|
||||||
Base::FileInfo fi(filename);
|
Base::FileInfo fi(filename);
|
||||||
if (binary) {
|
if (binary) {
|
||||||
// We want to write compressed VRML but Coin 2.4.3 doesn't do it even though
|
// We want to write compressed VRML but Coin 2.4.3 doesn't do it even though
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
#include <Inventor/misc/SoChildList.h>
|
#include <Inventor/misc/SoChildList.h>
|
||||||
#include <Inventor/nodes/SoMaterial.h>
|
#include <Inventor/nodes/SoMaterial.h>
|
||||||
#include <Inventor/nodes/SoMaterialBinding.h>
|
#include <Inventor/nodes/SoMaterialBinding.h>
|
||||||
|
#include <Inventor/nodes/SoNormalBinding.h>
|
||||||
#include <Inventor/events/SoLocation2Event.h>
|
#include <Inventor/events/SoLocation2Event.h>
|
||||||
#include <Inventor/SoPickedPoint.h>
|
#include <Inventor/SoPickedPoint.h>
|
||||||
|
|
||||||
|
@ -704,13 +705,14 @@ void SoVRMLAction::initClass()
|
||||||
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
|
SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
|
||||||
SO_ACTION_ADD_METHOD(SoMaterialBinding,callDoAction);
|
SO_ACTION_ADD_METHOD(SoMaterialBinding,callDoAction);
|
||||||
SO_ACTION_ADD_METHOD(SoMaterial,callDoAction);
|
SO_ACTION_ADD_METHOD(SoMaterial,callDoAction);
|
||||||
|
SO_ACTION_ADD_METHOD(SoNormalBinding,callDoAction);
|
||||||
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
|
SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
|
||||||
SO_ACTION_ADD_METHOD(SoIndexedLineSet,callDoAction);
|
SO_ACTION_ADD_METHOD(SoIndexedLineSet,callDoAction);
|
||||||
SO_ACTION_ADD_METHOD(SoIndexedFaceSet,callDoAction);
|
SO_ACTION_ADD_METHOD(SoIndexedFaceSet,callDoAction);
|
||||||
SO_ACTION_ADD_METHOD(SoPointSet,callDoAction);
|
SO_ACTION_ADD_METHOD(SoPointSet,callDoAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
SoVRMLAction::SoVRMLAction()
|
SoVRMLAction::SoVRMLAction() : overrideMode(true)
|
||||||
{
|
{
|
||||||
SO_ACTION_CONSTRUCTOR(SoVRMLAction);
|
SO_ACTION_CONSTRUCTOR(SoVRMLAction);
|
||||||
}
|
}
|
||||||
|
@ -719,7 +721,33 @@ SoVRMLAction::~SoVRMLAction()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoVRMLAction::callDoAction(SoAction *action,SoNode *node)
|
void SoVRMLAction::setOverrideMode(SbBool on)
|
||||||
{
|
{
|
||||||
|
overrideMode = on;
|
||||||
|
}
|
||||||
|
|
||||||
|
SbBool SoVRMLAction::isOverrideMode() const
|
||||||
|
{
|
||||||
|
return overrideMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoVRMLAction::callDoAction(SoAction *action, SoNode *node)
|
||||||
|
{
|
||||||
|
if (node->getTypeId().isDerivedFrom(SoNormalBinding::getClassTypeId()) && action->isOfType(SoVRMLAction::getClassTypeId())) {
|
||||||
|
SoVRMLAction* vrmlAction = static_cast<SoVRMLAction*>(action);
|
||||||
|
if (vrmlAction->overrideMode) {
|
||||||
|
SoNormalBinding* bind = static_cast<SoNormalBinding*>(node);
|
||||||
|
vrmlAction->bindList.push_back(bind->value.getValue());
|
||||||
|
// this normal binding causes some problems for the part view provider
|
||||||
|
// See also #0002222: Number of normals in exported VRML is wrong
|
||||||
|
if (bind->value.getValue() == static_cast<int>(SoNormalBinding::PER_VERTEX_INDEXED))
|
||||||
|
bind->value = SoNormalBinding::OVERALL;
|
||||||
|
}
|
||||||
|
else if (!vrmlAction->bindList.empty()) {
|
||||||
|
static_cast<SoNormalBinding*>(node)->value = static_cast<SoNormalBinding::Binding>(vrmlAction->bindList.front());
|
||||||
|
vrmlAction->bindList.pop_front();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
node->doAction(action);
|
node->doAction(action);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include <Inventor/fields/SoSFString.h>
|
#include <Inventor/fields/SoSFString.h>
|
||||||
#include <Inventor/nodes/SoLightModel.h>
|
#include <Inventor/nodes/SoLightModel.h>
|
||||||
#include "View3DInventorViewer.h"
|
#include "View3DInventorViewer.h"
|
||||||
|
#include <list>
|
||||||
|
|
||||||
class SoFullPath;
|
class SoFullPath;
|
||||||
class SoPickedPoint;
|
class SoPickedPoint;
|
||||||
|
@ -187,10 +188,14 @@ class GuiExport SoVRMLAction : public SoAction
|
||||||
public:
|
public:
|
||||||
SoVRMLAction();
|
SoVRMLAction();
|
||||||
~SoVRMLAction();
|
~SoVRMLAction();
|
||||||
|
void setOverrideMode(SbBool);
|
||||||
|
SbBool isOverrideMode() const;
|
||||||
|
|
||||||
static void initClass();
|
static void initClass();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SbBool overrideMode;
|
||||||
|
std::list<int> bindList;
|
||||||
static void callDoAction(SoAction *action,SoNode *node);
|
static void callDoAction(SoAction *action,SoNode *node);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user