~ubuntu-branches/ubuntu/quantal/aqsis/quantal

« back to all changes in this revision

Viewing changes to libs/core/api/graphicsstate.h

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-08-06 04:53:26 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090806045326-z6xeaaao62idxcc6
Tags: 1.6.0-0ubuntu1
* New upstream release
* debian/control:
  - changed name of lib package to libaqsis1 instead of aqsis-libsc2a
  - changed name of dev package to libaqsis-dev instead of aqsis-libs-dev
  - Added aqsis-data package
  - Revised summary text according to that specified by the RISpec (Pixar)
* Moved examples installation from aqsis.install to aqsis-data.install
* debian/rules: 
  - added content to binary-indep target
* debian/rules: added explicit name of mime file to force dh_installmime
  to generate postinst and prerm scripts

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Aqsis
 
2
// Copyright (C) 1997 - 2001, Paul C. Gregory
 
3
//
 
4
// Contact: pgregory@aqsis.org
 
5
//
 
6
// This library is free software; you can redistribute it and/or
 
7
// modify it under the terms of the GNU General Public
 
8
// License as published by the Free Software Foundation; either
 
9
// version 2 of the License, or (at your option) any later version.
 
10
//
 
11
// This library is distributed in the hope that it will be useful,
 
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
// General Public License for more details.
 
15
//
 
16
// You should have received a copy of the GNU General Public
 
17
// License along with this library; if not, write to the Free Software
 
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 
 
20
 
 
21
/** \file
 
22
                \brief Declares the RenderMan context classes.
 
23
                \author Paul C. Gregory (pgregory@aqsis.org)
 
24
*/
 
25
 
 
26
#ifndef CONTEXT_H_INCLUDED
 
27
#define CONTEXT_H_INCLUDED
 
28
 
 
29
#include        <aqsis/aqsis.h>
 
30
 
 
31
#include        <vector>
 
32
#include        <stack>
 
33
 
 
34
#include        <boost/enable_shared_from_this.hpp>
 
35
#include        <boost/shared_ptr.hpp>
 
36
 
 
37
#include        "options.h"
 
38
#include        "attributes.h"
 
39
#include        "transform.h"
 
40
#include        "lights.h"
 
41
#include        "csgtree.h"
 
42
 
 
43
namespace Aqsis {
 
44
 
 
45
class CqSurface;
 
46
class CqDeformingSurface;
 
47
 
 
48
enum EqModeBlock
 
49
{
 
50
    Outside = 0,
 
51
    BeginEnd,
 
52
    Frame,
 
53
    World,
 
54
    Attribute,
 
55
    Transform,
 
56
    Solid,
 
57
    Object,
 
58
    Motion,     
 
59
    Resource
 
60
};
 
61
 
 
62
//----------------------------------------------------------------------
 
63
/** Abstract base class to handle the current context of the renderer,
 
64
 * stores information about the current scoping and previous contexts.
 
65
 */
 
66
 
 
67
class CqModeBlock : public boost::enable_shared_from_this<CqModeBlock>
 
68
{
 
69
        public:
 
70
                /** Default constructor
 
71
                 * \param pconParent a pointer to the previous context.
 
72
                 */
 
73
                CqModeBlock( const boost::shared_ptr<CqModeBlock>& pconParent, EqModeBlock modetype = Outside);
 
74
                virtual ~CqModeBlock();
 
75
 
 
76
                virtual boost::shared_ptr<CqModeBlock>  BeginMainModeBlock();
 
77
                virtual boost::shared_ptr<CqModeBlock>  BeginFrameModeBlock();
 
78
                virtual boost::shared_ptr<CqModeBlock>  BeginWorldModeBlock();
 
79
                virtual boost::shared_ptr<CqModeBlock>  BeginAttributeModeBlock();
 
80
                virtual boost::shared_ptr<CqModeBlock>  BeginTransformModeBlock();
 
81
                virtual boost::shared_ptr<CqModeBlock>  BeginSolidModeBlock( CqString& type );
 
82
                virtual boost::shared_ptr<CqModeBlock>  BeginObjectModeBlock();
 
83
                virtual boost::shared_ptr<CqModeBlock>  BeginMotionModeBlock( TqInt N, TqFloat times[] );
 
84
                virtual boost::shared_ptr<CqModeBlock>  BeginResourceModeBlock();
 
85
 
 
86
#ifdef _DEBUG
 
87
 
 
88
                CqString className() const
 
89
                {
 
90
                        return CqString("CqModeBlock");
 
91
                }
 
92
#endif
 
93
 
 
94
                /** Delete the main context, overridable per derived class.
 
95
                 * \warning If called at this level it is an error, as only the appropriate context can delete itself.
 
96
                 */
 
97
                virtual void    EndMainModeBlock()
 
98
                {
 
99
                        logInvalidNesting();
 
100
                }
 
101
                /** Delete the main context, overridable per derived class.
 
102
                 * \warning If called at this level it is an error, as only the appropriate context can delete itself.
 
103
                 */
 
104
                virtual void    EndFrameModeBlock()
 
105
                {
 
106
                        logInvalidNesting();
 
107
                }
 
108
                /** Delete the main context, overridable per derived class.
 
109
                 * \warning If caled at this level it is an error, as only the appropriate context can delete itself.
 
110
                 */
 
111
                virtual void    EndWorldModeBlock()
 
112
                {
 
113
                        logInvalidNesting();
 
114
                }
 
115
                /** Delete the main context, overridable per derived class.
 
116
                 * \warning If called at this level it is an error, as only the appropriate context can delete itself.
 
117
                 */
 
118
                virtual void    EndAttributeModeBlock()
 
119
                {
 
120
                        logInvalidNesting();
 
121
                }
 
122
                /** Delete the main context, overridable per derived class.
 
123
                 * \warning If called at this level it is an error, as only the appropriate context can delete itself.
 
124
                 */
 
125
                virtual void    EndTransformModeBlock()
 
126
                {
 
127
                        logInvalidNesting();
 
128
                }
 
129
                /** Delete the main context, overridable per derived class.
 
130
                 * \warning If called at this level it is an error, as only the appropriate context can delete itself.
 
131
                 */
 
132
                virtual void    EndSolidModeBlock()
 
133
                {
 
134
                        logInvalidNesting();
 
135
                }
 
136
                /** Delete the main context, overridable per derived class.
 
137
                 * \warning If called at this level it is an error, as only the appropriate context can delete itself.
 
138
                 */
 
139
                virtual void    EndObjectModeBlock()
 
140
                {
 
141
                        logInvalidNesting();
 
142
                }
 
143
                /** Delete the main context, overridable per derived class.
 
144
                 * \warning If called at this level it is an error, as only the appropriate context can delete itself.
 
145
                 */
 
146
                virtual void    EndMotionModeBlock()
 
147
                {
 
148
                        logInvalidNesting();
 
149
                }
 
150
                /** Delete the main context, overridable per derived class.
 
151
                 * \warning If called at this level it is an error, as only the appropriate context can delete itself.
 
152
                 */
 
153
                virtual void    EndResourceModeBlock()
 
154
                {
 
155
                        logInvalidNesting();
 
156
                }
 
157
                virtual IqOptionsPtr    poptCurrent() const
 
158
                {
 
159
                        return( m_poptCurrent );
 
160
                }
 
161
                virtual IqOptionsPtr    poptWriteCurrent()
 
162
                {
 
163
                        if(!m_poptCurrent.unique())
 
164
                                m_poptCurrent = CqOptionsPtr(new CqOptions(*m_poptCurrent.get()));
 
165
                        return(m_poptCurrent);
 
166
                }       
 
167
                /** Push the current options onto a stack, allowing modification of the options
 
168
                 * and recovery of the current state at a later point.
 
169
                 */
 
170
                virtual IqOptionsPtr    pushOptions() = 0;
 
171
                /** Pop a previously pushed copy of the options from the stack.
 
172
                 */
 
173
                virtual IqOptionsPtr    popOptions() = 0;
 
174
                /** Get a read only pointer to the current attributes.
 
175
                 * \return a pointer to the current attributes.
 
176
                 */
 
177
                virtual CqAttributesPtr pattrCurrent() const
 
178
                {
 
179
                        return ( m_pattrCurrent );
 
180
                }
 
181
                /** Set the current set of attributes
 
182
                 * \return a pointer to the old attributes.
 
183
                 */
 
184
                virtual CqAttributesPtr pattrCurrent(CqAttributesPtr& newattrs)
 
185
                {
 
186
                        CqAttributesPtr prev = m_pattrCurrent;
 
187
                        m_pattrCurrent = newattrs;
 
188
                        return ( prev );
 
189
                }
 
190
                /** Get a pointer to the current attributes suitable for writing.
 
191
                 * \return an attribute pointer.
 
192
                 */
 
193
                virtual CqAttributesPtr pattrWriteCurrent()
 
194
                {
 
195
                        m_pattrCurrent = m_pattrCurrent->Write();
 
196
                        return ( m_pattrCurrent );
 
197
                }
 
198
                /** Get a read only pointer to the current transform.
 
199
                 * \return a pointer to the current transform.
 
200
                 */
 
201
                virtual CqTransformPtr  ptransCurrent() const
 
202
                {
 
203
                        return ( m_ptransCurrent );
 
204
                }
 
205
                /** Set the current transform.
 
206
                 * \return a pointer to the old transform.
 
207
                 */
 
208
                virtual CqTransformPtr  ptransSetCurrent(const CqTransformPtr& NewTrans)
 
209
                {
 
210
                        CqTransformPtr prev = m_ptransCurrent;
 
211
                        m_ptransCurrent = NewTrans;
 
212
                        return ( prev );
 
213
                }
 
214
                /** Get the current time, used only within Motion blocks, all other contexts return 0.
 
215
                 * \return the current frame time as a float.
 
216
                 */
 
217
                virtual TqFloat Time() const
 
218
                {
 
219
                        return ( 0.0f );
 
220
                }
 
221
                /// Advance the current frame time to the next specified time.
 
222
                virtual void    AdvanceTime()
 
223
                {}
 
224
                /// Get the current frame index if in a motion block.
 
225
                virtual TqInt   TimeIndex() const
 
226
                {
 
227
                        return( 0 );
 
228
                }
 
229
                /** Is this a motion block, should be overridden per derived class.
 
230
                 * \return boolean indicating whether this is a motion block.
 
231
                 */
 
232
                virtual bool    fMotionBlock() const
 
233
                {
 
234
                        return ( false );
 
235
                }
 
236
 
 
237
                /** Get a pointer to the previuos context.
 
238
                 * \return a context pointer.
 
239
                 */
 
240
                boost::shared_ptr<CqModeBlock>  pconParent()
 
241
                {
 
242
                        return ( m_pconParent );
 
243
                }
 
244
                const boost::shared_ptr<CqModeBlock>    pconParent() const
 
245
                {
 
246
                        return ( m_pconParent );
 
247
                }
 
248
 
 
249
                /** Get the type.
 
250
                 * \return a m_ModeType;
 
251
                 */
 
252
                EqModeBlock Type()
 
253
                {
 
254
                        return ( m_modetype );
 
255
                }
 
256
                /** Get a reference to the current transformation matrix, the result of combining all transformations up to this point.
 
257
                 * \return a matrix reference.
 
258
                 */
 
259
                const   CqMatrix&       matCurrent( TqFloat time ) const
 
260
                {
 
261
                        return ( ptransCurrent() ->matObjectToWorld( time ) );
 
262
                }
 
263
 
 
264
                virtual void    AddContextLightSource( const CqLightsourcePtr& pLS )
 
265
                {
 
266
                        if ( pconParent() )
 
267
                                pconParent() ->AddContextLightSource( pLS );
 
268
                }
 
269
 
 
270
                virtual bool    isSolid()
 
271
                {
 
272
                        return ( ( pconParent() ) ? pconParent() ->isSolid() : false );
 
273
                }
 
274
                /** Get a pointer to the CSG tree node related to this context.
 
275
                 * \return an options reference.
 
276
                 */
 
277
                virtual boost::shared_ptr<CqCSGTreeNode>        pCSGNode()
 
278
                {
 
279
                        return ( ( pconParent() ) ? pconParent() ->pCSGNode() : boost::shared_ptr<CqCSGTreeNode>() );
 
280
                }
 
281
 
 
282
                /** Log invalid context nesting
 
283
                 */
 
284
                virtual void logInvalidNesting() const;
 
285
 
 
286
        public:
 
287
                CqAttributesPtr m_pattrCurrent;         ///< The current attributes.
 
288
                CqTransformPtr m_ptransCurrent;         ///< The current transformation.
 
289
                CqOptionsPtr m_poptCurrent;
 
290
 
 
291
        private:
 
292
                boost::shared_ptr<CqModeBlock>  m_pconParent;                   ///< The previous context.
 
293
                EqModeBlock             m_modetype;                             ///< The current type of motionblock in order to double check the delete
 
294
}
 
295
;
 
296
 
 
297
 
 
298
//----------------------------------------------------------------------
 
299
/** Define the context that exists between calls to RiBegin/RiEnd.
 
300
 */
 
301
 
 
302
class CqMainModeBlock : public CqModeBlock
 
303
{
 
304
        public:
 
305
                CqMainModeBlock( const boost::shared_ptr<CqModeBlock>& pconParent );
 
306
                virtual ~CqMainModeBlock();
 
307
 
 
308
                /** Create a main context.
 
309
                 * \warning It is an error to call this within a main context block.
 
310
                 */
 
311
                virtual boost::shared_ptr<CqModeBlock>  BeginMainModeBlock()
 
312
                {
 
313
                        return boost::shared_ptr<CqModeBlock>();
 
314
                }               // Error
 
315
 
 
316
                /** Delete the main context.
 
317
                 * \attention This is the only valid context deletion from within this block.
 
318
                 */
 
319
                virtual void    EndMainModeBlock()
 
320
                {}
 
321
 
 
322
                virtual IqOptionsPtr    poptCurrent() const
 
323
                {
 
324
                        return( m_poptCurrent );
 
325
                }
 
326
                virtual IqOptionsPtr    poptWriteCurrent()
 
327
                {
 
328
                        if(!m_poptCurrent.unique())
 
329
                                m_poptCurrent = CqOptionsPtr(new CqOptions(*m_poptCurrent.get()));
 
330
                        return(m_poptCurrent);
 
331
                }       
 
332
                virtual IqOptionsPtr    pushOptions()
 
333
                {
 
334
                        CqOptionsPtr opts = CqOptionsPtr(new CqOptions(*m_poptCurrent.get()));
 
335
                        m_optionsStack.push(m_poptCurrent);
 
336
                        m_poptCurrent = opts;
 
337
                        return(m_poptCurrent);
 
338
                }
 
339
                virtual IqOptionsPtr    popOptions()
 
340
                {
 
341
                        assert(!m_optionsStack.empty());
 
342
                        CqOptionsPtr opts = m_optionsStack.top();
 
343
                        m_poptCurrent = opts;
 
344
                        m_optionsStack.pop();
 
345
                        return(m_poptCurrent);
 
346
                }
 
347
 
 
348
        private:
 
349
                std::stack<CqOptionsPtr>        m_optionsStack;
 
350
}
 
351
;
 
352
 
 
353
 
 
354
//----------------------------------------------------------------------
 
355
/** Define the context that exists between calls to RiFrameBegin/RiFrameEnd.
 
356
 */
 
357
 
 
358
class CqFrameModeBlock : public CqModeBlock
 
359
{
 
360
        public:
 
361
                CqFrameModeBlock( const boost::shared_ptr<CqModeBlock>& pconParent );
 
362
                virtual ~CqFrameModeBlock();
 
363
 
 
364
                /** Create a main context.
 
365
                 * \warning It is an error to call this within a frame context.
 
366
                 */
 
367
                virtual boost::shared_ptr<CqModeBlock>  BeginMainModeBlock()
 
368
                {
 
369
                        return boost::shared_ptr<CqModeBlock>();
 
370
                }       // Error
 
371
                /** Create a frame context.
 
372
                 * \warning It is an error to call this within a frame context.
 
373
                 */
 
374
                virtual boost::shared_ptr<CqModeBlock>  BeginFrameModeBlock()
 
375
                {
 
376
                        return boost::shared_ptr<CqModeBlock>();
 
377
                }       // Error
 
378
                /** Create a solid context.
 
379
                 * \warning It is an error to call this within a frame context
 
380
                 */
 
381
                virtual boost::shared_ptr<CqModeBlock>  BeginSolidModeBlock( CqString& /* type */ )
 
382
                {
 
383
                        return boost::shared_ptr<CqModeBlock>();
 
384
                }       // Error
 
385
 
 
386
                /** Delete the frame context.
 
387
                 * \attention This is the only valid context deletion from within this block.
 
388
                 */
 
389
                virtual void    EndFrameModeBlock()
 
390
                {}
 
391
 
 
392
                virtual IqOptionsPtr    poptCurrent() const
 
393
                {
 
394
                        return( m_poptCurrent );
 
395
                }
 
396
                virtual IqOptionsPtr    poptWriteCurrent()
 
397
                {
 
398
                        if(!m_poptCurrent.unique())
 
399
                                m_poptCurrent = CqOptionsPtr(new CqOptions(*m_poptCurrent.get()));
 
400
                        return(m_poptCurrent);
 
401
                }       
 
402
                virtual IqOptionsPtr    pushOptions()
 
403
                {
 
404
                        CqOptionsPtr opts = CqOptionsPtr(new CqOptions(*m_poptCurrent.get()));
 
405
                        m_optionsStack.push(m_poptCurrent);
 
406
                        m_poptCurrent = opts;
 
407
                        return(m_poptCurrent);
 
408
                }
 
409
                virtual IqOptionsPtr    popOptions()
 
410
                {
 
411
                        assert(!m_optionsStack.empty());
 
412
                        CqOptionsPtr opts = m_optionsStack.top();
 
413
                        m_poptCurrent = opts;
 
414
                        m_optionsStack.pop();
 
415
                        return(m_poptCurrent);
 
416
                }
 
417
 
 
418
        private:
 
419
                std::stack<CqOptionsPtr>        m_optionsStack;
 
420
}
 
421
;
 
422
 
 
423
 
 
424
//----------------------------------------------------------------------
 
425
/** Define the context that exists between calls to RiWorldBegin/RiWorldEnd.
 
426
 */
 
427
 
 
428
class CqWorldModeBlock : public CqModeBlock
 
429
{
 
430
        public:
 
431
                CqWorldModeBlock( const boost::shared_ptr<CqModeBlock>& pconParent );
 
432
                virtual ~CqWorldModeBlock();
 
433
 
 
434
                /** Create a main context.
 
435
                 * \warning It is an error to call this within a world context.
 
436
                 */
 
437
                virtual boost::shared_ptr<CqModeBlock>  BeginMainModeBlock()
 
438
                {
 
439
                        return boost::shared_ptr<CqModeBlock>();
 
440
                }       // Error
 
441
                /** Create a frame context.
 
442
                 * \warning It is an error to call this within a world context.
 
443
                 */
 
444
                virtual boost::shared_ptr<CqModeBlock>  BeginFrameModeBlock()
 
445
                {
 
446
                        return boost::shared_ptr<CqModeBlock>();
 
447
                }       // Error
 
448
                /** Create a world context.
 
449
                 * \warning It is an error to call this within a world context.
 
450
                 */
 
451
                virtual boost::shared_ptr<CqModeBlock>  BeginWorldModeBlock()
 
452
                {
 
453
                        return boost::shared_ptr<CqModeBlock>();
 
454
                }       // Error
 
455
 
 
456
                /** Delete the world context.
 
457
                 * \attention This is the only valid context deletion from within this block.
 
458
                 */
 
459
                virtual void    EndWorldModeBlock()
 
460
                {}
 
461
 
 
462
                virtual IqOptionsPtr    poptCurrent() const
 
463
                {
 
464
                        return( pconParent()->poptCurrent() );
 
465
                }
 
466
                virtual IqOptionsPtr    poptWriteCurrent()
 
467
                {
 
468
                        return( pconParent()->poptWriteCurrent() );
 
469
                }       
 
470
                virtual IqOptionsPtr    pushOptions()
 
471
                {
 
472
                        return(pconParent()->pushOptions());
 
473
                }
 
474
                virtual IqOptionsPtr    popOptions()
 
475
                {
 
476
                        return(pconParent()->popOptions());
 
477
                }
 
478
 
 
479
                virtual void    AddContextLightSource( const CqLightsourcePtr& pLS );
 
480
 
 
481
        private:
 
482
                std::vector<CqLightsourcePtr>   m_apWorldLights;
 
483
};
 
484
 
 
485
 
 
486
//----------------------------------------------------------------------
 
487
/** Define the context that exists between calls to RiAttributeBegin/RiAttributeEnd.
 
488
 */
 
489
 
 
490
class CqAttributeModeBlock : public CqModeBlock
 
491
{
 
492
        public:
 
493
                CqAttributeModeBlock( const boost::shared_ptr<CqModeBlock>& pconParent );
 
494
                virtual ~CqAttributeModeBlock();
 
495
 
 
496
                /** Create a main context.
 
497
                 * \warning It is an error to call this within a attribute context.
 
498
                 */
 
499
                virtual boost::shared_ptr<CqModeBlock>  BeginMainModeBlock()
 
500
                {
 
501
                        return boost::shared_ptr<CqModeBlock>();
 
502
                }       // Error
 
503
                /** Create a frame context.
 
504
                 * \warning It is an error to call this within a attribute context.
 
505
                 */
 
506
                virtual boost::shared_ptr<CqModeBlock>  BeginFrameModeBlock()
 
507
                {
 
508
                        return boost::shared_ptr<CqModeBlock>();
 
509
                }       // Error
 
510
                /** Create a world context.
 
511
                 * \warning It is an error to call this within a attribute context.
 
512
                 */
 
513
                virtual boost::shared_ptr<CqModeBlock>  BeginWorldModeBlock()
 
514
                {
 
515
                        return boost::shared_ptr<CqModeBlock>();
 
516
                }       // Error
 
517
 
 
518
                /** Delete the attribute context.
 
519
                 * \attention This is the only valid context deletion from within this block.
 
520
                 */
 
521
                virtual void    EndAttributeModeBlock()
 
522
                {}
 
523
 
 
524
                virtual IqOptionsPtr    poptCurrent() const
 
525
                {
 
526
                        return( pconParent()->poptCurrent() );
 
527
                }
 
528
                virtual IqOptionsPtr    poptWriteCurrent()
 
529
                {
 
530
                        return( pconParent()->poptWriteCurrent() );
 
531
                }       
 
532
                virtual IqOptionsPtr    pushOptions()
 
533
                {
 
534
                        return(pconParent()->pushOptions());
 
535
                }
 
536
                virtual IqOptionsPtr    popOptions()
 
537
                {
 
538
                        return(pconParent()->popOptions());
 
539
                }
 
540
 
 
541
        private:
 
542
};
 
543
 
 
544
 
 
545
//----------------------------------------------------------------------
 
546
/** Define the context that exists between calls to RiTransformBegin/RiTransformEnd.
 
547
 */
 
548
 
 
549
class CqTransformModeBlock : public CqModeBlock
 
550
{
 
551
        public:
 
552
                CqTransformModeBlock( const boost::shared_ptr<CqModeBlock>& pconParent );
 
553
                virtual ~CqTransformModeBlock();
 
554
 
 
555
                /** Create a main context.
 
556
                 * \warning It is an error to call this within a transform context.
 
557
                 */
 
558
                virtual boost::shared_ptr<CqModeBlock>  BeginMainModeBlock()
 
559
                {
 
560
                        return boost::shared_ptr<CqModeBlock>();
 
561
                }       // Error
 
562
                /** Create a frame context.
 
563
                 * \warning It is an error to call this within a transform context.
 
564
                 */
 
565
                virtual boost::shared_ptr<CqModeBlock>  BeginFrameModeBlock()
 
566
                {
 
567
                        return boost::shared_ptr<CqModeBlock>();
 
568
                }       // Error
 
569
                /** Create a world context.
 
570
                 * \warning It is an error to call this within a transform context.
 
571
                 */
 
572
                virtual boost::shared_ptr<CqModeBlock>  BeginWorldModeBlock()
 
573
                {
 
574
                        return boost::shared_ptr<CqModeBlock>();
 
575
                }       // Error
 
576
 
 
577
                /** Delete the transform context.
 
578
                 * \attention This is the only valid context deletion from within this block.
 
579
                 */
 
580
                virtual void    EndTransformModeBlock()
 
581
                {}
 
582
 
 
583
                virtual IqOptionsPtr    poptCurrent() const
 
584
                {
 
585
                        return( pconParent()->poptCurrent() );
 
586
                }
 
587
                virtual IqOptionsPtr    poptWriteCurrent()
 
588
                {
 
589
                        return( pconParent()->poptWriteCurrent() );
 
590
                }       
 
591
                virtual IqOptionsPtr    pushOptions()
 
592
                {
 
593
                        return(pconParent()->pushOptions());
 
594
                }
 
595
                virtual IqOptionsPtr    popOptions()
 
596
                {
 
597
                        return(pconParent()->popOptions());
 
598
                }
 
599
 
 
600
        private:
 
601
};
 
602
 
 
603
 
 
604
//----------------------------------------------------------------------
 
605
/** Define the context that exists between calls to RiSolidBegin/RiSolidEnd.
 
606
 */
 
607
 
 
608
class CqSolidModeBlock : public CqModeBlock
 
609
{
 
610
        public:
 
611
                CqSolidModeBlock( CqString& type, const boost::shared_ptr<CqModeBlock>& pconParent );
 
612
                virtual ~CqSolidModeBlock();
 
613
 
 
614
                /** Create a main context.
 
615
                 * \warning It is an error to call this within a solid context.
 
616
                 */
 
617
                virtual boost::shared_ptr<CqModeBlock>  BeginMainModeBlock()
 
618
                {
 
619
                        return boost::shared_ptr<CqModeBlock>();
 
620
                }       // Error
 
621
                /** Create a frame context.
 
622
                 * \warning It is an error to call this within a solid context.
 
623
                 */
 
624
                virtual boost::shared_ptr<CqModeBlock>  BeginFrameModeBlock()
 
625
                {
 
626
                        return boost::shared_ptr<CqModeBlock>();
 
627
                }       // Error
 
628
                /** Create a world context.
 
629
                 * \warning It is an error to call this within a solid context.
 
630
                 */
 
631
                virtual boost::shared_ptr<CqModeBlock>  BeginWorldModeBlock()
 
632
                {
 
633
                        return boost::shared_ptr<CqModeBlock>();
 
634
                }       // Error
 
635
 
 
636
                /** Delete the solid context.
 
637
                 * \attention This is the only valid context deletion from within this block.
 
638
                 */
 
639
                virtual void    EndSolidModeBlock()
 
640
                {}
 
641
 
 
642
                virtual IqOptionsPtr    poptCurrent() const
 
643
                {
 
644
                        return( pconParent()->poptCurrent() );
 
645
                }
 
646
                virtual IqOptionsPtr    poptWriteCurrent()
 
647
                {
 
648
                        return( pconParent()->poptWriteCurrent() );
 
649
                }       
 
650
                virtual IqOptionsPtr    pushOptions()
 
651
                {
 
652
                        return(pconParent()->pushOptions());
 
653
                }
 
654
                virtual IqOptionsPtr    popOptions()
 
655
                {
 
656
                        return(pconParent()->popOptions());
 
657
                }
 
658
 
 
659
 
 
660
                virtual bool    isSolid()
 
661
                {
 
662
                        return ( true );
 
663
                }
 
664
                virtual boost::shared_ptr<CqCSGTreeNode>        pCSGNode()
 
665
                {
 
666
                        return ( m_pCSGNode );
 
667
                }
 
668
 
 
669
        private:
 
670
                boost::shared_ptr<CqCSGTreeNode>        m_pCSGNode;                     ///< Pointer to the node in the CSG tree for this level in the solid definition.
 
671
                CqString                m_strType;
 
672
}
 
673
;
 
674
 
 
675
 
 
676
//----------------------------------------------------------------------
 
677
/** Define the context that exists between calls to RiObjectBegin/RiObjectEnd.
 
678
 */
 
679
 
 
680
class CqObjectModeBlock : public CqModeBlock
 
681
{
 
682
        public:
 
683
                CqObjectModeBlock( const boost::shared_ptr<CqModeBlock>& pconParent );
 
684
                virtual ~CqObjectModeBlock();
 
685
 
 
686
                /** Create a main context.
 
687
                 * \warning It is an error to call this within an object context.
 
688
                 */
 
689
                virtual boost::shared_ptr<CqModeBlock>  BeginMainModeBlock()
 
690
                {
 
691
                        return boost::shared_ptr<CqModeBlock>();
 
692
                }               // Error
 
693
                /** Create a frame context.
 
694
                 * \warning It is an error to call this within an object context.
 
695
                 */
 
696
                virtual boost::shared_ptr<CqModeBlock>  BeginFrameModeBlock()
 
697
                {
 
698
                        return boost::shared_ptr<CqModeBlock>();
 
699
                }               // Error
 
700
                /** Create a world context.
 
701
                 * \warning It is an error to call this within an object context.
 
702
                 */
 
703
                virtual boost::shared_ptr<CqModeBlock>  BeginWorldModeBlock()
 
704
                {
 
705
                        return boost::shared_ptr<CqModeBlock>();
 
706
                }               // Error
 
707
 
 
708
                /** Delete the object context.
 
709
                 * \attention This is the only valid context deletion from within this block.
 
710
                 */
 
711
                virtual void    EndObjectModeBlock()
 
712
                {}
 
713
 
 
714
                virtual IqOptionsPtr    poptCurrent() const
 
715
                {
 
716
                        return( pconParent()->poptCurrent() );
 
717
                }
 
718
                virtual IqOptionsPtr    poptWriteCurrent()
 
719
                {
 
720
                        return( pconParent()->poptWriteCurrent() );
 
721
                }       
 
722
                virtual IqOptionsPtr    pushOptions()
 
723
                {
 
724
                        return(pconParent()->pushOptions());
 
725
                }
 
726
                virtual IqOptionsPtr    popOptions()
 
727
                {
 
728
                        return(pconParent()->popOptions());
 
729
                }
 
730
                /** Get a pointer suitable for writing to the attributes at the parent context, as object context doesn't store attributes.
 
731
                 * \return an attributes pointer.
 
732
                 */
 
733
                virtual CqAttributesPtr pattrCurrent() const
 
734
                {
 
735
                        return ( pconParent() ->pattrCurrent() );
 
736
                }
 
737
                /** Get a pointer to the attributes at the parent context, as object context doesn't store attributes.
 
738
                 * \return an attributes pointer.
 
739
                 */
 
740
                virtual CqAttributesPtr pattrWriteCurrent()
 
741
                {
 
742
                        assert( false );
 
743
                        return CqAttributesPtr();
 
744
                }       // Illegal to change attributes here.
 
745
 
 
746
        private:
 
747
};
 
748
 
 
749
 
 
750
//----------------------------------------------------------------------
 
751
/** Define the context that exists between calls to RiMotionBegin/RiMotionEnd.
 
752
 */
 
753
 
 
754
class CqMotionModeBlock : public CqModeBlock
 
755
{
 
756
        public:
 
757
                CqMotionModeBlock( TqInt N, TqFloat times[], const boost::shared_ptr<CqModeBlock>& pconParent );
 
758
                virtual ~CqMotionModeBlock();
 
759
 
 
760
                /** Create a main context.
 
761
                 * \warning It is an error to call this within a motion context.
 
762
                 */
 
763
                virtual boost::shared_ptr<CqModeBlock>  BeginMainModeBlock()
 
764
                {
 
765
                        return boost::shared_ptr<CqModeBlock>();
 
766
                }               // Error
 
767
                /** Create a frame context.
 
768
                 * \warning It is an error to call this within a motion context.
 
769
                 */
 
770
                virtual boost::shared_ptr<CqModeBlock>  BeginFrameModeBlock()
 
771
                {
 
772
                        return boost::shared_ptr<CqModeBlock>();
 
773
                }               // Error
 
774
                /** Create a world context.
 
775
                 * \warning It is an error to call this within a motion context.
 
776
                 */
 
777
                virtual boost::shared_ptr<CqModeBlock>  BeginWorldModeBlock()
 
778
                {
 
779
                        return boost::shared_ptr<CqModeBlock>();
 
780
                }               // Error
 
781
                /** Create a attribute context.
 
782
                 * \warning It is an error to call this within a motion context.
 
783
                 */
 
784
                virtual boost::shared_ptr<CqModeBlock>  BeginAttributeModeBlock()
 
785
                {
 
786
                        return boost::shared_ptr<CqModeBlock>();
 
787
                }       // Error
 
788
                /** Create a transform context.
 
789
                 * \warning It is an error to call this within a motion context.
 
790
                 */
 
791
                virtual boost::shared_ptr<CqModeBlock>  BeginTransformModeBlock()
 
792
                {
 
793
                        return boost::shared_ptr<CqModeBlock>();
 
794
                }       // Error
 
795
                /** Create a solid context.
 
796
                 * \warning It is an error to call this within a motion context.
 
797
                 */
 
798
                virtual boost::shared_ptr<CqModeBlock>  BeginSolidModeBlock( CqString& /* type */ )
 
799
                {
 
800
                        return boost::shared_ptr<CqModeBlock>();
 
801
                }               // Error
 
802
                /** Create a object context.
 
803
                 * \warning It is an error to call this within a motion context.
 
804
                 */
 
805
                virtual boost::shared_ptr<CqModeBlock>  BeginObjectModeBlock()
 
806
                {
 
807
                        return boost::shared_ptr<CqModeBlock>();
 
808
                }               // Error
 
809
                /** Create a motion context.
 
810
                 * \warning It is an error to call this within a motion context.
 
811
                 */
 
812
                virtual boost::shared_ptr<CqModeBlock>  BeginMotionModeBlock( TqInt /* N */, TqFloat /* times */[] )
 
813
                {
 
814
                        return boost::shared_ptr<CqModeBlock>();
 
815
                }               // Error
 
816
 
 
817
                /** Delete the object context.
 
818
                 * \attention This is the only valid context deletion from within this block.
 
819
                 */
 
820
                virtual void    EndMotionModeBlock();
 
821
 
 
822
                virtual IqOptionsPtr    poptCurrent() const
 
823
                {
 
824
                        return( pconParent()->poptCurrent() );
 
825
                }
 
826
                virtual IqOptionsPtr    poptWriteCurrent()
 
827
                {
 
828
                        return( pconParent()->poptWriteCurrent() );
 
829
                }       
 
830
                virtual IqOptionsPtr    pushOptions()
 
831
                {
 
832
                        return(pconParent()->pushOptions());
 
833
                }
 
834
                virtual IqOptionsPtr    popOptions()
 
835
                {
 
836
                        return(pconParent()->popOptions());
 
837
                }
 
838
 
 
839
                /** Get the current time, as specified at initialisation of the block.
 
840
                 * \return the current time as a float, or if beyond the last time specified, 0.
 
841
                 */
 
842
                virtual TqFloat Time() const
 
843
                {
 
844
                        if ( m_iTime < m_aTimes.size() )
 
845
                                return ( m_aTimes[ m_iTime ] );
 
846
                        else
 
847
                                return ( 0.0f );
 
848
                }
 
849
                /// Advance the current time to the next specified time.
 
850
                virtual void    AdvanceTime()
 
851
                {
 
852
                        m_iTime++;
 
853
                }
 
854
                /// Get the current frame index if in a motion block.
 
855
                virtual TqInt   TimeIndex() const
 
856
                {
 
857
                        return( m_iTime );
 
858
                }
 
859
                /** Indicate that this is a motion block.
 
860
                 * \return boolean indicating whether this is a motion block.
 
861
                 */
 
862
                virtual bool    fMotionBlock() const
 
863
                {
 
864
                        return ( true );
 
865
                }
 
866
                /** Get the CqDeformingSurface, if generating a deformation motion blur sequence.
 
867
                 */
 
868
                virtual boost::shared_ptr<CqDeformingSurface> GetDeformingSurface() const
 
869
                {
 
870
                        return( m_pDeformingSurface );
 
871
                }
 
872
                /** Set the CqDeformingSurface, if generating a deformation motion blur sequence.
 
873
                 */
 
874
                virtual void SetDeformingSurface( const boost::shared_ptr<CqDeformingSurface>& pMotionSurface);
 
875
 
 
876
        private:
 
877
                TqUint  m_iTime;                ///< The index of the current frame time.
 
878
                std::vector<TqFloat>    m_aTimes;               ///< An array of specified frame times.
 
879
                boost::shared_ptr<CqDeformingSurface>           m_pDeformingSurface;
 
880
}
 
881
;
 
882
 
 
883
//----------------------------------------------------------------------
 
884
/** Define the context that exists between calls to RiResourceBegin/RiResourceEnd.
 
885
 */
 
886
 
 
887
class CqResourceModeBlock : public CqModeBlock
 
888
{
 
889
        public:
 
890
                CqResourceModeBlock( const boost::shared_ptr<CqModeBlock>& pconParent );
 
891
                virtual ~CqResourceModeBlock();
 
892
 
 
893
                /** Create a main context.
 
894
                 * \warning It is an error to call this within a attribute context.
 
895
                 */
 
896
                virtual boost::shared_ptr<CqModeBlock>  BeginMainModeBlock()
 
897
                {
 
898
                        return boost::shared_ptr<CqModeBlock>();
 
899
                }       // Error
 
900
                /** Create a frame context.
 
901
                 * \warning It is an error to call this within a attribute context.
 
902
                 */
 
903
                virtual boost::shared_ptr<CqModeBlock>  BeginFrameModeBlock()
 
904
                {
 
905
                        return boost::shared_ptr<CqModeBlock>();
 
906
                }       // Error
 
907
                /** Create a world context.
 
908
                 * \warning It is an error to call this within a attribute context.
 
909
                 */
 
910
                virtual boost::shared_ptr<CqModeBlock>  BeginWorldModeBlock()
 
911
                {
 
912
                        return boost::shared_ptr<CqModeBlock>();
 
913
                }       // Error
 
914
 
 
915
                /** Delete the attribute context.
 
916
                 * \attention This is the only valid context deletion from within this block.
 
917
                 */
 
918
                virtual void    EndResourceModeBlock()
 
919
                {}
 
920
 
 
921
                virtual IqOptionsPtr    poptCurrent() const
 
922
                {
 
923
                        return( pconParent()->poptCurrent() );
 
924
                }
 
925
                virtual IqOptionsPtr    poptWriteCurrent()
 
926
                {
 
927
                        return( pconParent()->poptWriteCurrent() );
 
928
                }       
 
929
                virtual IqOptionsPtr    pushOptions()
 
930
                {
 
931
                        return(pconParent()->pushOptions());
 
932
                }
 
933
                virtual IqOptionsPtr    popOptions()
 
934
                {
 
935
                        return(pconParent()->popOptions());
 
936
                }
 
937
 
 
938
        private:
 
939
};
 
940
 
 
941
 
 
942
//***
 
943
// Note: These inline functions are defined here to allow full definition of all
 
944
//               required classes first.
 
945
//***
 
946
 
 
947
//----------------------------------------------------------------------
 
948
/** Create a new main context, and link it to the current one.
 
949
 * \return a pointer to the new context.
 
950
 */
 
951
 
 
952
inline boost::shared_ptr<CqModeBlock> CqModeBlock::BeginMainModeBlock()
 
953
{
 
954
        return boost::shared_ptr<CqModeBlock>( new CqMainModeBlock( shared_from_this() ) );
 
955
}
 
956
 
 
957
 
 
958
//----------------------------------------------------------------------
 
959
/** Create a new frame context, and link it to the current one.
 
960
 * \return a pointer to the new context.
 
961
 */
 
962
 
 
963
inline boost::shared_ptr<CqModeBlock> CqModeBlock::BeginFrameModeBlock()
 
964
{
 
965
        return boost::shared_ptr<CqModeBlock>( new CqFrameModeBlock( shared_from_this() ) );
 
966
}
 
967
 
 
968
 
 
969
//----------------------------------------------------------------------
 
970
/** Create a new world context, and link it to the current one.
 
971
 * \return a pointer to the new context.
 
972
 */
 
973
 
 
974
inline boost::shared_ptr<CqModeBlock> CqModeBlock::BeginWorldModeBlock()
 
975
{
 
976
        return boost::shared_ptr<CqModeBlock>( new CqWorldModeBlock( shared_from_this() ) );
 
977
}
 
978
 
 
979
 
 
980
//----------------------------------------------------------------------
 
981
/** Create a new attribute context, and link it to the current one.
 
982
 * \return a pointer to the new context.
 
983
 */
 
984
 
 
985
inline boost::shared_ptr<CqModeBlock> CqModeBlock::BeginAttributeModeBlock()
 
986
{
 
987
        return boost::shared_ptr<CqModeBlock>( new CqAttributeModeBlock( shared_from_this() ) );
 
988
}
 
989
 
 
990
 
 
991
//----------------------------------------------------------------------
 
992
/** Create a new transform context, and link it to the current one.
 
993
 * \return a pointer to the new context.
 
994
 */
 
995
 
 
996
inline boost::shared_ptr<CqModeBlock> CqModeBlock::BeginTransformModeBlock()
 
997
{
 
998
        return boost::shared_ptr<CqModeBlock>( new CqTransformModeBlock( shared_from_this() ) );
 
999
}
 
1000
 
 
1001
 
 
1002
//----------------------------------------------------------------------
 
1003
/** Create a new solid context, and link it to the current one.
 
1004
 * \return a pointer to the new context.
 
1005
 */
 
1006
 
 
1007
inline boost::shared_ptr<CqModeBlock> CqModeBlock::BeginSolidModeBlock( CqString& type )
 
1008
{
 
1009
        return boost::shared_ptr<CqModeBlock>( new CqSolidModeBlock( type, shared_from_this() ) );
 
1010
}
 
1011
 
 
1012
 
 
1013
//----------------------------------------------------------------------
 
1014
/** Create a new object context, and link it to the current one.
 
1015
 * \return a pointer to the new context.
 
1016
 */
 
1017
 
 
1018
inline boost::shared_ptr<CqModeBlock> CqModeBlock::BeginObjectModeBlock()
 
1019
{
 
1020
        return boost::shared_ptr<CqModeBlock>( new CqObjectModeBlock( shared_from_this() ) );
 
1021
}
 
1022
 
 
1023
 
 
1024
//----------------------------------------------------------------------
 
1025
/** Create a new motion context, and link it to the current one.
 
1026
 * \return a pointer to the new context.
 
1027
 */
 
1028
 
 
1029
inline boost::shared_ptr<CqModeBlock> CqModeBlock::BeginMotionModeBlock( TqInt N, TqFloat times[] )
 
1030
{
 
1031
        return boost::shared_ptr<CqModeBlock>( new CqMotionModeBlock( N, times, shared_from_this() ) );
 
1032
}
 
1033
 
 
1034
//----------------------------------------------------------------------
 
1035
/** Create a new resource context, and link it to the current one.
 
1036
 * \return a pointer to the new context.
 
1037
 */
 
1038
 
 
1039
inline boost::shared_ptr<CqModeBlock> CqModeBlock::BeginResourceModeBlock()
 
1040
{
 
1041
        return boost::shared_ptr<CqModeBlock>( new CqResourceModeBlock( shared_from_this() ) );
 
1042
}
 
1043
//-----------------------------------------------------------------------
 
1044
 
 
1045
} // namespace Aqsis
 
1046
 
 
1047
#endif