## Discuss Scratch

- Discussion Forums
- » Help With Scripts
- » 3D polygon rendering order

- NormallyNormal
- Scratcher

24 posts

### 3D polygon rendering order

I am making a scratch program that renders 3D shapes.

The shapes are all made of triangular planes.

The question is, if it is assumed that none of the planes intersect, how can I get the order that I should render them in, knowing the X, Y, Z of each of the 3 corners of the triangle? For example, the back of a cube should render first, so it is behind the front of the cube. How would the program know when a plane is “behind” another?

I think the general idea would be something like:

Something closer to the center should render before (behind) something farther away from the center.

Something with a smaller Z value should render before (behind) something with a larger Z value. (Higher Z = closer to camera)

This is more of a mathematical question than specifically about scripts.

Thank you!

The shapes are all made of triangular planes.

The question is, if it is assumed that none of the planes intersect, how can I get the order that I should render them in, knowing the X, Y, Z of each of the 3 corners of the triangle? For example, the back of a cube should render first, so it is behind the front of the cube. How would the program know when a plane is “behind” another?

I think the general idea would be something like:

Something closer to the center should render before (behind) something farther away from the center.

Something with a smaller Z value should render before (behind) something with a larger Z value. (Higher Z = closer to camera)

This is more of a mathematical question than specifically about scripts.

Thank you!

*Last edited by NormallyNormal (Feb. 7, 2018 04:00:37)*

I'm normal. Most of the time. I'm normally normal.

- ParadoxScratching
- Scratcher

100+ posts

### 3D polygon rendering order

If you think it's too complicated, you can use this method instead. It's much easier to understand.

https://wiki.scratch.mit.edu/wiki/Animating_a_3D_Object

https://wiki.scratch.mit.edu/wiki/Animating_a_3D_Object

Did I help? If so, consider following me!

Forums not helping out your scripts? Want me to answer your questions in particular? Put your projects you have a question of in this studio! I would try my best to answer you. I care more about understanding the problem than knowing how to fix the problem.

https://scratch.mit.edu/studios/4636701/

- NormallyNormal
- Scratcher

24 posts

### 3D polygon rendering order

I think that the back-face culling will work. I've also got a few other ideas to try out. Thanks guys!

I'm normal. Most of the time. I'm normally normal.

- Discussion Forums
- » Help With Scripts
- » 3D polygon rendering order