Changeset 1039 for branches/Carsten_PtrWork2/Tutorials/22Shader.cpp
- Timestamp:
- 01/16/08 16:07:40 (1 year ago)
- Files:
-
- branches/Carsten_PtrWork2/Tutorials/22Shader.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/Carsten_PtrWork2/Tutorials/22Shader.cpp
r835 r1039 31 31 32 32 // The SimpleSceneManager to manage simple applications 33 SimpleSceneManager *_mgr= NULL;34 Node Ptr _scene = NullFC;35 SHLChunk Ptr _shl = NullFC;33 SimpleSceneManager *_mgr = NULL; 34 NodeGlobalRefPtr _scene; 35 SHLChunkGlobalRefPtr _shl; 36 36 37 37 // vertex shader program. … … 113 113 static Real32 t = glutGet(GLUT_ELAPSED_TIME); 114 114 115 Real32 td = (glutGet(GLUT_ELAPSED_TIME) - t) / 100.0f; 115 Real32 td = (glutGet(GLUT_ELAPSED_TIME) - t) / 100.0f; 116 116 117 _shl->setUniformParameter("time", td); 117 118 … … 133 134 134 135 // create light 135 Transform Ptr point1_trans;136 PointLight Ptr point1_core;137 Node Ptr point1 = makeCoredNode<PointLight>(&point1_core);138 Node Ptr point1_beacon = makeCoredNode<Transform>(&point1_trans);136 TransformGlobalRefPtr point1_trans; 137 PointLightGlobalRefPtr point1_core; 138 NodeGlobalRefPtr point1 = makeCoredNode<PointLight>(&point1_core); 139 NodeGlobalRefPtr point1_beacon = makeCoredNode<Transform>(&point1_trans); 139 140 point1_trans->editMatrix().setTranslate(0.0, 100.0, 0.0); 140 141 … … 146 147 147 148 // create bottom 148 Node Ptr bottom = makePlane(50.0, 50.0, 128, 128);149 NodeGlobalRefPtr bottom = makePlane(50.0, 50.0, 128, 128); 149 150 150 151 UChar8 imgdata[] = 151 152 { 255,0,0, 0,255,0, 0,0,255, 255,255,0 }; 152 Image Ptr bottom_img = Image::create();153 ImageGlobalRefPtr bottom_img = Image::create(); 153 154 bottom_img->set(Image::OSG_RGB_PF, 2, 2, 1, 1, 1, 0, imgdata); 154 155 155 TextureObjChunk Ptr bottom_tex = TextureObjChunk::create();156 TextureEnvChunk Ptr bottom_tex_env = TextureEnvChunk::create();156 TextureObjChunkGlobalRefPtr bottom_tex = TextureObjChunk::create(); 157 TextureEnvChunkGlobalRefPtr bottom_tex_env = TextureEnvChunk::create(); 157 158 158 159 bottom_tex->setImage(bottom_img); … … 163 164 bottom_tex_env->setEnvMode(GL_MODULATE); 164 165 165 SimpleMaterial Ptr bottom_mat = SimpleMaterial::create();166 SimpleMaterialGlobalRefPtr bottom_mat = SimpleMaterial::create(); 166 167 bottom_mat->setAmbient(Color3f(0.3,0.3,0.3)); 167 168 bottom_mat->setDiffuse(Color3f(1.0,1.0,1.0)); … … 169 170 bottom_mat->addChunk(bottom_tex_env); 170 171 171 Geometry Ptr bottom_geo = dynamic_cast<GeometryPtr>(bottom->getCore());172 GeometryGlobalRefPtr bottom_geo(dynamic_cast<GeometryPtr>(bottom->getCore())); 172 173 bottom_geo->setMaterial(bottom_mat); 173 174 174 175 // rotate the bottom about 90 degree. 175 Transform Ptr bottom_trans_core;176 Node Ptr bottom_trans = makeCoredNode<Transform>(&bottom_trans_core);176 TransformGlobalRefPtr bottom_trans_core; 177 NodeGlobalRefPtr bottom_trans = makeCoredNode<Transform>(&bottom_trans_core); 177 178 Quaternion q; 178 179 q.setValueAsAxisDeg(1, 0, 0, -90); … … 181 182 182 183 // create a sphere. 183 Node Ptr sphere = makeLatLongSphere(50, 50, 1.0);184 NodeGlobalRefPtr sphere = makeLatLongSphere(50, 50, 1.0); 184 185 185 186 // create the shader material 186 ChunkMaterial Ptr cmat = ChunkMaterial::create();187 ChunkMaterialGlobalRefPtr cmat = ChunkMaterial::create(); 187 188 _shl = SHLChunk::create(); 188 189 _shl->setVertexProgram(_vp_program); … … 198 199 cmat->addChunk(_shl); 199 200 200 Geometry Ptr spheregeo = dynamic_cast<GeometryPtr>(sphere->getCore());201 GeometryGlobalRefPtr spheregeo(dynamic_cast<GeometryPtr>(sphere->getCore())); 201 202 spheregeo->setMaterial(cmat); 202 203 … … 209 210 // create ShadowViewport with a gradient background. 210 211 //ShadowMapViewportPtr svp = ShadowMapViewport::create(); 211 GradientBackground Ptr gbg = GradientBackground::create();212 GradientBackgroundGlobalRefPtr gbg = GradientBackground::create(); 212 213 213 214 gbg->addLine(Color3f(0.7, 0.7, 0.8), 0); … … 227 228 228 229 // the connection between GLUT and OpenSG 229 GLUTWindow Ptr gwin= GLUTWindow::create();230 GLUTWindowGlobalRefPtr gwin = GLUTWindow::create(); 230 231 gwin->setGlutId(winid); 231 232 //gwin->addPort(svp); … … 290 291 { 291 292 case 27: 293 delete _mgr; 294 292 295 OSG::osgExit(); 293 296 exit(0);
