Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10403 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Jan 27, 2007, 12:21:10 AM (18 years ago)
Author:
patrick
Message:

fading now works

Location:
trunk/src/world_entities
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/blackscreen.cc

    r10400 r10403  
    2323#include "material.h"
    2424#include "state.h"
     25#include "camera.h"
     26#include "static_model.h"
    2527
    2628ObjectListDefinition(BlackScreen);
     
    7173  this->material->setDiffuse(0,0,0);
    7274  this->material->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     75
     76  this->build();
    7377
    7478  i=0;
     
    106110  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    107111
    108 this->material->setTransparency(i);
    109 this->material->select();
    110 
    111   glBegin(GL_QUADS);
    112   glVertex3f(0.,-100.0f,-100.0f);
    113   glVertex3f(0., -100.0f,100.0f);
    114   glVertex3f(0., 100.0f,100.0f);
    115   glVertex3f(0., 100.0f,-100.0f);
    116  
    117   glEnd();
     112  this->material->select();
     113
     114
     115  WorldEntity::draw(this->getModel( ));
     116
     117//   glBegin(GL_QUADS);
     118
     119//   glVertex3f(0.,-100.0f,-100.0f);
     120//   glVertex3f(0., -100.0f,100.0f);
     121//   glVertex3f(0., 100.0f,100.0f);
     122//   glVertex3f(0., 100.0f,-100.0f);
     123
     124//   glEnd();
    118125
    119126  glPopMatrix();
     
    130137else
    131138  fadeIn();
     139
     140  this->material->setTransparency(i);
     141  Camera* cam = State::getCamera();
     142  if( cam != NULL)
     143    this->setParent(cam);
    132144}
    133145
     
    176188    return 0;
    177189}
     190
     191
     192void BlackScreen::build()
     193{
     194  StaticModel* model = new StaticModel();
     195
     196  float size = 10.;
     197
     198  model->addVertex (-size, -size, size);
     199  model->addVertex (size, -size, size);
     200  model->addVertex (-size, size, size);
     201  model->addVertex (size, size, size);
     202  model->addVertex (-size, size, -size);
     203  model->addVertex (size, size, -size);
     204  model->addVertex (-size, -size, -size);
     205  model->addVertex (size, -size, -size);
     206
     207
     208  model->addVertexNormal (0.0, 0.0, 1.0);
     209  model->addVertexNormal (0.0, 1.0, 0.0);
     210  model->addVertexNormal (0.0, 0.0, -1.0);
     211  model->addVertexNormal (0.0, -1.0, 0.0);
     212  model->addVertexNormal (1.0, 0.0, 0.0);
     213  model->addVertexNormal (-1.0, 0.0, 0.0);
     214
     215  model->addVertexTexture (0.0, 1.0);
     216  model->addVertexTexture (1.0, 1.0);
     217  model->addVertexTexture (1.0, 0.0);
     218  model->addVertexTexture (0.0, 0.0);
     219
     220  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back
     221  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,5); // front
     222  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,1, 7,1,1, 1,2,1, 0,3,1); // bottom
     223  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,0,3, 3,1,3, 5,2,3, 4,3,3); // top
     224  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,2, 5,3,2, 7,0,2, 6,1,2); // left
     225  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,0, 1,1,0, 3,2,0, 2,3,0); // right
     226
     227  model->finalize();
     228
     229  this->setModel(model);
     230}
  • trunk/src/world_entities/blackscreen.h

    r10379 r10403  
    3636    virtual void draw() const;
    3737
     38  private:
     39    void build();
     40
    3841};
    3942
  • trunk/src/world_entities/camera.cc

    r10396 r10403  
    258258  Vector cameraPosition = this->getAbsCoor();
    259259  Vector targetPosition = this->target->getAbsCoor();
     260
    260261
    261262        //Setting the Camera Eye, lookAt and up Vectors
     
    497498  if (fabs(translateTo.len()  - (target->getAbsCoor()).len()) >= 11 )
    498499 {
    499    printf("translate\n");
    500500   Vector tmpVec= iterate(dt,  &translateTo,  &(masta->getAbsCoor()));
    501501   target->shiftCoor(speed*tmpVec.x, speed*tmpVec.y, speed*tmpVec.z);
  • trunk/src/world_entities/cameraman.cc

    r10400 r10403  
    2929                        addMethod("changeCurrTarget", Executor2<CameraMan, lua_State*,const std::string&,const std::string&>(&CameraMan::changeCurrTarget))
    3030                        ->addMethod("changeTarget", Executor3<CameraMan, lua_State*, const std::string&, const std::string&,const std::string&>(&CameraMan::changeTarget))
    31                         ->addMethod("setCam", Executor1<CameraMan, lua_State*, const std::string&>(&CameraMan::setCam)) 
     31                        ->addMethod("setCam", Executor1<CameraMan, lua_State*, const std::string&>(&CameraMan::setCam))
    3232                        ->addMethod("togglFade", Executor0<CameraMan, lua_State*>(&CameraMan::togglFade))
    3333                        ->addMethod("getCurrCameraCoorX", Executor0ret<CameraMan, lua_State*,float>(&CameraMan::getCurrCameraCoorX))
     
    4444  this->farClip = 1000.0;
    4545
    46   currentCam=State::getCamera();
    47   this->cameras.push_back(currentCam);
    48 
    49   State::setCamera(currentCam, currentCam->getTarget());
    5046  this->fadeToBlack=new BlackScreen();
    51   this->fadeToBlack->setParent(this->currentCam);
    52   this->fadeToBlack->setRelCoor(3., 0., 0.);
    53  
     47
     48  this->setCam( State::getCamera());
     49
    5450  if (root != NULL)
    5551    this->loadParams(root);
     
    6056{
    6157  BaseObject::loadParams(root);
    62  
     58
    6359  LOAD_PARAM_START_CYCLE(root, object);
    6460  {
     
    8379  if (cameraNo<cameras.size())
    8480  {
    85   currentCam=cameras[cameraNo];
     81    this->setCam( cameras[cameraNo]);
     82  }
     83}
     84
     85void CameraMan::setCam(const std::string& camName)
     86{
     87  BaseObject* object = ObjectListBase::getBaseObject("Camera", camName);
     88
     89  if(object != NULL)
     90  {
     91    Camera* currentCam = dynamic_cast<Camera*>(object) ;
     92
     93    this->setCam(currentCam);
     94    return;
     95  }
     96  printf("ERROR CAMERAMANAGER: Couldn't set camera : %s \n", camName.c_str());
     97}
     98
     99
     100void CameraMan::setCam(Camera* camera)
     101{
     102  if( camera == NULL)
     103  {
     104    PRINTF(0)("trying to add a zero camera! uiuiui!\n");
     105  }
     106  this->currentCam = camera;
     107
    86108  State::setCamera(currentCam, currentCam->getTarget());
    87109  OrxSound::SoundEngine::getInstance()->setListener(currentCam);
    88110
     111  // check if it is already added
     112  if( ! this->cameraIsInVector(currentCam) )
     113    this->cameras.push_back(currentCam);
     114
     115  this->fadeToBlack->setRelCoor(0., 0., 0.);
    89116  this->fadeToBlack->setParent(this->currentCam);
    90   this->fadeToBlack->setRelCoor(3., 0., 0.);
    91   }
    92 
    93 }
    94 
    95 void CameraMan::setCam(const std::string& camName)
    96 {
    97   BaseObject* object = ObjectListBase::getBaseObject("Camera", camName);
    98  
    99   if(object != NULL)
    100   {
    101    
    102     currentCam = dynamic_cast<Camera*>(object) ;
    103    
    104     if( ! this->cameraIsInVector(currentCam) )
    105       this->cameras.push_back(currentCam);
    106    
    107     State::setCamera(currentCam, currentCam->getTarget());
    108     OrxSound::SoundEngine::getInstance()->setListener(currentCam);
    109     this->fadeToBlack->setParent(this->currentCam);
    110     this->fadeToBlack->setRelCoor(3., 0., 0.);
    111     return;
    112   }
    113   printf("ERROR CAMERAMANAGER: Couldn't set camera : %s \n", camName.c_str());
    114  
    115 }
     117}
     118
    116119
    117120void CameraMan::moveCurrCam(int x, int y, int z)
    118121{
    119 currentCam->target->trans(x,y,z);
     122  currentCam->target->trans(x,y,z);
    120123}
    121124
     
    123126void CameraMan::moveCam(int x, int y, int z, int camNo)
    124127{
    125 cameras[camNo]->target->trans(x,y,z);
     128  cameras[camNo]->target->trans(x,y,z);
    126129}
    127130
  • trunk/src/world_entities/cameraman.h

    r10394 r10403  
    2222    void setCam(int CameraNo);
    2323    void setCam(const std::string& camName);
     24    void setCam(Camera* camera);
     25
    2426    void createCam(const TiXmlElement* root);
    2527    void moveCam(int x, int y, int z,  int camNo);
     
    3436    void setClipRegion(float nearClip, float farClip);
    3537    void togglFade();
    36    
     38
    3739    /// LOADING
    3840    virtual void loadParams(const TiXmlElement* root);
    39    
     41
    4042    /// POLLING
    4143    float getCurrCameraCoorX(){ return this->currentCam->getAbsCoorX(); }
  • trunk/src/world_entities/sound_entity.cc

    r10368 r10403  
    4141  this->soundSource.setSourceNode(this);
    4242
     43  this->bInit = false;
     44
    4345  if( root != NULL)
    4446    this->loadParams(root);
     
    7577{
    7678  this->soundBuffer = OrxSound::ResourceSoundBuffer(fileName);
     79  this->bInit = true;
    7780}
    7881
     
    8083void SoundEntity::activate()
    8184{
     85  this->soundSource.play();
    8286}
    8387
  • trunk/src/world_entities/sound_entity.h

    r10368 r10403  
    3737  private:
    3838
     39    bool                     bInit;
    3940    OrxSound::SoundSource    soundSource;
    4041    OrxSound::SoundBuffer    soundBuffer;
Note: See TracChangeset for help on using the changeset viewer.