Modelsunderray is driven ' me craz-ay 2004-03-26 - By Carl Welch
Back I figured it had something to do with the normals. The models I'm working with was built by another guy who has been inconsistent about the way he sets up his files (normals, z up or y-up). The code is supposed to work with any w3d he exports. I waste a lot of time trying to get code to work with his curve-ball files. I ended up just reversing the direction of the ray and placing it below the terrain, pointing up while the parented camera is above the surface.
On Thursday, March 25, 2004, at 10:35 PM, Thomas Williams wrote:
> Because ray casting does not work on the back side of polygons, ie > backfacing normals. It only works on front facing normals. So if your > terrain appeared to be visible, but in fact you had visibility set to > #both > or #back then you would seen the mesh, but the ray cast would fail. > Raycasting only works on the front side. > > now the problem you musty be asking, 'how do i flip the friggin > normals so > raycasting will work?' If you built the terrain in a 3d app, flip the > there. > But if you build the mesh in lingo, the you will have to change the > direction in which the polgons were created. When building faces, if > you > list the verts in a clockwise fashion, the normal will point upward. > If this > isn;t clear, think of the 'right hand rule'. Make a fist with your > right > hand, and let your thumb stick up (like a politician on victory night). > Build polygons starting with the tip of your index finger and > continuing > towards your thumb. The normal is then your thumb. > > glad you got the terrain to finally work. > > tom > > > >> I just tried rotating the terrain 180, so it would be upside down, and >> my script worked. Why is that? normals? >> >> >> On Thursday, March 25, 2004, at 07:46 PM, Thomas Williams wrote: >> >>> MUR will not work on the backfacing side of of a polygon. So make >>> sure >>> that >>> the terrain visibility is #front and is visible from where you are >>> casting >>> your ray. >>> >>> as for removeFromWorld(), realize that this only works for models >>> that >>> are >>> parented to the group("world"). models that are parented to anything >>> else >>> must be first parented to the world before they can be removed, and >>> then >>> reparented to their original parents after they are addToWorld(). If >>> this >>> seems like a pain in the arse, you're right it is. DirMX04 has made >>> this >>> much easier with the addition of the #modelList, which effectively >>> does the >>> removeFromWorld() routine for you. The only problem is that >>> publishing >>> from >>> mx04 in shockwave10 causes problems (it seems it is not ready for >>> prime >>> time) and you can publish 8.5 and expect the new syntax (ie >>> #modelList) to >>> work. So it seems that you are stuck with a removeFromWorld() system. >>> >>> tom >>> >>>> Assuming that the world orientation is Z up and not y up, this >>>> should >>>> cast a ray straight down. My first guess, given that it's terrain, >>>> is >>>> that you are in fact in a Y up world and casting your ray out toward >>>> camera rather than downward. Esp. given it's inclination to see >>>> other >>>> models. >>>> >>>> If you really only care about terrain, remove the other models from >>>> the >>>> world before you cast the ray -- it will increase the speed >>>> substantially if you have a lot of models in the world. Then cast >>>> your >>>> ray and count on the result being the terrain or a total failure. >>>> >>>> --al >>>> -- --Original Message-- -- >>>> From: dir3d-l-bounces@(protected) >>>> [mailto:dir3d-l-bounces@(protected)] On Behalf Of Carl >>>> Welch >>>> Sent: Thursday, March 25, 2004 8:52 PM >>>> To: dir3d-l@(protected) >>>> Subject: [Dir3d-l] Modelsunderray is driven' me craz-ay >>>> >>>> I've been trying to master terrain following for some time now. I've >>>> looked at just about every example on the web and in books that I >>>> can >>>> find. I just can't seem to get it to work for me. >>>> >>>> The only model this modelunderray script CAN'T see is "terrain", the >>>> one that I want to get isectposition.z from and put it into the >>>> camera's transform.position.z I don't think thats to much to >>>> ask. >>>> >>>> Terrain Following script: >>>> >>>> targetpos = scene.model("target").getworldtransform().position >>>> modelsList = scene.modelsunderray(vector(targetpos.X, >>>> targetpos.Y, >>>> 100), vector(0,0,-1), #detailed) >>>> whichmodel = void >>>> >>>> totalmodels = modelsList.count >>>> repeat with x = 1 to totalmodels >>>> put modelsList[x].model.name >>>> if modelsList[x].model.name = "terrain" then >>>> whichmodel = x >>>> exit repeat >>>> end if >>>> end repeat >>>> >>>> if whichmodel <> void then >>>> vertb = modelsList[whichmodel].isectposition.z >>>> else >>>> vertb = 5 >>>> end if >>>> scene.model("target").transform.position.z = vertb >>>> >>>> >>>> What concept am I not grasping to make this work? >>>> >>>> --Carl >>>> >>>> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ >>>> Dir3d-l mailing list >>>> Dir3d-l@(protected) >>>> http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l >>>> >>>> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ >>>> Dir3d-l mailing list >>>> Dir3d-l@(protected) >>>> http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l >>>> >>> >>> >>> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ >>> Dir3d-l mailing list >>> Dir3d-l@(protected) >>> http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l >>> >> >> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ >> Dir3d-l mailing list >> Dir3d-l@(protected) >> http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l >> > > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ > Dir3d-l mailing list > Dir3d-l@(protected) > http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l >
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ Dir3d-l mailing list Dir3d-l@(protected) http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l
|
|