 |
Author |
Topic: Light location and direction (Read 340 times) |
|
brew
|
Light location and direction
« on: Apr 5th, 2004, 8:47pm » |
|
Although I know lights aren't high priority at the moment, I wonder if I can ask a few questions... I've been revisiting an old light experiment based on a solar system as described in this opengl article - http://www.edm2.com/0510/opengl.html. My intension is to position a light source that radiated in all directions in the middle of my scene (where the sun is). My planets should then reflect this light only on the side that faces the light source. So... How does DIFFUSE emit light? Like a flashlight (with direction) or like a light bulb (emitting light equally to all directions - ignoring the socket, obviously). In my example the light is being painted on to one surface of each planet, so far so good, but when they rotate around the sun, the lit side also seems to rotate around the planets axis! Any hints as to how I can resolve this? http://processing.times-new-roman.com/solar_system_03/
|
|
|
|
brew
|
Re: Light location and direction
« Reply #1 on: Apr 21st, 2004, 11:01am » |
|
No-one?
|
|
|
|
brew
|
Re: Light location and direction
« Reply #2 on: May 3rd, 2004, 12:15pm » |
|
The solution was simple in the end. I have two methods in my Orbitals class that moves the planet, then renders it. I was using rotateY and as I rotate, the planet itself is rotating before being translated out. All I needed to do was reverse the rotateY after translating. <code> void move(){ rotateY(radians(rY)); render(); rY += rYMod; if(rY > 360){ rY -=360; } } void render(){ translate(d,0); rotateY(-radians(rY)); //<--- reverse rotation if (d == 0){ noLights(); fill(r,g,b); sphere(rad); } else { lights(); fill(r, g, b); sphere(rad); } } </code>
|
« Last Edit: May 3rd, 2004, 12:18pm by brew » |
|
|
|
|
|