Esenthel
Administrator
|
Re: sry.. help me with light params..
yes you forgot the 'add' method
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 |
|
b1s
Member
|
Re: sry.. help me with light params..
ohh.. it was .add()
sry for the spam
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 |
|
b1s
Member
|
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 |
|
b1s
Member
|
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 ¶ms)
{
//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 |
|
Esenthel
Administrator
|
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 |
|
Driklyn
Member
|
RE: sry.. help me with light params..
Blast from the past
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 |
|