# Determining the normals of generated collision solids

So, I’m having a bit of an error with regards to general smooth operation of a game engine I’m working on.

I implemented a pusher collision detector to prevent my player from running right on through boxes willy nilly, as players will do given the chance. Each of the boxes has six polygonal collision solids making a nice little collision box.

When I first implemented it, I had a problem with being able to walk through two sides of the boxes, but not the other. I did a bit of reading and discovered the source of the problem was probably normal vectors of the collision solids.

Now, remembering what I do about procedurally generating geometries, and the normal vectors of those being determined by the order in which I entered vectors, I figured it was probably something similar for collision solids. So, I figured that since I had two sides working and their opposites not working, I’d flip the direction I

Now it more or less works, but walking smoothly along walls does not – some of the faces (I think probably the top and bottom) have vectors that are pointing to the sides of the boxes, rather than up, down, or directly away as they ought to. This is causing the player to ‘stick’ to the edges of the boxes while walking along them in certain directions, halting movement.

Although I can just wildly experiment with altering the normals of the ones that are probably the culprit, what I’d really like to know is how to feed in the points of the polygons to get a given normal vector. I’m open to reading if someone could point me in the right direction. I didn’t notice anything on cursory inspection of the API docs for collision polygons, so I thought I’d ask here.

I’m confused. Is this a question about Panda? Which particular collision interface within Panda are you using?

Or are you asking about collisions in general, with no relation to Panda?

David

If I generate a collision polygon in panda manually, by specifying vertices, what determines the normal vectors of said collision polygons? Specifically, I’m talking about having those polygons interact with a pusher – when a collision occurs, the pusher ‘pushes’ in the direction of the normals of the polygon, if I’m not mistaken. That’s what I’ve gathered from scouring the forums, anyway.

It is in some way related to the relative positions of the polygons in terms of order.

It’s kind of hard to explain without diving into code, I suppose. However, if I create my collision polygon like this:

polygon = CollisionPolygon(
Point3(1, 0, 0),
Point3(0, 0, 0),
Point3(1, 0, 0),
Point3(1, 0, 1))

then the normal of the collision polygon will be the opposite of what it would be if I created my polygon like this:

polygon = CollisionPolygon(
Point3(1, 0, 1),
Point3(1, 0, 0),
Point3(0, 0, 0),
Point3(1, 0, 0))

However, I haven’t taken the time to figure out exactly how it works; I only know how to flip the direction of the normal, really. Not the process used for actually determining the normal vector based on the way the polygon is built.

The normal is determined by the plane of the vertices you give it. The winding order of the vertices determines the direction; by convention, the vertices should be given in a counter-clockwise direction, when seen from the face of the polygon.

David

Aha, thanks. That clears it up.