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

Revision 13041, 3.2 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

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 "StencilTwoSided.h"
17#include "Object.h"
18
19using namespace ive;
20
21void StencilTwoSided::write(DataOutputStream* out){
22    // Write Stencil's identification.
23    out->writeInt(IVESTENCILTWOSIDED);
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(FRONT));
34    out->writeInt(getFunctionRef(FRONT));
35    out->writeUInt(getFunctionMask(FRONT));
36
37    out->writeInt(getStencilFailOperation(FRONT));
38    out->writeInt(getStencilPassAndDepthFailOperation(FRONT));
39    out->writeInt(getStencilPassAndDepthPassOperation(FRONT));
40
41    out->writeUInt(getWriteMask(FRONT));
42
43    out->writeInt(getFunction(BACK));
44    out->writeInt(getFunctionRef(BACK));
45    out->writeUInt(getFunctionMask(BACK));
46
47    out->writeInt(getStencilFailOperation(BACK));
48    out->writeInt(getStencilPassAndDepthFailOperation(BACK));
49    out->writeInt(getStencilPassAndDepthPassOperation(BACK));
50
51    out->writeUInt(getWriteMask(BACK));
52}
53
54void StencilTwoSided::read(DataInputStream* in){
55    // Peek on Stencil's identification.
56    int id = in->peekInt();
57    if(id == IVESTENCILTWOSIDED)
58    {
59        // Read Stencil's identification.
60        id = in->readInt();
61        // If the osg class is inherited by any other class we should also read this from file.
62        osg::Object*  obj = dynamic_cast<osg::Object*>(this);
63        if(obj){
64            ((ive::Object*)(obj))->read(in);
65        }
66        else
67            in_THROW_EXCEPTION("Stencil::read(): Could not cast this osg::Stencil to an osg::Object.");
68
69        setFunction(FRONT, (Function)in->readInt());
70        setFunctionRef(FRONT, in->readInt());
71        setFunctionMask(FRONT, in->readUInt());
72
73        setStencilFailOperation(FRONT, (Operation)in->readInt());
74        setStencilPassAndDepthFailOperation(FRONT, (Operation)in->readInt());
75        setStencilPassAndDepthPassOperation(FRONT, (Operation)in->readInt());
76
77        setWriteMask(FRONT, in->readUInt());
78
79        setFunction(BACK, (Function)in->readInt());
80        setFunctionRef(BACK, in->readInt());
81        setFunctionMask(BACK, in->readUInt());
82
83        setStencilFailOperation(BACK, (Operation)in->readInt());
84        setStencilPassAndDepthFailOperation(BACK, (Operation)in->readInt());
85        setStencilPassAndDepthPassOperation(BACK, (Operation)in->readInt());
86
87        setWriteMask(BACK, in->readUInt());
88    }
89    else{
90        in_THROW_EXCEPTION("Stencil::read(): Expected Stencil identification.");
91    }
92}
Note: See TracBrowser for help on using the browser.