[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [pygame] 3-D stuff



Okay, conceptually, you want the intersection of a line and a
plane/facet/face:

http://astronomy.swin.edu.au/pbourke/geometry/linefacet/

The reflection vector is the length of the vector from the intersection to
the end point with reflection about the normal of the plane.

If I'm guessing correctly, you want to do a collision system with this?  If
so, there's lots of algos around the net for doing collision detection.
Mostly they do a lot of work to pre-test objects so that they only have to
do a small number of actual ray-triangle tests.

Just to do the test of whether the point is behind the plane would be
something like(untested):

def distance( planePoint, planeNormal, (x,y,z) ):
	A,B,C = planeNormal
	D = - dot(planeNormal, planePoint )
	value = (A*x) + (B*y) + (C*z) + D
	return value

Where value would be negative if behind, positive if in front of, 0 if on
the plane.  This is based on:
http://nate.scuzzy.net/docs/normals/

There's hundreds and hundreds of tutorials around the net regarding 3D
geometry applications for graphics.  I also find my notes from grade 13
algebra and geometry quite helpful.

HTH,
Mike

-----Original Message-----
From: owner-pygame-users@seul.org [mailto:owner-pygame-users@seul.org]On
Behalf Of Richard Jones
Sent: October 6, 2001 22:25
To: pygame-users@seul.org
Subject: [pygame] 3-D stuff


I'm really rusty in my 3d algorithms (it's taken me a while just to figure
out how to determine normals :)

I've been playing with pygame/pyopengl (well, mostly pyopengl so far) and
I'm
running into problems remembering fairly basic formulas :(

I have a point which has a movement vector. I need to know if the point will
be "behind" a plane (defined by three points) given a displacement by that
vector. If it does cross the plane, I need to know what the reflection
vector
will be. Does anyone have any algorithms / python code / URL references that
they could please throw my way?


   Richard

ps. I have a few things I could contribute to the pygame code repository. I
don't use pygame _yet_, just pyopengl. Eventually I'll want to do more that
just make pretty pictures though. The code I have does stuff like render a
3-d repeating map, generate a spark trail type thing, ... Is that useful
stuff for the repository?

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org