Changeset 8744 in orxonox.OLD for branches/terrain/src/world_entities/terrain_entity.cc
- Timestamp:
- Jun 23, 2006, 3:22:53 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/terrain/src/world_entities/terrain_entity.cc
r8741 r8744 115 115 void TerrainEntity::loadParams(const TiXmlElement* root) 116 116 { 117 WorldEntity::loadParams( root);117 WorldEntity::loadParams( root ); 118 118 119 119 LoadParam(root, "scale", this, TerrainEntity, setScale) 120 120 .describe("The scale in x,y,z direction"); 121 121 122 LoadParam( root, "light map", this, TerrainEntity, loadLightmap )122 LoadParam( root, "light_map", this, TerrainEntity, loadLightmap ) 123 123 .describe("The name of the lightmap."); 124 124 125 LoadParam( root, "elevation map", this, TerrainEntity, loadElevationmap )125 LoadParam( root, "elevation_map", this, TerrainEntity, loadElevationmap ) 126 126 .describe( "The name of the elevation map. Must be an 8bit image" ); 127 127 ResourceManager *manager = ResourceManager::getInstance(); 128 TiXmlElement * layer = (TiXmlElement*)root->FirstChild( "material_layer" ); 129 while ( layer ) { 130 LayerInfo *info = new LayerInfo(); 131 TiXmlElement *detail = (TiXmlElement*)layer->FirstChild( "detail_map" ); 132 if ( detail ) { 133 string detailmap( detail->Attribute( "file" ) ); 134 info->detail = (Texture*)manager->load( detailmap, 135 IMAGE, RP_GAME, (int)GL_TEXTURE_2D ); 136 if ( !info->detail ) { 137 PRINTF(0)( "%s not found\n", detailmap.c_str() ); 138 } 139 TiXmlElement *repeat = (TiXmlElement*)detail->FirstChild( "repeat" ); 140 if ( repeat ) { 141 repeat->QueryFloatAttribute( "x", &info->repeatX ); 142 repeat->QueryFloatAttribute( "z", &info->repeatZ ); 143 } 144 } 145 else { 146 PRINTF(0)( "Please specify a detail-map" ); 147 } 148 TiXmlElement *alpha = (TiXmlElement*)layer->FirstChild( "alpha" ); 149 if ( alpha ) { 150 if ( !alpha->Attribute( "full" ) ) { 151 string alphamap( alpha->Attribute( "file" ) ); 152 info->alpha = (Texture*)manager->load( alphamap, 153 IMAGE, RP_GAME, (int)GL_TEXTURE_2D ); 154 } 155 } 156 terrain->addMaterialLayer( info ); 157 layer = (TiXmlElement*)layer->NextSibling( "material_layer" ); 158 } 128 159 } 129 160 … … 140 171 void TerrainEntity::loadLightmap( const std::string& _lightFile ) 141 172 { 142 Material *mat = new Material( "TERR_LM" ); 143 mat->setDiffuse( 1.0f, 1.0f, 1.0f ); 144 mat->setAmbient( 1.0f, 1.0f, 1.0f ); 145 mat->setDiffuseMap( _lightFile, GL_TEXTURE_2D, 0 ); 146 mat->setDiffuseMap( std::string( "pictures/debug.png" ), GL_TEXTURE_2D, 1 ); 147 terrain->addMaterial( mat ); 173 ResourceManager *manager = ResourceManager::getInstance(); 174 Texture *lightmap = (Texture*)manager->load( _lightFile, 175 IMAGE, RP_GAME, (int)GL_TEXTURE_2D ); 176 if ( lightmap ) 177 terrain->setLightmap( lightmap ); 178 else 179 PRINTF(0)("no lightmap %s\n", _lightFile.c_str() ); 148 180 } 149 181 … … 173 205 glPushMatrix(); 174 206 175 /* translate */176 207 glTranslatef( this->getAbsCoor().x, 177 208 this->getAbsCoor().y, … … 184 215 terrain->draw( ); 185 216 } 186 187 217 glPopMatrix(); 188 /* 189 glMatrixMode(GL_MODELVIEW); 190 glPushMatrix(); 191 glLoadIdentity(); 192 Vector camera = State::getCameraNode()->getAbsCoor(); // Go on here ..........!!! 193 194 float height = heightMap->getHeight(camera.x, camera.z); 195 196 glEnable (GL_COLOR_MATERIAL) ; 197 glBegin(GL_QUADS); // Draw The Cube Using quads 198 glColor3f(0.0f,1.0f,0.0f); // Color Blue 199 glVertex3f(camera.x + 63.0f,TerrainEntity->getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f); // Top Right Of The Quad (Top) 200 glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f); // Top Left Of The Quad (Top) 201 glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f); // Bottom Left Of The Quad (Top) 202 glVertex3f(camera.x+ 63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f); // Bottom Right Of The Quad (Top) 203 glEnd(); // End Drawing The Plan 204 205 glPopMatrix();*/ 218 206 219 207 220 }
Note: See TracChangeset
for help on using the changeset viewer.