cartoon.cpp

来自「最新osg包」· C++ 代码 · 共 60 行

CPP
60
字号
/********************************************************************** * *    FILE:           Cartoon.cpp * *    DESCRIPTION:    Read/Write osgFX::Cartoon in binary format to disk. * *    CREATED BY:     Liang Aibin * *    HISTORY:        Created 23.8.2008 * **********************************************************************/#include "Exception.h"#include "Cartoon.h"#include "Effect.h"using namespace ive;void Cartoon::write(DataOutputStream* out){    // Write Cartoon's identification.    out->writeInt(IVECARTOON);    // If the osg class is inherited by any other class we should also write this to file.    osgFX::Effect*  effect = dynamic_cast<osgFX::Effect*>(this);    if(effect){        ((ive::Effect*)(effect))->write(out);    }    else        throw Exception("Cartoon::write(): Could not cast this osgFX::Cartoon to an osgFX::Effect.");    // Write Cartoon's properties.    out->writeVec4(getOutlineColor());    out->writeFloat(getOutlineLineWidth());    out->writeInt(getLightNumber());}void Cartoon::read(DataInputStream* in){    // Peek on Cartoon's identification.    int id = in->peekInt();    if(id == IVECARTOON){        // Read Cartoon's identification.        id = in->readInt();        // If the osg class is inherited by any other class we should also read this from file.        osgFX::Effect*  effect = dynamic_cast<osgFX::Effect*>(this);        if(effect){            ((ive::Effect*)(effect))->read(in);        }        else            throw Exception("Cartoon::read(): Could not cast this osgFX::Cartoon to an osgFX::Effect.");        // Read Cartoon's properties        setOutlineColor(in->readVec4());        setOutlineLineWidth(in->readFloat());        setLightNumber(in->readInt());    }    else{        throw Exception("Cartoon::read(): Expected Cartoon identification.");    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?