[Gcblue-commits] gcb_wx/src/graphics cspSky.cpp,1.10,1.11 tc3DTerrain.cpp,1.13,1.14 tcTerrainTexture
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-07-26 01:44:49
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5274/src/graphics Modified Files: cspSky.cpp tc3DTerrain.cpp tcTerrainTextureFactory.cpp Log Message: Index: tc3DTerrain.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DTerrain.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tc3DTerrain.cpp 19 Jul 2004 00:53:01 -0000 1.13 --- tc3DTerrain.cpp 26 Jul 2004 01:44:40 -0000 1.14 *************** *** 1,6 **** /* ! ** tc3DTerrain.cpp ! ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- /* ! ** @file tc3DTerrain.cpp ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 90,94 **** { wxASSERT(texFactory); ! if (texFactory) texFactory->Update(); } --- 90,94 ---- { wxASSERT(texFactory); ! //if (texFactory) texFactory->Update(); } *************** *** 111,117 **** } ! texFactory->BuildTextures(); terrain->SetAllElevations(&elevationArray[0], GRID_DIM, GRID_DIM, gridSpacing); ! unsigned t3 = tcTime::Get()->GetUpdated30HzCount(); //terrain->SetMaximumVisibleBlockSize(64); --- 111,126 ---- } ! texFactory->UpdateBaseTexture(baseTexture); ! ! //texFactory->BuildTextures(); ! ! ! terrain->SetAllElevations(&elevationArray[0], GRID_DIM, GRID_DIM, gridSpacing); ! ! terrain->SetTexture(baseTexture->GetBuffer(), baseTexture->GetWidth(), ! baseTexture->GetHeight()); ! ! unsigned t3 = tcTime::Get()->GetUpdated30HzCount(); //terrain->SetMaximumVisibleBlockSize(64); *************** *** 217,256 **** updateScheduled(false), updating(false), ! doGradualUpdate(true) { ! mapData = NULL; ! texFactory = NULL; ! gridSpacing = 1500.0f; gridOffset = -0.5f*((float)GRID_DIM)*gridSpacing; Demeter::Settings::GetInstance()->SetUseNormals(true); terrain = new Demeter::Terrain(&elevationArray[0], GRID_DIM, GRID_DIM, ! NULL ,GRID_DIM, GRID_DIM, ! NULL , 0, 0, ! gridSpacing,1.0f,50000, ! gridOffset,gridOffset); ! terrain->AllocateTextureCells(TEX_CELL_DIM, TEX_CELL_DIM); ! texFactory = new tcTerrainTextureFactory(terrain.get(), this, TEX_CELL_DIM); // deleted by terrain? ! terrain->SetTextureFactory(texFactory); ! Demeter::DemeterDrawable* pDrawable = new Demeter::DemeterDrawable; pDrawable->SetTerrain(terrain.get()); - - /* - osg::StateSet *terrain_state = pDrawable->getOrCreateStateSet(); - osg::Depth *depth = new osg::Depth; - depth->setFunction(osg::Depth::ALWAYS); - depth->setRange(1.0, 1.0); - depth->setWriteMask(true); - terrain_state->setAttributeAndModes(depth, osg::StateAttribute::ON); - // terrain_state->setMode(GL_DEPTH, osg::StateAttribute::OFF); - //terrain_state->setMode(GL_LIGHTING, StateAttribute::OFF); - // terrain_state->setMode(GL_CULL_FACE, StateAttribute::OFF); - //terrain_state->setMode(GL_FOG, osg::StateAttribute::ON); - terrain_state->setRenderBinDetails(-1,"RenderBin"); - */ --- 226,256 ---- updateScheduled(false), updating(false), ! doGradualUpdate(true), ! mapData(0), ! texFactory(0) { ! ! gridSpacing = 1000.0f; gridOffset = -0.5f*((float)GRID_DIM)*gridSpacing; Demeter::Settings::GetInstance()->SetUseNormals(true); + Demeter::Settings::GetInstance()->SetUseBorders(true); + + + + baseTexture = tcTerrainTextureFactory::CreateEmptyTexture(BASE_TEX_DIM); terrain = new Demeter::Terrain(&elevationArray[0], GRID_DIM, GRID_DIM, ! baseTexture->GetBuffer(), BASE_TEX_DIM, BASE_TEX_DIM, ! NULL, 0, 0, ! gridSpacing, 1.0f, 50000, ! gridOffset, gridOffset); + texFactory = new tcTerrainTextureFactory(terrain.get(), this, TEX_CELL_DIM); + + texFactory->UpdateCommonTexture(); Demeter::DemeterDrawable* pDrawable = new Demeter::DemeterDrawable; pDrawable->SetTerrain(terrain.get()); Index: tcTerrainTextureFactory.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcTerrainTextureFactory.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcTerrainTextureFactory.cpp 19 Jul 2004 00:53:01 -0000 1.9 --- tcTerrainTextureFactory.cpp 26 Jul 2004 01:44:40 -0000 1.10 *************** *** 49,52 **** --- 49,76 ---- /** + * Creates texSize x texSize square uninitialized texture + */ + Demeter::Texture* tcTerrainTextureFactory::CreateEmptyTexture(int texSize) + { + Demeter::Texture* texture; + + + + Uint8* pImage = new Uint8[texSize*texSize*3]; + texture = new Demeter::Texture(pImage, texSize, texSize, texSize, 0, + true, false, false); + texture->SetBufferPersistent(TRUE); ///< keeps tex in system memory for dynamic modification + delete pImage; + + return texture; + } + + void tcTerrainTextureFactory::UpdateBaseTexture(Demeter::Texture* texture) + { + UpdateTexture(texture, 0, 0, terrain->GetWidth(), terrain->GetHeight()); + } + + + /** * Create empty textures and update procedural texture data * if doGradualUpdate is true, set updateScheduled to true and *************** *** 95,100 **** Demeter::Texture* tcTerrainTextureFactory::CreateEmptyTexture(int nX, int nY) { - Demeter::Texture* pTexture; - // determine position of texture tile in grid bool edgeYLow = (nY < edgeDepthLow)||(nY >= gridDimension - edgeDepthLow); --- 119,122 ---- *************** *** 119,128 **** } ! Uint8* pImage = new Uint8[currentTextureSize*currentTextureSize*3]; ! pTexture = new Demeter::Texture(pImage,currentTextureSize,currentTextureSize,currentTextureSize,0,true,false,false); ! pTexture->SetBufferPersistent(TRUE); ///< keeps tex in system memory for dynamic modification ! delete pImage; ! ! return pTexture; } --- 141,145 ---- } ! return CreateEmptyTexture(currentTextureSize); } *************** *** 161,166 **** float width, float height) { ! ! float texelSpacing = width / pTexture->GetWidth(); // assumes square texture Uint8 *pImage = pTexture->GetBuffer(); --- 178,184 ---- float width, float height) { ! int nTexSize = pTexture->GetWidth(); ! float texSize = nTexSize; ! float texelSpacing = width / texSize; // assumes square texture Uint8 *pImage = pTexture->GetBuffer(); *************** *** 170,182 **** originY += yOffset; ! pTexture->UnloadTexture(); - int imageIndex = 0; float alpha[NUM_TEXTURES]; ! for (float y = originY; y < originY + height; y += texelSpacing) { ! for (float x = originX; x < originX + width; x += texelSpacing,imageIndex += 3) { // float elev = terrain->GetElevation(x,y); float elev = terrainManager->GetElevation(x,y); --- 188,204 ---- originY += yOffset; ! //pTexture->UnloadTexture(); float alpha[NUM_TEXTURES]; ! ! float y = originY; ! for (long yIdx = 0; yIdx < nTexSize; yIdx++) { ! float x = originX; ! for (long xIdx = 0; xIdx < nTexSize; xIdx++) { + long imageIndex = 3 * yIdx * nTexSize + 3 * xIdx; + // float elev = terrain->GetElevation(x,y); float elev = terrainManager->GetElevation(x,y); *************** *** 222,226 **** --- 244,252 ---- pImage[imageIndex + 1] = green; pImage[imageIndex + 2] = blue; + + x += texelSpacing; } + + y += texelSpacing; } } *************** *** 368,371 **** --- 394,400 ---- defaultTextureLand = new Demeter::Texture(mountainTexture->data(),texSize,texSize, texSize,0,true,false,false); + + groundDetailTexture = osgDB::readImageFile("sand_tex.bmp"); + } *************** *** 466,469 **** --- 495,508 ---- } + void tcTerrainTextureFactory::UpdateCommonTexture() + { + if (terrain) + { + terrain->SetCommonTexture(groundDetailTexture->data(), + groundDetailTexture->s(), groundDetailTexture->t()); + } + } + + tcTerrainTextureFactory::tcTerrainTextureFactory(Demeter::Terrain* pTerrain, tc3DTerrain *tm, int griddimension) Index: cspSky.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/cspSky.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** cspSky.cpp 24 Jun 2004 01:43:44 -0000 1.10 --- cspSky.cpp 26 Jul 2004 01:44:40 -0000 1.11 *************** *** 157,161 **** int i; // FIXME this all needs *extensive* cleaning. just hacking for now... ! float R = 1000000.0; float phi, theta; for (i=0; i<n; i++) { --- 157,164 ---- int i; // FIXME this all needs *extensive* cleaning. just hacking for now... ! /* moved this inside the clipping plane as workaround for ATI card black sky problem ! ** See http://csp.sourceforge.net/forum/viewtopic.php?t=171&highlight=sky ! */ ! float R = 900000.0; float phi, theta; for (i=0; i<n; i++) { *************** *** 1140,1144 **** float x, y, z; float alpha, theta; ! float radius = 1100000.0f; m_Horizon = new FalseHorizon; #ifdef TEXDOME --- 1143,1148 ---- float x, y, z; float alpha, theta; ! //float radius = 1100000.0f; ! float radius = 95000.0f; m_Horizon = new FalseHorizon; #ifdef TEXDOME |