CollisionTriangle
Blitz3D Forums/Blitz3D Programming/CollisionTriangle
| ||
Hi, I have a problem with CollisionTriangle, at first I going to show you the code: Graphics3D 1024,768,32,1 SetBuffer BackBuffer() Camera=CreateCamera() MoveEntity camera,0,1000,0 CameraRange camera,1,10000 ball=LoadMesh("Ball.3ds") RotateEntity ball,0,45,0 EntityRadius Ball,10 EntityType ball,1 parcours=LoadMesh("Bahn1.3ds") EntityType parcours,2 While Not KeyHit(1) Collisions 1,2,2,1 PointEntity camera,ball MoveEntity ball,0,0,1 If EntityCollided(ball,2) Then Vertex1=TriangleVertex(CollisionSurface(parcours,CountCollisions(parcours)),CollisionTriangle(parcours,CountCollisions(parcours)),1) Vertex2=TriangleVertex(CollisionSurface(parcours,CountCollisions(parcours)),CollisionTriangle(parcours,CountCollisions(parcours)),2) End If RenderWorld UpdateWorld Flip 0 Wend Ok, now I tell you my problem. I want to find the collided triangle of the parcours, but that is impossible because the ball collides with the parcours, not the parcours with the ball, so I can only find the collided triangle of the ball (do you know what I mean?). But how can I find the collided triangle of the parcours? gratefully, BlitzBasic303 |
| ||
Like this maybe ...Graphics3D 1024,768,32,1 SetBuffer BackBuffer() Camera=CreateCamera() MoveEntity camera,0,1000,0 CameraRange camera,1,10000 ball=LoadMesh("Ball.3ds") RotateEntity ball,0,45,0 EntityRadius Ball,10 EntityType ball,1 parcours=LoadMesh("Bahn1.3ds") EntityType parcours,2 While Not KeyHit(1) Collisions 1,2,2,1 PointEntity camera,ball MoveEntity ball,0,0,1 If EntityCollided(ball,2) Then For c = 1 To CountCollisions( ball ) Triangle = CollisionTriangle( ball , c ) Vertex0=TriangleVertex( CollisionSurface( ball, c ), Triangle , 0 ) Vertex1=TriangleVertex( CollisionSurface( ball, c ), Triangle , 1 ) Vertex2=TriangleVertex( CollisionSurface( ball, c ), Triangle , 2 ) Next End If RenderWorld UpdateWorld Flip 0 Wend |
| ||
No, i think you didn't unterstand me, I wanted to find the collided triangle of the parcours, not the one of the ball. |
| ||
Nope, I don't think you understand how the collision commands work. If the ball has collided with something it must be the 'parcours' ( whatever that is?? ). Therefore the collisiontriangle( ball, c ) will return the triangle index on the 'parcours'. Logically, the ball cannot collide with itself. Have you read or tried using the code I posted? Stevie |
| ||
Ohhh I'm so stupid! You're right! Sorry! Now it works! |