Revision c38d81dd

b/include/GeometryNode.h
67 67
    virtual ~GeometryNode();
68 68
    
69 69
    virtual void callbackUpdate();
70

  
71
    void setStateSetFromFile(const char* filename);
72
    void setStateSet        (const char* s);
73
    const char *getStateSet () const { return stateset->s_name; }
74
    void updateStateSet        ();
75

  
76
    int getRenderBin() const { return renderBin_; }
77
    int getLighting() const { return (int)lightingEnabled_; }
78
    
79
    void setRenderBin(int i);
80
    void setLighting(int i);
70
    virtual void updateStateSet();
81 71
    
82 72
    void setNumVertices(int i);
83 73
    void setVertex(int index, float x, float y, float z);
......
86 76

  
87 77
    virtual std::vector<lo_message> getState() const;
88 78

  
89
    
90 79
private:
91 80
    
92 81
    osg::ref_ptr<osg::Geode> geode_;
93 82
    osg::ref_ptr<osg::Geometry> geometry_;
94 83
    unsigned int numVertices_;
95 84
    
96
    t_symbol *stateset;
97
    
98
    int renderBin_;
99
    bool lightingEnabled_;
100 85
    bool updateFlag_;
101
    
102 86
};
103 87

  
104 88
} // end of namespace spin
b/include/GroupNode.h
102 102
    };
103 103
    enum globalsReportMode { NONE, GLOBAL_6DOF, GLOBAL_ALL };
104 104
    enum velocityMode { TRANSLATE, MOVE };
105
    
105
    enum ComputationMode { SERVER_SIDE, CLIENT_SIDE };
106 106
    enum OrientationMode
107 107
    {
108 108
        NORMAL,
......
130 130
    		float x, float y, float z);
131 131
	void setLock(const char* userString, int lock);
132 132

  
133

  
133
    /**
134
     * Print debug information about the node to standard out (when running in
135
     * console mode). It may be possible to redirect this to a text box for GUI
136
     * logs.
137
     */
134 138
    virtual void debug();
135 139
    
140
    /**
141
     * setStateSetFromFile guesses the type of stateset from the filename
142
     * extension, creates a new stateset of that type and assigns it to this
143
     * node
144
     */
145
    void setStateSetFromFile(const char* filename);
146
    
147
    /**
148
     * Assign an existing stateset to this node
149
     */
150
    void setStateSet(const char* s);
151
    t_symbol* getStateSetSymbol() const { return stateset_; }
152
    
153
    /**
154
     * This method actually applies the stateset to the subgraph, replacing any
155
     * existing stateset with this one. The setStateSet and setStateSetFromFile
156
     * methods just set the stateset_ symbol, while updateStateSet does the
157
     * actual work.
158
     *
159
     * Override this method in subclasses in order to change how stateset should
160
     * be applied. For example, to which node in the subgraph it should be
161
     * attached, or whether it should be merged with the existing stateset
162
     * (rather than merged).
163
     *
164
     * By default it is applied to the mainTransform.
165
     */
166
    virtual void updateStateSet();
167
    
168
    
136 169
    void setReportMode(globalsReportMode mode);
137 170

  
138 171
    void setInteractionMode(InteractionMode mode);
139 172
    
173
    void setComputationMode(ComputationMode mode);
174
    int getComputationMode() const { return (int)computationMode_; };
175

  
140 176
    /**
141 177
     * Set a clipping rectangle for the model so that geometry outside of the
142 178
     * region (+-x, +-y, +-z) will not be shown (or used in interactive events)
......
300 336
    void drawManipulator();
301 337

  
302 338
    osg::ref_ptr<UserNode> owner;
339
    
340
    t_symbol *stateset_;
303 341

  
304 342
    //osg::ref_ptr<osg::PositionAttitudeTransform> mainTransform;
305 343
    osg::ref_ptr<osg::MatrixTransform> mainTransform;
......
319 357
    osg::Vec3 _globalScale;
320 358
    float _globalRadius;
321 359

  
360
    bool computationMode_;
361

  
322 362
    enum OrientationMode orientationMode_;
323 363
    t_symbol* orientationTarget_;
324 364
    osg::Vec3 _orientation; // store the orientation as it comes in (in degrees)
......
337 377
    
338 378
private:
339 379

  
340
    
341 380
    osg::Timer_t lastTick;
342 381

  
343 382
};
b/include/ImageTexture.h
69 69
    ImageTexture(SceneManager *sceneManager, const char *initID);
70 70
    ~ImageTexture();
71 71

  
72
    /**
73
     * TO_BE_DONE
74
     */
72
    enum TextureMode { TEXTURE_2D, TEXTURE_RECTANGLE };
75 73

  
76 74
    virtual void debug();
77 75
    
......
86 84
    void setPath (const char* newPath);
87 85
    const char *getPath() const { return _path.c_str(); }
88 86

  
87
    void setTextureMode(TextureMode mode);
88
    int getTextureMode() const { return (int)textureMode_; };
89

  
89 90
    // must reimplement
90 91
    virtual std::vector<lo_message> getState() const;
91 92

  
92
    
93
protected:
94

  
95
    void draw();
96

  
93 97
private:
94 98
    
95 99
    osg::ref_ptr<osg::Image> _image;
96 100
    std::string _path;
97

  
98
    bool _useTextureRectangle;
101
    
102
    TextureMode textureMode_;
99 103
};
100 104

  
101 105
} // end of namespace spin
b/include/ModelNode.h
184 184
     * Note: for this to work, stateRegistration must be enabled.
185 185
     */
186 186
    void setStateSet (int index, const char *replacement);
187
    void updateStateSet();
187 188

  
188 189
    /**
189 190
     * For each subclass of ReferencedNode, we override the getState() method to
b/include/ShapeNode.h
108 108
     * \param alpha Opacity channel. Number in the range [0, 1]
109 109
     */
110 110
    void setColor            (float red, float green, float blue, float alpha);
111
    void setTextureFromFile    (const char* filename);
112 111
    void setRenderBin        (int i);
113 112
    void setLighting        (int i);
114 113

  
115
    void setStateSetFromFile(const char* filename);
116
    void setStateSet        (const char* s);
117
    const char *getStateSet () const { return stateset->s_name; }
118
    void updateStateSet        ();
114
    virtual void updateStateSet();
119 115

  
120 116
    int getShape() const { return (int)shape; }
121 117
    int getBillboard() const { return (int)billboard; }
......
123 119
    int getRenderBin() const { return renderBin; }
124 120
    int getLighting() const { return (int)lightingEnabled; }
125 121

  
126
    //void addSharedVideoTexture(osg::Node *n, std::string shID);
127
    //void addVideoTexture(osg::Node *n, std::string texturePath);
128
    void addImageTexture(osg::Node *n, std::string texturePath);
129 122
    
130 123
    /**
131 124
     * For each subclass of ReferencedNode, we override the getState() method to
......
135 128

  
136 129
    shapeType shape;
137 130
    
138
    t_symbol *stateset;
139 131

  
140 132
    billboardType billboard;
141 133

  
......
145 137
    std::string texturePath;
146 138

  
147 139
    int renderBin;
148

  
149 140
    bool lightingEnabled;
150 141

  
151 142
    //osg::ref_ptr<osg::Image> textureImage; // store textureImage so we don't waste time in the callback
......
156 147

  
157 148
protected:
158 149
    virtual void drawShape();
159
    virtual void drawTexture();
160 150

  
161 151
};
162 152

  
b/src/osgWrappers/introspection/CollisionShape.cpp
37 37
	          Properties::VIRTUAL,
38 38
	          __void__debug,
39 39
	          "",
40
	          "Debug print (to log/console) ");
40
	          "Print debug information about the node to standard out (when running in console mode). It may be possible to redirect this to a text box for GUI logs. ");
41 41
	I_Method1(void, setMass, IN, float, mass,
42 42
	          Properties::NON_VIRTUAL,
43 43
	          __void__setMass__float,
b/src/osgWrappers/introspection/GeometryNode.cpp
33 33
	          __void__callbackUpdate,
34 34
	          "",
35 35
	          "For nodes that require regular programmatic control, there is a callback that is evaluated with every refresh. This function can thus be used for animations, or any other periodic updates.Note that changes to the scene graph structure (eg, moving/deleting nodes should NOT be done within this callback because traversals stacks will become corrupted. The technique is rather to enable a flag and then do the actual change in the SceneManager::updateGraph() method. ");
36
	I_Method1(void, setStateSetFromFile, IN, const char *, filename,
37
	          Properties::NON_VIRTUAL,
38
	          __void__setStateSetFromFile__C5_char_P1,
39
	          "",
40
	          "");
41
	I_Method1(void, setStateSet, IN, const char *, s,
42
	          Properties::NON_VIRTUAL,
43
	          __void__setStateSet__C5_char_P1,
44
	          "",
45
	          "");
46
	I_Method0(const char *, getStateSet,
47
	          Properties::NON_VIRTUAL,
48
	          __C5_char_P1__getStateSet,
49
	          "",
50
	          "");
51 36
	I_Method0(void, updateStateSet,
52 37
	          Properties::VIRTUAL,
53 38
	          __void__updateStateSet,
54 39
	          "",
55
	          "In derived classes, you can handle how a stateset gets applied to a node (eg, which part of the subgraph it is attached by overriding the updateStateSet method. ");
56
	I_Method0(int, getRenderBin,
57
	          Properties::NON_VIRTUAL,
58
	          __int__getRenderBin,
59
	          "",
60
	          "");
61
	I_Method0(int, getLighting,
62
	          Properties::NON_VIRTUAL,
63
	          __int__getLighting,
64
	          "",
65
	          "");
66
	I_Method1(void, setRenderBin, IN, int, i,
67
	          Properties::NON_VIRTUAL,
68
	          __void__setRenderBin__int,
69
	          "",
70
	          "");
71
	I_Method1(void, setLighting, IN, int, i,
72
	          Properties::NON_VIRTUAL,
73
	          __void__setLighting__int,
74
	          "",
75
	          "");
40
	          "This method actually applies the stateset to the subgraph, replacing any existing stateset with this one. The setStateSet and setStateSetFromFile methods just set the stateset_ symbol, while updateStateSet does the actual work.Override this method in subclasses in order to change how stateset should be applied. For example, to which node in the subgraph it should be attached, or whether it should be merged with the existing stateset (rather than merged).By default it is applied to the mainTransform. ");
76 41
	I_Method1(void, setNumVertices, IN, int, i,
77 42
	          Properties::NON_VIRTUAL,
78 43
	          __void__setNumVertices__int,
......
98 63
	          __std_vectorT1_lo_message___getState,
99 64
	          "",
100 65
	          "For each subclass of ReferencedNode, we override the getState() method to fill the vector with the correct set of methods for this particular node ");
101
	I_SimpleProperty(int, Lighting, 
102
	                 __int__getLighting, 
103
	                 __void__setLighting__int);
104 66
	I_SimpleProperty(int, NumVertices, 
105 67
	                 0, 
106 68
	                 __void__setNumVertices__int);
107
	I_SimpleProperty(int, RenderBin, 
108
	                 __int__getRenderBin, 
109
	                 __void__setRenderBin__int);
110 69
	I_SimpleProperty(std::vector< lo_message >, State, 
111 70
	                 __std_vectorT1_lo_message___getState, 
112 71
	                 0);
113
	I_SimpleProperty(const char *, StateSet, 
114
	                 __C5_char_P1__getStateSet, 
115
	                 __void__setStateSet__C5_char_P1);
116
	I_SimpleProperty(const char *, StateSetFromFile, 
117
	                 0, 
118
	                 __void__setStateSetFromFile__C5_char_P1);
119 72
END_REFLECTOR
120 73

  
b/src/osgWrappers/introspection/GroupNode.cpp
12 12

  
13 13
#include <GroupNode.h>
14 14
#include <SceneManager.h>
15
#include <spinUtil.h>
15 16

  
16 17
// Must undefine IN and OUT macros defined in Windows headers
17 18
#ifdef IN
......
58 59
	I_EnumLabel(spin::GroupNode::MOVE);
59 60
END_REFLECTOR
60 61

  
62
BEGIN_ENUM_REFLECTOR(spin::GroupNode::ComputationMode)
63
	I_DeclaringFile("GroupNode.h");
64
	I_EnumLabel(spin::GroupNode::SERVER_SIDE);
65
	I_EnumLabel(spin::GroupNode::CLIENT_SIDE);
66
END_REFLECTOR
67

  
61 68
BEGIN_ENUM_REFLECTOR(spin::GroupNode::OrientationMode)
62 69
	I_DeclaringFile("GroupNode.h");
63 70
	I_EnumLabel(spin::GroupNode::NORMAL);
......
102 109
	          Properties::VIRTUAL,
103 110
	          __void__debug,
104 111
	          "",
105
	          "Debug print (to log/console) ");
112
	          "Print debug information about the node to standard out (when running in console mode). It may be possible to redirect this to a text box for GUI logs. ");
113
	I_Method1(void, setStateSetFromFile, IN, const char *, filename,
114
	          Properties::NON_VIRTUAL,
115
	          __void__setStateSetFromFile__C5_char_P1,
116
	          "",
117
	          "setStateSetFromFile guesses the type of stateset from the filename extension, creates a new stateset of that type and assigns it to this node ");
118
	I_Method1(void, setStateSet, IN, const char *, s,
119
	          Properties::NON_VIRTUAL,
120
	          __void__setStateSet__C5_char_P1,
121
	          "",
122
	          "Assign an existing stateset to this node ");
123
	I_Method0(spin::t_symbol *, getStateSetSymbol,
124
	          Properties::NON_VIRTUAL,
125
	          __t_symbol_P1__getStateSetSymbol,
126
	          "",
127
	          "");
128
	I_Method0(void, updateStateSet,
129
	          Properties::VIRTUAL,
130
	          __void__updateStateSet,
131
	          "",
132
	          "This method actually applies the stateset to the subgraph, replacing any existing stateset with this one. The setStateSet and setStateSetFromFile methods just set the stateset_ symbol, while updateStateSet does the actual work.Override this method in subclasses in order to change how stateset should be applied. For example, to which node in the subgraph it should be attached, or whether it should be merged with the existing stateset (rather than merged).By default it is applied to the mainTransform. ");
106 133
	I_Method1(void, setReportMode, IN, spin::GroupNode::globalsReportMode, mode,
107 134
	          Properties::NON_VIRTUAL,
108 135
	          __void__setReportMode__globalsReportMode,
......
113 140
	          __void__setInteractionMode__InteractionMode,
114 141
	          "",
115 142
	          "");
143
	I_Method1(void, setComputationMode, IN, spin::GroupNode::ComputationMode, mode,
144
	          Properties::NON_VIRTUAL,
145
	          __void__setComputationMode__ComputationMode,
146
	          "",
147
	          "");
148
	I_Method0(int, getComputationMode,
149
	          Properties::NON_VIRTUAL,
150
	          __int__getComputationMode,
151
	          "",
152
	          "");
116 153
	I_Method3(void, setClipping, IN, float, x, IN, float, y, IN, float, z,
117 154
	          Properties::NON_VIRTUAL,
118 155
	          __void__setClipping__float__float__float,
......
316 353
	I_SimpleProperty(osg::Vec3, Clipping, 
317 354
	                 __osg_Vec3__getClipping, 
318 355
	                 0);
356
	I_SimpleProperty(int, ComputationMode, 
357
	                 __int__getComputationMode, 
358
	                 0);
319 359
	I_SimpleProperty(float, Damping, 
320 360
	                 __float__getDamping, 
321 361
	                 __void__setDamping__float);
......
349 389
	I_SimpleProperty(std::vector< lo_message >, State, 
350 390
	                 __std_vectorT1_lo_message___getState, 
351 391
	                 0);
392
	I_SimpleProperty(const char *, StateSet, 
393
	                 0, 
394
	                 __void__setStateSet__C5_char_P1);
395
	I_SimpleProperty(const char *, StateSetFromFile, 
396
	                 0, 
397
	                 __void__setStateSetFromFile__C5_char_P1);
398
	I_SimpleProperty(spin::t_symbol *, StateSetSymbol, 
399
	                 __t_symbol_P1__getStateSetSymbol, 
400
	                 0);
352 401
	I_SimpleProperty(osg::MatrixTransform *, Transform, 
353 402
	                 __osg_MatrixTransform_P1__getTransform, 
354 403
	                 0);
b/src/osgWrappers/introspection/ImageTexture.cpp
21 21
#undef OUT
22 22
#endif
23 23

  
24
BEGIN_ENUM_REFLECTOR(spin::ImageTexture::TextureMode)
25
	I_DeclaringFile("ImageTexture.h");
26
	I_EnumLabel(spin::ImageTexture::TEXTURE_2D);
27
	I_EnumLabel(spin::ImageTexture::TEXTURE_RECTANGLE);
28
END_REFLECTOR
29

  
24 30
BEGIN_OBJECT_REFLECTOR(spin::ImageTexture)
25 31
	I_DeclaringFile("ImageTexture.h");
26 32
	I_BaseType(spin::Shader);
......
32 38
	          Properties::VIRTUAL,
33 39
	          __void__debug,
34 40
	          "",
35
	          "TO_BE_DONE ");
41
	          "Print debug information to console. ");
36 42
	I_Method0(bool, isValid,
37 43
	          Properties::NON_VIRTUAL,
38 44
	          __bool__isValid,
......
48 54
	          __C5_char_P1__getPath,
49 55
	          "",
50 56
	          "");
57
	I_Method1(void, setTextureMode, IN, spin::ImageTexture::TextureMode, mode,
58
	          Properties::NON_VIRTUAL,
59
	          __void__setTextureMode__TextureMode,
60
	          "",
61
	          "");
62
	I_Method0(int, getTextureMode,
63
	          Properties::NON_VIRTUAL,
64
	          __int__getTextureMode,
65
	          "",
66
	          "");
51 67
	I_Method0(std::vector< lo_message >, getState,
52 68
	          Properties::VIRTUAL,
53 69
	          __std_vectorT1_lo_message___getState,
54 70
	          "",
55 71
	          "Just like a ReferencedNode, each subclass of ReferencedStateSet must override the getState() method to pass it's current state. ");
72
	I_ProtectedMethod0(void, draw,
73
	                   Properties::NON_VIRTUAL,
74
	                   Properties::NON_CONST,
75
	                   __void__draw,
76
	                   "",
77
	                   "");
56 78
	I_SimpleProperty(const char *, Path, 
57 79
	                 __C5_char_P1__getPath, 
58 80
	                 __void__setPath__C5_char_P1);
59 81
	I_SimpleProperty(std::vector< lo_message >, State, 
60 82
	                 __std_vectorT1_lo_message___getState, 
61 83
	                 0);
84
	I_SimpleProperty(int, TextureMode, 
85
	                 __int__getTextureMode, 
86
	                 0);
62 87
END_REFLECTOR
63 88

  
b/src/osgWrappers/introspection/Menu3D.cpp
172 172
	                 0);
173 173
END_REFLECTOR
174 174

  
175
TYPE_NAME_ALIAS(std::vector< osg::observer_ptr< spin::TextNode > >, spin::MenuVector)
176

  
177
STD_VECTOR_REFLECTOR(std::vector< osg::observer_ptr< spin::TextNode > >)
178

  
b/src/osgWrappers/introspection/ModelNode.cpp
115 115
	          __void__setStateSet__int__C5_char_P1,
116 116
	          "",
117 117
	          "For statesets embedded in the model, it is possible to swap with some other (already existing) stateset.Note: for this to work, stateRegistration must be enabled. ");
118
	I_Method0(void, updateStateSet,
119
	          Properties::VIRTUAL,
120
	          __void__updateStateSet,
121
	          "",
122
	          "This method actually applies the stateset to the subgraph, replacing any existing stateset with this one. The setStateSet and setStateSetFromFile methods just set the stateset_ symbol, while updateStateSet does the actual work.Override this method in subclasses in order to change how stateset should be applied. For example, to which node in the subgraph it should be attached, or whether it should be merged with the existing stateset (rather than merged).By default it is applied to the mainTransform. ");
118 123
	I_Method0(std::vector< lo_message >, getState,
119 124
	          Properties::VIRTUAL,
120 125
	          __std_vectorT1_lo_message___getState,
b/src/osgWrappers/introspection/PointCloud.cpp
56 56
	          Properties::VIRTUAL,
57 57
	          __void__debug,
58 58
	          "",
59
	          "Debug print (to log/console) ");
59
	          "Print debug information about the node to standard out (when running in console mode). It may be possible to redirect this to a text box for GUI logs. ");
60 60
	I_Method0(void, callbackUpdate,
61 61
	          Properties::VIRTUAL,
62 62
	          __void__callbackUpdate,
b/src/osgWrappers/introspection/SceneManager.cpp
282 282
	          __void__setUpdateRate__float,
283 283
	          "",
284 284
	          "Sets the update delay for the physics engine (in seconds). The default is 0.02 seconds (ie, 50hz). ");
285
	I_Method2(void, detectCollision, IN, bool &, lastColState, IN, btCollisionWorld *, cw,
286
	          Properties::NON_VIRTUAL,
287
	          __void__detectCollision__bool_R1__btCollisionWorld_P1,
288
	          "",
289
	          "");
285 290
	I_SimpleProperty(std::vector< std::string >, AllNodeTypes, 
286 291
	                 __std_vectorT1_std_string___getAllNodeTypes, 
287 292
	                 0);
......
311 316
	I_PublicMemberProperty(bool, graphicalMode);
312 317
	I_PublicMemberProperty(osg::ref_ptr< spin::GroupNode >, globalObserver);
313 318
	I_PublicMemberProperty(std::string, resourcesPath);
319
	I_PublicMemberProperty(bool, lastColState);
320
	I_PublicMemberProperty(btDynamicsWorld *, dynamicsWorld_);
314 321
END_REFLECTOR
315 322

  
316 323
TYPE_NAME_ALIAS(std::vector< osg::ref_ptr< spin::ReferencedNode > >, spin::nodeListType)
b/src/osgWrappers/introspection/ShapeNode.cpp
66 66
	          __void__setColor__float__float__float__float,
67 67
	          "",
68 68
	          " param red Red channel. Number in the range [0, 1]  green Green channel. Number in the range [0, 1]  blue Blue channel. Number in the range [0, 1]  alpha Opacity channel. Number in the range [0, 1]  ");
69
	I_Method1(void, setTextureFromFile, IN, const char *, filename,
70
	          Properties::NON_VIRTUAL,
71
	          __void__setTextureFromFile__C5_char_P1,
72
	          "",
73
	          "");
74 69
	I_Method1(void, setRenderBin, IN, int, i,
75 70
	          Properties::NON_VIRTUAL,
76 71
	          __void__setRenderBin__int,
......
81 76
	          __void__setLighting__int,
82 77
	          "",
83 78
	          "");
84
	I_Method1(void, setStateSetFromFile, IN, const char *, filename,
85
	          Properties::NON_VIRTUAL,
86
	          __void__setStateSetFromFile__C5_char_P1,
87
	          "",
88
	          "");
89
	I_Method1(void, setStateSet, IN, const char *, s,
90
	          Properties::NON_VIRTUAL,
91
	          __void__setStateSet__C5_char_P1,
92
	          "",
93
	          "");
94
	I_Method0(const char *, getStateSet,
95
	          Properties::NON_VIRTUAL,
96
	          __C5_char_P1__getStateSet,
97
	          "",
98
	          "");
99 79
	I_Method0(void, updateStateSet,
100 80
	          Properties::VIRTUAL,
101 81
	          __void__updateStateSet,
102 82
	          "",
103
	          "In derived classes, you can handle how a stateset gets applied to a node (eg, which part of the subgraph it is attached by overriding the updateStateSet method. ");
83
	          "This method actually applies the stateset to the subgraph, replacing any existing stateset with this one. The setStateSet and setStateSetFromFile methods just set the stateset_ symbol, while updateStateSet does the actual work.Override this method in subclasses in order to change how stateset should be applied. For example, to which node in the subgraph it should be attached, or whether it should be merged with the existing stateset (rather than merged).By default it is applied to the mainTransform. ");
104 84
	I_Method0(int, getShape,
105 85
	          Properties::NON_VIRTUAL,
106 86
	          __int__getShape,
......
126 106
	          __int__getLighting,
127 107
	          "",
128 108
	          "");
129
	I_Method2(void, addImageTexture, IN, osg::Node *, n, IN, std::string, texturePath,
130
	          Properties::NON_VIRTUAL,
131
	          __void__addImageTexture__osg_Node_P1__std_string,
132
	          "",
133
	          "");
134 109
	I_Method0(std::vector< lo_message >, getState,
135 110
	          Properties::VIRTUAL,
136 111
	          __std_vectorT1_lo_message___getState,
......
142 117
	                   __void__drawShape,
143 118
	                   "",
144 119
	                   "");
145
	I_ProtectedMethod0(void, drawTexture,
146
	                   Properties::VIRTUAL,
147
	                   Properties::NON_CONST,
148
	                   __void__drawTexture,
149
	                   "",
150
	                   "");
151 120
	I_SimpleProperty(int, Billboard, 
152 121
	                 __int__getBillboard, 
153 122
	                 0);
......
169 138
	I_SimpleProperty(std::vector< lo_message >, State, 
170 139
	                 __std_vectorT1_lo_message___getState, 
171 140
	                 0);
172
	I_SimpleProperty(const char *, StateSet, 
173
	                 __C5_char_P1__getStateSet, 
174
	                 __void__setStateSet__C5_char_P1);
175
	I_SimpleProperty(const char *, StateSetFromFile, 
176
	                 0, 
177
	                 __void__setStateSetFromFile__C5_char_P1);
178
	I_SimpleProperty(const char *, TextureFromFile, 
179
	                 0, 
180
	                 __void__setTextureFromFile__C5_char_P1);
181 141
	I_PublicMemberProperty(spin::ShapeNode::shapeType, shape);
182
	I_PublicMemberProperty(spin::t_symbol *, stateset);
183 142
	I_PublicMemberProperty(spin::ShapeNode::billboardType, billboard);
184 143
	I_PublicMemberProperty(osg::Vec4, _color);
185 144
	I_PublicMemberProperty(std::string, texturePath);
b/src/osgWrappers/introspection/spinApp.cpp
172 172
	I_PublicMemberProperty(boost::python::object, _pyNamespace);
173 173
	I_PublicMemberProperty(bool, _pyInitialized);
174 174
	I_PublicMemberProperty(osg::ref_ptr< spin::UserNode >, userNode);
175
	I_PublicMemberProperty(spatosc::Scene *, audioScene);
175 176
	I_PublicMemberProperty(bool, hasAudioRenderer);
176 177
	I_PublicMemberProperty(spin::SceneManager *, sceneManager);
177 178
END_REFLECTOR
b/src/spin/GeometryNode.cpp
69 69
	this->setName(string(id->s_name) + ".GeometryNode");
70 70
	nodeType = "GeometryNode";
71 71

  
72

  
73
	stateset = gensym("NULL");
74
	renderBin_ = 11;
75
	lightingEnabled_ = true;
76 72
    updateFlag_ = false;
77 73

  
78
    
79 74
    numVertices_ = 4;
80 75
    osg::Vec3Array *vertexArray_ = new osg::Vec3Array(numVertices_);
81 76
    osg::Vec4Array *colorArray_ = new osg::Vec4Array(numVertices_);
......
145 140
    
146 141
// -----------------------------------------------------------------------------
147 142

  
148

  
149
void GeometryNode::setStateSetFromFile(const char* filename)
150
{
151
	osg::ref_ptr<ReferencedStateSet> ss = sceneManager->createStateSet(filename);
152
	if (ss.valid())
153
	{
154
		if (ss->id == stateset) return; // we're already using that stateset
155
		stateset = ss->id;
156
		updateStateSet();
157
		BROADCAST(this, "ss", "setStateSet", getStateSet());
158
	}
159
}
160

  
161
void GeometryNode::setStateSet (const char* s)
162
{
163
	if (gensym(s)==stateset) return;
164

  
165
	osg::ref_ptr<ReferencedStateSet> ss = sceneManager->getStateSet(s);
166
	if (ss.valid())
167
	{
168
		stateset = ss->id;
169
		updateStateSet();
170
		BROADCAST(this, "ss", "setStateSet", getStateSet());
171
	}
172
}
173

  
174 143
void GeometryNode::updateStateSet()
175 144
{
176
	osg::ref_ptr<ReferencedStateSet> ss = dynamic_cast<ReferencedStateSet*>(stateset->s_thing);
145
	osg::ref_ptr<ReferencedStateSet> ss = dynamic_cast<ReferencedStateSet*>(stateset_->s_thing);
177 146
	if (geode_.valid() && ss.valid()) geode_->setStateSet( ss.get() );
178 147
}
179 148

  
180
 
181
void GeometryNode::setRenderBin (int i)
182
{
183
	if (renderBin_ == i) return;
184

  
185
	renderBin_ = i;
186

  
187
	if (geode_.valid())
188
	{
189
		osg::StateSet *ss = geode_->getOrCreateStateSet();
190
		ss->setRenderBinDetails( (int)renderBin_, "RenderBin");
191
		//setStateSet( shapeStateSet );
192
	}
193

  
194
	BROADCAST(this, "si", "setRenderBin", renderBin_);
195
}
196
    
197
void GeometryNode::setLighting (int i)
198
{
199
	if (lightingEnabled_==(bool)i) return;
200
	lightingEnabled_ = (bool)i;
201

  
202
	if (geode_.valid() && !stateset->s_thing)
203
	{
204
		osg::StateSet *ss = geode_->getOrCreateStateSet();
205
		if (lightingEnabled_) ss->setMode( GL_LIGHTING, osg::StateAttribute::ON );
206
		else ss->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
207
	}
208

  
209
	BROADCAST(this, "si", "setLighting", getLighting());
210

  
211
}
212
    
213 149
void GeometryNode::setNumVertices(int i)
214 150
{
215 151
    if (numVertices_ != i)
......
310 246
	osg::Vec3 v3;
311 247
	osg::Vec4 v4;
312 248

  
313
	msg = lo_message_new();
314
	lo_message_add(msg,  "ss", "setStateSet", getStateSet());
315
	ret.push_back(msg);
316

  
317
	msg = lo_message_new();
318
	lo_message_add(msg, "si", "setRenderBin", getRenderBin());
319
	ret.push_back(msg);
320

  
321
	msg = lo_message_new();
322
	lo_message_add(msg, "si", "setLighting", getLighting());
323
	ret.push_back(msg);
324

  
325 249
	// put this one last:
326 250
	/*
327 251
	msg = lo_message_new();
b/src/spin/GroupNode.cpp
210 210
    //mainTransform->setPosition(osg::Vec3(0.0,0.0,0.0));
211 211
    this->addChild(mainTransform.get());
212 212

  
213
    
213
    computationMode_ = SERVER_SIDE;
214

  
215
    stateset_ = gensym("NULL");
214 216

  
215 217
    clipNode = new osg::ClipNode();
216 218
    clipNode->setCullingActive(false);
......
259 261
    // Now we need to update translation/orientation based on our velocity/spin.
260 262
    // We find out how many seconds passed since the last time this was called,
261 263
    // and move by _velocity*dt (ie, m/s) and rotate by _spin*dt (ie, deg/sec)
262
    if ( spinApp::Instance().getContext()->isServer() )
264
    
265
    if (spinApp::Instance().getContext()->isServer())
266
    {
267
        if (computationMode_==SERVER_SIDE)
268
        {
269
            // update based on velocity and broadcast
270
        
271
        }
272
        else
273
        {
274
        
275
            // don't broadcast any massages but keep the node's position up to date
276
         }   
277
    }
278
    else
279
    {
280
        // just call move(), translate(), etc.
281
    }
282
    
283
    if (1)
263 284
    {
264 285
        osg::Timer_t tick = osg::Timer::instance()->tick();
265 286
        float dt = osg::Timer::instance()->delta_s(lastTick,tick);
......
515 536
}
516 537

  
517 538

  
518
// ***********************************************************
519
// ***********************************************************
539
// -----------------------------------------------------------------------------
520 540

  
521
/*
522
void GroupNode::reportGlobals (int b)
541
void GroupNode::setComputationMode (ComputationMode mode)
523 542
{
524
    if (this->_reportGlobals != (bool)b)
543
    if (this->computationMode_ != (int)mode)
525 544
    {
526
        this->_reportGlobals = (bool) b;
527
        BROADCAST(this, "si", "reportGlobals", (int) this->_reportGlobals);
545
        this->computationMode_ = mode;
546
        BROADCAST(this, "si", "setComputationMode", getComputationMode());
528 547
    }
529 548
}
530
*/
531 549

  
532 550
void GroupNode::setReportMode (globalsReportMode mode)
533 551
{
......
584 602
    }
585 603
}
586 604

  
605
// -----------------------------------------------------------------------------
606

  
607
void GroupNode::setStateSetFromFile(const char* filename)
608
{
609
	osg::ref_ptr<ReferencedStateSet> ss = sceneManager->createStateSet(filename);
610
	if (ss.valid())
611
	{
612
		if (ss->id == stateset_) return; // we're already using that stateset
613
		stateset_ = ss->id;
614
		updateStateSet();
615
		BROADCAST(this, "ss", "setStateSet", getStateSetSymbol()->s_name);
616
	}
617
}
618

  
619
void GroupNode::setStateSet (const char* s)
620
{
621
	if (gensym(s)==stateset_) return;
622

  
623
	osg::ref_ptr<ReferencedStateSet> ss = sceneManager->getStateSet(s);
624
	if (ss.valid())
625
	{
626
		stateset_ = ss->id;
627
		updateStateSet();
628
		BROADCAST(this, "ss", "setStateSet", getStateSetSymbol()->s_name);
629
	}
630
}
631

  
632
void GroupNode::updateStateSet()
633
{
634
	osg::ref_ptr<ReferencedStateSet> ss = dynamic_cast<ReferencedStateSet*>(stateset_->s_thing);
635
	if (mainTransform.valid() && ss.valid()) mainTransform->setStateSet( ss.get() );
636
}
637

  
638

  
639

  
640
// -----------------------------------------------------------------------------
641

  
587 642
void GroupNode::setClipping(float x, float y, float z)
588 643
{
589 644
    _clipping = osg::Vec3d(x,y,z);
......
1166 1221
    lo_message msg;
1167 1222
    osg::Vec3 v;
1168 1223

  
1224
	msg = lo_message_new();
1225
	lo_message_add(msg,  "ss", "setStateSet", getStateSetSymbol()->s_name);
1226
	ret.push_back(msg);
1227

  
1228
    msg = lo_message_new();
1229
    lo_message_add(msg, "si", "setComputationMode", getComputationMode());
1230
    ret.push_back(msg);
1169 1231

  
1170 1232
    msg = lo_message_new();
1171 1233
    lo_message_add(msg, "si", "setReportMode", getReportMode());
b/src/spin/ImageTexture.cpp
65 65
	classType = "ImageTexture";
66 66

  
67 67
	_path = "NULL";
68
	_useTextureRectangle = false;
68
	textureMode_ = TEXTURE_2D;
69 69
}
70 70

  
71 71
// destructor
......
92 92
// *****************************************************************************
93 93
void ImageTexture::setPath (const char* newPath)
94 94
{
95
	// only do this if the id has changed:
96
	if (_path == std::string(newPath)) return;
97

  
98
	_path = std::string(newPath);
99
	
100
	if (sceneManager->isGraphical())
101
	{
102

  
103
		std::string fullPath = getAbsolutePath(_path);
104

  
105
		std::cout << "Loading image: " << fullPath << std::endl;
106

  
107
		//osg::setNotifyLevel(osg::DEBUG_FP);
108
		osg::ref_ptr<osg::Image> test = osgDB::readImageFile(fullPath);
109
		//osg::setNotifyLevel(osg::FATAL);
110
		
111
		if (test.valid())
112
		{
113
			this->setName("ImageTexture("+_path+")");
114

  
115
			// create a texture object
116
			osg::Texture *tex;
117
			if (_useTextureRectangle)
118
			{
119
				tex = new osg::TextureRectangle;
120
			} else {
121
				tex = new osg::Texture2D;
122
			}
123
		
124
			tex->setResizeNonPowerOfTwoHint(false);
125
			tex->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
126
			//tex->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
127
			//tex->setWrap(osg::Texture::WRAP_R, osg::Texture::REPEAT);
128
			if (textureRepeatS_)
129
				tex->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
130
			else
131
				tex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP);
132
			if (textureRepeatT_)
133
				tex->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
134
			else
135
				tex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP);
136

  
137
			// set the image:
138
			tex->setImage(0,test.get());
139
			
140
			// set transparent border:
141
			tex->setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,0.0f));
142
		
143
			// add texture to stateset:
144
			this->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
145

  
146
			// osg::TexEnv::REPLACE  osg::TexEnv::DECAL  osg::TexEnv::MODULATE osg::TexEnv::BLEND
147
			osg::TexEnv* texenv = new osg::TexEnv();
148
			texenv->setMode(textureBlend_);
149
			this->setTextureAttribute(0, texenv, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
150
	
151
			// set lighting:
152
			if (lightingEnabled_) this->setMode( GL_LIGHTING, osg::StateAttribute::ON );
153
			else this->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
154

  
155
			// set renderbin:
156
			this->setRenderBinDetails( renderBin_, "RenderBin");
157

  
158
			// if image has transparency, enable blending:
159
			if (1)//(_imageStream->isImageTranslucent())
160
			{
161
				this->setMode(GL_BLEND, osg::StateAttribute::ON);
162
				this->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
163
			} else
164
            {
165
                this->setMode(GL_BLEND, osg::StateAttribute::OFF);
166
				this->setRenderingHint(osg::StateSet::DEFAULT_BIN);
167
            }
168
		
169
		}
95
	if (_path != std::string(newPath))
96
    {
97
        _path = std::string(newPath);
98
        if (sceneManager->isGraphical()) this->draw();
99
        BROADCAST(this, "ss", "setPath", getPath());
100
    }
101
}
170 102

  
171
		else {
172
			std::cout << "ImageTexture ERROR. Bad format?: " << _path << std::endl;
173
		}
174
	}
103
void ImageTexture::setTextureMode(TextureMode mode)
104
{
105
    if (this->textureMode_ != (int)mode)
106
    {
107
        this->textureMode_ = mode;
108
        if (sceneManager->isGraphical()) this->draw();
109
        BROADCAST(this, "si", "setTextureMode", (int) this->textureMode_);
110
    }
111
}
175 112

  
176
	BROADCAST(this, "ss", "setPath", getPath());
113
void ImageTexture::draw()
114
{
115
    std::string fullPath = getAbsolutePath(_path);
116
    std::cout << "Loading image: " << fullPath << std::endl;
117

  
118
    //osg::setNotifyLevel(osg::DEBUG_FP);
119
    osg::ref_ptr<osg::Image> test = osgDB::readImageFile(fullPath);
120
    //osg::setNotifyLevel(osg::FATAL);
121
    
122
    if (test.valid())
123
    {
124
        this->setName("ImageTexture("+_path+")");
125

  
126
        // create a texture object
127
        osg::Texture *tex;
128
        if (textureMode_==TEXTURE_RECTANGLE)
129
        {
130
            tex = new osg::TextureRectangle;
131
        } else {
132
            tex = new osg::Texture2D;
133
        }
134
    
135
        tex->setResizeNonPowerOfTwoHint(false);
136
        tex->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
137
        //tex->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
138
        //tex->setWrap(osg::Texture::WRAP_R, osg::Texture::REPEAT);
139
        if (textureRepeatS_)
140
            tex->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
141
        else
142
            tex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP);
143
        if (textureRepeatT_)
144
            tex->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
145
        else
146
            tex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP);
147

  
148
        // set the image:
149
        tex->setImage(0,test.get());
150
        
151
        // set transparent border:
152
        tex->setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,0.0f));
153
    
154
        // add texture to stateset:
155
        this->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
156

  
157
        // osg::TexEnv::REPLACE  osg::TexEnv::DECAL  osg::TexEnv::MODULATE osg::TexEnv::BLEND
158
        osg::TexEnv* texenv = new osg::TexEnv();
159
        texenv->setMode(textureBlend_);
160
        this->setTextureAttribute(0, texenv, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
161

  
162
        // set lighting:
163
        if (lightingEnabled_) this->setMode( GL_LIGHTING, osg::StateAttribute::ON );
164
        else this->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
165

  
166
        // set renderbin:
167
        this->setRenderBinDetails( renderBin_, "RenderBin");
168

  
169
        // if image has transparency, enable blending:
170
        if (1)//(_imageStream->isImageTranslucent())
171
        {
172
            this->setMode(GL_BLEND, osg::StateAttribute::ON);
173
            this->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
174
        } else
175
        {
176
            this->setMode(GL_BLEND, osg::StateAttribute::OFF);
177
            this->setRenderingHint(osg::StateSet::DEFAULT_BIN);
178
        }
179
    
180
    }
181

  
182
    else {
183
        std::cout << "ImageTexture ERROR. Bad format?: " << _path << std::endl;
184
    }
177 185
}
178 186

  
179 187

  
......
187 195
	lo_message msg;
188 196
	
189 197
	msg = lo_message_new();
198
	lo_message_add(msg, "si", "setTextureMode", getTextureMode());
199
	ret.push_back(msg);
200
	
201
	msg = lo_message_new();
190 202
	lo_message_add(msg, "ss", "setPath", getPath());
191 203
	ret.push_back(msg);
192 204
	
b/src/spin/ModelNode.cpp
99 99
    _attachCentroid = false;
100 100
    _registerStates = false;
101 101
	_statesetList.clear();
102
    _statesetList.push_back(stateset_);
102 103
    _renderBin = 10;
103 104
    _lightingOverride = 0;
104 105

  
......
280 281

  
281 282
void ModelNode::setStateSet (int i, const char *replacement)
282 283
{
283
	osg::ref_ptr<ReferencedStateSet> ssOrig, ssReplacement;
284

  
285
	if ( i < (int)_statesetList.size() )
286
	{
287
		ssOrig = dynamic_cast<ReferencedStateSet*>(_statesetList[i]->s_thing);
288
	}
289

  
290
	ssReplacement = sceneManager->getStateSet(replacement);
291

  
292
	if (ssOrig.valid() && ssReplacement.valid())
293
	{
294

  
295
		// oops. this method might replace other model's stateset (if more than
296
		// one model is currently using ssOrig:
297
		/*
298
		for (int j=0; j < ssOrig->getNumParents(); j++)
299
		{
300
			// stateset can be shared by several parents within the model, but
301
			// they must be either of type osg::Drawable or osg::Node
302
			osg::Drawable *drawable = dynamic_cast<osg::Drawable*>(ssOrig->getParent(j));
303
			osg::Node *node = dynamic_cast<osg::Node*>(ssOrig->getParent(j));
304
			if (drawable) drawable->setStateSet(ssReplacement.get());
305
			else if (node) node->setStateSet(ssReplacement.get());
306
			else std::cout << "ERROR: setStateSet for model " << id->s_name << " had problems." << std::endl;
307
		}
308
		*/
284
    osg::ref_ptr<ReferencedStateSet> ssReplacement = sceneManager->getStateSet(replacement);
309 285

  
286
    if (i==0)
287
    {
288
        osg::ref_ptr<ReferencedStateSet> ss = dynamic_cast<ReferencedStateSet*>(stateset_->s_thing);
289
        if (mainTransform.valid() && ss.valid()) mainTransform->setStateSet( ss.get() );
290
    }
291
    else if ((i>0) && (i<_statesetList.size()))
292
    {
293
        osg::ref_ptr<ReferencedStateSet> ssOrig = dynamic_cast<ReferencedStateSet*>(_statesetList[i]->s_thing);
310 294

  
311
		// We need to search through the drawables and nodes that originally had
312
		// statesets and replace ssOrig with ssReplacement:
313
		std::vector<osg::Drawable*>::iterator dItr;
314
		for (dItr=_ssDrawableList.begin(); dItr!=_ssDrawableList.end(); ++dItr)
315
		{
316
			if ((*dItr)->getStateSet() == ssOrig.get())
317
			{
318
				(*dItr)->setStateSet(ssReplacement.get());
319
			}
320
		}
321
		std::vector<osg::Node*>::iterator nItr;
322
		for (nItr=_ssNodeList.begin(); nItr!=_ssNodeList.end(); ++nItr)
323
		{
324
			if ((*nItr)->getStateSet() == ssOrig.get())
325
			{
326
				(*nItr)->setStateSet(ssReplacement.get());
327
			}
328
		}
295
        if (ssOrig.valid() && ssReplacement.valid())
296
        {
297
            // We need to search through the drawables and nodes that originally had
298
            // statesets and replace ssOrig with ssReplacement:
299
            std::vector<osg::Drawable*>::iterator dItr;
300
            for (dItr=_ssDrawableList.begin(); dItr!=_ssDrawableList.end(); ++dItr)
301
            {
302
                if ((*dItr)->getStateSet() == ssOrig.get())
303
                {
304
                    (*dItr)->setStateSet(ssReplacement.get());
305
                }
306
            }
307
            std::vector<osg::Node*>::iterator nItr;
308
            for (nItr=_ssNodeList.begin(); nItr!=_ssNodeList.end(); ++nItr)
309
            {
310
                if ((*nItr)->getStateSet() == ssOrig.get())
311
                {
312
                    (*nItr)->setStateSet(ssReplacement.get());
313
                }
314
            }
315
        }
316
    }
317
    
318
    if (ssReplacement.valid())
319
    {
320
        _statesetList[i] = ssReplacement->id;
321
        BROADCAST(this, "sis", "setStateSet", i, _statesetList[i]->s_name);
322
    }
323
}
329 324

  
330
		_statesetList[i] = ssReplacement->id;
331
		BROADCAST(this, "sis", "setStateSet", i, _statesetList[i]->s_name);
332
	}
325
void ModelNode::updateStateSet()
326
{
327
    // updateStateSet should do nothing for ModelNode.
328
    this->setStateSet(0, stateset_->s_name);
333 329
}
334 330

  
335 331
void ModelNode::setLighting(int i)
......
354 350
// ===================================================================
355 351
void ModelNode::drawModel()
356 352
{
357
	int i,j;
358

  
359 353
	pthread_mutex_lock(&sceneMutex);
360 354
	
361 355
	if (model.valid())
......
366 360
        model = NULL;
367 361
        _centroid->setPosition(osg::Vec3(0.0,0.0,0.0));
368 362
		_statesetList.clear();
363
        _statesetList.push_back(stateset_);
369 364
		_ssDrawableList.clear();
370 365
		_ssNodeList.clear();
371 366

  
372 367
		//if (sceneManager->sharedStateManager.valid()) sceneManager->sharedStateManager->prune();
373 368
		
374 369
		
375
		for (i=0; i<MODELNODE_NUM_ANIM_CONTROLS; i++)
370
		for (int i=0; i<MODELNODE_NUM_ANIM_CONTROLS; i++)
376 371
		{
377 372
			// re-initialize:
378 373
			switcher[i] = NULL;
......
416 411

  
417 412
			SearchVisitor searchVisitor;
418 413
			char buf[16];
419
			for (i=0; i<MODELNODE_NUM_ANIM_CONTROLS; i++)
414
			for (int i=0; i<MODELNODE_NUM_ANIM_CONTROLS; i++)
420 415
			{
421 416

  
422 417
				sprintf( buf, "%02d", i );
......
432 427
					animationMode[i] = SWITCH;
433 428
					// initialize so only first frame is visible:
434 429
					switcher[i]->setValue(0, true);
435
					for (j=1; j<switcher[i]->getNumChildren(); j++) switcher[i]->setValue(j, false);
430
					for (int j=1; j<switcher[i]->getNumChildren(); j++) switcher[i]->setValue(j, false);
436 431

  
437 432
				}
438 433

  
......
548 543
							ss->replace((*itr).get());
549 544
							this->_statesetList.push_back(ss->id);
550 545
							std::cout << "  Replaced placeholder texture with " << ss->classType << ": " << ss->id->s_name << std::endl;
546
                            
547
                            //
548
                            std::cout << "Now we have " << _statesetList.size() << " statesets:" << std::endl;
549
                            for (int i=0; i<_statesetList.size(); i++)
550
                            {
551
                                std::cout << " - " << _statesetList[i]->s_name << std::endl;
552
                            }
551 553

  
552 554
						}
553 555

  
554

  
555

  
556
						// OLD:
557
						/*
558
						// check if the imagefile (minus extension) is a directory, and replace if necessary
559
						if (osgDB::getDirectoryContents(osgDB::getNameLessExtension(imageFile)).size())
560
						{
561
							osg::ref_ptr<VideoTexture> vid = dynamic_cast<VideoTexture*>(sceneManager->createStateSet(osgDB::getStrippedName(imageFile).c_str(), "VideoTexture"));
562

  
563
							//osg::ref_ptr<VideoTexture> vid = dynamic_cast<VideoTexture*>(sceneManager->createStateSet((string(id->s_name)+"/"+osgDB::getStrippedName(imageFile)).c_str(), "VideoTexture"));
564
							//osg::ref_ptr<VideoTexture> vid = new VideoTexture(sceneManager, (string(id->s_name)+"/"+osgDB::getStrippedName(imageFile)).c_str());
565
							if (vid.valid())
566
							{
567
								vid->setVideoPath(osgDB::getNameLessExtension(getRelativePath(imageFile)).c_str());
568
								vid->replace((*itr).get());
569
								//(*itr) = vid.get();
570
								std::cout << "  Replaced placeholder texture with " << vid->classType << ": " << vid->id->s_name << std::endl;
571
							}
572
						}
573

  
574
						// if filename contains "shared_video_texture", then replace
575
						// current TextureAttribute with a SharedVideoTexture
576
						if ((pos=imageFile.find("shared_video_texture01")) != string::npos)
577
						{
578
							std::string shID = "shvid_"+imageFile.substr(pos+20, imageFile.rfind(".")-(pos+20));
579
							osg::ref_ptr<SharedVideoTexture> shvid = dynamic_cast<SharedVideoTexture*>(sceneManager->createStateSet(shID.c_str(), "SharedVideoTexture"));
580
							if (shvid.valid())
581
							{
582
								shvid->setTextureID(shID.c_str());
583
								(*itr)->removeAttribute(attr);
584
								shvid->replace((*itr).get());
585
								std::cout << "  Replaced placeholder texture with " << shvid->classType << ": " << shvid->id->s_name << std::endl;
586
							}
587
						}
588

  
589
						// Check if filename (minus extension) is a movie format:
590
						//
591
						// ... the idea is that the model was created with using
592
						// a placeholder image with a name like: texture.avi.jpg
593
						//
594
						// ... we look for a video file in the same path, but with
595
						// the image extension stripped off: eg, texture.avi
596
						//
597
						// We replace the image with an ImageStream, and all YUV
598
						// texture mapping will remain (assuming the image and video
599
						// have identical resolutions.
600

  
601
						else if (isVideoPath(imageFileLessExtension))
602
						{
603
							std::string vidPath;
604
							if (imageFileLessExtension.substr(1)=="/")
605
							{
606
								// absolute path, so don't change it
607
								vidPath = imageFileLessExtension;
608
							}
609
							else {
610
								// relative path:
611
								vidPath = osgDB::concatPaths(osgDB::getFilePath(getAbsolutePath(modelPath)), imageFileLessExtension);
612
							}
613

  
614
							std::cout << "... imageFileLessExtension: " << imageFileLessExtension << std::endl;
615
							std::cout << "... vidPath: " << vidPath << std::endl;
616
							std::cout << "--> " << (string(id->s_name)+"/"+osgDB::getStrippedName(imageFileLessExtension)).c_str() << std::endl;
617

  
618
							osg::ref_ptr<VideoTexture> vid = dynamic_cast<VideoTexture*>(sceneManager->createStateSet(osgDB::getStrippedName(imageFileLessExtension).c_str(), "VideoTexture"));
619
							//osg::ref_ptr<VideoTexture> vid = dynamic_cast<VideoTexture*>(sceneManager->createStateSet((string(id->s_name)+"/"+osgDB::getStrippedName(imageFile)).c_str(), "VideoTexture"));
620
							//osg::ref_ptr<VideoTexture> vid = new VideoTexture(sceneManager, (string(id->s_name)+"/"+osgDB::getStrippedName(imageFile)).c_str());
621
							if (vid.valid())
622
							{
623
								vid->setVideoPath(vidPath.c_str());
624
								vid->replace((*itr).get());
625
								//(*itr) = vid.get();
626
							}
627
						}
628
						*/
629

  
630

  
631

  
632 556
					} // if texture attribute
633 557
				} // stateset iterator
634 558
			} // if _registerStates
......
697 621
    lo_message_add(msg, "si", "setLighting", getLighting());
698 622
    ret.push_back(msg);
699 623
    
700
	msg = lo_message_new();
701
	lo_message_add(msg, "si", "setRenderBin", getRenderBin());
702
	ret.push_back(msg);
703
	
704 624
	for (i=0; i<MODELNODE_NUM_ANIM_CONTROLS; i++)
705 625
	{
706 626
		if (switcher[i].valid() || sequencer[i].valid())
......
719 639
	lo_message_add(msg, "si", "setRenderBin", getRenderBin());
720 640
	ret.push_back(msg);
721 641

  
722
	for (i=0; i<_statesetList.size(); i++)
642
	for (i=1; i<_statesetList.size(); i++)
723 643
	{
724 644
		msg = lo_message_new();
725 645
        lo_message_add(msg, "sis", "setStateSet", i, _statesetList[i]->s_name);
b/src/spin/SceneManager.cpp
1827 1827
		statesetsToSave = getSavableStateSets(*childIter, withUsers);
1828 1828
	}
1829 1829

  
1830
	// the only subgraphs which can have statesets are:
1831

  
1832

  
1833
	// oops this doesn't work on the server (isGraphical==false) because it
1834
	// doesn't actually add the statesets to the nodes
1835
	/*
1836
	if ((n->nodeType=="ShapeNode") || (n->nodeType=="ModelNode"))
1837
	{
1838
		std::cout << "getting statesets for shape/model: " << n->id->s_name <<  std::endl;
1839

  
1840

  
1841
		// to actually find the stateset, we use the TextureStateSetFinder
1842
		// node visitor
1843
		StateSetList statesets;
1844
		TextureStateSetFinder f(statesets);
1845
		n->accept(f);
1846

  
1847
		// these statesets could be regular osg statesets, but we keep only
1848
		// those which can be cast as ReferencedStateSet
1849
		for (StateSetList::iterator itr=statesets.begin(); itr!=statesets.end(); ++itr)
1850
		{
1851
			std::cout << "found one ... testing if referenced stateset" <<  std::endl;
1852

  
1853
			ReferencedStateSet *refStateSet = dynamic_cast<ReferencedStateSet*>((*itr).get());
1854
			if (refStateSet) statesetsToSave.push_back(refStateSet);
1855
		}
1856
	}
1857
	*/
1858

  
1859
	if (n->nodeType == "ShapeNode")
1860
	{
1861
		ShapeNode *shp = dynamic_cast<ShapeNode*>(n);
1862
		if (shp)
1863
		{
1864
			statesetsToSave.push_back(shp->stateset);
1865
		}
1866
	}
1867
	else if (n->nodeType == "ModelNode")
1830
	if (n->nodeType == "ModelNode")
1868 1831
	{
1869 1832
		ModelNode *mdl = dynamic_cast<ModelNode*>(n);
1870 1833
		if (mdl)
1871 1834
		{
1872 1835
			statesetsToSave.insert( statesetsToSave.begin(), mdl->_statesetList.begin(), mdl->_statesetList.end());
1873 1836
		}
1874
	}
1837
	}    
1838
    else
1839
    {
1840
        GroupNode *grp = dynamic_cast<GroupNode*>(n);
1841
		if (grp)
1842
		{
1843
            t_symbol *ss = grp->getStateSetSymbol();
1844
            if (ss->s_thing)
1845
                statesetsToSave.push_back(ss);
1846
		}
1847
    }
1848
    
1875 1849
	return statesetsToSave;
1876 1850
}
1877 1851

  
b/src/spin/ShapeNode.cpp
74 74
	shape = BOX;
75 75
	billboard = RELATIVE; // ie, no billboard
76 76
	texturePath = "NULL";
77
	stateset = gensym("NULL");
78 77
	renderBin = 11;
79 78
	lightingEnabled = true;
80 79
    
......
157 156
}
158 157

  
159 158
// ===================================================================
160
void ShapeNode::setTextureFromFile (const char* s)
161
{
162
	string path = getRelativePath(string(s));
163
	
164
	// don't do anything if the current texture is already loaded:
165
	if (path==texturePath) return;
166
	else texturePath=path;
167
	
168
	//drawTexture();
169

  
170
	BROADCAST(this, "ss", "setTextureFromFile", texturePath.c_str());
171
}
172

  
173
void ShapeNode::setStateSetFromFile(const char* filename)
174
{
175
	osg::ref_ptr<ReferencedStateSet> ss = sceneManager->createStateSet(filename);
176
	if (ss.valid())
177
	{
178
		if (ss->id == stateset) return; // we're already using that stateset
179
		stateset = ss->id;
180
		updateStateSet();
181
		BROADCAST(this, "ss", "setStateSet", getStateSet());
182
	}
183
}
184

  
185
void ShapeNode::setStateSet (const char* s)
186
{
187
	if (gensym(s)==stateset) return;
188

  
189
	osg::ref_ptr<ReferencedStateSet> ss = sceneManager->getStateSet(s);
190
	if (ss.valid())
191
	{
192
		stateset = ss->id;
193
		updateStateSet();
194
		BROADCAST(this, "ss", "setStateSet", getStateSet());
195
	}
196
}
197 159

  
198 160
void ShapeNode::updateStateSet()
199 161
{
200
	osg::ref_ptr<ReferencedStateSet> ss = dynamic_cast<ReferencedStateSet*>(stateset->s_thing);
162
	osg::ref_ptr<ReferencedStateSet> ss = dynamic_cast<ReferencedStateSet*>(stateset_->s_thing);
201 163
	if (shapeGeode.valid() && ss.valid()) shapeGeode->setStateSet( ss.get() );
202 164
}
203 165

  
......
223 185
	if (lightingEnabled==(bool)i) return;
224 186
	lightingEnabled = (bool)i;
225 187

  
226
	if (shapeGeode.valid() && !stateset->s_thing)
188
	if (shapeGeode.valid() && !stateset_->s_thing)
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff