Qbasicnews.com
January 22, 2019, 07:11:33 AM
 Pages: [1]
 Author Topic: 3D in general.... (not really part of the mapping)  (Read 2785 times)
Oz
I hold this place together

Posts: 923

 « on: April 13, 2004, 12:27:35 PM »

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~
 Logged
Pieslice Productions
Member

Posts: 47

 « Reply #1 on: April 14, 2004, 11:55:40 AM »

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.

cosmoX has excellent matrix stuff and the builtin visibility check. but it requires that the vertices of a triangle are sorted in clockwise order.
 Logged

ll formed pragma
Pieslice Productions
Member

Posts: 47

 « Reply #2 on: April 14, 2004, 11:59:11 AM »

check out TerraScape Breakdown Velocity sources for practical code examples on the subject. the link can be found on this site.
 Logged

ll formed pragma
relsoft
*/-\*

Posts: 3927

 « Reply #3 on: April 15, 2004, 09:22:25 AM »

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
 Logged

y smiley is 24 bit.

Genso's Junkyard:
http://rel.betterwebber.com/
Oz
I hold this place together

Posts: 923

 « Reply #4 on: April 15, 2004, 01:58:20 PM »

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~
 Logged
Oz
I hold this place together

Posts: 923

 « Reply #5 on: April 15, 2004, 02:00:30 PM »

I found my problem......wasn't using 2D projected zNormal

Thnx for the help

Alex~
 Logged
 Pages: [1]