Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / flashing light?

Author
Message
Opposing force
19
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 14th Sep 2005 19:20
i've tryed everything but i cant do it. I need to set a blue light to follow everywhere where an object (cop car) goes and for it to flash as well. Please help.
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 14th Sep 2005 20:23
I've done something similar, a light attached to an object that rotates with the object and moves with the object I made it like this:
LOAD OBJECT "car.x",1 `Load your car.
POSITION OBJECT 1,0,0,0 `Position car.
MAKE OBJECT PLAIN 999,0.01,0.01:HIDE OBJECT 999 `Make a plain (small) and then hide it.
POSITION OBJECT 999,0,0,0 `Position plain.
Position it at same co-ordinates as your car.
MAKE MESH FROM OBJECT 1,999 `Make mesh from plain
ADD LIMB 999,1,1:HIDE LIMB 999,1 `Create limb from mesh, hide and attach to car
GLUE OBJECT TO LIMB 1,999,1 `Car is attached to limb with is attached to plain
MAKE OBJECT PLAIN 998,0.001,0.001 `Make another plain
ADD LIMB 999,2,1:HIDE LIMB 999,2 `Limb for light
GLUE OBJECT TO LIMB 998,999,2 `Plain for light is attached to car
OFFSET LIMB 999,2,x#,y#,z# `Offset plain to car so light can be positioned correctly

Creat light:
MAKE LIGHT 1

Work out co-ords for light to be placed:
lx#=LIMB POSITION(999,2):ly#=LIMB POSITION(999,2):lz#=LIMB POSITION(999,3)
SET POINT LIGHT 1,lx#,ly#,lz# ` According to Instructions should make light omnidirectional (all directions)

To make it flash, just turn the light on and off at certain intervals.

So to summerise, load your car. A mesh is made from a small plain, to reduce the number of polygons (so I've been told). The car and a small plain is attached to the this primary plain. The primary plain is used to rotate/move the car - you won't see the plain and will even forget it is there.
The light position is worked out by knowing the co-ord values of the offset limb that will have to be positioned correctly (you will have to play to work this one out)
Hence no matter where the car is or what rotation it is at the light will appear to be attached to the car.
It is a complex soultion, but it works on my game and looks amazing. The only problem is you are limited to 8 lights (0 being the default light)
For a simpler solution, create a set of police lights on a 3d program and load them seperate to your car model.
Use the limb commands to limb the light model to your car in the correct position. To create a light effect simply change the texture of your light model or should I say the colours.
I hope this helps, and has made sense, The first soultion will work best if you lower the ambient light for a night time scenario. But the second is much easier.

Lee
Medusa
21
Years of Service
User Offline
Joined: 7th Sep 2003
Location:
Posted: 25th Sep 2005 04:16
Quote: "Flashing light on squad car"

Try to think in Algorithms rather than code.
You want an extra light to sit on top of your car and go wherever the car and presumably the fake light goes.
If my cop light is object 4 and my new light is light 2
e.g. position light 2,object4x,object4y,object4z
Placed outside the main loop or gosub or function this event would only happen once and the car would leave the light behind.
A simple solution is to place the instruction inside the do loop and every time the program loops it will place your light in the right spot. As your program will loop at least 30 fps the light will appear constant.
As for flashing - can you
hide light, color light black, red, blue or rotate etc
Think in terms of what effect you are trying to achieve rather than code.
Once you work it out the actual code is minimal.
Regards

mpc
Opposing force
19
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 25th Sep 2005 20:10
ok i'll try that

Login to post a reply

Server time is: 2025-05-22 13:08:50
Your offset time is: 2025-05-22 13:08:50