From Liang Aibin:
"1. Location: <OSG_SOURCE_ROOT>\src\osgPlugins\osg\Fog.cpp
Reason: ".osg" writter plugins output incorrected string for osg::Fog's Mode.
How to Fix:
Line 138 in Fog.cpp: case(Fog::LINEAR): return "NERVER";
Change to: case(Fog::LINEAR): return "LINEAR";
2. Location: <OSG_SOURCE_ROOT>\src\osgPlugins\ive\
Reason: ".ive" writter plugins missing to process "osg::Fog".
How to Fix:
(1). Line 86 in ReadWrite.h:
Add: #define IVEFOG 0x00001133
(2). In CMakeLists.txt
"SET(TARGET_SRC" section Add: Fog.cpp
"SET(TARGET_H" section Add: Fog.h
(3). In DataInputStream.cpp
Line 54,Add: #include "Fog.h"
Line 1185,Add: else if(attributeID == IVEFOG){
attribute = new osg::Fog();
((ive::Fog*)(attribute))->read(this);
}
(4). In DataOutputStream.cpp
Line 57,Add: #include "Fog.h"
Line 832,Add: // This is a Fog
else if(dynamic_cast<const osg::Fog*>(attribute)){
((ive::Fog*)(attribute))->write(this);
}
(5). Add newly created ive::Fog Object in Fog.h and Fog.cpp.
"
This commit is contained in:
67
src/osgPlugins/ive/Fog.cpp
Normal file
67
src/osgPlugins/ive/Fog.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: Fog.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::Fog in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Liang Aibin
|
||||
*
|
||||
* HISTORY: Created 17.06.2008
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Fog.h"
|
||||
#include "Object.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Fog::write(DataOutputStream* out){
|
||||
|
||||
// write Fog's identification
|
||||
out->writeInt(IVEFOG);
|
||||
|
||||
// if the osg class is inherited by any other class we should also write this to file
|
||||
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
||||
if(obj)
|
||||
((ive::Object*)(obj))->write(out);
|
||||
else
|
||||
throw Exception("Fog::write(): Could not cast this osg::Fog to an osg::Object.");
|
||||
|
||||
// write Fog's properties
|
||||
out->writeInt(getMode());
|
||||
out->writeFloat(getDensity());
|
||||
out->writeFloat(getStart());
|
||||
out->writeFloat(getEnd());
|
||||
out->writeVec4(getColor());
|
||||
out->writeInt(getFogCoordinateSource());
|
||||
}
|
||||
|
||||
void Fog::read(DataInputStream* in){
|
||||
|
||||
// peek on Fog's identification
|
||||
int id = in->peekInt();
|
||||
if(id == IVEFOG)
|
||||
{
|
||||
// read Fog's identification
|
||||
id = in->readInt();
|
||||
|
||||
// if the osg class is inherited by any other class we should also read this from file
|
||||
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
||||
if(obj)
|
||||
((ive::Object*)(obj))->read(in);
|
||||
else
|
||||
throw Exception("Fog::read(): Could not cast this osg::Fog to an osg::Object.");
|
||||
|
||||
// Read Fog's properties
|
||||
setMode(osg::Fog::Mode(in->readInt()));
|
||||
setDensity(in->readFloat());
|
||||
setStart(in->readFloat());
|
||||
setEnd(in->readFloat());
|
||||
setColor(in->readVec4());
|
||||
setFogCoordinateSource(in->readInt());
|
||||
}
|
||||
else{
|
||||
throw Exception("Fog::read(): Expected Fog identification.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user