orangeduck / Corange

Pure C Game Engine
http://www.youtube.com/watch?v=482GxqTWXtA
Other
1.78k stars 199 forks source link

Direction of a plane. #47

Closed rainwoodman closed 4 years ago

rainwoodman commented 4 years ago

Could you clarify if the direction of the planes in a box are pointing outward or inward?

https://github.com/orangeduck/Corange/blob/3c99c2e25c338b27ee831406aaed0159ec3a77a2/include/cengine.h#L564

blogdron commented 4 years ago

Have you been looking for this?

https://github.com/orangeduck/Corange/blob/3c99c2e25c338b27ee831406aaed0159ec3a77a2/src/cengine.c#L2521

This create a box from 6 planes from positions and directions for planes

https://github.com/orangeduck/Corange/blob/3c99c2e25c338b27ee831406aaed0159ec3a77a2/src/cengine.c#L2599

You can invert box https://github.com/orangeduck/Corange/blob/3c99c2e25c338b27ee831406aaed0159ec3a77a2/src/cengine.c#L2635

This how plane renderer - translate to triangle

https://github.com/orangeduck/Corange/blob/3c99c2e25c338b27ee831406aaed0159ec3a77a2/src/rendering/renderer.c#L1729

Plane is abstraction you can change direction in the renderer

I hope I haven’t mixed anything up. But wait for Daniel

rainwoodman commented 4 years ago

Thanks. I think this line confirms the directions are pointing outward.

I am not trained in computer geometry. After looking through a few slides online, I realized it is probably the usual convention to have the norm vectors of faces pointing outward.

blogdron commented 4 years ago

After looking through a few slides online https://learnopengl.com/Advanced-OpenGL/Face-culling you can change it behavior

I am not trained in CG

me too bro hahaahha =)

You better describe what you want to do. So it will be clearer how to help you. By the way, I also did not study computer graphics and am not a programmer. =) But if you sequentially examine the code from the data structure before the rendering takes place (thanks to the C code this path is linear and explicit), you can understand how and what works, you just need to spend time and are not afraid of the incomprehensible, but just watch how it is implemented =)

rainwoodman commented 4 years ago

Thanks for the link on vertex ordering.

I was using the sphere-box intersection routines for culling simulation boxes against a spherical shell.

Here is the rough idea: the particles in the simulation are organized in boxes; the boxes are tiled to provide full coverage to a sphere. Rendering here means solving an equation, not depositing pixels into an image. For a shell with a finite thickness, many tiled boxes can be culled -- I do not need to solve forthe particles in those culled boxes if I only care about particles in the shell.