Home   Help Search Login Register  

Author Topic: Heights above water  (Read 1398 times)

0 Members and 1 Guest are viewing this topic.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Heights above water
« on: 13 Aug 2004, 21:05:24 »
Here is the problem:

I am currently making a bridge section addon that has a lamp.

I have successfully made the model.

I decided on Road class object and to place the lamp by calling a script from class Eventhandlers in the models config.cpp.

This works very well.  The lamp is placed exactly where it should be even if you setPos the bridge up or down.........but........only if the bridge is on land.

As soon as you place the bridge on water the lamp is placed high above the bridge.

If I alter the script to execute a separate part for bridges placed over water I can only get the lamp to within about 6 metres below the lamp position.  Altering the height any more, even by as much as 0.01 metres will cause the lamp to be about 20 metres above the correct position.

I have run out of ideas.

The model used for the lamp is empty.p3d which resides in Data3d.pbo.

This is, as the name suggests, an empty model.
It has 1 resolution LOD (0.000), 0 vertices, 0 faces and 0 textures.

Has anyone else come across this problem before?

If so, and they have a solution, I would love to hear it.

The height for any building placed over water in the editor is always -0.054121, which is for all intents and purposes 0, or is it?

Hoping someone can throw me a bone here.

I am running 1.96 btw.


Planck
I know a little about a lot, and a lot about a little.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Heights above water
« Reply #1 on: 14 Aug 2004, 01:00:44 »
I think what is happening when you are placing it over the water, is that at first OFP is thinking you mean "place it 19 meters above the water level", but when you raise it more, OFP suddenly thinks "place it 20 meters above the top of the bridge". I'm not sure how to get around this problem, except perhaps by making a new version of "empty.p3d", which has the light eminating from 6 meters above the object's center. I know nothing about O2 though, so I would have no idea how to do that.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Heights above water
« Reply #2 on: 14 Aug 2004, 01:31:55 »
What happens is:

When the bridge section is placed on land, the light source is placed at the same location.

The X and Y coordinates are irrelevant for now, but the bridge sections height is 0 metres.
The light source height is also 0 metres.

The light source is then raised by 26 metres.  This is the exact point for the light to be at

I can setPos the bridge down or up and the light source will go down and up accordingly, because it is referrenced from the height of the object.  So if the object height was -10 metres, the light is placed at +16 metres.

The whole thing works beautifully, as long as the bridge section is on land.

As soon as you place a bridge section on the water, the light source is at approximately +40 metres.

If I alter the height to place the light source, the closest I can get it to the desired point is approximately +20 metres.
If I nudge it just a little more, say 0.01 metres more, the light source is once again back to about +40 metres.

It seems to be deliberately trying to drive me insane.  Unfortunately it doesn't know, I am already insane.

Although I am using empty.p3d as the model, the actual light source is defined in the config.cpp, empty is just the vehicle it uses.

Thanks for you input General

btw......I don't think it is an issue with the model, I think I would have the same problem with the original Resistsnce bridge if I were to try it with that.
I believe it is a game engine quirk.



Planck
« Last Edit: 14 Aug 2004, 01:34:28 by Planck »
I know a little about a lot, and a lot about a little.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Heights above water
« Reply #3 on: 14 Aug 2004, 02:11:32 »
Here's something to try. Are you doing:

_light = "light" createvehicle [getpos _bridge select 0, getpos _bridge select 1, 20]

Or are you doing:

_light = "light" createvehicle [0,0,0]
_light setpos [getpos _bridge select 0, getpos _bridge select 1, 20]

Try both methods, because sometimes they can have different results.

And what I meant about the model, is that may be the only way to get around this problem. If you can't get the model to center itself where you want it to, perhaps you could make the place where the light comes out of the model be about 6 m above the "model" itself. And I know the model is empty.
« Last Edit: 14 Aug 2004, 02:13:10 by General Barron »
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Heights above water
« Reply #4 on: 14 Aug 2004, 15:12:35 »
Hello GB,

I have tried both methods actually.

The first method produces the light source on the ground beside the bridge, not at the bridge position.  It doesn't matter what height I give it for the third parameter (20.....26..... 100,000), the light source remains on the ground

The second method is the one I am using, it produces the light at the correct height for the bridge, whatever height I set the bridge at.

The bridge works perfectly with its light source, as long as the bridge is on land.

I will try constructing another 'empty.p3d', with the light offset by 6 metres.
Hopefully it will work, but I have my doubts.

I may end up releasing this bridge as a 'land only bridge'.  It would be perfectly fine in water though,as long as you didn't use it at night.


Once again thanks for the input.



Planck
I know a little about a lot, and a lot about a little.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Heights above water
« Reply #5 on: 14 Aug 2004, 16:22:09 »
Ahhhhhhhh success.

Thank you General Barron, your idea for a altered copy of the 'empty.p3d' worked wonderfully.

I had considered this previously, but had discounted it for two reasons.
The first being it would increase the size of the addon and the second being I was sceptical about it working.

But as the empty.p3d is only 1 kb in size, the extra doesn't make a great deal of difference.  And it just takes another person to suggest something to give you that extra incentive to at least try it.

My altered copy has one extra LOD......Memory LOD with the 'light position at 6 metres above.

Everything seems to work beautifully now, even when placed on water.

I think I will now place this on the Beta testing board so people can test it out and find any problems for me.


Once again General thank you for your input.   8)

Edit:   I found another way of implementing this without using empty.p3d.
Just giving the bridge model a 'light' point in the memory LOD.
It works, but I have yet to see if it will still function correctly as a bridge......and........AI are happy with it.


Planck
« Last Edit: 14 Aug 2004, 17:12:47 by Planck »
I know a little about a lot, and a lot about a little.