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

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

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/**********************************************************************
2 *
3 *    FILE:            Stencil.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::Stencil in binary format to disk.
6 *
7 *    CREATED BY:        Auto generated by iveGenerated
8 *                    and later modified by Rune Schmidt Jensen.
9 *
10 *    HISTORY:        Created 21.3.2003
11 *
12 *    Copyright 2003 VR-C
13 **********************************************************************/
14
15#include "Exception.h"
16#include "Stencil.h"
17#include "Object.h"
18
19using namespace ive;
20
21void Stencil::write(DataOutputStream* out){
22    // Write Stencil's identification.
23    out->writeInt(IVESTENCIL);
24    // If the osg class is inherited by any other class we should also write this to file.
25    osg::Object*  obj = dynamic_cast<osg::Object*>(this);
26    if(obj){
27        ((ive::Object*)(obj))->write(out);
28    }
29    else
30        out_THROW_EXCEPTION("Stencil::write(): Could not cast this osg::Stencil to an osg::Object.");
31    // Write Stencil's properties.
32
33    out->writeInt(getFunction());
34    out->writeInt(getFunctionRef());
35    out->writeUInt(getFunctionMask());
36
37    out->writeInt(getStencilFailOperation());
38    out->writeInt(getStencilPassAndDepthFailOperation());
39    out->writeInt(getStencilPassAndDepthPassOperation());
40
41    out->writeUInt(getWriteMask());
42
43
44}
45
46void Stencil::read(DataInputStream* in){
47    // Peek on Stencil's identification.
48    int id = in->peekInt();
49    if(id == IVESTENCIL)
50    {
51        // Read Stencil's identification.
52        id = in->readInt();
53        // If the osg class is inherited by any other class we should also read this from file.
54        osg::Object*  obj = dynamic_cast<osg::Object*>(this);
55        if(obj){
56            ((ive::Object*)(obj))->read(in);
57        }
58        else
59            in_THROW_EXCEPTION("Stencil::read(): Could not cast this osg::Stencil to an osg::Object.");
60
61        setFunction((Function)in->readInt());
62        setFunctionRef(in->readInt());
63        setFunctionMask(in->readUInt());
64
65        setStencilFailOperation((Operation)in->readInt());
66        setStencilPassAndDepthFailOperation((Operation)in->readInt());
67        setStencilPassAndDepthPassOperation((Operation)in->readInt());
68
69        setWriteMask(in->readUInt());
70
71    }
72    else{
73        in_THROW_EXCEPTION("Stencil::read(): Expected Stencil identification.");
74    }
75}
Note: See TracBrowser for help on using the browser.