Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10531 in orxonox.OLD


Ignore:
Timestamp:
Jan 31, 2007, 1:27:36 AM (17 years ago)
Author:
bknecht
Message:

explosions and such

Location:
trunk/src/world_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/npcs/npc.cc

    r10512 r10531  
    3737#include "track/track.h"
    3838
     39#include "particles/dot_emitter.h"
     40#include "particles/emitter_node.h"
     41#include "particles/sprite_particles.h"
    3942
    4043#include "weapons/test_gun.h"
     
    6770                        ->addMethod("setAI", Executor1<NPC, lua_State*, bool>(&NPC::setAI))
    6871                        ->addMethod("setVisibility", Executor1<WorldEntity, lua_State*, bool>(&WorldEntity::setVisibility))
     72                        ->addMethod("destroy", Executor0<NPC, lua_State*/*, WorldEntity**/>(&NPC::destroy))
    6973                       );
    7074
     
    243247}
    244248
     249void NPC::destroy( /*WorldEntity* killer*/ )
     250{
     251
     252  PRINTF(5)("NPC destroy\n");
     253
     254  EmitterNode* node  = NULL;
     255  DotEmitter* emitter = NULL;
     256  SpriteParticles*  explosionParticles  = NULL;
     257
     258  explosionParticles = new SpriteParticles(200);
     259  explosionParticles->setName("SpaceShipExplosionParticles");
     260  explosionParticles->setLifeSpan(.2, .3);
     261  explosionParticles->setRadius(0.0, 10.0);
     262  explosionParticles->setRadius(.5, 6.0);
     263  explosionParticles->setRadius(1.0, 3.0);
     264  explosionParticles->setColor(0.0, 1,1,1,.9);
     265  explosionParticles->setColor(0.1,  1,1,0,.9);
     266  explosionParticles->setColor(0.5, .8,.4,0,.5);
     267  explosionParticles->setColor(1.0, .2,.2,.2,.5);
     268
     269
     270  emitter = new DotEmitter( 2000, 70, 360);
     271  //emitter->setSpread( 0, M_2_PI);
     272  emitter->setEmissionRate( 200.0);
     273  //emitter->setEmissionVelocity( 200.0);
     274  //emitter->setSystem( explosionParticles);
     275  //emitter->setAbsCoor( this->getAbsCoor());
     276
     277  node  = new EmitterNode( .1f);
     278  node->setupParticle( emitter, explosionParticles);
     279  node->setAbsDir( this->getAbsDir());
     280  node->setVelocity( this->getVelocity() * .9f);
     281  node->setAbsCoor( this->getAbsCoor());
     282  if( !node->start())
     283    PRINTF(0)("Explosion node not correctly started!");
     284/*
     285  PNode* node          = new PNode();
     286  node->setAbsCoor(this->getAbsCoor());
     287  Explosion* explosion = new Explosion();
     288  explosion->explode( node, Vector(5,5,5));
     289*/
     290/*
     291  if( this->hasPlayer())
     292  {
     293        this->setAbsCoor(Vector(-10000,10000,10000));
     294        this->hide();
     295  }
     296  else
     297  {*/
     298    //this->setAbsCoor( this->getAbsCoor() + Vector(100,0,0) + Vector(1,0,0) * VECTOR_RAND(150).dot(Vector(1,0,0)));
     299  //}
     300
     301}
    245302
    246303void NPC::setWeaponConfig(int i)
  • trunk/src/world_entities/npcs/npc.h

    r10512 r10531  
    3535  void setAI(bool activate);
    3636  inline void enableAI(int flag) { this->bAIEnabled = (bool)flag; }
     37  void destroy( /*WorldEntity* killer*/ );
    3738
    3839private:
  • trunk/src/world_entities/space_ships/space_ship.cc

    r10526 r10531  
    9393                        //->addMethod("setCameraSpeed", Executor1<SpaceShip, lua_State*, float>(&SpaceShip::setCameraSpeed))
    9494                        ->addMethod("pause", Executor1<WorldEntity, lua_State*, bool>(&WorldEntity::pauseTrack))
     95                        ->addMethod("setCameraDist", Executor1<SpaceShip, lua_State*, float>(&SpaceShip::setCameraDistance))
    9596                       );
    9697
     
    616617  {
    617618    this->bRight = event.bPressed;
     619    printf("ShipCoors: %f , %f, %f \n", this->getAbsCoor().x, this->getAbsCoor().y, this->getAbsCoor().z);
    618620  }
    619621  else if( event.type == KeyMapper::PEV_FORWARD)
    620622  {
    621623    this->bForward = event.bPressed; //this->shiftCoor(0,.1,0);
     624
    622625  }
    623626  else if( event.type == KeyMapper::PEV_BACKWARD)
     
    11411144void SpaceShip::setCameraDistance(float dist)
    11421145{
    1143   State::getCamera()->setViewTopDistance(dist);
     1146     
     1147  CameraMan* cm = State::getCameraman();
     1148  Camera* c = cm->getCurrentCam();
     1149  c->setViewTopDistance(dist);
     1150 
     1151  if (this->hasPlayer())
     1152    this->isTravelDistanceInit = false;
    11441153}
    11451154
    11461155void SpaceShip::setCameraFovy(float fovy)
    11471156{
    1148   State::getCamera()->setViewTopFovy(fovy);
     1157     
     1158  CameraMan* cm = State::getCameraman();
     1159  Camera* c = cm->getCurrentCam();
     1160  c->setViewTopFovy(fovy);
     1161 
     1162  if (this->hasPlayer())
     1163    this->isTravelDistanceInit = false;
    11491164}
    11501165
     
    11531168     CameraMan* cm = State::getCameraman();
    11541169     Camera* c = cm->getCurrentCam();
    1155 
    1156 
     1170     
     1171     
    11571172  float x = 1.25 * this->actionWidthPercentage * fabsf(c->getAbsCoor().y) * tan(c->getFovy()*M_PI /360.0);
    11581173  float y = x / c->getAspectRatio() / this->actionWidthPercentage;
  • trunk/src/world_entities/space_ships/space_ship.h

    r10516 r10531  
    9292
    9393    virtual void hit(float damage, WorldEntity* killer);
     94   
     95    void                  setCameraDistance(float dist);
    9496
    9597  private:
     
    188190    float                 cameraSpeed;
    189191
    190     void                  setCameraDistance(float dist);
     192
    191193    void                  setCameraFovy(float fovy);
    192194
Note: See TracChangeset for help on using the changeset viewer.