~saiarcot895/ubuntu/trusty/openscenegraph/armhf-support

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osgPlugins/ive/Cartoon.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Loic Dachary (OuoU)
  • Date: 2009-03-23 14:08:20 UTC
  • mfrom: (1.1.7 upstream) (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090323140820-i4j3jozdlhyn4lre
rules prevent lib64 with -D LIB_POSTFIX="" (Closes: #517671)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************************
 
2
 *
 
3
 *    FILE:           Cartoon.cpp
 
4
 *
 
5
 *    DESCRIPTION:    Read/Write osgFX::Cartoon 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 "Cartoon.h"
 
15
#include "Effect.h"
 
16
 
 
17
using namespace ive;
 
18
 
 
19
void Cartoon::write(DataOutputStream* out){
 
20
    // Write Cartoon's identification.
 
21
    out->writeInt(IVECARTOON);
 
22
    // If the osg class is inherited by any other class we should also write this to file.
 
23
    osgFX::Effect*  effect = dynamic_cast<osgFX::Effect*>(this);
 
24
    if(effect){
 
25
        ((ive::Effect*)(effect))->write(out);
 
26
    }
 
27
    else
 
28
        throw Exception("Cartoon::write(): Could not cast this osgFX::Cartoon to an osgFX::Effect.");
 
29
 
 
30
    // Write Cartoon's properties.
 
31
    out->writeVec4(getOutlineColor());
 
32
    out->writeFloat(getOutlineLineWidth());
 
33
    out->writeInt(getLightNumber());
 
34
}
 
35
 
 
36
void Cartoon::read(DataInputStream* in){
 
37
    // Peek on Cartoon's identification.
 
38
    int id = in->peekInt();
 
39
    if(id == IVECARTOON){
 
40
        // Read Cartoon'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
        osgFX::Effect*  effect = dynamic_cast<osgFX::Effect*>(this);
 
45
        if(effect){
 
46
            ((ive::Effect*)(effect))->read(in);
 
47
        }
 
48
        else
 
49
            throw Exception("Cartoon::read(): Could not cast this osgFX::Cartoon to an osgFX::Effect.");
 
50
 
 
51
        // Read Cartoon's properties
 
52
        setOutlineColor(in->readVec4());
 
53
        setOutlineLineWidth(in->readFloat());
 
54
        setLightNumber(in->readInt());
 
55
    }
 
56
    else{
 
57
        throw Exception("Cartoon::read(): Expected Cartoon identification.");
 
58
    }
 
59
}