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

« back to all changes in this revision

Viewing changes to renderer/render/options.cpp

  • 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 � 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 Implements the classes and structures for handling RenderMan options.
23
 
                \author Paul C. Gregory (pgregory@aqsis.org)
24
 
*/
25
 
 
26
 
#include        <math.h>
27
 
 
28
 
#include        "aqsis.h"
29
 
#include        "options.h"
30
 
#include        "renderer.h"
31
 
#include        "imagebuffer.h"
32
 
#include        "imagers.h"
33
 
#include        "ri.h"
34
 
 
35
 
START_NAMESPACE( Aqsis )
36
 
 
37
 
 
38
 
//---------------------------------------------------------------------
39
 
/** Initialise the matrices for this camera according to the status of the camera attributes.
40
 
 */
41
 
 
42
 
void CqOptions::InitialiseCamera()
43
 
{
44
 
        // Setup the Normalising and projection matrices according to the projection
45
 
        // type
46
 
        CqMatrix        matCameraToScreen;
47
 
        CqMatrix        matScreenToCamera;
48
 
        CqMatrix        matScreenToNDC;
49
 
        CqMatrix        matNDCToRaster;
50
 
        TqInt proj = GetIntegerOption( "System", "Projection" ) [ 0 ];
51
 
        switch ( proj )
52
 
        {
53
 
                        case    ProjectionOrthographic:
54
 
                        {
55
 
                                // Define a matrix to convert from right top left handed coordinate systems.
56
 
                                CqMatrix Trl( 1, 1, -1 );
57
 
 
58
 
                                TqFloat l = GetFloatOption( "System", "ScreenWindow" ) [ 0 ];
59
 
                                TqFloat r = GetFloatOption( "System", "ScreenWindow" ) [ 1 ];
60
 
                                TqFloat t = GetFloatOption( "System", "ScreenWindow" ) [ 2 ];
61
 
                                TqFloat b = GetFloatOption( "System", "ScreenWindow" ) [ 3 ];
62
 
                                TqFloat n = GetFloatOption( "System", "Clipping" ) [ 0 ];
63
 
                                TqFloat f = GetFloatOption( "System", "Clipping" ) [ 1 ];
64
 
 
65
 
                                matCameraToScreen.Identity();
66
 
                                matCameraToScreen.SetfIdentity( TqFalse );
67
 
                                matCameraToScreen.SetElement( 0, 0, 2.0f / ( r - l ) );
68
 
                                matCameraToScreen.SetElement( 3, 0, -( r + l ) / ( r - l ) );
69
 
                                matCameraToScreen.SetElement( 1, 1, 2.0f / ( t - b ) );
70
 
                                matCameraToScreen.SetElement( 3, 1, -( t + b ) / ( t - b ) );
71
 
                                matCameraToScreen.SetElement( 2, 2, -2.0f / ( f - n ) );
72
 
                                matCameraToScreen.SetElement( 3, 2, -( f + n ) / ( f - n ) );
73
 
                                matCameraToScreen.SetElement( 2, 3, 0 );
74
 
                                matCameraToScreen.SetElement( 3, 3, 1 );
75
 
 
76
 
                                // Combine with the right to left matrix.
77
 
                                matCameraToScreen *= Trl;
78
 
 
79
 
                                // Set up the screen to frame matrix
80
 
                                TqFloat FrameX = ( GetFloatOption( "System", "FrameAspectRatio" ) [ 0 ] >= 1.0 ) ? GetIntegerOption( "System", "Resolution" ) [ 0 ] :
81
 
                                                 ( GetIntegerOption( "System", "Resolution" ) [ 1 ] * GetFloatOption( "System", "FrameAspectRatio" ) [ 0 ] ) / GetFloatOption( "System", "PixelAspectRatio" ) [ 0 ];
82
 
                                TqFloat FrameY = ( GetIntegerOption( "System", "FrameAspectRatio" ) [ 0 ] < 1.0 ) ? GetIntegerOption( "System", "Resolution" ) [ 1 ] :
83
 
                                                 ( GetIntegerOption( "System", "Resolution" ) [ 0 ] * GetFloatOption( "System", "PixelAspectRatio" ) [ 0 ] ) / GetFloatOption( "System", "FrameAspectRatio" ) [ 0 ];
84
 
                                matScreenToNDC.Identity();
85
 
                                matNDCToRaster.Identity();
86
 
                                // Translate from -1,-1-->1,1 to 0,0-->2,2
87
 
                                CqMatrix        T;
88
 
                                T.Translate( 1, 1, 0 );
89
 
                                // Scale by 0.5 (0,0 --> 1,1) NDC
90
 
                                CqMatrix        S( 0.5, 0.5, 0 );
91
 
                                CqMatrix        S2( FrameX, FrameY, 0 );
92
 
                                // Invert y to fit top down format
93
 
                                CqMatrix        S3( 1, -1, 1 );
94
 
                                matScreenToNDC = S * T * S3; // S*T*S2
95
 
                                matNDCToRaster = S2;
96
 
 
97
 
                                // Setup the view frustum clipping volume
98
 
                                // Left clipping plane
99
 
                                CqPlane pl(1,0,0,fabs(l));
100
 
                                QGetRenderContext()->clippingVolume().addPlane(pl);
101
 
 
102
 
                                // Right clipping plane
103
 
                                CqPlane pr(-1,0,0,fabs(r));
104
 
                                QGetRenderContext()->clippingVolume().addPlane(pr);
105
 
 
106
 
                                // Top clipping plane
107
 
                                CqPlane pt(0,-1,0,fabs(t));
108
 
                                QGetRenderContext()->clippingVolume().addPlane(pt);
109
 
 
110
 
                                // Bottom clipping plane
111
 
                                CqPlane pb(0,1,0,fabs(b));
112
 
                                QGetRenderContext()->clippingVolume().addPlane(pb);
113
 
 
114
 
                                // Near clipping plane
115
 
                                CqPlane pn(0,0,1,fabs(n));
116
 
                                QGetRenderContext()->clippingVolume().addPlane(pn);
117
 
 
118
 
                                // Far clipping plane
119
 
                                CqPlane pf(0,0,-1,fabs(f));
120
 
                                QGetRenderContext()->clippingVolume().addPlane(pf);
121
 
 
122
 
                                break;
123
 
                        }
124
 
 
125
 
                        case    ProjectionPerspective:
126
 
                        {
127
 
                                TqFloat fov = GetFloatOption( "System", "Clipping" ) [ 0 ] * ( tan( RAD( GetFloatOption( "System", "FOV" ) [ 0 ] / 2.0f ) ) );
128
 
                                TqFloat l = GetFloatOption( "System", "ScreenWindow" ) [ 0 ] * fov;
129
 
                                TqFloat r = GetFloatOption( "System", "ScreenWindow" ) [ 1 ] * fov;
130
 
                                TqFloat t = GetFloatOption( "System", "ScreenWindow" ) [ 2 ] * fov;
131
 
                                TqFloat b = GetFloatOption( "System", "ScreenWindow" ) [ 3 ] * fov;
132
 
                                TqFloat n = GetFloatOption( "System", "Clipping" ) [ 0 ];
133
 
                                TqFloat f = GetFloatOption( "System", "Clipping" ) [ 1 ];
134
 
 
135
 
                                matCameraToScreen.Identity();
136
 
                                matCameraToScreen.SetfIdentity( TqFalse );
137
 
                                matCameraToScreen.SetElement( 0, 0, ( 2.0f * n ) / ( r - l ) );
138
 
                                matCameraToScreen.SetElement( 2, 0, ( r + l ) / ( r - l ) );
139
 
                                matCameraToScreen.SetElement( 1, 1, ( 2.0f * n ) / ( t - b ) );
140
 
                                matCameraToScreen.SetElement( 2, 1, ( t + b ) / ( t - b ) );
141
 
                                TqFloat a = f / ( f - n );
142
 
                                //                      matCameraToScreen.SetElement(2,2,-((f+n)/(f-n)));
143
 
                                matCameraToScreen.SetElement( 2, 2, a );
144
 
                                //                      matCameraToScreen.SetElement(3,2,-((2.0f*f*n)/(f-n)));
145
 
                                matCameraToScreen.SetElement( 3, 2, -n * a );
146
 
                                matCameraToScreen.SetElement( 2, 3, 1 );
147
 
                                matCameraToScreen.SetElement( 3, 3, 0 );
148
 
 
149
 
                                // Set up the screen to frame matrix
150
 
                                TqFloat FrameX = ( GetFloatOption( "System", "FrameAspectRatio" ) [ 0 ] >= 1.0 ) ? GetIntegerOption( "System", "Resolution" ) [ 0 ] :
151
 
                                                 ( GetIntegerOption( "System", "Resolution" ) [ 1 ] * GetFloatOption( "System", "FrameAspectRatio" ) [ 0 ] ) / GetFloatOption( "System", "PixelAspectRatio" ) [ 0 ];
152
 
                                TqFloat FrameY = ( GetFloatOption( "System", "FrameAspectRatio" ) [ 0 ] < 1.0 ) ? GetIntegerOption( "System", "Resolution" ) [ 1 ] :
153
 
                                                 ( GetIntegerOption( "System", "Resolution" ) [ 0 ] * GetFloatOption( "System", "PixelAspectRatio" ) [ 0 ] ) / GetFloatOption( "System", "FrameAspectRatio" ) [ 0 ];
154
 
 
155
 
                                matScreenToNDC.Identity();
156
 
                                matNDCToRaster.Identity();
157
 
                                // Translate from -1,-1-->1,1 to 0,0-->2,2
158
 
                                CqMatrix        T;
159
 
                                T.Translate( 1.0f, 1.0f, 0.0f );
160
 
                                // Scale by 0.5 (0,0 --> 1,1) NDC
161
 
                                CqMatrix        S( 0.5f, 0.5f, 1.0f );
162
 
                                CqMatrix        S2( FrameX, FrameY, 1.0f );
163
 
                                // Invert y to fit top down format
164
 
                                CqMatrix        S3( 1.0f, -1.0f, 1.0f );
165
 
                                matScreenToNDC = S * T * S3; // S*T*S2
166
 
                                matNDCToRaster = S2;
167
 
 
168
 
                                // Setup the view frustum clipping volume
169
 
                                // Left clipping plane
170
 
                                CqPlane pl(matCameraToScreen[0][3] + matCameraToScreen[0][0],
171
 
                                           matCameraToScreen[1][3] + matCameraToScreen[1][0],
172
 
                                           matCameraToScreen[2][3] + matCameraToScreen[2][0],
173
 
                                           matCameraToScreen[3][3] + matCameraToScreen[3][0]);
174
 
                                QGetRenderContext()->clippingVolume().addPlane(pl);
175
 
 
176
 
                                // Right clipping plane
177
 
                                CqPlane pr(matCameraToScreen[0][3] - matCameraToScreen[0][0],
178
 
                                           matCameraToScreen[1][3] - matCameraToScreen[1][0],
179
 
                                           matCameraToScreen[2][3] - matCameraToScreen[2][0],
180
 
                                           matCameraToScreen[3][3] - matCameraToScreen[3][0]);
181
 
                                QGetRenderContext()->clippingVolume().addPlane(pr);
182
 
 
183
 
                                // Top clipping plane
184
 
                                CqPlane pt(matCameraToScreen[0][3] - matCameraToScreen[0][1],
185
 
                                           matCameraToScreen[1][3] - matCameraToScreen[1][1],
186
 
                                           matCameraToScreen[2][3] - matCameraToScreen[2][1],
187
 
                                           matCameraToScreen[3][3] - matCameraToScreen[3][1]);
188
 
                                QGetRenderContext()->clippingVolume().addPlane(pt);
189
 
 
190
 
                                // Bottom clipping plane
191
 
                                CqPlane pb(matCameraToScreen[0][3] + matCameraToScreen[0][1],
192
 
                                           matCameraToScreen[1][3] + matCameraToScreen[1][1],
193
 
                                           matCameraToScreen[2][3] + matCameraToScreen[2][1],
194
 
                                           matCameraToScreen[3][3] + matCameraToScreen[3][1]);
195
 
                                QGetRenderContext()->clippingVolume().addPlane(pb);
196
 
 
197
 
                                // Near clipping plane
198
 
                                CqPlane pn(matCameraToScreen[0][2],
199
 
                                           matCameraToScreen[1][2],
200
 
                                           matCameraToScreen[2][2],
201
 
                                           matCameraToScreen[3][2]);
202
 
                                QGetRenderContext()->clippingVolume().addPlane(pn);
203
 
 
204
 
                                // Far clipping plane
205
 
                                CqPlane pf(matCameraToScreen[0][3] - matCameraToScreen[0][2],
206
 
                                           matCameraToScreen[1][3] - matCameraToScreen[1][2],
207
 
                                           matCameraToScreen[2][3] - matCameraToScreen[2][2],
208
 
                                           matCameraToScreen[3][3] - matCameraToScreen[3][2]);
209
 
                                QGetRenderContext()->clippingVolume().addPlane(pf);
210
 
 
211
 
                                break;
212
 
                        }
213
 
        }
214
 
        CqMatrix matWorldToCamera( QGetRenderContext() ->matSpaceToSpace( "world", "camera", NULL, NULL, QGetRenderContext()->Time() ) );
215
 
        QGetRenderContext() ->SetmatScreen( matCameraToScreen * matWorldToCamera );
216
 
        QGetRenderContext() ->SetmatNDC( matScreenToNDC * matCameraToScreen * matWorldToCamera );
217
 
        QGetRenderContext() ->SetmatRaster( matNDCToRaster * matScreenToNDC * matCameraToScreen * matWorldToCamera );
218
 
 
219
 
        CqMatrix matWorldToScreen = matCameraToScreen * matWorldToCamera;
220
 
 
221
 
        CqMatrix dofm = QGetRenderContext() ->matVSpaceToSpace( "camera", "raster", NULL, NULL, QGetRenderContext()->Time() );
222
 
 
223
 
        CqVector3D      dofe( 1, 1, -1 );
224
 
        CqVector3D      dofc( 0, 0, -1 );
225
 
 
226
 
        dofe = dofm *  dofe;
227
 
        dofc = dofm *  dofc;
228
 
 
229
 
        QGetRenderContext() ->SetDepthOfFieldScale( fabs(dofe.x()-dofc.x()), fabs(dofe.y()-dofc.y()) );
230
 
}
231
 
 
232
 
 
233
 
//---------------------------------------------------------------------
234
 
/** Default constructor.
235
 
 */
236
 
 
237
 
 
238
 
 
239
 
CqOptions::CqOptions() :
240
 
                m_funcFilter( RiGaussianFilter ),
241
 
                m_pshadImager( NULL )
242
 
{
243
 
        InitialiseDefaultOptions();
244
 
}
245
 
 
246
 
//---------------------------------------------------------------------
247
 
/** Copy constructor.
248
 
 */
249
 
 
250
 
CqOptions::CqOptions( const CqOptions& From ) :
251
 
                m_funcFilter( RiGaussianFilter ),
252
 
                m_pshadImager( NULL )
253
 
{
254
 
        *this = From;
255
 
}
256
 
 
257
 
 
258
 
//---------------------------------------------------------------------
259
 
/** Destructor.
260
 
 */
261
 
 
262
 
CqOptions::~CqOptions()
263
 
{
264
 
}
265
 
 
266
 
 
267
 
//---------------------------------------------------------------------
268
 
/** Assignment operator.
269
 
 */
270
 
 
271
 
CqOptions& CqOptions::operator=( const CqOptions& From )
272
 
{
273
 
        m_funcFilter = From.m_funcFilter;
274
 
        m_pshadImager = From.m_pshadImager;
275
 
 
276
 
        //DeleteImager();
277
 
 
278
 
        // Copy the system options.
279
 
        m_aOptions.resize( From.m_aOptions.size() );
280
 
        TqInt i = From.m_aOptions.size();
281
 
        while ( i-- > 0 )
282
 
        {
283
 
                m_aOptions[ i ] = From.m_aOptions[ i ];
284
 
        }
285
 
 
286
 
        return ( *this );
287
 
}
288
 
 
289
 
 
290
 
 
291
 
#define ADD_SYSTEM_PARAM(name, type, sltype, id, def) \
292
 
        CqParameterTypedUniform<type,id,sltype>* p##name = new CqParameterTypedUniform<type,id,sltype>(#name); \
293
 
        p##name->pValue()[0] = ( def ); \
294
 
        pdefopts->AddParameter(p##name);
295
 
 
296
 
#define ADD_SYSTEM_PARAM2(name, type, sltype, id, def0, def1) \
297
 
        CqParameterTypedUniformArray<type,id,sltype>* p##name = new CqParameterTypedUniformArray<type,id,sltype>(#name,2); \
298
 
        p##name->pValue()[0] = ( def0 ); \
299
 
        p##name->pValue()[1] = ( def1 ); \
300
 
        pdefopts->AddParameter(p##name);
301
 
 
302
 
#define ADD_SYSTEM_PARAM3(name, type, sltype, id, def0, def1, def2) \
303
 
        CqParameterTypedUniformArray<type,id,sltype>* p##name = new CqParameterTypedUniformArray<type,id,sltype>(#name,3); \
304
 
        p##name->pValue()[0] = ( def0 ); \
305
 
        p##name->pValue()[1] = ( def1 ); \
306
 
        p##name->pValue()[2] = ( def2 ); \
307
 
        pdefopts->AddParameter(p##name);
308
 
 
309
 
#define ADD_SYSTEM_PARAM4(name, type, sltype, id, def0, def1, def2, def3) \
310
 
        CqParameterTypedUniformArray<type,id,sltype>* p##name = new CqParameterTypedUniformArray<type,id,sltype>(#name,4); \
311
 
        p##name->pValue()[0] = ( def0 ); \
312
 
        p##name->pValue()[1] = ( def1 ); \
313
 
        p##name->pValue()[2] = ( def2 ); \
314
 
        p##name->pValue()[3] = ( def3 ); \
315
 
        pdefopts->AddParameter(p##name);
316
 
 
317
 
 
318
 
void CqOptions::InitialiseDefaultOptions()
319
 
{
320
 
        boost::shared_ptr<CqNamedParameterList> pdefopts( new CqNamedParameterList( "System" ) );
321
 
 
322
 
        ADD_SYSTEM_PARAM( PixelVariance, TqFloat, TqFloat, type_float, 1.0f );
323
 
        ADD_SYSTEM_PARAM2( PixelSamples, TqInt, TqFloat, type_integer, 2, 2 );
324
 
        ADD_SYSTEM_PARAM2( FilterWidth, TqFloat, TqFloat, type_float, 2.0f, 2.0f );
325
 
        ADD_SYSTEM_PARAM2( Exposure, TqFloat, TqFloat, type_float, 1.0f, 1.0f );
326
 
        ADD_SYSTEM_PARAM( Imager, CqString, CqString, type_string, "null" );
327
 
        ADD_SYSTEM_PARAM( DisplayType, CqString, CqString, type_string, "file" );
328
 
        ADD_SYSTEM_PARAM( DisplayName, CqString, CqString, type_string, "aqsis.tif" );
329
 
        ADD_SYSTEM_PARAM( DisplayMode, TqInt, TqFloat, type_integer, ModeRGB );
330
 
 
331
 
        ADD_SYSTEM_PARAM( Hider, CqString, CqString, type_string, "hidden" );
332
 
        ADD_SYSTEM_PARAM( ColorSamples, TqInt, TqFloat, type_integer, 3 );
333
 
        ADD_SYSTEM_PARAM( RelativeDetail, TqFloat, TqFloat, type_float, 1.0f );
334
 
 
335
 
        ADD_SYSTEM_PARAM2( Resolution, TqInt, TqFloat, type_integer, 640, 480 );
336
 
        ADD_SYSTEM_PARAM( PixelAspectRatio, TqFloat, TqFloat, type_float, 1.0f );
337
 
        ADD_SYSTEM_PARAM4( CropWindow, TqFloat, TqFloat, type_float, 0.0f, 1.0f, 0.0f, 1.0f );
338
 
        ADD_SYSTEM_PARAM( FrameAspectRatio, TqFloat, TqFloat, type_float, 4.0f / 3.0f );
339
 
        ADD_SYSTEM_PARAM4( ScreenWindow, TqFloat, TqFloat, type_float, -( 4.0f / 3.0f ), ( 4.0f / 3.0f ), 1.0f, -1.0f );
340
 
        ADD_SYSTEM_PARAM( Projection, TqInt, TqFloat, type_integer, ProjectionOrthographic );
341
 
        ADD_SYSTEM_PARAM2( Clipping, TqFloat, TqFloat, type_float, FLT_EPSILON, FLT_MAX );
342
 
        ADD_SYSTEM_PARAM3( DepthOfField, TqFloat, TqFloat, type_float, FLT_MAX, FLT_MAX, FLT_MAX );
343
 
        ADD_SYSTEM_PARAM2( Shutter, TqFloat, TqFloat, type_float, 0.0f, 1.0f );
344
 
        ADD_SYSTEM_PARAM( FOV, TqFloat, TqFloat, type_float, 90.0f );
345
 
        ADD_SYSTEM_PARAM( SqrtGridSize, TqFloat, TqFloat, type_float, 16.0f );                                  // Grid size square root.
346
 
 
347
 
        AddOption( pdefopts );
348
 
 
349
 
        pdefopts = boost::shared_ptr<CqNamedParameterList>( new CqNamedParameterList( "Quantize" ) );
350
 
 
351
 
        ADD_SYSTEM_PARAM4( Color, TqFloat, TqFloat, type_float, 255.0f, 0.0f, 255.0f, 0.5f );
352
 
        ADD_SYSTEM_PARAM4( Depth, TqFloat, TqFloat, type_float,   0.0f, 0.0f,   0.0f, 0.0f );
353
 
 
354
 
        AddOption( pdefopts );
355
 
}
356
 
 
357
 
 
358
 
//---------------------------------------------------------------------
359
 
/** Get a system option parameter, takes name and parameter name.
360
 
 * \param strName The name of the option.
361
 
 * \param strParam The name of the paramter on the option.
362
 
 * \return CqParameter pointer or 0 if not found.
363
 
 */
364
 
 
365
 
const CqParameter* CqOptions::pParameter( const char* strName, const char* strParam ) const
366
 
{
367
 
        const CqNamedParameterList* pList = pOption( strName ).get();
368
 
        if ( pList )
369
 
        {
370
 
                const CqParameter * pParam;
371
 
                if ( ( pParam = pList->pParameter( strParam ) ) != 0 )
372
 
                        return ( pParam );
373
 
        }
374
 
        return ( 0 );
375
 
}
376
 
 
377
 
 
378
 
//---------------------------------------------------------------------
379
 
/** Get a system option parameter, takes name and parameter name.
380
 
 * \param strName The name of the option.
381
 
 * \param strParam The name of the paramter on the option.
382
 
 * \return CqParameter pointer or 0 if not found.
383
 
 */
384
 
 
385
 
CqParameter* CqOptions::pParameterWrite( const char* strName, const char* strParam )
386
 
{
387
 
        CqNamedParameterList* pList = pOptionWrite( strName ).get();
388
 
        if ( pList )
389
 
        {
390
 
                CqParameter * pParam;
391
 
                if ( ( pParam = pList->pParameter( strParam ) ) != 0 )
392
 
                        return ( pParam );
393
 
        }
394
 
        return ( 0 );
395
 
}
396
 
 
397
 
 
398
 
//---------------------------------------------------------------------
399
 
/** Get a float system option parameter.
400
 
 * \param strName The name of the attribute.
401
 
 * \param strParam The name of the paramter on the attribute.
402
 
 * \return Float pointer 0 if not found.
403
 
 */
404
 
 
405
 
TqFloat* CqOptions::GetFloatOptionWrite( const char* strName, const char* strParam, TqInt arraySize )
406
 
{
407
 
        CqParameter * pParam = pParameterWrite( strName, strParam );
408
 
        if ( pParam != 0 )
409
 
                return ( static_cast<CqParameterTyped<TqFloat, TqFloat>*>( pParam ) ->pValue() );
410
 
        else
411
 
        {
412
 
                // As we are getting a writeable copy, we should create if it doesn't exist.
413
 
                CqNamedParameterList* pList = pOptionWrite( strName ).get();
414
 
                if(arraySize <= 1)
415
 
                {       
416
 
                        CqParameterTypedUniform<TqFloat, type_float, TqFloat>* pOpt = new CqParameterTypedUniform<TqFloat, type_float, TqFloat>(strParam, arraySize);
417
 
                        pList->AddParameter(pOpt);
418
 
                        return ( pOpt->pValue() );
419
 
                }
420
 
                else
421
 
                {
422
 
                        CqParameterTypedUniformArray<TqFloat, type_float, TqFloat>* pOpt = new CqParameterTypedUniformArray<TqFloat, type_float, TqFloat>(strParam, arraySize);
423
 
                        pList->AddParameter(pOpt);
424
 
                        return ( pOpt->pValue() );
425
 
                }
426
 
        }
427
 
}
428
 
 
429
 
 
430
 
//---------------------------------------------------------------------
431
 
/** Get an integer system option parameter.
432
 
 * \param strName The name of the attribute.
433
 
 * \param strParam The name of the paramter on the attribute.
434
 
 * \return Integer pointer 0 if not found.
435
 
 */
436
 
 
437
 
TqInt* CqOptions::GetIntegerOptionWrite( const char* strName, const char* strParam, TqInt arraySize )
438
 
{
439
 
        CqParameter * pParam = pParameterWrite( strName, strParam );
440
 
        if ( pParam != 0 )
441
 
                return ( static_cast<CqParameterTyped<TqInt, TqFloat>*>( pParam ) ->pValue() );
442
 
        else
443
 
        {
444
 
                // As we are getting a writeable copy, we should create if it doesn't exist.
445
 
                CqNamedParameterList* pList = pOptionWrite( strName ).get();
446
 
                if(arraySize <= 1)
447
 
                {
448
 
                        CqParameterTypedUniform<TqInt, type_integer, TqInt>* pOpt = new CqParameterTypedUniform<TqInt, type_integer, TqInt>(strParam, arraySize);
449
 
                        pList->AddParameter(pOpt);
450
 
                        return ( pOpt->pValue() );
451
 
                }
452
 
                else
453
 
                {
454
 
                        CqParameterTypedUniformArray<TqInt, type_integer, TqInt>* pOpt = new CqParameterTypedUniformArray<TqInt, type_integer, TqInt>(strParam, arraySize);
455
 
                        pList->AddParameter(pOpt);
456
 
                        return ( pOpt->pValue() );
457
 
                }
458
 
        }
459
 
}
460
 
 
461
 
 
462
 
//---------------------------------------------------------------------
463
 
/** Get a string system option parameter.
464
 
 * \param strName The name of the attribute.
465
 
 * \param strParam The name of the paramter on the attribute.
466
 
 * \return CqString pointer 0 if not found.
467
 
 */
468
 
 
469
 
CqString* CqOptions::GetStringOptionWrite( const char* strName, const char* strParam, TqInt arraySize )
470
 
{
471
 
        CqParameter * pParam = pParameterWrite( strName, strParam );
472
 
        if ( pParam != 0 )
473
 
                return ( static_cast<CqParameterTyped<CqString, CqString>*>( pParam ) ->pValue() );
474
 
        else
475
 
        {
476
 
                // As we are getting a writeable copy, we should create if it doesn't exist.
477
 
                CqNamedParameterList* pList = pOptionWrite( strName ).get();
478
 
                if(arraySize <= 1)
479
 
                {
480
 
                        CqParameterTypedUniform<CqString, type_string, CqString>* pOpt = new CqParameterTypedUniform<CqString, type_string, CqString>(strParam, arraySize);
481
 
                        pList->AddParameter(pOpt);
482
 
                        return ( pOpt->pValue() );
483
 
                }
484
 
                else
485
 
                {
486
 
                        CqParameterTypedUniformArray<CqString, type_string, CqString>* pOpt = new CqParameterTypedUniformArray<CqString, type_string, CqString>(strParam, arraySize);
487
 
                        pList->AddParameter(pOpt);
488
 
                        return ( pOpt->pValue() );
489
 
                }
490
 
        }
491
 
}
492
 
 
493
 
 
494
 
//---------------------------------------------------------------------
495
 
/** Get a point system option parameter.
496
 
 * \param strName The name of the attribute.
497
 
 * \param strParam The name of the paramter on the attribute.
498
 
 * \return CqVector3D pointer 0 if not found.
499
 
 */
500
 
 
501
 
CqVector3D* CqOptions::GetPointOptionWrite( const char* strName, const char* strParam, TqInt arraySize )
502
 
{
503
 
        CqParameter * pParam = pParameterWrite( strName, strParam );
504
 
        if ( pParam != 0 )
505
 
                return ( static_cast<CqParameterTyped<CqVector3D, CqVector3D>*>( pParam ) ->pValue() );
506
 
        else
507
 
        {
508
 
                // As we are getting a writeable copy, we should create if it doesn't exist.
509
 
                CqNamedParameterList* pList = pOptionWrite( strName ).get();
510
 
                if(arraySize <= 1)
511
 
                {
512
 
                        CqParameterTypedUniform<CqVector3D, type_point, CqVector3D>* pOpt = new CqParameterTypedUniform<CqVector3D, type_point, CqVector3D>(strParam, arraySize);
513
 
                        pList->AddParameter(pOpt);
514
 
                        return ( pOpt->pValue() );
515
 
                }
516
 
                else
517
 
                {
518
 
                        CqParameterTypedUniformArray<CqVector3D, type_point, CqVector3D>* pOpt = new CqParameterTypedUniformArray<CqVector3D, type_point, CqVector3D>(strParam, arraySize);
519
 
                        pList->AddParameter(pOpt);
520
 
                        return ( pOpt->pValue() );
521
 
                }
522
 
        }
523
 
}
524
 
 
525
 
 
526
 
//---------------------------------------------------------------------
527
 
/** Get a color system option parameter.
528
 
 * \param strName The name of the attribute.
529
 
 * \param strParam The name of the paramter on the attribute.
530
 
 * \return CqColor pointer 0 if not found.
531
 
 */
532
 
 
533
 
CqColor* CqOptions::GetColorOptionWrite( const char* strName, const char* strParam, TqInt arraySize )
534
 
{
535
 
        CqParameter * pParam = pParameterWrite( strName, strParam );
536
 
        if ( pParam != 0 )
537
 
                return ( static_cast<CqParameterTyped<CqColor, CqColor>*>( pParam ) ->pValue() );
538
 
        else
539
 
        {
540
 
                // As we are getting a writeable copy, we should create if it doesn't exist.
541
 
                CqNamedParameterList* pList = pOptionWrite( strName ).get();
542
 
                if( arraySize <= 1)
543
 
                {
544
 
                        CqParameterTypedUniform<CqColor, type_color, CqColor>* pOpt = new CqParameterTypedUniform<CqColor, type_color, CqColor>(strParam, arraySize);
545
 
                        pList->AddParameter(pOpt);
546
 
                        return ( pOpt->pValue() );
547
 
                }
548
 
                else
549
 
                {
550
 
                        CqParameterTypedUniformArray<CqColor, type_color, CqColor>* pOpt = new CqParameterTypedUniformArray<CqColor, type_color, CqColor>(strParam, arraySize);
551
 
                        pList->AddParameter(pOpt);
552
 
                        return ( pOpt->pValue() );
553
 
                }
554
 
        }
555
 
}
556
 
 
557
 
 
558
 
//---------------------------------------------------------------------
559
 
/** Get a float system option parameter.
560
 
 * \param strName The name of the attribute.
561
 
 * \param strParam The name of the paramter on the attribute.
562
 
 * \return Float pointer 0 if not found.
563
 
 */
564
 
 
565
 
const TqFloat* CqOptions::GetFloatOption( const char* strName, const char* strParam ) const
566
 
{
567
 
        const CqParameter * pParam = pParameter( strName, strParam );
568
 
        if ( pParam != 0 )
569
 
                return ( static_cast<const CqParameterTyped<TqFloat, TqFloat>*>( pParam ) ->pValue() );
570
 
        else
571
 
                return ( 0 );
572
 
}
573
 
 
574
 
 
575
 
//---------------------------------------------------------------------
576
 
/** Get an integer system option parameter.
577
 
 * \param strName The name of the attribute.
578
 
 * \param strParam The name of the paramter on the attribute.
579
 
 * \return Integer pointer 0 if not found.
580
 
 */
581
 
 
582
 
const TqInt* CqOptions::GetIntegerOption( const char* strName, const char* strParam ) const
583
 
{
584
 
        const CqParameter * pParam = pParameter( strName, strParam );
585
 
        if ( pParam != 0 )
586
 
                return ( static_cast<const CqParameterTyped<TqInt, TqFloat>*>( pParam ) ->pValue() );
587
 
        else
588
 
                return ( 0 );
589
 
}
590
 
 
591
 
 
592
 
//---------------------------------------------------------------------
593
 
/** Get a string system option parameter.
594
 
 * \param strName The name of the attribute.
595
 
 * \param strParam The name of the paramter on the attribute.
596
 
 * \return CqString pointer 0 if not found.
597
 
 */
598
 
 
599
 
const CqString* CqOptions::GetStringOption( const char* strName, const char* strParam ) const
600
 
{
601
 
        const CqParameter * pParam = pParameter( strName, strParam );
602
 
        if ( pParam != 0 )
603
 
                return ( static_cast<const CqParameterTyped<CqString, CqString>*>( pParam ) ->pValue() );
604
 
        else
605
 
                return ( 0 );
606
 
}
607
 
 
608
 
 
609
 
//---------------------------------------------------------------------
610
 
/** Get a point system option parameter.
611
 
 * \param strName The name of the attribute.
612
 
 * \param strParam The name of the paramter on the attribute.
613
 
 * \return CqVector3D pointer 0 if not found.
614
 
 */
615
 
 
616
 
const CqVector3D* CqOptions::GetPointOption( const char* strName, const char* strParam ) const
617
 
{
618
 
        const CqParameter * pParam = pParameter( strName, strParam );
619
 
        if ( pParam != 0 )
620
 
                return ( static_cast<const CqParameterTyped<CqVector3D, CqVector3D>*>( pParam ) ->pValue() );
621
 
        else
622
 
                return ( 0 );
623
 
}
624
 
 
625
 
 
626
 
//---------------------------------------------------------------------
627
 
/** Get a color system option parameter.
628
 
 * \param strName The name of the attribute.
629
 
 * \param strParam The name of the paramter on the attribute.
630
 
 * \return Color pointer 0 if not found.
631
 
 */
632
 
 
633
 
const CqColor* CqOptions::GetColorOption( const char* strName, const char* strParam ) const
634
 
{
635
 
        const CqParameter * pParam = pParameter( strName, strParam );
636
 
        if ( pParam != 0 )
637
 
                return ( static_cast<const CqParameterTyped<CqColor, CqColor>*>( pParam ) ->pValue() );
638
 
        else
639
 
                return ( 0 );
640
 
}
641
 
 
642
 
EqVariableType CqOptions::getParameterType(const char* strName, const char* strParam) const
643
 
{
644
 
        const CqParameter* pParam = pParameter(strName, strParam);
645
 
        if(pParam == NULL)
646
 
                return type_invalid;
647
 
        else
648
 
                return(pParam->Type());
649
 
}
650
 
 
651
 
EqVariableClass CqOptions::getParameterClass(const char* strName, const char* strParam) const
652
 
{
653
 
        const CqParameter* pParam = pParameter(strName, strParam);
654
 
        if(pParam == NULL)
655
 
                return class_invalid;
656
 
        else
657
 
                return(pParam->Class());
658
 
}
659
 
 
660
 
TqUint CqOptions::getParameterSize(const char* strName, const char* strParam) const
661
 
{
662
 
        const CqParameter* pParam = pParameter(strName, strParam);
663
 
        if(pParam == NULL)
664
 
                return 0;
665
 
        else
666
 
                return(pParam->Size());
667
 
}
668
 
 
669
 
TqInt CqOptions::getParameterArraySize(const char* strName, const char* strParam) const
670
 
{
671
 
        const CqParameter* pParam = pParameter(strName, strParam);
672
 
        if(pParam == NULL)
673
 
                return 0;
674
 
        else
675
 
                return(pParam->Count());
676
 
}
677
 
 
678
 
void CqOptions::SetpshadImager( const boost::shared_ptr<IqShader>& pshadImager )
679
 
{
680
 
        delete m_pshadImager;
681
 
 
682
 
        m_pshadImager = new CqImagersource(pshadImager, TqTrue);
683
 
        m_pshadImager->pShader()->PrepareDefArgs();
684
 
}
685
 
 
686
 
 
687
 
boost::shared_ptr<IqShader>     CqOptions::pshadImager() const
688
 
{
689
 
        if(m_pshadImager)
690
 
                return ( m_pshadImager->pShader() );
691
 
        else
692
 
                return boost::shared_ptr<IqShader>();
693
 
}
694
 
 
695
 
//---------------------------------------------------------------------
696
 
/** Force the imager shader to be executed
697
 
 * \param gx The width of the bucket in pixels.
698
 
 * \param gy the height of the bucket in pixels.
699
 
 * \param x The origin of the bucket within the overall image.
700
 
 * \param y The origin of the bucket within the overall image.
701
 
 * \param color Initial value Ci.
702
 
 * \param opacity Initial value Oi.
703
 
 * \param depth Initial value depth (not required).
704
 
 * \param coverage Initial value "alpha"
705
 
 */
706
 
void CqOptions::InitialiseColorImager( IqBucket* pBucket )
707
 
{
708
 
        // Each time with finished up a bucket; we will execute the imager shader
709
 
        // on the gridsize about the same size as the bucket
710
 
        if ( m_pshadImager != NULL )
711
 
        {
712
 
                m_pshadImager->Initialise( pBucket );
713
 
        }
714
 
}
715
 
 
716
 
//---------------------------------------------------------------------
717
 
/** Get a color from the imager shader.
718
 
 * \param x The X in raster coordinate system.
719
 
 * \param y The Y in raster coordiante system.
720
 
 * \return Color  Black if not found.
721
 
 * Right now it is returning the current background colour if found
722
 
 */
723
 
CqColor CqOptions::GetColorImager( TqFloat x, TqFloat y )
724
 
{
725
 
        CqColor result( 0, 0, 0 );
726
 
 
727
 
        if ( m_pshadImager != NULL )
728
 
        {
729
 
                // get the color from the current imager than
730
 
                result = m_pshadImager->Color( x, y );
731
 
        }
732
 
 
733
 
        return result;
734
 
}
735
 
 
736
 
//---------------------------------------------------------------------
737
 
/** Get a color from the imager shader.
738
 
 * \param x The X in raster coordinate system.
739
 
 * \param y The Y in raster coordiante system.
740
 
 * \return Color  Black if not found.
741
 
 * Right now it is returning the current background colour if found
742
 
 */
743
 
TqFloat CqOptions::GetAlphaImager( TqFloat x, TqFloat y )
744
 
{
745
 
        TqFloat result = 1.0;
746
 
 
747
 
        if ( m_pshadImager != NULL )
748
 
        {
749
 
                // get the color from the current imager than
750
 
                result = m_pshadImager->Alpha( x, y );
751
 
        }
752
 
 
753
 
        return result;
754
 
}
755
 
 
756
 
 
757
 
//---------------------------------------------------------------------
758
 
/** Get an opacity from the imager shader.
759
 
 * \param x The X in raster coordinate system.
760
 
 * \param y The Y in raster coordiante system.
761
 
 * \return Color  White right now
762
 
 * Right now it is returning the current background colour if found
763
 
 */
764
 
 
765
 
CqColor CqOptions::GetOpacityImager( TqFloat x, TqFloat y )
766
 
{
767
 
        CqColor result = gColWhite;
768
 
 
769
 
        if ( m_pshadImager != NULL )
770
 
        {
771
 
                // get the opacity from the current imager than
772
 
                result = m_pshadImager->Opacity( x, y );
773
 
        }
774
 
 
775
 
 
776
 
        return result;
777
 
}
778
 
 
779
 
 
780
 
//---------------------------------------------------------------------
781
 
 
782
 
END_NAMESPACE( Aqsis )