I know this has probably been asked a million or so times, but searching is getting me nowhere! (all the returned solutions aren't what I'm looking for!)
I have created a Sky dome using 'MAKE OBJECT SPHERE nOBJ, -1000, 18, 9' the negative value turns it inside out.
I have loaded a texture using 'LOAD IMAGE "MyTexture.png", nIMG'
I then Texture The Object using 'TEXTURE OBJECT nOBJ, nIMG'
Lastly I position the Object using 'POSITION OBJECT nOBJ, 0.0, 0.0, 0.0'
nothing too impressive so far and this displays my image as expected...
The fancy bit that I'm struggling with is, within my image (which is a seamless spherical map) there is a light source (a sun!)
My application scans this image to calculate the position of the sun in X & Y coordinates from the top left of the image
dX = 360.0 * (X.Pos / Image.Width) <-- Returns a Value 0.0 to 1.0 * 360.0 related to position across image (multiplied into degrees)
dY = 360.0 * (Y.Pos / Image.Height) <-- Returns a Value 0.0 to 1.0 * 360.0 related to position down image (multiplied into degrees)
I'm now attempting convert this into 3D coordinates to position a light, and this is where I'm messing up somewhere
fX = 1000 * SIN(dy) * COS(dx)
fY = 1000 * SIN(dy) * SIN(dx)
fZ = 1000 * COS(dy)
Then I position the light using 'POSITION LIGHT 0, fx, fy, fz'
And finally direct the light using 'POINT LIGHT 0, 0.0, 0.0, 0.0'
As a sanity check (because the results were weren't what I expected!) I created another object and placed it at the generated calculations.
The fX and fY values were both 0.0 so I changed the multiplications between SIN 7 COS with +/- which gave me even weirder results (1.0, 0.0, 500.0)!
For some reason I can't get my code working it looks correct, but it's definitely not working!
Any ideas or references to working solutions would be appreciated
Many thanks Alan