[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

3D Engine and problems

Hey, im making a dx8 engine, if you want to see the first version, visit http://www.y3knetwork.com and goto rendertech. Im having a slight problem though. Im trying to make lights, and I cant set the attenuation range. can someone explain?
Thanks
0
alkakios
Asked:
alkakios
  • 2
1 Solution
 
joachimcCommented:
Hmm the attenuation is set on spotlights

In the D3DLIGHT8 you have
D3DLIGHT8 myLight;
D3DCOLORVALUE myColor;
D3DVECTOR myPosition;
D3DVECTOR myPointAt;

//Set position of light
myPosition.x = 10;
myPosition.y = 10;
myPosition.z = 10;

//Set direction of light
myPointAt.x = 0;
myPointAt.y = 0;
myPointAt.z = 0;

myColor.r = 1;
myColor.g = 1;
myColor.b = 1;
myColor.a = 1; //Alpha

//Linear attenuation
myLight.Attenuation0 = MyLightAttenuation;
//squared attenuation
myLight.Attenuation1 = MyLightAttenuation;
//exponential attenuation
myLight.Attenuation2 = MyLightAttenuation;
myLight.Diffuse =

Then you have to create a spotlight
myLight.Type = D3DLIGHT_SPOT;
myLight.Position = myPosition;
myLight.Direction = myPointAt;
myLight.Diffuse = myColor;
myLight.Specular = myColor;

//Turn on light
myD3DDevice->SetLight(0, &myLight);
myD3DDevice->LightEnable(0, TRUE);
myD3DDevice->SetRenderState( D3DRS_LIGHTING, TRUE );

Experiment with the Attenuation to get it right.
That's about it
/Joachim

0
 
joachimcCommented:
so

What's happening here ???

/Joachim
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now