Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

sorting 3D faces/polygons

ShkaboinkaShkaboinka Member Posts: 79
I know the theory, but I do not know the math. From what I can gather, here is how you would correctly render a bunch of 3D faces/polygons perfectly (in every case):

sort them in order of which is in FRONT; to do this, you find the equation for the plane that a face lies on (for this reason, it may be best to just use triangles), and plug some point of another face into the equation and get the missing X, Y, Z, or whatever; it is is on the same side as the camera (both are less than or greater than what the missing value should be), then that point is in front of the face.

When comparing 2 faces, you compare each point of a face with the other; if they are not all on the same side, then the face is split...

You sort them like this, and then draw them in order from front most to last most.

..BUT I DO NOT KNOW THE MATH!!!!!!!! so frustrating...

can anybody help me? or is nobody ever here anymore (except those who do NOT do any of this by themselves, but use engines to do it for them).

Also, since I am using java, I cannot tell it to shade each pixel just so... what I CAN do is have a gradient or one color for a face that would match the lighting angle/distance, and also the angle to the screen if transparent(a transparent face gets "thicker" as it turns away from you)

Comments

  • ninchagoraninchagora Member Posts: 82
    : I know the theory, but I do not know the math. From what I can gather, here is how you would correctly render a bunch of 3D faces/polygons perfectly (in every case):
    :
    : sort them in order of which is in FRONT; to do this, you find the equation for the plane that a face lies on (for this reason, it may be best to just use triangles), and plug some point of another face into the equation and get the missing X, Y, Z, or whatever; it is is on the same side as the camera (both are less than or greater than what the missing value should be), then that point is in front of the face.
    :
    : When comparing 2 faces, you compare each point of a face with the other; if they are not all on the same side, then the face is split...
    :
    : You sort them like this, and then draw them in order from front most to last most.
    :
    : ..BUT I DO NOT KNOW THE MATH!!!!!!!! so frustrating...
    :
    : can anybody help me? or is nobody ever here anymore (except those who do NOT do any of this by themselves, but use engines to do it for them).
    :
    : Also, since I am using java, I cannot tell it to shade each pixel just so... what I CAN do is have a gradient or one color for a face that would match the lighting angle/distance, and also the angle to the screen if transparent(a transparent face gets "thicker" as it turns away from you)
    :

    Hey, are you still interested in this?


    I suppose you need to sort polygon vertices by their distance from camera.

    Also you would like to know on which side of a polygon plane lies an arbitrary point (possibly vertex of another triangle) in order to determine whether you should split it or not.

    Also you need intersection of a triangle edge with another plane in order to split a triangle into a triangle and a trapezoid (which is represented as 2 triangles).

    I assume you already know all about lighting/shading and transparency.
    (but maybe you don't know maths - how to find the angles).


    If (you are)
    then I will look through some old sketches and code I've written about it;
    else I won't bother;


    Tell, do you have fixed camera and object positions tranformed into camera's coordinate system, or you have objects in their positions, and camera with its position and angles, or three vectors, or whatever you have.

    Have you considered raytracing?
    It can easily and accurately render effects like shadows, reflections, transparency, refraction - but not in real time, of course.

    Of course there are many people that use engines and code generators etc., but... You don't program in machine language, but use high-level languages with compiler and/or interpreter.
    Everything has its purpose. They probably need to make something in a short time, and you probably want to explore and have fun making your own graphics engine.
Sign In or Register to comment.