PDA

View Full Version : Moving the light source


markreno
04-24-2007, 05:13 PM
Hello

My son is working on a small program trying a few things out.
He has refocused the world's light source onto one of his objects and we cannot figure out how to return the light source back to it's "starting state".

The line of code the refocused the light source is:
"light point at The Technal Cat"

Would anyone be able to suggest a way to return the light source back to its starting state or provide some insight into how to more appropriately move the focus of the light source on to a single object and then be able to return it to it's starting position.

Thanks very much!
- Mark

DickBaldwin
04-24-2007, 08:06 PM
I have a couple of suggestions.

Suggestion #1
When you create a new world, all of the objects in the world have random viewpoints.

I believe that when creating a new world, the first thing that you should do is to align the viewpoints of all the objects with the viewpoint of the world object in order to establish a base viewpoint for all of the objects. This should include the camera and the ground as well as any objects that you have added from the gallery. If you plan on doing anything with the light, this should include the light also. (See the lessons at http://www.dickbaldwin.com/tocalice.htm with particular emphasis on Setting the Stage.) Having established a base viewpoint for all the objects, you know where they are and can move them around in a repeatable fashion.

This is easy to do and I have provided numerous code samples showing how to do it.

Suggestion #2
I haven't worked out all the details on this, but here is an idea that you might be able to expand on.

Assume that you don't create a base viewpoint for the light. Before moving the light, you could use one or more of the functions belonging to the light to establish and save its position so that you would know how to return to that position later. Two obvious candidates are

getPosition
getPointOfView

You could save the returned values in variables of type Position and/or type PointOfView and use those values to restore the original viewpoint of the light. However, I'm not sure exactly how to parse the data in those variables to get what you need to move the light back to its original viewpoint. That will take some further study.

Dick Baldwin

DickBaldwin
04-24-2007, 09:05 PM
Suggestion #2
I haven't worked out all the details on this, but here is an idea that you might be able to expand on.

Assume that you don't create a base viewpoint for the light. Before moving the light, you could use one or more of the functions belonging to the light to establish and save its position so that you would know how to return to that position later. Two obvious candidates are

getPosition
getPointOfView

You could save the returned values in variables of type Position and/or type PointOfView and use those values to restore the original viewpoint of the light. However, I'm not sure exactly how to parse the data in those variables to get what you need to move the light back to its original viewpoint. That will take some further study.

Dick Baldwin

I have attached a short program that illustrates this approach. This program gets and saves the initial pointOfView of the light. Then it changes the pov of the light. After ten seconds, it restores the pov to the original.

Dick Baldwin

DrJim
04-24-2007, 09:42 PM
If you are going to move the world light, I strongly suggest you drop a dummy object at it when you first start the world. You can then always get the world light back to its starting position by setting it's "point of view" (i.e., both it's position and orientation) to that of the dummy object. Trying to get it back to its original orientation just using the mouse is nearly impossible.

In general, I don't recommend doing anything with the world light, beyond the basics of adjusting its color and intensity, unless you are familiar with "ambient" lights from other applications - and probably not even then. I have not seen the world light's characteristics documented very well - in fairness I haven't looked all that hard - just quickly skimmed Dick's tutorials, for example. It does seem to be an "ambient light" in that it has orientation but no falloff with distance. It does not cast shadows and doesn't seem to provide reflected light (:confused: ???) but does provide directional illumination of surfaces.

The control of the other two available lights (the bulb and the spotlight) is somewhat more intuitive, at least to me. :rolleyes: The bulb's light is emitted in all directions and its intensity does fall off with distance. The spotlight "is a spotlight." No shadows, as far as I know, in either case. (Lance A did post a way to simulate shadow effects a while back and I've seen a student video that used that approach for a very nice dance effect. :) )

One final note. If you have even a moderately high end graphics card, you probably will see different lighting effects if you use "slow and steady Alice," with its software rendering, rather than the regular hardware graphics accelerator.

DickBaldwin
04-25-2007, 08:19 AM
Even the Java 3D Light System (see http://www.developer.com/java/other/article.php/3622246) doesn't cast shadows. From what I read, the ability to write code to cast shadows in Java 3D is fairly difficult.

Dick Baldwin