About Store Forum Documentation Contact



Post Reply 
sry.. help me with light params..
Author Message
b1s Offline
Member

Post: #1
sry.. help me with light params..
im really confused about the light parameters from the editor to own project..

i would like to set up in world editor things like color, range, vol, vol_max..

after reading the headers, customparams tutorial etc.
i still cant figure out how to do this..

im creating my lights as the tutorial says.. just cant pick up any additional params..
if someone could point me to the right direction i would appreciate it alot.
sry for all the enconviniance..

Code:
void Item::create(Game::ObjParams &obj)
{
   __super::create(obj); // default create

   // add custom children
   for(Game::ObjParams *cur=&obj; cur; cur=cur->base()) // check 'obj' and all its bases
      FREPA(cur->sub_obj) // for each sub-object in 'cur'
      {
         Game::ObjParams &o=cur->sub_obj[i];
        
         switch(Game::World.objType(o.type())) // check the type of sub-object
         {
            case OBJ_LGT_PNT: // if its light, then create our member from its parameters
               light_point.create(o);  

            break;
         }
      }
}




edit:
btw heres a little update after 48hrs of installing.. im loving this engine.
[Image: wip.jpg]
06-20-2009 11:35 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
Re: sry.. help me with light params..
I'm very happy that you like the engine smile And great screens!

As for the lights you should create your custom game light object class

struct LightObject : Game::Obj
{
Vec color;
Flt range;

void create(Game::ObjParams &params)
{
color=params.get...
range=params.get...
}
void draw()
{
if(Renderer()==RM_LIGHT)
{
LightSqr(..)draw();
}
}
};

this should be something more or less like it smile
and don't forget to set the parameters in the World Editor

and at the start of the game call
Game::ObjMemx<LightObject> lights;
World.setType(OBJ_LGT_PNT,lights);

I've written it from my memory wink

I will try to automate the lighting process in the next versions of the World Editor (currently it's being much updated smile )
06-21-2009 11:16 AM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #3
Re: sry.. help me with light params..
whats that LightSqr ?
should i somehow tell there what to draw?
06-21-2009 12:20 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #4
Re: sry.. help me with light params..
Im shooting in the dark here and very confused...

ehheh.. sry mate..
Code:
struct LightObject : Game::Obj
{
Game::LightPoint light_point;
virtual void create(Game::ObjParams &obj);
Vec color;
Flt range;
}

void create(Game::ObjParams &params)
{
__super::create(obj); // default create

switch(Game::World.objType(&params.type())) // check the type of object
     {
        case OBJ_LGT_PNT: // if its light, then create our member from its parameters
           power=params.findParam("power")->asFlt();
           light_point.create(&params);
        break;
     }
}


any right direction there?
06-21-2009 12:52 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
Re: sry.. help me with light params..
Game::LightPoint light_point; // you don't need this


void LightObject::create(Game::ObjParams &params)
{
power=params.getParam("power")->asFlt();
...
}


LightSqr is a point light with fast fading (based on x squared function)
06-21-2009 01:04 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #6
Re: sry.. help me with light params..
Too much errors for me to understand anything..
i changed to your first proposal type...

Code:
/******************************************************************************/
#include "stdafx.h"
#include "../../../../../data/enum/_enums.h"
Sound sound;
/******************************************************************************/
Game::ObjMemx<Game::Static> Statics; // container for static objects
Game::ObjMemx<Game::Item  > Items  ; // container for item   objects
Game::ObjMemx<      Player> Players; // container for player objects
Game::ObjMemx<LightObject>    lights; // container for point light objects

/******************************************************************************/

struct LightObject : Game::Obj
{
Vec color;
Flt power;
void create(Game::ObjParams &params)
    {
    power=params.getParam("power").asFlt();
    }
void draw()
    {
    if(Renderer()==RM_LIGHT)
        {
        LightPoint(power);
        draw();
        }
    }
};
/******************************************************************************/
// Define viewing modes:
enum VIEW_MODE // Viewing Mode
{
   VIEW_FPP, // First Person
   VIEW_TPP, // Third Person
   VIEW_ISO, // Isometric
   VIEW_NUM, // number of view modes
};
UInt View; // current VIEW_MODE
/******************************************************************************/
struct Player : Game::Chr
{
   virtual Bool update();
   virtual void draw(); // extend drawing to disable head rendering in FPP mode
};

Bool Player::update()
{
   if(action)
   {
      if(Kb.b(KB_W) || Kb.b(KB_S) || Kb.b(KB_A) || Kb.b(KB_D) || Kb.b(KB_Q) || Kb.b(KB_E))actionBreak();
   }

   if(!action)
   {
      // turn & move
      input.anglei.x=Kb.b(KB_Q)-Kb.b(KB_E);
      input.anglei.y=Kb.b(KB_T)-Kb.b(KB_G);
      input.diri  .x=Kb.b(KB_D)-Kb.b(KB_A);
      input.diri  .z=Kb.b(KB_W)-Kb.b(KB_S);
      input.diri  .y=Kb.b(KB_SPACE)-Kb.b(KB_LCTRL);

      // dodge, crouch, walk, jump
      input.dodge = Kb.bd(KB_D)-Kb.bd(KB_A);
      input.crouch= Kb.b (KB_LCTRL);
      input.walk  = !Kb.b (KB_LSHIFT );
      input.jump  =(Kb.bp(KB_SPACE ) ? 3.5 : 0);

      // mouse turn
      if(View!=VIEW_ISO) // don't use mouse turning when in Isometric mode
      {
         Flt  max=DegToRad(900)*Tm.d(),
              dx =Ms.dir_ds.x*1.7,
              dy =Ms.dir_ds.y*1.7*Ms.inv();
         angle.x-=Mid(dx,-max,max);
         angle.y+=Mid(dy,-max,max);
      }

      // ready stance change
      ready^=Kb.bp(KB_R);
   }

   return __super::update();
}

void Player::draw()
{
   Bool disable_head_draw=(View==VIEW_FPP && Renderer()!=RM_SHD_MAP && mesh); // disable drawing head when we're in FPP mode and we're not in shadowing mode (if this isn't included player will cast head-less shadows)

   if(disable_head_draw)mesh->hide("head"); // hide "head" mesh part in 'mesh'

   __super::draw(); // call default drawing

   if(disable_head_draw)mesh->show("head"); // un-hide "head" mesh part, so other objects which use the same mesh will have the head rendered properly
}

/******************************************************************************/
void InitPre()
{
    App.name("Damien");
    App.flag=APP_MS_EXCLUSIVE|APP_FULL_TOGGLE;
    IOPath("../data");
    PakAdd("engine.pak");

    D.full(true).sync(false).shdMapSize(1024).hpRt(true);
    D.full(true).mtnMode(MTN_LOW); // enable motion blur
    D.mtnVelScale(0.1);            // increase motion blurring
    D.full(true).ambMode(AMB_HIGH3).ambSoft(1).ambJitter(1).ambHalfRes(1).ambPo​wer(0.2); // set initial ambient occlusion parameters
    D.mode(1024,768).volLight(true).volAdd(true).volMax(0.8);
    //D.full(true).bloom(0.8,0.5,0.5,true);
    D.full(true).hdr(true).hdrMaxBright(0.8).hdrMaxDark(0).hdrExposure(0.8).hdr​Contrast(3).hdrWeighted(false);
    D.edgeSoften(2,1);
    D.superSample(1);
    D.bumpMode(BUMP_NORMAL); // Bumpmapping Mode
    D.shdMode(SHD_MAP_HW).shdSoft(1);

}
/******************************************************************************/
Bool Init()
{
   Physics.create();
   Sky    .set   (*Images("gfx/sky/skybox.gfx"));
    
   Sun &sun=Suns.New(); sun.set(*Images("gfx/sky/sun.gfx")).light_color=Vec(0.65,0.4,0);sun.vol_steam=0.6;sun.rays.mode=SUN_RAYS_LOW;sun.​vol=0.9;sun.vol_exponent=0.65;sun.pos=!Vec(-1,0.4,-1);sun.size=0.05;


   // create the world
   Game::World.init()
                .setType(Statics,OBJ_STATIC)
                .setType(Players,OBJ_CHR   )
                .setItem(Items  ,OBJ_ITEM  )
                .setType(lights,OBJ_LGT_PNT)
                .New("World/world/"        );

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Main()
{
   if(Kb.bp(KB_ESC))return false;

   Game::World.update(Cam.at);
   if(!sound.playing()) // if already playing
      {
        sound.play("music/sneaky.ogg",true);
        sound.volume(0.1);
      }
  
  
   // set next camera mode when Tab pressed
   if(Kb.bp(KB_TAB))
   {
      View=(View+1)%VIEW_NUM;

      if(View==VIEW_ISO) // when set to isometric view
      {
         Cam.dist =   10; // set bigger camera distance at start
         Cam.pitch=-PI_4; // set starting camera pitch angle
      }
   }

   // setup the camera
   if(Players.elms()) // if we have at least one player
   {
      // set camera depending on current view mode
      switch(View)
      {
         case VIEW_FPP:
         {
            OrientP &head=Players[0].cskel.getPoint("head"); // obtain player "head" skeleton point (this was created in Mesh Editor)
            Cam.setPosDir(head.pos,head.dir,head.perp); // set camera from 'head' position, direction and perpendicular to direction
         }break;
        
         case VIEW_TPP:
         {
            Cam.dist=Max(1.0f,Cam.dist*ScaleFactor(Ms.wheel()*-0.1)); // update camera distance according to mouse wheel
            Cam.setSpherical(Players[0].pos()+Vec(0,0.5,0), Players[0].angle.x, Players[0].angle.y, 0, Cam.dist); // set spherical camera looking at player position with given player angles
         }break;
        
         default: // VIEW_ISO
         {
            Cam.yaw  -=Ms.ds.x; // update camera yaw   angle according to mouse smooth delta x
            Cam.pitch+=Ms.ds.y; // update camera pitch angle according to mouse smooth delta y
            Clamp(Cam.pitch,-PI_2,0); // clamp to possible camera pitch angle
            Cam.dist  =Max(1.0f,Cam.dist*ScaleFactor(Ms.wheel()*-0.1)); // update camera distance according to mouse wheel
            Cam.setSpherical(Players[0].pos(), Cam.yaw, Cam.pitch, 0, Cam.dist); // set spherical camera looking at player using camera angles
         }break;
      }

      // after setting camera position and angles:
      Cam.updateVelocities().set(); // update camera velocities and activate it
   }
   else // when no player on the scene
   {
      CamHandle(0.1,100,CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT)); // default camera handling actions
   }

   return true;
}
/******************************************************************************/
void Render()
{
    
    Game::World.draw();
}
void Draw()
{
   Renderer(Render);
   D.text(0,0.9,S+"Fps: "+Tm.fps());
}
/******************************************************************************/
06-21-2009 01:28 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
Re: sry.. help me with light params..
could you post the errors which you're receiving?

from the codes

Code:
Game::ObjMemx<LightObject>   lights; // container for point light objects

/******************************************************************************/

struct LightObject : Game::Obj
{
Vec color;
Flt power;
void create(Game::ObjParams &params)
   {
   power=params.getParam("power").asFlt();
   }
void draw()
   {
   if(Renderer()==RM_LIGHT)
      {
      LightPoint(power);
      draw();
      }
   }
};

I'm guessing that you're using in the container the class which is declared at a later stage.
First you should declara a class, and only then you can use it smile
06-21-2009 02:08 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
Re: sry.. help me with light params..
Code:
void draw()
   {
   if(Renderer()==RM_LIGHT)
      {
      LightPoint(power);
      draw();
      }
   }

and this code should be changed to this

void draw()
{
if(Renderer()==RM_LIGHT)
{
LightPoint(power,...).add();
}
}
06-21-2009 02:09 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
Re: sry.. help me with light params..
dont forget to access the color and light position here

{
power=params.getParam("power").asFlt();
}

{
power=..
color=..
pos=params.pos();
}


struct LightObject
{
Flt power;
Vec color,pos;

please check for tutorials on how to create custom game object class (there are that will help you smile )
06-21-2009 02:11 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #10
Re: sry.. help me with light params..
oh.. thank you.. you are very helpfull..
lets see if can get the idea from this..

ill do some modifications as you instructed.. lets see if i get any errors after that.
06-21-2009 02:15 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #11
Re: sry.. help me with light params..
i checked the extending the obj class tutorial .. and tried to copy/paste that..

With something like this..
i have no idea whats needed and what isnt..
Also im not sure how to get Vec from parameters..


Code:
struct LightObject : Game::Obj
{
Vec color;
Vec position;
Flt power;
// provide necessary methods required by Game::Obj :
virtual void create(Game::ObjParams &obj); // extend default creation

virtual Matrix matrix(              ){return position      ;} // get matrix
virtual void   matrix(Matrix &matrix){     T.position=matrix.pos;} // set matrix

virtual Bool update(){return true;} // object update
virtual void draw  ();
virtual void disable(){}
virtual void enable(){}

// constructor
LightObject();

// io methods
virtual void save(File &f);
virtual Bool load(File &f);

};

LightObject::LightObject() // initialize values in constructor
{
   position.zero();
}

void LightObject ::create(Game::ObjParams &params)
   {
    //color=params.getParam("color").asCol();
    position=params.matrixFinal().pos;
    power=params.getParam("power").asFlt();
   }

void LightObject ::draw()
    {
    if(Renderer()==RM_LIGHT)
        {
        SetMatrix();
        LightPoint(power,position,Vec(1,1,1),0,0);
        }
    }

/******************************************************************************/
void LightObject ::save(File &f)
{
   __super::save(f); // default save

   f<<position; // save custom parameters
}
Bool LightObject ::load(File &f)
{
   if(__super::load(f)) // if default load was successful
   {
      f>>position; // load custom parameters
      return true; // return success
   }
   return false; // return failure
}
/******************************************************************************/



Errors:
Code:
>------ Build started: Project: Tutorials, Configuration: Release Win32 ------
1>Compiling...
1>game.cpp
1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\esenthelengine\Misc/Misc.h(108) : error C2259: 'LightObject' : cannot instantiate abstract class
1>        due to following members:
1>        'void EE::Game::Obj::pos(EE::Vec &)' : is abstract
1>        d:\program files (x86)\microsoft visual studio 9.0\vc\include\esenthelengine\Game/Object.h(21) : see declaration of 'EE::Game::Obj::pos'
1>        'EE::Vec EE::Game::Obj::pos(void)' : is abstract
1>        d:\program files (x86)\microsoft visual studio 9.0\vc\include\esenthelengine\Game/Object.h(20) : see declaration of 'EE::Game::Obj::pos'
1>        d:\program files (x86)\microsoft visual studio 9.0\vc\include\esenthelengine\Misc/Misc.h(108) : while compiling class template member function 'void EE::ClassFunc<TYPE>::New(Ptr)'
1>        with
1>        [
1>            TYPE=LightObject
1>        ]
1>        d:\program files (x86)\microsoft visual studio 9.0\vc\include\esenthelengine\Misc/Memory Containers.h(390) : see reference to class template instantiation 'EE::ClassFunc<TYPE>' being compiled
1>        with
1>        [
1>            TYPE=LightObject
1>        ]
1>        d:\program files (x86)\microsoft visual studio 9.0\vc\include\esenthelengine\Misc/Memory Containers.h(390) : while compiling class template member function 'EE::Memx<TYPE>::Memx(Int)'
1>        with
1>        [
1>            TYPE=LightObject
1>        ]
1>        d:\program files (x86)\microsoft visual studio 9.0\vc\include\esenthelengine\Game/World.h(16) : see reference to class template instantiation 'EE::Memx<TYPE>' being compiled
1>        with
1>        [
1>            TYPE=LightObject
1>        ]
1>        .\Source\Advanced\4 - Demos, Game Basics\Game Basics\game.cpp(141) : see reference to class template instantiation 'EE::Game::ObjMemx<TYPE>' being compiled
1>        with
1>        [
1>            TYPE=LightObject
1>        ]
1>Build log was saved at "file://e:\Damien\Damien_0.001\Source\Release\BuildLog.htm"
1>Tutorials - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
06-21-2009 02:47 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #12
Re: sry.. help me with light params..
yes, very good smile
but you forgot to implement the required 'pos' methods (they need to be implemented just like you did with the 'matrix' methods smile )
06-21-2009 08:58 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #13
Re: sry.. help me with light params..
ok.. it builds now.. just crashes when it dosent find some param..
i
06-21-2009 09:12 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #14
Re: sry.. help me with light params..
maybe this means that you havent set the parameter for the object in the world editor smile
Game::ObjParams::getParam works that way, so it returns an error message when the requested parameter isn't found
06-21-2009 09:19 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #15
Re: sry.. help me with light params..
i tried manually just changing the LightPoint(power,,,) values to something... and now lights at all.. im propably missing something here..



Code:
/******************************************************************************/
#include "stdafx.h"
#include "../../../../../data/enum/_enums.h"
Sound sound;
/******************************************************************************/
struct LightObject : Game::Obj
{
Vec color;
Vec position;
Flt power;
// provide necessary methods required by Game::Obj :
virtual void create(Game::ObjParams &obj); // extend default creation

virtual Vec  pos(        ){return position    ;} // get position
virtual void pos(Vec &pos){     T.position=pos;} // set position

virtual Matrix matrix(              ){return position      ;} // get matrix
virtual void   matrix(Matrix &matrix){     T.position=matrix.pos;} // set matrix

virtual Bool update(){return true;} // object update
virtual void draw  ();
virtual void disable(){}
virtual void enable(){}

// constructor
LightObject();

// io methods
virtual void save(File &f);
virtual Bool load(File &f);

};

LightObject::LightObject() // initialize values in constructor
{
   position.zero();
}

void LightObject ::create(Game::ObjParams &params)
   {
   //color=params.getParam("color").asCol();
   position=params.matrixFinal().pos;
   //power=params.getParam("power").asFlt();
    power = 1;

   }

void LightObject ::draw()
   {
   if(Renderer()==RM_LIGHT)
      {
      SetMatrix();
      LightPoint(50,position,Vec(1,1,1),0,0);
      }
   }

/******************************************************************************/
void LightObject ::save(File &f)
{
   __super::save(f); // default save

   f<<position; // save custom parameters
}
Bool LightObject ::load(File &f)
{
   if(__super::load(f)) // if default load was successful
   {
      f>>position; // load custom parameters
      return true; // return success
   }
   return false; // return failure
}
/******************************************************************************/



// Define viewing modes:
enum VIEW_MODE // Viewing Mode
{
   VIEW_FPP, // First Person
   VIEW_TPP, // Third Person
   VIEW_ISO, // Isometric
   VIEW_NUM, // number of view modes
};
UInt View; // current VIEW_MODE
/******************************************************************************/
struct Player : Game::Chr
{
   virtual Bool update();
   virtual void draw(); // extend drawing to disable head rendering in FPP mode
};
/******************************************************************************/
Game::ObjMemx<Game::Static> Statics; // container for static objects
Game::ObjMemx<Game::Item  > Items  ; // container for item   objects
Game::ObjMemx<      Player> Players; // container for player objects
Game::ObjMemx<LightObject>   lights; // container for point light objects


/******************************************************************************/
Bool Player::update()
{
   if(action)
   {
      if(Kb.b(KB_W) || Kb.b(KB_S) || Kb.b(KB_A) || Kb.b(KB_D) || Kb.b(KB_Q) || Kb.b(KB_E))actionBreak();
   }

   if(!action)
   {
      // turn & move
      input.anglei.x=Kb.b(KB_Q)-Kb.b(KB_E);
      input.anglei.y=Kb.b(KB_T)-Kb.b(KB_G);
      input.diri  .x=Kb.b(KB_D)-Kb.b(KB_A);
      input.diri  .z=Kb.b(KB_W)-Kb.b(KB_S);
      input.diri  .y=Kb.b(KB_SPACE)-Kb.b(KB_LCTRL);

      // dodge, crouch, walk, jump
      input.dodge = Kb.bd(KB_D)-Kb.bd(KB_A);
      input.crouch= Kb.b (KB_LCTRL);
      input.walk  = !Kb.b (KB_LSHIFT );
      input.jump  =(Kb.bp(KB_SPACE ) ? 3.5 : 0);

      // mouse turn
      if(View!=VIEW_ISO) // don't use mouse turning when in Isometric mode
      {
         Flt  max=DegToRad(900)*Tm.d(),
              dx =Ms.dir_ds.x*1.7,
              dy =Ms.dir_ds.y*1.7*Ms.inv();
         angle.x-=Mid(dx,-max,max);
         angle.y+=Mid(dy,-max,max);
      }

      // ready stance change
      ready^=Kb.bp(KB_R);
   }

   return __super::update();
}

void Player::draw()
{
   Bool disable_head_draw=(View==VIEW_FPP && Renderer()!=RM_SHD_MAP && mesh); // disable drawing head when we're in FPP mode and we're not in shadowing mode (if this isn't included player will cast head-less shadows)

   if(disable_head_draw)mesh->hide("head"); // hide "head" mesh part in 'mesh'

   __super::draw(); // call default drawing

   if(disable_head_draw)mesh->show("head"); // un-hide "head" mesh part, so other objects which use the same mesh will have the head rendered properly
}



/******************************************************************************/
void InitPre()
{
    App.name("Damien");
    App.flag=APP_MS_EXCLUSIVE|APP_FULL_TOGGLE;
    IOPath("../data");
    PakAdd("engine.pak");
    

    D.full(true).sync(false).shdMapSize(512).hpRt(true);
    D.full(true).mtnMode(MTN_LOW); // enable motion blur
    D.mtnVelScale(0.2);            // increase motion blurring
    D.ambMode(AMB_HIGH1).ambSoft(1).ambJitter(1).ambHalfRes(1).ambPower(0.2); // set initial ambient occlusion parameters
    D.mode(1280,768).volLight(true).volAdd(false).volMax(0.8);
    //D.full(true).bloom(1.1,0.8,0.5,true);
    //D.full(true).hdr(true).hdrMaxBright(0.9).hdrMaxDark(1).hdrExposure(0.9).hdrContr​ast(5).hdrWeighted(true);
    //D.edgeSoften(2,1);
    //D.superSample(1);
    D.bumpMode(BUMP_NORMAL); // Bumpmapping Mode
    D.shdMode(SHD_MAP_HW).shdSoft(1);
    
    //D.edgeDetect (3);  
    //D.hwDepthBuffer  (true);  
    //D.filter(10);
    //D.filterMipMaps(true);
    //D.texQuality(16);
    //D.dof(1,3,0.9,1,3);
    
    //D.multiSample(40);
    //ViewportFull.range=50;

}
/******************************************************************************/
Bool Init()
{
   Physics.create();
   Sky    .set   (*Images("gfx/sky/skybox.gfx"));
    
   Sun &sun=Suns.New(); sun.set(*Images("gfx/sky/sun.gfx")).light_color=Vec(0.65,0.4,0);sun.vol_steam=0.6;sun.rays.mode=SUN_RAYS_LOW;sun.​vol=0.9;sun.vol_exponent=0.65;sun.pos=!Vec(-1,0.4,-1);sun.size=0.05;


   // create the world
   Game::World.init()
                .setType(Statics,OBJ_STATIC)
                .setType(Players,OBJ_CHR   )
                .setItem(Items  ,OBJ_ITEM  )
                .setType(lights,OBJ_LGT_PNT)
                .New("World/world/"        );

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Main()
{
   if(Kb.bp(KB_ESC))return false;

   Game::World.update(Cam.at);
   if(!sound.playing()) // if already playing
      {
        sound.play("music/sneaky.ogg",true);
        sound.volume(0.1);
      }
  
  
   // set next camera mode when Tab pressed
   if(Kb.bp(KB_TAB))
   {
      View=(View+1)%VIEW_NUM;

      if(View==VIEW_ISO) // when set to isometric view
      {
         Cam.dist =   10; // set bigger camera distance at start
         Cam.pitch=-PI_4; // set starting camera pitch angle
      }
   }

   // setup the camera
   if(Players.elms()) // if we have at least one player
   {
      // set camera depending on current view mode
      switch(View)
      {
         case VIEW_FPP:
         {
            OrientP &head=Players[0].cskel.getPoint("head"); // obtain player "head" skeleton point (this was created in Mesh Editor)
            Cam.setPosDir(head.pos,head.dir,head.perp); // set camera from 'head' position, direction and perpendicular to direction
         }break;
        
         case VIEW_TPP:
         {
            Cam.dist=Max(1.0f,Cam.dist*ScaleFactor(Ms.wheel()*-0.1)); // update camera distance according to mouse wheel
            Cam.setSpherical(Players[0].pos()+Vec(0,0.5,0), Players[0].angle.x, Players[0].angle.y, 0, Cam.dist); // set spherical camera looking at player position with given player angles
         }break;
        
         default: // VIEW_ISO
         {
            Cam.yaw  -=Ms.ds.x; // update camera yaw   angle according to mouse smooth delta x
            Cam.pitch+=Ms.ds.y; // update camera pitch angle according to mouse smooth delta y
            Clamp(Cam.pitch,-PI_2,0); // clamp to possible camera pitch angle
            Cam.dist  =Max(1.0f,Cam.dist*ScaleFactor(Ms.wheel()*-0.1)); // update camera distance according to mouse wheel
            Cam.setSpherical(Players[0].pos(), Cam.yaw, Cam.pitch, 0, Cam.dist); // set spherical camera looking at player using camera angles
         }break;
      }

      // after setting camera position and angles:
      Cam.updateVelocities().set(); // update camera velocities and activate it
   }
   else // when no player on the scene
   {
      CamHandle(0.1,100,CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT)); // default camera handling actions
   }

   return true;
}
/******************************************************************************/
void Render()
{
    
    Game::World.draw();
}
void Draw()
{
   Renderer(Render);
   D.text(0,0.9,S+"Fps: "+Tm.fps());
}
/******************************************************************************/
06-21-2009 09:19 PM
Find all posts by this user Quote this message in a reply
Post Reply