2
// Copyright � 1997 - 2001, Paul C. Gregory
4
// Contact: pgregory@aqsis.org
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.
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.
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
22
\brief Implements the classes and structures for handling RenderMan options.
23
\author Paul C. Gregory (pgregory@aqsis.org)
31
#include "imagebuffer.h"
35
START_NAMESPACE( Aqsis )
38
//---------------------------------------------------------------------
39
/** Initialise the matrices for this camera according to the status of the camera attributes.
42
void CqOptions::InitialiseCamera()
44
// Setup the Normalising and projection matrices according to the projection
46
CqMatrix matCameraToScreen;
47
CqMatrix matScreenToCamera;
48
CqMatrix matScreenToNDC;
49
CqMatrix matNDCToRaster;
50
TqInt proj = GetIntegerOption( "System", "Projection" ) [ 0 ];
53
case ProjectionOrthographic:
55
// Define a matrix to convert from right top left handed coordinate systems.
56
CqMatrix Trl( 1, 1, -1 );
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 ];
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 );
76
// Combine with the right to left matrix.
77
matCameraToScreen *= Trl;
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
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
97
// Setup the view frustum clipping volume
98
// Left clipping plane
99
CqPlane pl(1,0,0,fabs(l));
100
QGetRenderContext()->clippingVolume().addPlane(pl);
102
// Right clipping plane
103
CqPlane pr(-1,0,0,fabs(r));
104
QGetRenderContext()->clippingVolume().addPlane(pr);
106
// Top clipping plane
107
CqPlane pt(0,-1,0,fabs(t));
108
QGetRenderContext()->clippingVolume().addPlane(pt);
110
// Bottom clipping plane
111
CqPlane pb(0,1,0,fabs(b));
112
QGetRenderContext()->clippingVolume().addPlane(pb);
114
// Near clipping plane
115
CqPlane pn(0,0,1,fabs(n));
116
QGetRenderContext()->clippingVolume().addPlane(pn);
118
// Far clipping plane
119
CqPlane pf(0,0,-1,fabs(f));
120
QGetRenderContext()->clippingVolume().addPlane(pf);
125
case ProjectionPerspective:
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 ];
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 );
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 ];
155
matScreenToNDC.Identity();
156
matNDCToRaster.Identity();
157
// Translate from -1,-1-->1,1 to 0,0-->2,2
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
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);
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);
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);
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);
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);
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);
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 );
219
CqMatrix matWorldToScreen = matCameraToScreen * matWorldToCamera;
221
CqMatrix dofm = QGetRenderContext() ->matVSpaceToSpace( "camera", "raster", NULL, NULL, QGetRenderContext()->Time() );
223
CqVector3D dofe( 1, 1, -1 );
224
CqVector3D dofc( 0, 0, -1 );
229
QGetRenderContext() ->SetDepthOfFieldScale( fabs(dofe.x()-dofc.x()), fabs(dofe.y()-dofc.y()) );
233
//---------------------------------------------------------------------
234
/** Default constructor.
239
CqOptions::CqOptions() :
240
m_funcFilter( RiGaussianFilter ),
241
m_pshadImager( NULL )
243
InitialiseDefaultOptions();
246
//---------------------------------------------------------------------
247
/** Copy constructor.
250
CqOptions::CqOptions( const CqOptions& From ) :
251
m_funcFilter( RiGaussianFilter ),
252
m_pshadImager( NULL )
258
//---------------------------------------------------------------------
262
CqOptions::~CqOptions()
267
//---------------------------------------------------------------------
268
/** Assignment operator.
271
CqOptions& CqOptions::operator=( const CqOptions& From )
273
m_funcFilter = From.m_funcFilter;
274
m_pshadImager = From.m_pshadImager;
278
// Copy the system options.
279
m_aOptions.resize( From.m_aOptions.size() );
280
TqInt i = From.m_aOptions.size();
283
m_aOptions[ i ] = From.m_aOptions[ i ];
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);
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);
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);
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);
318
void CqOptions::InitialiseDefaultOptions()
320
boost::shared_ptr<CqNamedParameterList> pdefopts( new CqNamedParameterList( "System" ) );
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 );
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 );
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.
347
AddOption( pdefopts );
349
pdefopts = boost::shared_ptr<CqNamedParameterList>( new CqNamedParameterList( "Quantize" ) );
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 );
354
AddOption( pdefopts );
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.
365
const CqParameter* CqOptions::pParameter( const char* strName, const char* strParam ) const
367
const CqNamedParameterList* pList = pOption( strName ).get();
370
const CqParameter * pParam;
371
if ( ( pParam = pList->pParameter( strParam ) ) != 0 )
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.
385
CqParameter* CqOptions::pParameterWrite( const char* strName, const char* strParam )
387
CqNamedParameterList* pList = pOptionWrite( strName ).get();
390
CqParameter * pParam;
391
if ( ( pParam = pList->pParameter( strParam ) ) != 0 )
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.
405
TqFloat* CqOptions::GetFloatOptionWrite( const char* strName, const char* strParam, TqInt arraySize )
407
CqParameter * pParam = pParameterWrite( strName, strParam );
409
return ( static_cast<CqParameterTyped<TqFloat, TqFloat>*>( pParam ) ->pValue() );
412
// As we are getting a writeable copy, we should create if it doesn't exist.
413
CqNamedParameterList* pList = pOptionWrite( strName ).get();
416
CqParameterTypedUniform<TqFloat, type_float, TqFloat>* pOpt = new CqParameterTypedUniform<TqFloat, type_float, TqFloat>(strParam, arraySize);
417
pList->AddParameter(pOpt);
418
return ( pOpt->pValue() );
422
CqParameterTypedUniformArray<TqFloat, type_float, TqFloat>* pOpt = new CqParameterTypedUniformArray<TqFloat, type_float, TqFloat>(strParam, arraySize);
423
pList->AddParameter(pOpt);
424
return ( pOpt->pValue() );
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.
437
TqInt* CqOptions::GetIntegerOptionWrite( const char* strName, const char* strParam, TqInt arraySize )
439
CqParameter * pParam = pParameterWrite( strName, strParam );
441
return ( static_cast<CqParameterTyped<TqInt, TqFloat>*>( pParam ) ->pValue() );
444
// As we are getting a writeable copy, we should create if it doesn't exist.
445
CqNamedParameterList* pList = pOptionWrite( strName ).get();
448
CqParameterTypedUniform<TqInt, type_integer, TqInt>* pOpt = new CqParameterTypedUniform<TqInt, type_integer, TqInt>(strParam, arraySize);
449
pList->AddParameter(pOpt);
450
return ( pOpt->pValue() );
454
CqParameterTypedUniformArray<TqInt, type_integer, TqInt>* pOpt = new CqParameterTypedUniformArray<TqInt, type_integer, TqInt>(strParam, arraySize);
455
pList->AddParameter(pOpt);
456
return ( pOpt->pValue() );
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.
469
CqString* CqOptions::GetStringOptionWrite( const char* strName, const char* strParam, TqInt arraySize )
471
CqParameter * pParam = pParameterWrite( strName, strParam );
473
return ( static_cast<CqParameterTyped<CqString, CqString>*>( pParam ) ->pValue() );
476
// As we are getting a writeable copy, we should create if it doesn't exist.
477
CqNamedParameterList* pList = pOptionWrite( strName ).get();
480
CqParameterTypedUniform<CqString, type_string, CqString>* pOpt = new CqParameterTypedUniform<CqString, type_string, CqString>(strParam, arraySize);
481
pList->AddParameter(pOpt);
482
return ( pOpt->pValue() );
486
CqParameterTypedUniformArray<CqString, type_string, CqString>* pOpt = new CqParameterTypedUniformArray<CqString, type_string, CqString>(strParam, arraySize);
487
pList->AddParameter(pOpt);
488
return ( pOpt->pValue() );
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.
501
CqVector3D* CqOptions::GetPointOptionWrite( const char* strName, const char* strParam, TqInt arraySize )
503
CqParameter * pParam = pParameterWrite( strName, strParam );
505
return ( static_cast<CqParameterTyped<CqVector3D, CqVector3D>*>( pParam ) ->pValue() );
508
// As we are getting a writeable copy, we should create if it doesn't exist.
509
CqNamedParameterList* pList = pOptionWrite( strName ).get();
512
CqParameterTypedUniform<CqVector3D, type_point, CqVector3D>* pOpt = new CqParameterTypedUniform<CqVector3D, type_point, CqVector3D>(strParam, arraySize);
513
pList->AddParameter(pOpt);
514
return ( pOpt->pValue() );
518
CqParameterTypedUniformArray<CqVector3D, type_point, CqVector3D>* pOpt = new CqParameterTypedUniformArray<CqVector3D, type_point, CqVector3D>(strParam, arraySize);
519
pList->AddParameter(pOpt);
520
return ( pOpt->pValue() );
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.
533
CqColor* CqOptions::GetColorOptionWrite( const char* strName, const char* strParam, TqInt arraySize )
535
CqParameter * pParam = pParameterWrite( strName, strParam );
537
return ( static_cast<CqParameterTyped<CqColor, CqColor>*>( pParam ) ->pValue() );
540
// As we are getting a writeable copy, we should create if it doesn't exist.
541
CqNamedParameterList* pList = pOptionWrite( strName ).get();
544
CqParameterTypedUniform<CqColor, type_color, CqColor>* pOpt = new CqParameterTypedUniform<CqColor, type_color, CqColor>(strParam, arraySize);
545
pList->AddParameter(pOpt);
546
return ( pOpt->pValue() );
550
CqParameterTypedUniformArray<CqColor, type_color, CqColor>* pOpt = new CqParameterTypedUniformArray<CqColor, type_color, CqColor>(strParam, arraySize);
551
pList->AddParameter(pOpt);
552
return ( pOpt->pValue() );
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.
565
const TqFloat* CqOptions::GetFloatOption( const char* strName, const char* strParam ) const
567
const CqParameter * pParam = pParameter( strName, strParam );
569
return ( static_cast<const CqParameterTyped<TqFloat, TqFloat>*>( pParam ) ->pValue() );
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.
582
const TqInt* CqOptions::GetIntegerOption( const char* strName, const char* strParam ) const
584
const CqParameter * pParam = pParameter( strName, strParam );
586
return ( static_cast<const CqParameterTyped<TqInt, TqFloat>*>( pParam ) ->pValue() );
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.
599
const CqString* CqOptions::GetStringOption( const char* strName, const char* strParam ) const
601
const CqParameter * pParam = pParameter( strName, strParam );
603
return ( static_cast<const CqParameterTyped<CqString, CqString>*>( pParam ) ->pValue() );
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.
616
const CqVector3D* CqOptions::GetPointOption( const char* strName, const char* strParam ) const
618
const CqParameter * pParam = pParameter( strName, strParam );
620
return ( static_cast<const CqParameterTyped<CqVector3D, CqVector3D>*>( pParam ) ->pValue() );
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.
633
const CqColor* CqOptions::GetColorOption( const char* strName, const char* strParam ) const
635
const CqParameter * pParam = pParameter( strName, strParam );
637
return ( static_cast<const CqParameterTyped<CqColor, CqColor>*>( pParam ) ->pValue() );
642
EqVariableType CqOptions::getParameterType(const char* strName, const char* strParam) const
644
const CqParameter* pParam = pParameter(strName, strParam);
648
return(pParam->Type());
651
EqVariableClass CqOptions::getParameterClass(const char* strName, const char* strParam) const
653
const CqParameter* pParam = pParameter(strName, strParam);
655
return class_invalid;
657
return(pParam->Class());
660
TqUint CqOptions::getParameterSize(const char* strName, const char* strParam) const
662
const CqParameter* pParam = pParameter(strName, strParam);
666
return(pParam->Size());
669
TqInt CqOptions::getParameterArraySize(const char* strName, const char* strParam) const
671
const CqParameter* pParam = pParameter(strName, strParam);
675
return(pParam->Count());
678
void CqOptions::SetpshadImager( const boost::shared_ptr<IqShader>& pshadImager )
680
delete m_pshadImager;
682
m_pshadImager = new CqImagersource(pshadImager, TqTrue);
683
m_pshadImager->pShader()->PrepareDefArgs();
687
boost::shared_ptr<IqShader> CqOptions::pshadImager() const
690
return ( m_pshadImager->pShader() );
692
return boost::shared_ptr<IqShader>();
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"
706
void CqOptions::InitialiseColorImager( IqBucket* pBucket )
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 )
712
m_pshadImager->Initialise( pBucket );
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
723
CqColor CqOptions::GetColorImager( TqFloat x, TqFloat y )
725
CqColor result( 0, 0, 0 );
727
if ( m_pshadImager != NULL )
729
// get the color from the current imager than
730
result = m_pshadImager->Color( x, y );
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
743
TqFloat CqOptions::GetAlphaImager( TqFloat x, TqFloat y )
745
TqFloat result = 1.0;
747
if ( m_pshadImager != NULL )
749
// get the color from the current imager than
750
result = m_pshadImager->Alpha( x, y );
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
765
CqColor CqOptions::GetOpacityImager( TqFloat x, TqFloat y )
767
CqColor result = gColWhite;
769
if ( m_pshadImager != NULL )
771
// get the opacity from the current imager than
772
result = m_pshadImager->Opacity( x, y );
780
//---------------------------------------------------------------------
782
END_NAMESPACE( Aqsis )