Locating "Floor" Z coordinate
|
Hans Reitveld
Registered User
Join date: 21 Jun 2005
Posts: 16
|
12-14-2005 09:06
When I manually rez an object from inventory, it appears sitting on whatever local surface there is - the land, the floor in a build, an elevated floor in a multi-story build. Clearly, there is a way to identify the Z coordinate that represents the plane on which local objects sit. When I rez the same object using llRezObject, I have to specify a vector position for the rezzed object. I have experimented and searched the forums, but I can't figure out how to find the Z coordinate that SL obviously calculates when I rez the object by pulling it out of inventory, rather than having a script do it.
Can someone show me what I'm missing?
|
Kim Ludd
Registered User
Join date: 6 Jun 2005
Posts: 17
|
12-14-2005 09:20
|
Damien Took
Meat Popsicle
Join date: 3 Dec 2004
Posts: 151
|
12-14-2005 09:21
Have you tried just setting the z position to 0? You can get ground height, ground contour and ground normal. But if you are rezzing it from another object just use the z value of the position of the object doing the rezzing. I think your only option is to use a functions and calculations to get this z value, there is no magic function or constant for this z value. Be careful with GroundHeight though, it only seems to be accurate when the object is attached to your AV. Otherwise it is about 10m or so off.
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
12-14-2005 09:29
Rez a physical object and drop it, and wait for the collision_start?
|
Dianne Mechanique
Back from the Dead
Join date: 28 Mar 2005
Posts: 2,648
|
12-14-2005 09:31
From: Damien Took Have you tried just setting the z position to 0? You can get ground height, ground contour and ground normal. But if you are rezzing it from another object just use the z value of the position of the object doing the rezzing. I think your only option is to use a functions and calculations to get this z value, there is no magic function or constant for this z value. Be careful with GroundHeight though, it only seems to be accurate when the object is attached to your AV. Otherwise it is about 10m or so off. I am lousy at scripting, but perhaps getting the avatars feet position (z value) would do it. if an avatar resses something on the ground, the ground is the same height as that measurement (mostly).
|
Hans Reitveld
Registered User
Join date: 21 Jun 2005
Posts: 16
|
Avatar Feet Position
12-14-2005 09:51
From: Dianne Mechanique ...perhaps getting the avatars feet position (z value) would do it. if an avatar resses something on the ground, the ground is the same height as that measurement (mostly). That would work - I suppose I could have a "ground sensing attachment" attached to a foot  I wonder how SL does it, though - since ovbiously it knows where the "floor" is, even on a multi-story build, where the proper Z coordinate might be 30 or 40 meters.
|
Damien Took
Meat Popsicle
Join date: 3 Dec 2004
Posts: 151
|
12-14-2005 09:59
Honestly that sounds like way more work than you need to do. If you use one object, with physics enabled, to rez the other object you need you will already have the z value you need. Drop the base object on the ground or floor where you want the other object to rez. In the base object use llGetPos(), that will get you your z value, then rez the new object using that z value. You can put the rez function in the touch even of the base object. If you need a script example I will post it here. 
|
Lit Noir
Arrant Knave
Join date: 3 Jan 2004
Posts: 260
|
12-14-2005 10:21
What about llGetAgentSize to get the size of the avatar bounding box, and assuming llGetPos for the av does return the standard center of the the bounding box, basic math should get you the Z coord. Maybe. Never tried it.
EDIT: For some inane reason, I got it in my hed that this was an object being rezeed from an attachment, which isn't your question. The other solution I was going to propose before I tried to be clever was a very tight sensor pointing down, using llDetectedPos to get the z-axis, but this will bury the object a bit in the floor, and you'd need to check for ground as well if the sensor picked up nothing.
|
Damien Took
Meat Popsicle
Join date: 3 Dec 2004
Posts: 151
|
12-14-2005 10:36
Lit, wouldn't you need the object to be attached to the center of the AV to use llGetPos on an AV?
Then you have to communicate that to the object that is rezzing. It just seems like an extra step to me. But maybe you can get that from a script in the rezzing object, I'm not sure.
|
Lit Noir
Arrant Knave
Join date: 3 Jan 2004
Posts: 260
|
12-14-2005 10:54
Well, according to the wiki, at least as I read it, GetPos in the parent prim of an attachment returns the av position. So it could work. Course that really only makes sense rezzing from an av-attached object.
Back on the sensor front, if the object will only be rezzed when people are around, my first and second methods could be combined, find an av, get the bounding box size and position, do math, voila. But only works if av's are around.
Course, I joined in this thread confused, and I think I might be contagious now. (as in making things more confusing, not that others are being so).
|
Hans Reitveld
Registered User
Join date: 21 Jun 2005
Posts: 16
|
Avatar Size as Z Coordinate factor
12-14-2005 11:15
Actually, I tried llGetAgentSize, but it returns the same value whether the avatar is standing or sitting - and I imagine a seated avatar has a lower center of mass than a standing one. Doing something with physics seems like a reasonable kludge - I'll try that.
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
12-14-2005 11:28
I'm pretty sure, not 100% but pretty sure there's not a straight scripting solution to this. There are some clever work arounds as suggested, but not a simple solution.
I'm pretty sure that SL has a system that detects what you point at - be that rezzing an object, clicking edit etc. that is not directly accessible from scripting. (It MIGHT be from mouselook with whatever that camera pointing at function is (sorry, having a bad hair day and can't find it in the wiki). I should add that it detects the SOLID you're pointing at - don't believe me, trying rezzing a boat near your border with some Linden Land. You can be pointing at 'your' water, but get a "The parcel owner does not permit creating objects here" type message, because the solid you've hit is actually the ground under the water that is Linden owned.
|
Damien Took
Meat Popsicle
Join date: 3 Dec 2004
Posts: 151
|
12-14-2005 11:31
Hans, what exactly are you trying to do? When do you want the object rezzed? When something is touched, when an AV passes by? It will be easier to come up with a solution, I think, if we know what you are trying to do. 
|
Hans Reitveld
Registered User
Join date: 21 Jun 2005
Posts: 16
|
(Sort of) Solution
12-14-2005 13:29
The answer seems to be to have the object enble physics, fall to the local floor, then disable physics. And the application is essentially a very short range "flying carpet" sort of thing. It needs to be at (or close to) ground level to avoid the avatar seeming to float in the air 
|
Damien Took
Meat Popsicle
Join date: 3 Dec 2004
Posts: 151
|
12-14-2005 13:34
Ahh, that would work then. The land collision event can turn physics off. You could even have it transparent until it collides with the ground so that by the time it is in the correct spot it will appear as if it was already there instead of falling into position.
|
Leone Trescothick
Registered User
Join date: 27 Dec 2005
Posts: 9
|
01-04-2006 01:36
From: Hans Reitveld The answer seems to be to have the object enble physics, fall to the local floor, then disable physics. And the application is essentially a very short range "flying carpet" sort of thing. It needs to be at (or close to) ground level to avoid the avatar seeming to float in the air  So any chance of posting this up/PM/IM it to me? I've got an object which will always rez about 0.5m above the ground. For some reason since the base is a sphere with a dimple, SL wants to rez it where it would be if the sphere had no dimple....0.5m above the ground. If physics gets turned on it falls to the ground nicely. If the script could turn on physics let it fall then turn off physics that would be nice (unless there's a better way to do it?).
|
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
|
01-04-2006 02:25
From: Leone Trescothick So any chance of posting this up/PM/IM it to me? I've got an object which will always rez about 0.5m above the ground. For some reason since the base is a sphere with a dimple, SL wants to rez it where it would be if the sphere had no dimple....0.5m above the ground. If physics gets turned on it falls to the ground nicely. If the script could turn on physics let it fall then turn off physics that would be nice (unless there's a better way to do it?). I can confirm this from my observations. Objects are placed based on the bounding boxes of the prims (which you see when resizing) and not the solid bits of the prim, which may be a lot smaller.
|