Ask a Question related to Macromedia Director 3D, Design and Development.
-
AndrewNock #1
ModelsUnderRay not working
Hey all,
I'm moving the load of my crane, with a bounding box around it. This moves ok
with the crane.
Unfort, using modelsUnderRay, the code will only stop once the building
touches the middle of the bounding box, not the outside. How do i fix this?
Thanks, Andy
--------
--LEFT--
--------
-- initialize a position and a direction vector
tPosition = pCharBoundingBox.worldPosition
--tDirection = pCharBoundingBox.transform.xAxis
tDirection = pLoad.transform.xAxis
-- cast the ray
tList = member("Crane").modelsUnderRay(tPosition, tDirection, tOptionsList)
-- -- if ray picks up models, then check for collision
if (tList.count) then me.checkForCollision(tList[1])
AndrewNock Guest
-
ModelsUnderRay
Hello, I've just learnt the ModelsUnderRay technique for collision detection from the UNSW tutorial and have checked various sites to make sure... -
modelsUnderRay() working really slow?
I'm using modelsUnderRay() for a two different projects I'm working on, but as soon as I activate it, both start to come to almost a complete halt.... -
modelsUnderRay Help please!
if i wanted to make sure a round table did not collide with a ball using modelsUnderRay would i have to use a bounding box,(as i imagine the result... -
modelsunderray ba*d!
I have a couple of issues here. 1: I have a character proxy model that I controll around a 3D world. Using modelsunderray I am trying to detect... -
ModelsUnderRay ... again, again, again.
English: Hi! Someone it has worked with the command modelsunderray in worlds where the walls do NOT BE necessarily oriented in the axes X and AND... -
-
AndrewNock #3
Re: ModelsUnderRay not working
HI, thanks for the reply, here is the rest of the relevant code...
-- build your modelList
tModelList = [member("Crane").model("Ground"),member("Crane").mo del("Load"),
member("Crane").model("Building04"), member("Crane").model("Target01"),
member("Crane").model("Obstacle01")]
-- build your optional argument list
tOptionsList = [#maxNumberOfModels: 10, #levelOfDetail: #detailed,
#modelList:tModelList, #maxDistance: 3]
AndrewNock Guest
-
Roofy #4
Re: ModelsUnderRay not working
[q]Originally posted by: AndrewNock
Hey all,
I'm moving the load of my crane, with a bounding box around it. This moves ok
with the crane.
Unfort, using modelsUnderRay, the code will only stop once the building
touches the middle of the bounding box, not the outside. How do i fix this?
Thanks, Andy
2 things...
1. From my experiemce with modelUnderRay it seem like it checks the model's
pivot point. For example say you have a cube where the width is 50 units,
length is 100 units, and the height is 10 units, and the pivot point is in the
center of the cube. instead of saying this....
collisData = modelsUnderRay( your settings)
if collisdata.count then
dist = collisData[1][4]
if dist < yourModel.worldPosition then
your code
end if
Instead, you need to build hover offset. Using my cube example, my hover
distance would be half of the width, length, or height total units depending on
which side you are detecting collision on. So lets say the width side of the
cube is colliding with the ground. Now knowing the width of the cube is 50
units then the additional hover offset would be 25 (width of the cube / 2). In
other words the code would look somthing like this...
collisData = modelsUnderRay( my settings)
if collisdata.count then
dist = collisData[1][4]
hoverOffset = myCubeExample.worldPosition + 25
if dist < hoverOffset then
my additional code
end if
Just note that you cannot get an object's demenions that has been buillt in
another 3D application
2. I never seen using a property list for your arguments with the command
modelsUnderRay, so this might also be causing problems as well.
Roofy Guest
-
Sumerian #5
Re: ModelsUnderRay not working
Hi Andrew,
When I do models underray, I basically always do it something like this:
dirns=[vector(0,1,0),vector(1,0,0),vector(0,-1,0),vector(-1,0,0)]
diam=20 repeat with i=1 to dirns.count
dog=gmem.modelsunderray(pos,dirns[i],1,#detailed)
if dog.count>0 then
if dog[1].distance<diam then
pos=dog[1].isectposition-dirns[i]*diam
--anything facy here
end if
end if
end repeat
This does the four coordinates (NESW), and you can add top and bottom to the
array.
The "pos" is your vector position, and diam is a chosen distance that you will
feel is close enough to your object to be considered a collision.
It's nice because it does the lot in a onner, the only problem being that
modelsunderray has the drawback of your being able to theoretically squeeze
yourself through the tiniest gap, and into the wrong place if you're unlucky.
P.S: Has anybody sorted ouit an equation to use the collision detection? I've
tried occasionally, and always ended up back with the ray-cast.
Cheers,
James ([url]http://www.gamevial.com[/url])
Sumerian Guest
-
Andrew Morton #6
Re: ModelsUnderRay not working
Sumerian wrote:
....> When I do models underray, I basically always do it something like
> this:
>
> dirns=[vector(0,1,0),vector(1,0,0),vector(0,-1,0),vector(-1,0,0)]
About modelsUnderRay aligned with an axis:-
[url]http://nuttybar.drama.uga.edu/pipermail/dir3d-l/2005-November/010090.html[/url]
Andrew (but not that one)
Andrew Morton Guest



Reply With Quote

