From Lilin Xiong, "I change ive plugin a little for osgText inout, so the ive plugin supports backdrop setting,
and Text3D, FadeText inout : 1. in DataInputStream.cpp, add 1286--1293 lines; 2. in Text.cpp, add some code for text's Backdrop setting; 3. in IveVersion.h, add line 39, increase the VERSION to VERSION_028(line 41) 4. in ReadWrite.h, add line 146,147 5. add file FadeText.h, FadeText.cpp, Text3D.h, Text3D.cpp."
This commit is contained in:
parent
82ed445a31
commit
dba344feba
@ -93,6 +93,8 @@ SET(TARGET_SRC
|
|||||||
TexGenNode.cpp
|
TexGenNode.cpp
|
||||||
TexMat.cpp
|
TexMat.cpp
|
||||||
Text.cpp
|
Text.cpp
|
||||||
|
FadeText.cpp
|
||||||
|
Text3D.cpp
|
||||||
Texture1D.cpp
|
Texture1D.cpp
|
||||||
Texture2D.cpp
|
Texture2D.cpp
|
||||||
Texture3D.cpp
|
Texture3D.cpp
|
||||||
@ -198,6 +200,8 @@ SET(TARGET_H
|
|||||||
TexGenNode.h
|
TexGenNode.h
|
||||||
TexMat.h
|
TexMat.h
|
||||||
Text.h
|
Text.h
|
||||||
|
FadeText.h
|
||||||
|
Text3D.h
|
||||||
Texture1D.h
|
Texture1D.h
|
||||||
Texture2D.h
|
Texture2D.h
|
||||||
Texture3D.h
|
Texture3D.h
|
||||||
|
@ -97,6 +97,9 @@
|
|||||||
#include "HeightFieldLayer.h"
|
#include "HeightFieldLayer.h"
|
||||||
#include "CompositeLayer.h"
|
#include "CompositeLayer.h"
|
||||||
|
|
||||||
|
#include "FadeText.h"
|
||||||
|
#include "Text3D.h"
|
||||||
|
|
||||||
#include <osg/Endian>
|
#include <osg/Endian>
|
||||||
#include <osg/Notify>
|
#include <osg/Notify>
|
||||||
#include <osg/io_utils>
|
#include <osg/io_utils>
|
||||||
@ -1280,6 +1283,14 @@ osg::Drawable* DataInputStream::readDrawable()
|
|||||||
drawable = new osgText::Text();
|
drawable = new osgText::Text();
|
||||||
((Text*)(drawable))->read(this);
|
((Text*)(drawable))->read(this);
|
||||||
}
|
}
|
||||||
|
else if(drawableTypeID == IVEFADETEXT){
|
||||||
|
drawable = new osgText::FadeText();
|
||||||
|
((FadeText*)(drawable))->read(this);
|
||||||
|
}
|
||||||
|
else if(drawableTypeID == IVETEXT3D){
|
||||||
|
drawable = new osgText::Text3D();
|
||||||
|
((Text3D*)(drawable))->read(this);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw Exception("Unknown drawable drawableTypeIDentification in Geode::read()");
|
throw Exception("Unknown drawable drawableTypeIDentification in Geode::read()");
|
||||||
|
|
||||||
|
61
src/osgPlugins/ive/FadeText.cpp
Normal file
61
src/osgPlugins/ive/FadeText.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
*
|
||||||
|
* FILE: FadeText.cpp
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Read/Write osgText::FadeText in binary format to disk.
|
||||||
|
*
|
||||||
|
* CREATED BY: Auto generated by iveGenerator
|
||||||
|
* and later modified by Rune Schmidt Jensen.
|
||||||
|
*
|
||||||
|
* HISTORY: Created 27.3.2003
|
||||||
|
*
|
||||||
|
* Copyright 2003 VR-C
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#include "Exception.h"
|
||||||
|
#include "FadeText.h"
|
||||||
|
#include "Text.h"
|
||||||
|
#include "Drawable.h"
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
|
#include <osgDB/FileUtils>
|
||||||
|
#include <osgDB/FileNameUtils>
|
||||||
|
#include <osg/Notify>
|
||||||
|
|
||||||
|
using namespace ive;
|
||||||
|
|
||||||
|
void FadeText::write(DataOutputStream* out){
|
||||||
|
// Write FadeText's identification.
|
||||||
|
out->writeInt(IVEFADETEXT);
|
||||||
|
// If the osg class is inherited by any other class we should also write this to file.
|
||||||
|
osgText::Text* text = dynamic_cast<osgText::Text*>(this);
|
||||||
|
if(text){
|
||||||
|
((ive::Text*)(text))->write(out);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw Exception("FadeText::write(): Could not cast this osgText::FadeText to an osgText::Tex.");
|
||||||
|
|
||||||
|
// Write FadeText's properties.
|
||||||
|
out->writeFloat(getFadeSpeed());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FadeText::read(DataInputStream* in){
|
||||||
|
// Read FadeText's identification.
|
||||||
|
int id = in->peekInt();
|
||||||
|
if(id == IVEFADETEXT){
|
||||||
|
|
||||||
|
id = in->readInt();
|
||||||
|
// If the osg class is inherited by any other class we should also read this from file.
|
||||||
|
osgText::Text* text = dynamic_cast<osgText::Text*>(this);
|
||||||
|
if(text){
|
||||||
|
((ive::Text*)(text))->read(in);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw Exception("FadeText::read(): Could not cast this osgText::FadeText to an osgText::Text.");
|
||||||
|
|
||||||
|
setFadeSpeed(in->readFloat());
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
throw Exception("FadeText::read(): Expected FadeText identification.");
|
||||||
|
}
|
||||||
|
}
|
15
src/osgPlugins/ive/FadeText.h
Normal file
15
src/osgPlugins/ive/FadeText.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef IVE_FADETEXT
|
||||||
|
#define IVE_FADETEXT 1
|
||||||
|
|
||||||
|
#include <osgText/FadeText>
|
||||||
|
#include "ReadWrite.h"
|
||||||
|
|
||||||
|
namespace ive{
|
||||||
|
class FadeText : public osgText::FadeText, public ReadWrite {
|
||||||
|
public:
|
||||||
|
void write(DataOutputStream* out);
|
||||||
|
void read(DataInputStream* in);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -36,8 +36,9 @@
|
|||||||
#define VERSION_0025 25
|
#define VERSION_0025 25
|
||||||
#define VERSION_0026 26
|
#define VERSION_0026 26
|
||||||
#define VERSION_0027 27
|
#define VERSION_0027 27
|
||||||
|
#define VERSION_0028 28
|
||||||
|
|
||||||
#define VERSION VERSION_0027
|
#define VERSION VERSION_0028
|
||||||
|
|
||||||
/* 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
|
||||||
|
@ -143,6 +143,9 @@ namespace ive {
|
|||||||
//osgText classes
|
//osgText classes
|
||||||
#define IVETEXT 0x10000001
|
#define IVETEXT 0x10000001
|
||||||
|
|
||||||
|
#define IVETEXT3D 0x10000002
|
||||||
|
#define IVEFADETEXT 0x10000003
|
||||||
|
|
||||||
class ReadWrite{
|
class ReadWrite{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -75,6 +75,23 @@ void Text::write(DataOutputStream* out){
|
|||||||
out->writeVec4(getColor());
|
out->writeVec4(getColor());
|
||||||
out->writeUInt(getDrawMode());
|
out->writeUInt(getDrawMode());
|
||||||
|
|
||||||
|
if ( out->getVersion() >= VERSION_0028 )
|
||||||
|
{
|
||||||
|
out->writeUInt(getBackdropType());
|
||||||
|
|
||||||
|
out->writeFloat(getBackdropHorizontalOffset());
|
||||||
|
out->writeFloat(getBackdropVerticalOffset());
|
||||||
|
|
||||||
|
out->writeVec4(getBackdropColor());
|
||||||
|
out->writeUInt(getBackdropImplementation());
|
||||||
|
|
||||||
|
out->writeUInt(getColorGradientMode());
|
||||||
|
out->writeVec4(getColorGradientTopLeft());
|
||||||
|
out->writeVec4(getColorGradientBottomLeft());
|
||||||
|
out->writeVec4(getColorGradientBottomRight());
|
||||||
|
out->writeVec4(getColorGradientTopRight());
|
||||||
|
}
|
||||||
|
|
||||||
// text :: Modified from osgPlugins::osg
|
// text :: Modified from osgPlugins::osg
|
||||||
const osgText::String& textstring = getText();
|
const osgText::String& textstring = getText();
|
||||||
bool isACString = true;
|
bool isACString = true;
|
||||||
@ -149,7 +166,7 @@ void Text::read(DataInputStream* in){
|
|||||||
|
|
||||||
setCharacterSize(c_height,aspectRatio);
|
setCharacterSize(c_height,aspectRatio);
|
||||||
|
|
||||||
setCharacterSizeMode((osgText::Text::CharacterSizeMode) in->readUInt());
|
setCharacterSizeMode((osgText::TextBase::CharacterSizeMode) in->readUInt());
|
||||||
|
|
||||||
setMaximumWidth(in->readFloat());
|
setMaximumWidth(in->readFloat());
|
||||||
setMaximumHeight(in->readFloat());
|
setMaximumHeight(in->readFloat());
|
||||||
@ -159,7 +176,7 @@ void Text::read(DataInputStream* in){
|
|||||||
setLineSpacing(in->readFloat());
|
setLineSpacing(in->readFloat());
|
||||||
}
|
}
|
||||||
|
|
||||||
setAlignment((osgText::Text::AlignmentType) in->readUInt());
|
setAlignment((osgText::TextBase::AlignmentType) in->readUInt());
|
||||||
|
|
||||||
//Nothing to do...
|
//Nothing to do...
|
||||||
//setAxisAlignment((osgText::Text::AxisAlignment) in->readUint());
|
//setAxisAlignment((osgText::Text::AxisAlignment) in->readUint());
|
||||||
@ -172,6 +189,27 @@ void Text::read(DataInputStream* in){
|
|||||||
setColor(in->readVec4());
|
setColor(in->readVec4());
|
||||||
setDrawMode(in->readUInt());
|
setDrawMode(in->readUInt());
|
||||||
|
|
||||||
|
if ( in->getVersion() >= VERSION_0028 )
|
||||||
|
{
|
||||||
|
setBackdropType((osgText::Text::BackdropType) in->readUInt());
|
||||||
|
|
||||||
|
float horizontalOffset,verticalOffset;
|
||||||
|
horizontalOffset = in->readFloat();
|
||||||
|
verticalOffset = in->readFloat();
|
||||||
|
setBackdropOffset(horizontalOffset,verticalOffset);
|
||||||
|
|
||||||
|
setBackdropColor(in->readVec4());
|
||||||
|
setBackdropImplementation((osgText::Text::BackdropImplementation) in->readUInt());
|
||||||
|
setColorGradientMode((osgText::Text::ColorGradientMode) in->readUInt());
|
||||||
|
|
||||||
|
osg::Vec4 colorGradientTopLeft,colorGradientBottomLeft,colorGradientBottomRight,colorGradientTopRight;
|
||||||
|
colorGradientTopLeft = in->readVec4();
|
||||||
|
colorGradientBottomLeft = in->readVec4();
|
||||||
|
colorGradientBottomRight = in->readVec4();
|
||||||
|
colorGradientTopRight = in->readVec4();
|
||||||
|
setColorGradientCorners(colorGradientTopLeft,colorGradientBottomLeft,colorGradientBottomRight,colorGradientTopRight);
|
||||||
|
}
|
||||||
|
|
||||||
if(in->readBool())
|
if(in->readBool())
|
||||||
setText(in->readString());
|
setText(in->readString());
|
||||||
else
|
else
|
||||||
@ -203,6 +241,6 @@ void Text::read(DataInputStream* in){
|
|||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
throw Exception("ShadeModel::read(): Expected ShadeModel identification.");
|
throw Exception("Text::read(): Expected Text identification.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
217
src/osgPlugins/ive/Text3D.cpp
Normal file
217
src/osgPlugins/ive/Text3D.cpp
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
*
|
||||||
|
* FILE: Text3D.cpp
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Read/Write osgText::Text3D in binary format to disk.
|
||||||
|
*
|
||||||
|
* CREATED BY: Auto generated by iveGenerator
|
||||||
|
* and later modified by Rune Schmidt Jensen.
|
||||||
|
*
|
||||||
|
* HISTORY: Created 27.3.2003
|
||||||
|
*
|
||||||
|
* Copyright 2003 VR-C
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#include "Exception.h"
|
||||||
|
#include "Text3D.h"
|
||||||
|
#include "Text.h"
|
||||||
|
#include "Drawable.h"
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
|
#include <osgDB/FileUtils>
|
||||||
|
#include <osgDB/FileNameUtils>
|
||||||
|
#include <osg/Notify>
|
||||||
|
|
||||||
|
using namespace ive;
|
||||||
|
|
||||||
|
void Text3D::write(DataOutputStream* out){
|
||||||
|
// Write Text's identification.
|
||||||
|
out->writeInt(IVETEXT3D);
|
||||||
|
// 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::Drawable*)(obj))->write(out);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw Exception("Text::write(): Could not cast this osgText::Text to an osg::Drawable.");
|
||||||
|
// Write Text's properties.
|
||||||
|
if( getFont() )
|
||||||
|
{
|
||||||
|
std::string fname = getFont()->getFileName();
|
||||||
|
|
||||||
|
if(!fname.empty())
|
||||||
|
{
|
||||||
|
if(out->getUseOriginalExternalReferences())
|
||||||
|
{
|
||||||
|
out->writeString(fname); //Saving file name with local directory
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out->writeString(osgDB::getSimpleFileName(fname)); //Saving original file name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
out->writeString(""); //Blank string
|
||||||
|
}
|
||||||
|
else
|
||||||
|
out->writeString(""); //Blank string
|
||||||
|
|
||||||
|
out->writeUInt(getFontWidth());
|
||||||
|
out->writeUInt(getFontHeight());
|
||||||
|
out->writeFloat(getCharacterHeight());
|
||||||
|
out->writeFloat(getCharacterAspectRatio());
|
||||||
|
out->writeUInt(getCharacterSizeMode());
|
||||||
|
out->writeFloat(getMaximumWidth());
|
||||||
|
out->writeFloat(getMaximumHeight());
|
||||||
|
|
||||||
|
out->writeFloat(getLineSpacing());
|
||||||
|
|
||||||
|
out->writeUInt(getAlignment());
|
||||||
|
|
||||||
|
out->writeQuat(getRotation()); //FIXME: controllare che ci sia
|
||||||
|
|
||||||
|
out->writeBool(getAutoRotateToScreen());
|
||||||
|
out->writeUInt(getLayout());
|
||||||
|
out->writeVec3(getPosition());
|
||||||
|
// out->writeVec4(getColor());
|
||||||
|
out->writeUInt(getDrawMode());
|
||||||
|
|
||||||
|
//for text3d's property
|
||||||
|
out->writeFloat(getCharacterDepth());
|
||||||
|
out->writeUInt(getRenderMode());
|
||||||
|
|
||||||
|
// text :: Modified from osgPlugins::osg
|
||||||
|
const osgText::String& textstring = getText();
|
||||||
|
bool isACString = true;
|
||||||
|
osgText::String::const_iterator itr;
|
||||||
|
for(itr=textstring.begin();
|
||||||
|
itr!=textstring.end() && isACString;
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
if (*itr==0 || *itr>256) isACString=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isACString)
|
||||||
|
{
|
||||||
|
std::string str;
|
||||||
|
|
||||||
|
for(itr=textstring.begin();
|
||||||
|
itr!=textstring.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
str += (char)(*itr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//std::copy(textstring.begin(),textstring.end(),std::back_inserter(str));
|
||||||
|
|
||||||
|
out->writeBool(true);
|
||||||
|
out->writeString(str);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// do it the hardway...output each character as an int
|
||||||
|
osg::ref_ptr<osg::UIntArray> strarr = new osg::UIntArray(textstring.size());
|
||||||
|
|
||||||
|
for(itr=textstring.begin();
|
||||||
|
itr!=textstring.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
strarr->push_back((*itr));
|
||||||
|
}
|
||||||
|
|
||||||
|
out->writeBool(false);
|
||||||
|
out->writeUIntArray(strarr.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Text3D::read(DataInputStream* in){
|
||||||
|
// Peek on Text3D's identification.
|
||||||
|
int id = in->peekInt();
|
||||||
|
if(id == IVETEXT3D){
|
||||||
|
// Read Text3D'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::Drawable*)(obj))->read(in);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw Exception("Text::read(): Could not cast this osgText::Text to an osg::Drawable.");
|
||||||
|
// Read Text's properties
|
||||||
|
|
||||||
|
unsigned int width, height;
|
||||||
|
float c_height, aspectRatio;
|
||||||
|
|
||||||
|
setFont(in->readString());
|
||||||
|
|
||||||
|
width = in->readUInt();
|
||||||
|
height = in->readUInt();
|
||||||
|
|
||||||
|
setFontResolution(width,height);
|
||||||
|
|
||||||
|
c_height = in->readFloat();
|
||||||
|
aspectRatio = in->readFloat();
|
||||||
|
|
||||||
|
setCharacterSize(c_height,aspectRatio);
|
||||||
|
|
||||||
|
setCharacterSizeMode((osgText::TextBase::CharacterSizeMode) in->readUInt());
|
||||||
|
|
||||||
|
setMaximumWidth(in->readFloat());
|
||||||
|
setMaximumHeight(in->readFloat());
|
||||||
|
|
||||||
|
if ( in->getVersion() >= VERSION_0020 )
|
||||||
|
{
|
||||||
|
setLineSpacing(in->readFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
setAlignment((osgText::TextBase::AlignmentType) in->readUInt());
|
||||||
|
|
||||||
|
//Nothing to do...
|
||||||
|
//setAxisAlignment((osgText::Text::AxisAlignment) in->readUint());
|
||||||
|
|
||||||
|
setRotation(in->readQuat());
|
||||||
|
setAutoRotateToScreen(in->readBool());
|
||||||
|
setLayout((osgText::Text::Layout) in->readUInt());
|
||||||
|
|
||||||
|
setPosition(in->readVec3());
|
||||||
|
// setColor(in->readVec4());
|
||||||
|
setDrawMode(in->readUInt());
|
||||||
|
|
||||||
|
//for text3d's property
|
||||||
|
setCharacterDepth(in->readFloat());
|
||||||
|
setRenderMode((osgText::Text3D::RenderMode) in->readUInt());
|
||||||
|
|
||||||
|
if(in->readBool())
|
||||||
|
setText(in->readString());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( in->getVersion() >= VERSION_0018 )
|
||||||
|
{
|
||||||
|
osgText::String textstr;
|
||||||
|
osg::ref_ptr<osg::UIntArray> arr = in->readUIntArray();
|
||||||
|
for(unsigned int i = 0; i < arr->getNumElements(); i++)
|
||||||
|
{
|
||||||
|
textstr.push_back( arr->at(i) );
|
||||||
|
}
|
||||||
|
|
||||||
|
setText(textstr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// buggy original path, should have used a UIntArray originally, now fixed above.
|
||||||
|
std::string textstr;
|
||||||
|
osg::ref_ptr<osg::UByteArray> arr = in->readUByteArray();
|
||||||
|
for(unsigned int i = 0; i < arr->getNumElements(); i++)
|
||||||
|
{
|
||||||
|
textstr += (char) arr->at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
setText(textstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
throw Exception("Text3D::read(): Expected ShadeModel identification.");
|
||||||
|
}
|
||||||
|
}
|
15
src/osgPlugins/ive/Text3D.h
Normal file
15
src/osgPlugins/ive/Text3D.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef IVE_TEXT3D
|
||||||
|
#define IVE_TEXT3D 1
|
||||||
|
|
||||||
|
#include <osgText/Text3D>
|
||||||
|
#include "ReadWrite.h"
|
||||||
|
|
||||||
|
namespace ive{
|
||||||
|
class Text3D : public osgText::Text3D, public ReadWrite {
|
||||||
|
public:
|
||||||
|
void write(DataOutputStream* out);
|
||||||
|
void read(DataInputStream* in);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user