Added osgFX::MultiTextureControl node for managing blending between
different texture layers.
This commit is contained in:
@@ -61,6 +61,8 @@
|
||||
#include "MultiSwitch.h"
|
||||
#include "VisibilityGroup.h"
|
||||
|
||||
#include "MultiTextureControl.h"
|
||||
|
||||
#include "Geometry.h"
|
||||
#include "ShapeDrawable.h"
|
||||
#include "Shape.h"
|
||||
@@ -952,6 +954,10 @@ osg::Node* DataInputStream::readNode()
|
||||
node = new osgSim::LightPointNode();
|
||||
((ive::LightPointNode*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVEMULTITEXTURECONTROL){
|
||||
node = new osgFX::MultiTextureControl();
|
||||
((ive::MultiTextureControl*)(node))->read(this);
|
||||
}
|
||||
else{
|
||||
throw Exception("Unknown node identification in DataInputStream::readNode()");
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@
|
||||
#include "MultiSwitch.h"
|
||||
#include "VisibilityGroup.h"
|
||||
|
||||
#include "MultiTextureControl.h"
|
||||
|
||||
#include "Geometry.h"
|
||||
#include "ShapeDrawable.h"
|
||||
|
||||
@@ -733,6 +735,9 @@ void DataOutputStream::writeNode(const osg::Node* node)
|
||||
else if(dynamic_cast<const osgSim::LightPointNode*>(node)){
|
||||
((ive::LightPointNode*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osgFX::MultiTextureControl*>(node)){
|
||||
((ive::MultiTextureControl*)(node))->write(this);
|
||||
}
|
||||
else
|
||||
throw Exception("Unknown node in Group::write()");
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ CXXFILES =\
|
||||
Material.cpp\
|
||||
MatrixTransform.cpp\
|
||||
MultiSwitch.cpp\
|
||||
MultiTextureControl.cpp\
|
||||
Node.cpp\
|
||||
Object.cpp\
|
||||
OccluderNode.cpp\
|
||||
@@ -77,7 +78,7 @@ CXXFILES =\
|
||||
VertexProgram.cpp\
|
||||
VisibilityGroup.cpp\
|
||||
|
||||
LIBS += -losgSim -losgText $(OSG_LIBS) $(OTHER_LIBS)
|
||||
LIBS += -losgFX -losgSim -losgText $(OSG_LIBS) $(OTHER_LIBS)
|
||||
|
||||
TARGET_BASENAME = ive
|
||||
include $(TOPDIR)/Make/cygwin_plugin_def
|
||||
|
||||
70
src/osgPlugins/ive/MultiTextureControl.cpp
Normal file
70
src/osgPlugins/ive/MultiTextureControl.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: MultiTextureControl.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::MultiTextureControl in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerate
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 24.3.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "MultiTextureControl.h"
|
||||
#include "Group.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void MultiTextureControl::write(DataOutputStream* out){
|
||||
// Write MultiTextureControl's identification.
|
||||
out->writeInt(IVEMULTITEXTURECONTROL);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("MultiTextureControl::write(): Could not cast this osg::MultiTextureControl to an osg::Group.");
|
||||
// Write MultiTextureControl's properties.
|
||||
|
||||
|
||||
// Write rangelist
|
||||
unsigned int size = getNumTextureWeights();
|
||||
out->writeUInt(size);
|
||||
for(unsigned int i=0;i<size;i++){
|
||||
out->writeFloat(getTextureWeight(i));
|
||||
}
|
||||
}
|
||||
|
||||
void MultiTextureControl::read(DataInputStream* in){
|
||||
// Peek on MultiTextureControl's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEMULTITEXTURECONTROL){
|
||||
// Read MultiTextureControl's identification.
|
||||
id = in->readInt();
|
||||
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("MultiTextureControl::read(): Could not cast this osg::MultiTextureControl to an osg::Group.");
|
||||
// Read MultiTextureControl's properties
|
||||
|
||||
|
||||
// Read rangelist
|
||||
unsigned int size = in->readUInt();
|
||||
for(unsigned int i=0;i<size;i++)
|
||||
{
|
||||
float value = in->readFloat();
|
||||
setTextureWeight(i, value);
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("MultiTextureControl::read(): Expected MultiTextureControl identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/MultiTextureControl.h
Normal file
15
src/osgPlugins/ive/MultiTextureControl.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_MULTITEXTYRECONTROL
|
||||
#define IVE_MULTITEXTYRECONTROL 1
|
||||
|
||||
#include <osgFX/MultiTextureControl>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class MultiTextureControl : public osgFX::MultiTextureControl, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -96,8 +96,13 @@ namespace ive {
|
||||
#define IVELIGHTPOINTNODE 0x00100007
|
||||
#define IVEMULTISWITCH 0x00100008
|
||||
|
||||
#define IVEVISIBILITYGROUP 0x00100009
|
||||
#define IVEDIRECTIONALSECTOR 0x0010000A
|
||||
|
||||
#define IVEVISIBILITYGROUP 0x00100009
|
||||
#define IVEDIRECTIONALSECTOR 0x0010000A
|
||||
|
||||
// osgFX classes
|
||||
#define IVEMULTITEXTURECONTROL 0x01000001
|
||||
|
||||
|
||||
class ReadWrite{
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ CXXFILES =\
|
||||
IO_AnisotropicLighting.cpp\
|
||||
IO_BumpMapping.cpp\
|
||||
IO_Cartoon.cpp\
|
||||
IO_MultiTextureControl.cpp\
|
||||
IO_Scribe.cpp\
|
||||
IO_SpecularHighlights.cpp\
|
||||
IO_Effect.cpp\
|
||||
|
||||
79
src/osgPlugins/osgFX/IO_MultiTextureControl.cpp
Normal file
79
src/osgPlugins/osgFX/IO_MultiTextureControl.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
#include <osgFX/MultiTextureControl>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
bool MultiTextureControl_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool MultiTextureControl_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy MultiTextureControl_Proxy
|
||||
(
|
||||
new osgFX::MultiTextureControl,
|
||||
"osgFX::MultiTextureControl",
|
||||
"Object Node osgFX::MultiTextureControl Group",
|
||||
MultiTextureControl_readLocalData,
|
||||
MultiTextureControl_writeLocalData
|
||||
);
|
||||
|
||||
bool MultiTextureControl_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgFX::MultiTextureControl &mtc = static_cast<osgFX::MultiTextureControl &>(obj);
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
bool matchFirst = false;
|
||||
if ((matchFirst=fr.matchSequence("TextureWeights {")) || fr.matchSequence("TextureWeights %i {"))
|
||||
{
|
||||
|
||||
// set up coordinates.
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
if (matchFirst)
|
||||
{
|
||||
fr += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
fr += 3;
|
||||
}
|
||||
|
||||
float weight=0.0f;
|
||||
unsigned int i=0;
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
if (fr[0].getFloat(weight))
|
||||
{
|
||||
mtc.setTextureWeight(i,weight);
|
||||
++fr;
|
||||
++i;
|
||||
}
|
||||
else
|
||||
{
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
|
||||
iteratorAdvanced = true;
|
||||
++fr;
|
||||
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool MultiTextureControl_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgFX::MultiTextureControl &mtc = static_cast<const osgFX::MultiTextureControl &>(obj);
|
||||
|
||||
fw.indent() << "TextureWeights "<<mtc.getNumTextureWeights()<<" {"<< std::endl;
|
||||
fw.moveIn();
|
||||
|
||||
for(unsigned int i=0; i<mtc.getNumTextureWeights();++i)
|
||||
{
|
||||
fw.indent() << mtc.getTextureWeight(i)<<std::endl;
|
||||
}
|
||||
fw.moveOut();
|
||||
fw.indent() << "}"<< std::endl;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user