Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3070 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Dec 3, 2004, 8:22:38 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/importer: ability to readIn BMP files for the diffuse-color-Texture

Location:
orxonox/trunk/importer
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/importer/framework.cc

    r3069 r3070  
    8787  glLightfv(GL_LIGHT1, GL_SPECULAR, whiteLight);
    8888 
     89
     90  glEnable(GL_TEXTURE_2D);
    8991  rotatorP = .0;
    9092  rotatorV = .0;
  • orxonox/trunk/importer/material.cc

    r3069 r3070  
    8484  setShininess(2.0);
    8585  setTransparency(0.0);
     86
     87  diffuseTextureSet = false;
     88  ambientTextureSet = false;
     89  specularTextureSet = false;
     90
    8691 
    8792}
     
    243248  setTransparency (atof(tr));
    244249}
     250
     251// MAPPING //
     252
     253/**
     254   \brief Sets the Materials Diffuse Map
     255   \param dMap the Name of the Image to Use
     256*/
     257void Material::setDiffuseMap(char* dMap)
     258{
     259  if (verbose>=2)
     260    printf ("setting Diffuse Map %s\n", dMap);
     261
     262  diffuseTextureSet = loadBMP(dMap, &diffuseTexture);
     263
     264}
     265
     266/**
     267   \brief Sets the Materials Ambient Map
     268   \param aMap the Name of the Image to Use
     269*/
     270void Material::setAmbientMap(char* aMap)
     271{
     272  SDL_Surface* ambientMap;
     273
     274}
     275
     276/**
     277   \brief Sets the Materials Specular Map
     278   \param sMap the Name of the Image to Use
     279*/
     280void Material::setSpecularMap(char* sMap)
     281{
     282  SDL_Surface* specularMap;
     283
     284}
     285
     286/**
     287   \brief Sets the Materials Bumpiness
     288   \param bump the Name of the Image to Use
     289*/
     290void Material::setBump(char* bump)
     291{
     292
     293}
     294
     295/**
     296   \brief reads in a Windows BMP-file, and imports it to openGL.
     297   \param bmpName The name of the Image to load.
     298   \param texture A pointer to the Texture which should be read to.
     299*/
     300bool Material::loadBMP (char* bmpName, GLuint* texture)
     301{
     302  SDL_Surface* map;
     303  if (map = SDL_LoadBMP(bmpName))
     304    {
     305
     306      glGenTextures( 1, texture );
     307      /* Typical Texture Generation Using Data From The Bitmap */
     308      glBindTexture( GL_TEXTURE_2D, *texture );
     309     
     310      /* Generate The Texture */
     311      glTexImage2D( GL_TEXTURE_2D, 0, 3, map->w,
     312                    map->h, 0, GL_BGR,
     313                    GL_UNSIGNED_BYTE, map->pixels );
     314     
     315      /* Linear Filtering */
     316      glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
     317      glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
     318      if ( map )
     319        SDL_FreeSurface( map );
     320
     321      return true;
     322    }
     323  else
     324    return false;
     325}
     326
     327
     328
    245329
    246330/**
     
    294378  else if (illumModel >= 2)
    295379    glShadeModel(GL_SMOOTH);
    296 }
     380
     381  if (diffuseTextureSet)
     382    glBindTexture(GL_TEXTURE_2D, diffuseTexture);
     383 
     384}
  • orxonox/trunk/importer/material.h

    r3069 r3070  
    1111#include <GL/gl.h>
    1212#include <GL/glu.h>
     13#include <SDL/SDL.h>
    1314#include <stdlib.h>
    1415#include <fstream>
     
    2526  ~Material ();
    2627
     28  GLuint diffuseTexture;
     29  GLuint ambientTexture;
     30  GLuint specularTexture;
     31 
     32  bool diffuseTextureSet;
     33  bool ambientTextureSet;
     34  bool specularTextureSet;
    2735
    2836  void setName (char* mtlName);
     
    4048  void setTransparency (float trans);
    4149  void setTransparency (char* trans);
     50
     51  // MAPPING //
     52  void setDiffuseMap(char* dMap);
     53  void setAmbientMap(char* aMap);
     54  void setSpecularMap(char* sMap);
     55  void setBump(char* bump);
     56
     57  bool loadBMP (char* bmpName, GLuint* texture);
     58
    4259
    4360  Material* search (char* mtlName);
  • orxonox/trunk/importer/object.cc

    r3069 r3070  
    575575          tmpMat->setTransparency(Buffer+2);
    576576        }
    577       else if (!strncpy(Buffer, "Tf ", 3))
     577      else if (!strncmp(Buffer, "Tf ", 3))
    578578        {
    579579          tmpMat->setTransparency(Buffer+3);
    580580        }
     581     
     582      else if (!strncmp(Buffer, "map_Kd ", 7))
     583        {
     584          tmpMat->setDiffuseMap(Buffer+7);
     585        }
     586      else if (!strncmp(Buffer, "map_Ka ", 7))
     587        {
     588          tmpMat->setAmbientMap(Buffer+7);
     589        }
     590      else if (!strncmp(Buffer, "map_Ks ", 7))
     591        {
     592          tmpMat->setSpecularMap(Buffer+7);
     593        }
     594      else if (!strncmp(Buffer, "bump ", 5))
     595        {
     596          tmpMat->setBump(Buffer+7);
     597        }
     598     
    581599
    582600    }
Note: See TracChangeset for help on using the changeset viewer.