Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3D in general.... (not really part of the mapping)
#1
here is my new structure for 3D....

Code:
Type ModelData
   x       as integer
   y       as integer
   z       as integer
End Type

Type TriType
    a      as integer
    b      as integer
    c       as integer
   clr      as integer
    i        as integer
End Type

DIM SHARED Object(1 to 3, 1 to points%) AS ModelData
DIM SHARED Poly(1 to polygons%) AS TriType

REM - Object(1         -Origin
REM -             2         -New
REM -             3         -Initial

How would i go about making this all work?
I have the rotation forumla.......and translation stuff......
but how do i render only the visible sides? How do I render the triangles?

I do have sum things ready, but ony fragments....


Any help would help

Alex~
Reply
#2
for triangles, it's best to use a third party lib like UGL or CosmoX. the visible sides get rendered if their normals point towards the screen. if your object is convex, you do not have to arrange, eg. sort, the triangles. they're automatically in correct order. if you have concave object, like most of the objects are, you can arrange it to the convex parts, and sort only the convex parts by their distance. you can also sort the triangles by their average z values. avoid flat planes and intersecting polygons. they are almost impossible to draw correctly without a z buffer.
i know, 3d can be quite a challenge.

[edit]
cosmoX has excellent matrix stuff and the builtin visibility check. but it requires that the vertices of a triangle are sorted in clockwise order.
ll formed pragma
Reply
#3
check out TerraScape Breakdown Velocity sources for practical code examples on the subject. the link can be found on this site.
ll formed pragma
Reply
#4
Code:
x1 = Model(Poly(i).p1).ScrX       'Get triangles from "projected"
    X2 = Model(Poly(i).p2).ScrX       'X and Y coords since Znormal
    x3 = Model(Poly(i).p3).ScrX       'Does not require a Z coord
    y1 = Model(Poly(i).p1).ScrY       'V1= Point1 connected to V2 then
    y2 = Model(Poly(i).p2).ScrY       'V2 to V3 and so on...
    y3 = Model(Poly(i).p3).ScrY


    'Use the Znormal,the Ray perpendicular(Orthogonal) to the XY plane
    'Defined by the Triangle (X1,Y1,X2,Y2,X3,Y3)
    'if Less or equal(=>) 0 then its facing in the opposite direction so
    'don't plot. If < then its facing towards you so Plot.
    znormal = (X2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)
    IF znormal < 0 THEN
                    DrawTri x1, y1, X2, y2, x3, y3, Clr
    END IF
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#5
I want to avoid library use...
Rel - I am using Z-normals, but im getting nasty stuff, like the front doesn't show properly, and the entire screen is filled when i use PAINT

I'll post the code after I try sum new things...

How would i go about making a library, so i can make a 3D primitive library......any tutorials will do.....


Alex~
Reply
#6
I found my problem......wasn't using 2D projected zNormal

Thnx for the help

Alex~
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)