LIGHTS - POINT

If you have a room or a cave etc. in your world, you need to install a light (or lights) inside it. There are the type: point. This lights shine in all directions from a specific location in the 3D world. The effect is similar to a bare light bulb hanging in a room.

In our exercice/demo we have used auxiliary-spheres created in 3ds max.

The code is similar:

-- Create point lights
  l1=myworld.model("light1") --light1 is the name of aux-sphere in max
  l1.visibility = #none
  myworld.newLight("pt1", #point)
  pt1Light = myworld.light("pt1")
  pt1Light.color = rgb(4, 155, 176)
  pt1Light.transform.position = l1.transform.position


AVATAR DRIVING A CAR

A bonus in this lesson:

If you have some large terrain, walk is not a good option. You can put your avatar in a car!

Realy we only change the variable avatarheight and the value of the acceleration added when the player press the up-arrow-key.

In this case, the inercia doesn't stops the "car" if the player is not pressing the key. He needs to press the down-arrow key to stop or go back.

CHANGING THE AVATAR VELOCITY

A "human being" has a limit of walk velocity. But in the 3D worlds you can make the avatar to run sometimes irreally.

How the velocity of the avatar is defined?

In the avatarobj script we have the variable:

                       acc = 0.025

Each time the player press the up/down arrow keys 0.025 is added to the avatar's velocity.

But, in the line of code;

distanceforward = distanceforward + acc - 0.015
we can imagine that 0.015 is an inertia factor against the aceleration, subtracted every loop-timestep.

So, if we increase the value of acc we need to increase this inertia factor value or the avatar will not stop never :-) We have used this trick in the car velocity.

THE DEMO

In our demo you need to enter inside the cave in your car!. We didn't made the auxiliary sphere invisible. The light has some blue...

Only for fun, there are a hole in the floor, inside the cave, and you will die! WOW! Funny?




PREVIOUS LESSON NEXT LESSON
T. CONTENTS HOMEPAGE