About Store Forum Documentation Contact



Post Reply 
sry.. help me with light params..
Author Message
Esenthel Offline
Administrator

Post: #16
Re: sry.. help me with light params..
yes you forgot the 'add' method smile

LightPoint(50,position,Vec(1,1,1),0,0);
->
LightPoint(50,position,Vec(1,1,1),0,0).add();
06-21-2009 09:20 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #17
Re: sry.. help me with light params..
ohh.. it was .add() grin
sry for the spam grin

ok.. so it works now. somewhat.. i think i can manage to get the parameters somehow working..
its now just a matter of basic stuff.. once again thank you very much..
06-21-2009 09:21 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #18
Re: sry.. help me with light params..
hmph..
is there a function for str to vec.. cant find it anywhere..
or what do you suggest for the color parameters from light.
i was thinking of adding it as a str param and converting that to vec..

nvm.. found it finally..
06-22-2009 05:12 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #19
Re: sry.. help me with light params..
Okay.. pos, colors, power, vol are working now well..
im slightly in a loss with cone light..
i would like to be able to see how the cone is pointing in the editor and i dont have the slightest idea about how to really setup the direction..




Code:
struct LightObject : Game::Obj
{
Vec color;
Vec position;
Vec dir;
Flt length;
Flt power;
Flt vol;
Flt vol_max;
//1=point,2=Spot
int type;


// 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)
   {
    //Type
    if(params.findParam("type"))type=params.getParam("type").asInt();else type=1;

    //position
    position=params.matrixFinal().pos;
    
    //Direction
    if (type == 2)
        {
        //direction=params.matrixFinal().pos;
        //length
        if(params.findParam("length"))length=params.getParam("length").asFlt();else length=3;
        }

    
    //Power parameters
    if(params.findParam("power"))power=params.getParam("power").asFlt();else power=5;
    
    //Color parameters
    if(params.findParam("color"))
        {
        Str col = params.getParam("color").asStr();
        color = TextVec(col);
        }
    else color=Vec(1,1,1);

    //Volume parameters
    if(params.findParam("vol"))vol=params.getParam("vol").asFlt();else vol=0;
    if(params.findParam("vol_max"))vol_max=params.getParam("vol_max").asFlt();else vol_max=0.5;



   }

void LightObject ::draw()
   {
   if(Renderer()==RM_LIGHT)
      {
          SetMatrix();
          switch(type)
          {
            case 1:
                LightSqr(power,position,color,vol,vol_max).add();
            break;
            case 2:
                dir = Vec(0,0,0);
                //LightCone(length,pos,dir,color,vol,vol_max).add();
            break;
          }
      }
   }

/******************************************************************************/
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
}
/******************************************************************************/
06-22-2009 07:59 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #20
Re: sry.. help me with light params..
when you have the object selected in the World Editor, you can see its axes (red=x, green=y, blue=z)
set object (cone light) in the editor so that for example 'z' (blue) points to desired light direction

then in codes in 'create' method you can use something like that:

Vec direction=obj_params.matrixFinal().z;
06-22-2009 08:11 PM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #21
RE: sry.. help me with light params..
Those are some really nice screen shots smile
12-01-2010 02:11 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #22
RE: sry.. help me with light params..
Blast from the past grin

Was excited at first cause I thought this was an update on Lucius, but then I saw the date...
12-01-2010 07:32 AM
Find all posts by this user Quote this message in a reply
Post Reply