root/OpenSceneGraph/trunk/src/osgPlugins/ive/Effect.cpp @ 13041

Revision 13041, 1.7 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/**********************************************************************
2 *
3 *    FILE:           Effect.cpp
4 *
5 *    DESCRIPTION:    Read/Write osgFX::Effect in binary format to disk.
6 *
7 *    CREATED BY:     Liang Aibin
8 *
9 *    HISTORY:        Created 23.8.2008
10 *
11 **********************************************************************/
12
13#include "Exception.h"
14#include "Effect.h"
15#include "Group.h"
16
17using namespace ive;
18
19void Effect::write(DataOutputStream* out){
20    // Write Effect's identification.
21    out->writeInt(IVEEFFECT);
22    // If the osg class is inherited by any other class we should also write this to file.
23    osg::Group*  group = dynamic_cast<osg::Group*>(this);
24    if(group){
25        ((ive::Group*)(group))->write(out);
26    }
27    else
28        out_THROW_EXCEPTION("Effect::write(): Could not cast this osgFX::Effect to an osg::Group.");
29
30    // Write Effect's properties.
31    out->writeBool(getEnabled());
32
33    out->writeInt(getSelectedTechnique());
34}
35
36void Effect::read(DataInputStream* in){
37    // Peek on Effect's identification.
38    int id = in->peekInt();
39    if(id == IVEEFFECT){
40        // Read Effect's identification.
41        id = in->readInt();
42
43        // If the osg class is inherited by any other class we should also read this from file.
44        osg::Group*  group = dynamic_cast<osg::Group*>(this);
45        if(group){
46            ((ive::Group*)(group))->read(in);
47        }
48        else
49            in_THROW_EXCEPTION("Effect::read(): Could not cast this osgFX::Effect to an osg::Group.");
50
51        // Read Effect's properties
52        setEnabled(in->readBool());
53
54        selectTechnique(in->readInt());
55    }
56    else{
57        in_THROW_EXCEPTION("Effect::read(): Expected Effect identification.");
58    }
59}
Note: See TracBrowser for help on using the browser.