Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3436 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Mar 1, 2005, 6:16:49 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: added new Class light, that handles lights (needed for Bump-mapping).
Because Light is very important in 3D, I have created this Class

Location:
orxonox/trunk/src
Files:
8 edited
2 copied

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/Makefile.am

    r3433 r3436  
    3737                 curve.cc \
    3838                 glmenu_imagescreen.cc \
    39                  skysphere.cc
     39                 skysphere.cc \
     40                 light.cc
    4041
    4142noinst_HEADERS = ability.h \
     
    7980                 glmenu_imagescreen.h \
    8081                 debug.h \
    81                  skysphere.h
     82                 skysphere.h \
     83                 light.h
    8284
    8385## orxonox.conf will be used from home-dir instead.
  • orxonox/trunk/src/Makefile.in

    r3433 r3436  
    6464        helper_parent.$(OBJEXT) track_manager.$(OBJEXT) \
    6565        matrix.$(OBJEXT) curve.$(OBJEXT) glmenu_imagescreen.$(OBJEXT) \
    66         skysphere.$(OBJEXT)
     66        skysphere.$(OBJEXT) light.$(OBJEXT)
    6767orxonox_OBJECTS = $(am_orxonox_OBJECTS)
    6868orxonox_LDADD = $(LDADD)
     
    8181@AMDEP_TRUE@    ./$(DEPDIR)/helper_parent.Po \
    8282@AMDEP_TRUE@    ./$(DEPDIR)/ini_parser.Po ./$(DEPDIR)/keynames.Po \
    83 @AMDEP_TRUE@    ./$(DEPDIR)/list.Po ./$(DEPDIR)/material.Po \
    84 @AMDEP_TRUE@    ./$(DEPDIR)/matrix.Po ./$(DEPDIR)/model.Po \
    85 @AMDEP_TRUE@    ./$(DEPDIR)/null_parent.Po ./$(DEPDIR)/objModel.Po \
    86 @AMDEP_TRUE@    ./$(DEPDIR)/orxonox.Po ./$(DEPDIR)/p_node.Po \
    87 @AMDEP_TRUE@    ./$(DEPDIR)/player.Po ./$(DEPDIR)/skysphere.Po \
     83@AMDEP_TRUE@    ./$(DEPDIR)/light.Po ./$(DEPDIR)/list.Po \
     84@AMDEP_TRUE@    ./$(DEPDIR)/material.Po ./$(DEPDIR)/matrix.Po \
     85@AMDEP_TRUE@    ./$(DEPDIR)/model.Po ./$(DEPDIR)/null_parent.Po \
     86@AMDEP_TRUE@    ./$(DEPDIR)/objModel.Po ./$(DEPDIR)/orxonox.Po \
     87@AMDEP_TRUE@    ./$(DEPDIR)/p_node.Po ./$(DEPDIR)/player.Po \
     88@AMDEP_TRUE@    ./$(DEPDIR)/skysphere.Po \
    8889@AMDEP_TRUE@    ./$(DEPDIR)/story_entity.Po ./$(DEPDIR)/texture.Po \
    8990@AMDEP_TRUE@    ./$(DEPDIR)/track_manager.Po ./$(DEPDIR)/vector.Po \
     
    246247                 curve.cc \
    247248                 glmenu_imagescreen.cc \
    248                  skysphere.cc
     249                 skysphere.cc \
     250                 light.cc
    249251
    250252noinst_HEADERS = ability.h \
     
    288290                 glmenu_imagescreen.h \
    289291                 debug.h \
    290                  skysphere.h
     292                 skysphere.h \
     293                 light.h
    291294
    292295EXTRA_DIST = orxonox.conf
     
    316319          esac; \
    317320        done; \
    318         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/Makefile'; \
     321        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/Makefile'; \
    319322        cd $(top_srcdir) && \
    320           $(AUTOMAKE) --gnu  src/Makefile
     323          $(AUTOMAKE) --foreign  src/Makefile
    321324.PRECIOUS: Makefile
    322325Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
     
    384387@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ini_parser.Po@am__quote@
    385388@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keynames.Po@am__quote@
     389@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/light.Po@am__quote@
    386390@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@
    387391@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/material.Po@am__quote@
  • orxonox/trunk/src/console/Makefile.in

    r3433 r3436  
    203203          esac; \
    204204        done; \
    205         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/console/Makefile'; \
     205        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/console/Makefile'; \
    206206        cd $(top_srcdir) && \
    207           $(AUTOMAKE) --gnu  src/console/Makefile
     207          $(AUTOMAKE) --foreign  src/console/Makefile
    208208.PRECIOUS: Makefile
    209209Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/gui/Makefile.in

    r3433 r3436  
    234234          esac; \
    235235        done; \
    236         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/gui/Makefile'; \
     236        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/gui/Makefile'; \
    237237        cd $(top_srcdir) && \
    238           $(AUTOMAKE) --gnu  src/gui/Makefile
     238          $(AUTOMAKE) --foreign  src/gui/Makefile
    239239.PRECIOUS: Makefile
    240240Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/importer/Makefile.in

    r3433 r3436  
    215215          esac; \
    216216        done; \
    217         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/importer/Makefile'; \
     217        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/importer/Makefile'; \
    218218        cd $(top_srcdir) && \
    219           $(AUTOMAKE) --gnu  src/importer/Makefile
     219          $(AUTOMAKE) --foreign  src/importer/Makefile
    220220.PRECIOUS: Makefile
    221221Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/light.cc

    r3435 r3436  
    1212
    1313   ### File Specific:
    14    main-programmer: ...
     14   main-programmer: Benjamin Grauer
    1515   co-programmer: ...
    1616*/
    1717
    1818
    19 #include "proto_class.h"
     19#include "light.h"
    2020
     21#include "glincl.h"
    2122
    2223using namespace std;
     
    2425
    2526/**
    26    \brief standard constructor
    27    \todo this constructor is not jet implemented - do it
     27   \brief standard constructor for a Light
    2828*/
    29 ProtoClass::ProtoClass ()
     29Light::Light ()
    3030{
    31    this->setClassName ("ProtoClass");
     31  this->init();
    3232}
    3333
     34Light::Light(Vector position)
     35{
     36  this->init();
     37  this->setPosition(position);
     38}
    3439
    3540/**
     
    3843
    3944*/
    40 ProtoClass::~ProtoClass () {}
     45Light::~Light ()
     46{
     47  glDisable(GL_LIGHTING);
     48  glDisable(GL_LIGHT0);
     49}
     50
     51/**
     52   \brief initializes a new Light with default values, and enables GL_LIGHTING
     53*/
     54void Light::init()
     55{
     56  this->setClassName ("Light");
     57  glEnable (GL_LIGHTING);
     58  glEnable (GL_LIGHT0);
     59 
     60  this->setPosition(Vector(0.0, 0.0, 0.0));
     61  this->setDiffuseColor(1.0, 1.0, 1.0);
     62  this->setSpecularColor(1.0, 1.0, 1.0);
     63  //  lmodelAmbient[] = {.1, .1, .1, 1.0};
     64 
     65}
     66
     67// set Attributes
     68/**
     69   \brief Sets a Position for the Light.
     70   \param position The new position of the Light.
     71   \todo patrick: is it ok to set a Light Position even if it is derived from p_node??
     72*/
     73void Light::setPosition(Vector position)
     74{
     75  this->lightPosition[0] = position.x;
     76  this->lightPosition[1] = position.y;
     77  this->lightPosition[2] = position.z;
     78  this->lightPosition[3] = 0.0;
     79
     80  glLightfv (GL_LIGHT0, GL_POSITION, lightPosition);
     81
     82}
     83
     84/**
     85   \brief sets an emitting Diffuse color for the Light
     86   \param r red
     87   \param g green
     88   \param b blue
     89*/
     90void Light::setDiffuseColor(GLfloat r, GLfloat g, GLfloat b)
     91{
     92  this->diffuseColor[0] = r;
     93  this->diffuseColor[1] = g;
     94  this->diffuseColor[2] = b;
     95  this->diffuseColor[3] = 1.0;
     96
     97  glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuseColor);
     98}
    4199
    42100
    43101/**
    44    \brief nonsense - delete this method
    45    \param realy nothing to give
    46    \returns true or false - probably nothing?
     102   \brief sets an emitting Ambient color for the Light
     103   \param r red
     104   \param g green
     105   \param b blue
     106*/
     107void Light::setSpecularColor(GLfloat r, GLfloat g, GLfloat b)
     108{
     109  this->specularColor[0] = r;
     110  this->specularColor[1] = g;
     111  this->specularColor[2] = b;
     112  this->specularColor[3] = 1.0;
    47113
    48    this is just to show the doxygen abilities (this for example is an extension for a long comment)
     114  glLightfv (GL_LIGHT0, GL_SPECULAR, specularColor);
     115}
     116
     117// get Attributes
     118
     119/**
     120   \returns the Position of the Light
    49121*/
    50 bool ProtoClass::doNonSense (int nothing) {}
     122Vector Light::getPosition(void)
     123{
     124  Vector tmpPosition(lightPosition[0], lightPosition[1], lightPosition[2]);
     125  return tmpPosition;
     126}
  • orxonox/trunk/src/light.h

    r3435 r3436  
    11/*!
    2     \file proto_class.h
    3     \brief Definition of the proto class template, used quickly start work
    4     \todo Example: this shows how to use simply add a Marker that here has to be done something.
     2    \file light.h
     3    \brief Handles Lights.
    54
    6     The Protoclass exists, to help you quikly getting the run for how to develop in orxonox.
    7     It is an example for the CODING-CONVENTION, and a starting-point for every class.
     5    A Light is one of the more important things in a 3D-environment,
     6    without it one sees nothing :)
     7    It is here for diffuse-, specular- and Bump-Mappings.
    88*/
    99
    10 #ifndef _PROTO_CLASS_H
    11 #define _PROTO_CLASS_H
     10#ifndef _LIGHT_H
     11#define _LIGHT_H
    1212
    13 #include "stdincl.h"
     13#include "world_entity.h"
     14#include "glincl.h"
    1415
    15 /*class Test;*/ /* forward definition of class Test (without including it here!)*/
     16// FORWARD DEFINITIONS //
     17class Vector;
    1618
    17 //! A default class that aids you to start creating a new class
     19//! A class that handles Lights
    1820/**
    19    here can be some longer description of this class
     21   A Light is a source that emits light rays (photons)
    2022*/
    21 class ProtoClass : public BaseObject {
     23class Light : public WorldEntity
     24{
     25 
    2226
    2327 public:
    24   ProtoClass ();
    25   ~ProtoClass ();
     28  Light(void);
     29  Light(Vector position);
     30  ~Light(void);
    2631
    27   bool doNonSense (int nothing);
     32  // set Attributes
     33  void setPosition(Vector position);
     34  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
     35  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
     36 
     37  // get Attributes
     38  Vector getPosition(void);
     39 private:
     40  GLfloat lightPosition[4];   //!< The Position of this Light
     41  GLfloat lmodelAmbient[4];   //!< The general Ambient Color
     42  GLfloat diffuseColor[4];    //!< The Diffuse Color this Light emmits
     43  GLfloat specularColor[4];   //!< The specular Color of this Light
    2844
    29  private:
    30   int nonSense;  //!< doxygen tag here like this for all the variables - delete this variable if you use this
    31 
     45  void init();
    3246};
    3347
    34 #endif /* _PROTO_CLASS_H */
     48#endif /* _LIGHT_H */
  • orxonox/trunk/src/orxonox.cc

    r3398 r3436  
    173173  glClearColor (0.0, 0.0, 0.0, 0.0);
    174174  glEnable (GL_DEPTH_TEST);
    175  
    176   // LIGHTING
    177   GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0};
    178   GLfloat whiteLight[] = {1.0, 1.0, 1.0,1.0};
    179   GLfloat lightPosition[] = {10.0, 10, 19.0, 0.0};
    180 
    181   glLightfv (GL_LIGHT0, GL_DIFFUSE, whiteLight);
    182   glLightfv (GL_LIGHT0, GL_SPECULAR, whiteLight);
    183   glEnable (GL_LIGHTING);
    184   glEnable (GL_LIGHT0);
    185   glEnable (GL_DEPTH_TEST);
    186   glLightfv (GL_LIGHT0, GL_POSITION, lightPosition);
    187   glLightfv (GL_LIGHT0, GL_DIFFUSE, whiteLight);
    188175   
    189   //glEnable (GL_TEXTURE_2D);
    190   //  glEnable(GL_COLOR);
    191   //  glShadeModel(GL_SMOOTH);
    192  
    193   // create camera
    194   //localcamera = new Camera(world); /* \todo camera/input node not used anymore*/
    195  
    196176  return 0;
    197177}
  • orxonox/trunk/src/world.cc

    r3433 r3436  
    2828#include "glmenu_imagescreen.h"
    2929#include "skysphere.h"
     30#include "light.h"
    3031
    3132using namespace std;
     
    171172void World::load()
    172173{
     174  light0 = new Light(Vector(10.0, 10.0, 19.0));
     175
    173176  //  BezierCurve* tmpCurve = new BezierCurve();
    174177  if(this->debugWorldNr != -1)
  • orxonox/trunk/src/world.h

    r3433 r3436  
    1717class GLMenuImageScreen;
    1818class Skysphere;
     19class Light;
    1920
    2021//! The game environment
     
    7677  SDL_Surface *loadImage;
    7778  Skysphere* skySphere;
     79  Light* light0;
    7880
    7981  WorldEntity* localPlayer;
Note: See TracChangeset for help on using the changeset viewer.