CodeBase - get nearest collision normal from a mesh and show normals as lines
Return to the CodeBase listing
Category: Collision
Version: 1.0
Information
Uploaded: 1st Apr 2004 16:07
Modified: 1st Apr 2004 16:49
Author: Markus
Summary
If you need the collision normal to bounce a sphere or align a object to the ground you need this :-) i think it is very usefull . the screenshot shows all normals from a object in special use ;-)
Full Description
there are two source codes in one <br /> the secend is to see what you are dooing ;-)<br /> <br /> first use this like a sphere to mesh intersection<br /> <br /> vl as float<br /> dx as float<br /> dy as float<br /> dz as float<br /> r=make vector3(cv)<br /> SET VECTOR3 cv,Kugel.vx,Kugel.vy,Kugel.vz<br /> vl=LENGTH VECTOR3(cv)<br /> NORMALIZE VECTOR3 cv,cv<br /> dx=X VECTOR3(cv)<br /> dy=Y VECTOR3(cv)<br /> dz=Z VECTOR3(cv)<br /> r=DELETE VECTOR3(cv)<br /> <br /> if vl<0.1<br /> vl=0.0<br /> endif<br /> if vl>5.0<br /> vl=5.0<br /> endif<br /> <br /> entf=intersect object(oc,object position x(ObjNr),object position y(ObjNr),object position z(ObjNr),object position x(ObjNr)+dx*(vl+oKugelRadius*5.0),object position y(ObjNr)+dy*(vl+oKugelRadius*5.0),object position z(ObjNr)+dz*(vl+oKugelRadius*5.0))<br /> <br /> if entf>0.0<br /> <br /> ax=object position x(ObjNr)+dx*entf<br /> ay=object position y(ObjNr)+dy*entf<br /> az=object position z(ObjNr)+dz*entf<br /> <br /> ax=ax-dx*(oKugelRadius+0.25)<br /> ay=ay-dy*(oKugelRadius+0.25)<br /> az=az-dz*(oKugelRadius+0.25)<br /> <br /> NormalAdd(ax,ay,az,CollisionNX,CollisionNY,CollisionNZ,10.0) `to see one line<br /> rem NormalCountToZero() <br /> CollisionNormal(oc,ax,ay,az) `look in this and read the remark !<br /> <br />
Comments
No comments yet.