April 18, 2024, 05:57:58 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Lighting.. trans

Started by J B Wood (Zumwalt), August 21, 2006, 09:04:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

J B Wood (Zumwalt)


// attempt our tank lighting
transll.addchild(DLightL);
DLightL.Create(s,LIGHT_POINT,2);
DLightL.SetPhi(1);
DLightL.SetAttenuation(0,1/5.0,0);
DLightL.SetSpecular(.5,.5,.5,1);
DLightL.SetRange(100);
DLightL.SetAmbient (1,1,1,1);
DLightL.Position(-1.25,1.5,3.25);
DLightL.SetFallOff(1.0);

translr.addchild(DLightR);
DlightR.Create(s,LIGHT_POINT,3);
DLightR.SetPhi(1);
DLightR.SetRange(100);
DLightR.SetAttenuation(0,1/5.0,0);
DLightR.SetSpecular(.5,.5,.5,1);
DLightR.position(1.25,1.5,3.25);
DLightR.SetFallOff(1.0);
DLightR.SetAmbient (1,1,1,1);
   



Whats wrong with this? I have tried LIGHT_SPOT, LIGHT_POINT, and LIGHT_DIRECTIONAL
I want to use a light on a trans location i have determined.

Ionic Wind Support Team

What problem are you having?
Ionic Wind Support Team

J B Wood (Zumwalt)

It doesn't work.
Simply put, I place them as shown above and nothing happens.
If I disable the global light for the scene and only have these 2, I would expect to see 2 flashlight effects using LIGHT_SPOT, I get absolutely no light at all from either of these 2 light sources.

I thought the ID had to be unique (last number or 2 and 3), I have tried this about 10 different ways and the wife threw a book at me since I was making to much clicking noise on my computer last night and ordered me to go to be.

All I am trying to do is add 2 spot lights on my tank where the headlights are, plus I will replace the global ligth with a directional light from the center of the tank to a sphere that surrounds the tank to light it up, atleast that is the hope.

Ionic Wind Support Team

Well your attenuation seems a bit high.  Drops off every 5 units.

And I would need to see your rendering code.   You have to 'draw' the lights by having them (or the transformations) as a child of the scene or any transformations won't be appled and they will be just static light sources.
Ionic Wind Support Team

J B Wood (Zumwalt)

Code is at home so I will post it later tonight.
If I make the light itself a child to the scene, the lights still don't show up and on exit of the application the application bombs with a microsoft error report.
I will totally simplify the cod tonight to just 1 movable light on a terrain.
I will make the light a child of a sphere or something so you can see what I am attempting to do.
Was hoping you had some sort of 'flashlight' example code lying around :)

Ionic Wind Support Team

August 22, 2006, 02:19:29 PM #5 Last Edit: August 22, 2006, 02:22:54 PM by Paul Turley
Well you can rotate a light, just can't use a transformation yet.  It doesn't use a standard matrix like an object does so doesn't respect world/object space transformations.  You'll have you use direction, position and rotation for now.

I'll work on making it respect the world transform for beta1.


//Skinned X example
//Arrow keys to move camera.
//PgUp/PgDn to pan up and down.
//Z and X to rotate on Z axis.

declare import,timeGetTime(),int;

global sub main()
{
C3DScreen s;
C3DCamera c;
C3DMesh m;
C3DObject scene;
C3DLight light;
CDirectInput di;
float fadjust,fTarget;
//target 60FPS for camera movement
fTarget = 1.0f / /*FPS*/60.0f * 1000.0f;
fAdjust = 1.0f;

s.CreateWindowed(0,0,800,600,AWS_CAPTION|AWS_VISIBLE|AWS_SIZE|AWS_CENTERED,0,"Light Example - ESC exits",NULL,false);
di.Init(s);
c.Create(s);
c.Position(0,0,-10);
c.Orient(0,0,1,0,1,0);
c.SetBackPlane(10000);

s.Clear(RGBA(0,0,0,255));
s.BeginScene(c);
s.RenderText(0,10,"Loading objects...",RGBA(255,255,0,255));
s.RenderScene();

m.CreateSphere(s,25,2,false);
m.enablelighting(true);

light.Create(s,LIGHT_SPOT,1);
light.Position(0,0,-30);
light.SetAttenuation(0,1/30.0,0);

scene.CreateScene(s);
scene.AddChild(light);
scene.AddChild(m);
int fps = 0;
int startTime;
do
{
startTime = timeGetTime();
//check for keys and move camera accordingly
IF di.KeyDown(DIK_UP)
c.Move(0.0f,1f * fAdjust);
IF di.KeyDown(DIK_DOWN)
c.Move(0.0f,-1f * fAdjust);
IF di.KeyDown(DIK_RIGHT)
c.Rotate(1*.01745 * fAdjust,0,0);
IF di.KeyDown(DIK_LEFT)
c.Rotate(-1*.01745 * fAdjust,0,0);
IF di.KeyDown(DIK_Z)
c.Rotate(0,0,-1 *.01745 * fAdjust);
IF di.KeyDown(DIK_X)
c.Rotate(0,0,1 *.01745 * fAdjust);
IF di.KeyDown(DIK_PRIOR)
c.Rotate(0,-1 *.01745 * fAdjust,0);
IF di.KeyDown(DIK_NEXT)
c.Rotate(0,1 *.01745 * fAdjust,0);
IF di.KeyDown(DIK_R)
c.LookAt(0,0,10000);

s.Clear(RGBA(128,128,128,255));
s.BeginScene(c);
light.Rotate(timeGetTime()/1000.0f,0,0);
scene.Draw();
s.RenderText(0,10,"FPS:"+NumToStr(fps),RGBA(255,255,0,255));
s.RenderText(0,30,"Use arrow keys to move around",RGBA(255,255,0,255));
fps = s.RenderScene();
fAdjust = (timeGetTime() - startTime) / fTarget;
}until di.KeyDown(DIK_ESCAPE);
Scene.Free();
}
Ionic Wind Support Team

Ionic Wind Support Team

OK. Got it ;)

In beta 1 lights now respect the scene heirarchy and will transfrorm to the parent object.  So you can use transfrom objects to offset and rotate a spot light around a mesh for example.
Ionic Wind Support Team

Ionic Wind Support Team

Beta 1 also adds a LookAt(x,y,z) method to objects.  It assumes an initial orientation of the mesh of 0,0,1.  Which means the model is facing away from the camera.  You can of course change the orientation after loading.
Ionic Wind Support Team

kryton9

Can't wait to try out the new commands.

J B Wood (Zumwalt)

Paul, have I ever told you how much you rock?
I mean seriously.
YOU ROCK

I will patiently await beta 01 ;)
Tank on hold until then, I need a way to fully light up the tank, and the tank body won't respect world lighting like the turrets do for some reason, it is shadowed and always black if I enable lights on it.

What I plan on doing is creating a light directional with a center point of the tank body and extending out only just past the edge of the tank body to hopefully keep the tank lit along with the immediate terrain around the tank, the headlights will be just that, spotlights just like a car ;)

Anyway enough of my babble, going back to my CCSI class work.