00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #define OSG_COMPILEMYEXTENSIONLIB
00047
00048 #include <OSGConfig.h>
00049
00050 #include "OSGFatBorderChunk.h"
00051
00052
00053 const char* vertexProgStandard =
00054 "!!ARBvp1.0\n"
00055
00056 "PARAM mvp[] = { state.matrix.mvp };\n"
00057 "PARAM mv[] = { state.matrix.modelview[0] };\n"
00058 "PARAM m_one = { -1.0, -1.0, -1.0, 0.0 };\n"
00059 "PARAM small = { 0.00001, 0.00001, 0.00001, 0.0 };\n"
00060 "TEMP temp, temp2, temp3;\n"
00061
00062
00063
00064
00065
00066 "MOV result.texcoord[0], vertex.texcoord[1];\n"
00067
00068
00069
00070
00071
00072
00073
00074
00075 "DP3 temp2.x, mv[0], vertex.normal;\n"
00076 "DP3 temp2.y, mv[1], vertex.normal;\n"
00077 "DP3 temp2.z, mv[2], vertex.normal;\n"
00078 "DP3 temp, temp2, temp2;\n"
00079 "RSQ temp, temp.x;\n"
00080 "MUL temp2, temp, temp2;\n"
00081
00082 "DP3 temp.x, state.light[0].position, temp2;\n"
00083 "DP3 temp.y, state.light[0].half, temp2;\n"
00084 "MOV temp.w, state.material.shininess.x;\n"
00085 "LIT temp, temp;\n"
00086 "MAD temp3, temp.y, state.lightprod[0].front.diffuse, state.lightprod[0].front.ambient;\n"
00087 "ADD temp3, temp3, state.material.emission;\n"
00088 "MAD temp3, temp.z, state.lightprod[0].front.specular, temp3;\n"
00089
00090
00091 "MUL temp2, temp2, m_one;\n"
00092 "DP3 temp.x, state.light[0].position, temp2;\n"
00093 "DP3 temp.y, state.light[0].half, temp2;\n"
00094 "MOV temp.w, state.material.shininess.x;\n"
00095 "LIT temp, temp;\n"
00096 "MAD temp3, temp.y, state.lightprod[0].back.diffuse, temp3;\n"
00097 "MAD result.color, temp.z, state.lightprod[0].back.specular, temp3;\n"
00098
00099
00100
00101
00102
00103 "MUL temp2, m_one, mv[2];\n"
00104 "DP3 temp, temp2, temp2;\n"
00105 "RSQ temp, temp.x;\n"
00106 "MUL temp2, temp, temp2;\n"
00107
00108
00109
00110
00111
00112
00113
00114 "XPD temp, temp2, vertex.texcoord[0];\n"
00115 "DP3 temp3, temp, temp;\n"
00116 "ADD temp3, temp3, small;\n"
00117 "RSQ temp3, temp3.x;\n"
00118 "MUL temp, temp3, temp;\n"
00119
00120 "DP3 temp3, vertex.texcoord[0], vertex.texcoord[0];\n"
00121 "MUL temp3, {1,1,1,0}, temp3.x;\n"
00122
00123 "MAD temp, temp, temp3, vertex.position;\n"
00124 "MAD temp, temp2, temp3, temp;\n"
00125
00126
00127
00128
00129
00130
00131 "DP4 result.position.x, mvp[0], temp;\n"
00132 "DP4 result.position.y, mvp[1], temp;\n"
00133 "DP4 result.position.z, mvp[2], temp;\n"
00134 "DP4 result.position.w, mvp[3], temp;\n"
00135
00136 "END\n";
00137
00138 const char* vertexProgFBasedLight =
00139 "!!ARBvp1.0\n"
00140
00141 "PARAM mvp[] = { state.matrix.mvp };\n"
00142 "PARAM mv[] = { state.matrix.modelview[0] };\n"
00143 "PARAM m_one = { -1.0, -1.0, -1.0, 0.0 };\n"
00144 "PARAM small = { 0.00001, 0.00001, 0.00001, 0.0 };\n"
00145 "TEMP temp, temp2, temp3;\n"
00146
00147
00148
00149
00150
00151 "MOV result.texcoord[1], vertex.texcoord[1];\n"
00152 "MOV result.texcoord[0], vertex.normal;\n"
00153
00154
00155
00156
00157
00158 "MUL temp2, m_one, mv[2];\n"
00159 "DP3 temp, temp2, temp2;\n"
00160 "RSQ temp, temp.x;\n"
00161 "MUL temp2, temp, temp2;\n"
00162
00163
00164
00165
00166
00167
00168
00169 "XPD temp, temp2, vertex.texcoord[0];\n"
00170 "DP3 temp3, temp, temp;\n"
00171 "ADD temp3, temp3, small;\n"
00172 "RSQ temp3, temp3.x;\n"
00173 "MUL temp, temp3, temp;\n"
00174
00175 "DP3 temp3, vertex.texcoord[0], vertex.texcoord[0];\n"
00176 "MUL temp3, {1,1,1,0}, temp3.x;\n"
00177
00178 "MAD temp, temp, temp3, vertex.position;\n"
00179 "MAD temp, temp2, temp3, temp;\n"
00180
00181
00182
00183
00184
00185
00186 "DP4 result.position.x, mvp[0], temp;\n"
00187 "DP4 result.position.y, mvp[1], temp;\n"
00188 "DP4 result.position.z, mvp[2], temp;\n"
00189 "DP4 result.position.w, mvp[3], temp;\n"
00190
00191
00192
00193
00194 "END\n";
00195
00196 OSG_USING_NAMESPACE
00197
00202
00203
00204
00205
00206
00207
00208
00209
00210 void FatBorderChunk::initMethod (void)
00211 {
00212 }
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 FatBorderChunk::FatBorderChunk(void) :
00226 Inherited()
00227 {
00228
00229
00230 }
00231
00232 FatBorderChunk::FatBorderChunk(const FatBorderChunk &source) :
00233 Inherited(source)
00234 {
00235 }
00236
00237
00238 void FatBorderChunk::onCreate(const FatBorderChunk *)
00239 {
00240 if(GlobalSystemState == Startup)
00241 return;
00242
00243 Inherited::onCreate(NULL);
00244 activateWithStandardLighting();
00245 }
00246
00247 FatBorderChunk::~FatBorderChunk(void)
00248 {
00249 }
00250
00251
00252
00253 void FatBorderChunk::changed(BitVector whichField, UInt32 origin)
00254 {
00255 Inherited::changed(whichField, origin);
00256 }
00257
00258 void FatBorderChunk::dump( UInt32 ,
00259 const BitVector ) const
00260 {
00261 SLOG << "Dump FatBorderChunk NI" << std::endl;
00262 }
00263
00264 void FatBorderChunk::activateWithStandardLighting( )
00265 {
00266 beginEditCP( FatBorderChunkPtr( this ), ProgramFieldMask );
00267 {
00268 setProgram( vertexProgStandard );
00269
00270 }
00271 endEditCP( FatBorderChunkPtr( this ), ProgramFieldMask );
00272 }
00273
00274 void FatBorderChunk::activateWithFragmentBasedLighting( )
00275 {
00276 beginEditCP( FatBorderChunkPtr( this ), ProgramFieldMask );
00277 {
00278 setProgram( vertexProgFBasedLight );
00279
00280 }
00281 endEditCP( FatBorderChunkPtr( this ), ProgramFieldMask );
00282 }
00283
00284
00285
00286
00287 #ifdef OSG_SGI_CC
00288 #pragma set woff 1174
00289 #endif
00290
00291 #ifdef OSG_LINUX_ICC
00292 #pragma warning( disable : 177 )
00293 #endif
00294
00295 namespace
00296 {
00297 static Char8 cvsid_cpp [] = "@(#)$Id: $";
00298 static Char8 cvsid_hpp [] = OSGFATBORDERCHUNKBASE_HEADER_CVSID;
00299 static Char8 cvsid_inl [] = OSGFATBORDERCHUNKBASE_INLINE_CVSID;
00300
00301 static Char8 cvsid_fields_hpp[] = OSGFATBORDERCHUNKFIELDS_HEADER_CVSID;
00302 }
00303
00304 #ifdef __sgi
00305 #pragma reset woff 1174
00306 #endif
00307