3d hidden surfaces, Z buffer ? good 3d implementation must see this code. 
Author Message
 3d hidden surfaces, Z buffer ? good 3d implementation must see this code.

hi,

i am working in 3d coord. system.
I built my plane type elements and formed a box with that 4 planes. But as i
rotate the system, some overlappings occur. The planes that should be behind
the front ones are not. and vice versa.. I need a hiding algorithm.(i heard
z buffering).PLS ASSIST...
i need a code that hides the planes that are behind others or lines....!!!
there is a formula but dont know if it is ok or not :
(z=(x1-x0)*(y2-y0)-(y1-yo)*(x2-xo)   if  z<0 then not visible)
i think this formula is for triangular shapes  what should be the one for
planes (4 sides)???

thanks
Devrim Pakkan

www.alargesoft.com

MY METHOD OF DRAWING AND STORING 3D POINTS...
'***********************************
Public Type plane
x(1 To 4) As Double
y(1 To 4) As Double
z(1 To 4) As Double
sx(1 To 4) As Long '  for 2d projection
sy(1 To 4) As Long
End Type

Public Type building3d
key As Integer
walls(1 To 4) As plane
name As String
color As ColorConstants
width As Double
height As Double
length As Double
End Type

'drawing algorithm....
       For kk = 1 To 4
        For k = 1 To 4
        x(k) = bul3d(i).duvar(kk).x(k)
        y(k) = bul3d(i).duvar(kk).y(k)
        z(k) = bul3d(i).duvar(kk).z(k)
        Call Rotate3D(x(k), y(k), z(k), yaw, pit, rol)
        'perspective
        x(k) = (((canvas.ScaleWidth / 1) * x(k)) / ((canvas.ScaleWidth / 1)
+ z(k))) + 0
        y(k) = (((canvas.ScaleHeight / 1) * y(k)) / ((canvas.ScaleHeight /
1) + z(k))) + 0
       'origin adjustment and zoom
        bul3d(i).duvar(kk).sx(k) = (x(k) * zoomfac + coord.x)
        bul3d(i).duvar(kk).sy(k) = (y(k) * zoomfac + coord.y)
       Points(k).x = bul3d(i).duvar(kk).sx(k)
       Points(k).y = bul3d(i).duvar(kk).sy(k)
       Next k
       Call Polygon(canvas.hdc, Points(1), NumPoints)  '    API CALLS
        Next kk
'********************************************

thanks
Atakan Devrim Pakkan



Mon, 09 Jun 2003 23:37:52 GMT  
 3d hidden surfaces, Z buffer ? good 3d implementation must see this code.
hi,

i draw the 3d box (room or building) with four planes. there is no roof and
a ceeling so you are able to see the inside. But as the planes are drawn
respectively on screen. Some false overlappings occur.

For example :  planes are drawn one by one
west is 1
nort is 2
east 3
south 4

if you camera sees the main plane from south there wont be any problem but
if your camare is looking from west than there is a problem because the last
drawn plane(south) overlaps the west plane and 3d vison lost!!!!  HOW do you
solve this problem.. I am sure there are techniques but i am a beginner...

THANKS
DEVRIM PAKKAN



Mon, 09 Jun 2003 23:50:10 GMT  
 3d hidden surfaces, Z buffer ? good 3d implementation must see this code.
The formula you have will work for planes.  The formula actually gives the
cross product of 2 vectors (from pt. 0 to pt. 1 and from pt. 0 to pt.2).
Since 3 points fully define a plane, you can represent one vertex as pt.0
and the two adjacent vertices as pts. 1 and 2 and use the same formula.

Hope this helps.

Keith Rebello

Quote:

>hi,

>i am working in 3d coord. system.
>I built my plane type elements and formed a box with that 4 planes. But as
i
>rotate the system, some overlappings occur. The planes that should be
behind
>the front ones are not. and vice versa.. I need a hiding algorithm.(i heard
>z buffering).PLS ASSIST...
>i need a code that hides the planes that are behind others or lines....!!!
>there is a formula but dont know if it is ok or not :
>(z=(x1-x0)*(y2-y0)-(y1-yo)*(x2-xo)   if  z<0 then not visible)
>i think this formula is for triangular shapes  what should be the one for
>planes (4 sides)???

>thanks
>Devrim Pakkan

>www.alargesoft.com

>MY METHOD OF DRAWING AND STORING 3D POINTS...
>'***********************************
>Public Type plane
>x(1 To 4) As Double
>y(1 To 4) As Double
>z(1 To 4) As Double
>sx(1 To 4) As Long '  for 2d projection
>sy(1 To 4) As Long
>End Type

>Public Type building3d
>key As Integer
>walls(1 To 4) As plane
>name As String
>color As ColorConstants
>width As Double
>height As Double
>length As Double
>End Type

>'drawing algorithm....
>       For kk = 1 To 4
>        For k = 1 To 4
>        x(k) = bul3d(i).duvar(kk).x(k)
>        y(k) = bul3d(i).duvar(kk).y(k)
>        z(k) = bul3d(i).duvar(kk).z(k)
>        Call Rotate3D(x(k), y(k), z(k), yaw, pit, rol)
>        'perspective
>        x(k) = (((canvas.ScaleWidth / 1) * x(k)) / ((canvas.ScaleWidth / 1)
>+ z(k))) + 0
>        y(k) = (((canvas.ScaleHeight / 1) * y(k)) / ((canvas.ScaleHeight /
>1) + z(k))) + 0
>       'origin adjustment and zoom
>        bul3d(i).duvar(kk).sx(k) = (x(k) * zoomfac + coord.x)
>        bul3d(i).duvar(kk).sy(k) = (y(k) * zoomfac + coord.y)
>       Points(k).x = bul3d(i).duvar(kk).sx(k)
>       Points(k).y = bul3d(i).duvar(kk).sy(k)
>       Next k
>       Call Polygon(canvas.hdc, Points(1), NumPoints)  '    API CALLS
>        Next kk
>'********************************************

>thanks
>Atakan Devrim Pakkan



Tue, 10 Jun 2003 03:11:08 GMT  
 3d hidden surfaces, Z buffer ? good 3d implementation must see this code.

i used (z=(x1-x0)*(y2-y0)-(y1-yo)*(x2-xo)   if  z<0 then not visible) this
formula but no use.

i have 4 point x(1 to 4)  y(1 to 4) z(1 to 4) and their projection to  sx(1
to 4)  sy(1 to 4) How to implement that formula to my 4 points. how 3 points
defines a plane ? pls state the formulation
THANKS


Quote:
> The formula you have will work for planes.  The formula actually gives the
> cross product of 2 vectors (from pt. 0 to pt. 1 and from pt. 0 to pt.2).
> Since 3 points fully define a plane, you can represent one vertex as pt.0
> and the two adjacent vertices as pts. 1 and 2 and use the same formula.

> Hope this helps.

> Keith Rebello


> >hi,

> >i am working in 3d coord. system.
> >I built my plane type elements and formed a box with that 4 planes. But
as
> i
> >rotate the system, some overlappings occur. The planes that should be
> behind
> >the front ones are not. and vice versa.. I need a hiding algorithm.(i
heard
> >z buffering).PLS ASSIST...
> >i need a code that hides the planes that are behind others or
lines....!!!
> >there is a formula but dont know if it is ok or not :
> >(z=(x1-x0)*(y2-y0)-(y1-yo)*(x2-xo)   if  z<0 then not visible)
> >i think this formula is for triangular shapes  what should be the one for
> >planes (4 sides)???

> >thanks
> >Devrim Pakkan

> >www.alargesoft.com

> >MY METHOD OF DRAWING AND STORING 3D POINTS...
> >'***********************************
> >Public Type plane
> >x(1 To 4) As Double
> >y(1 To 4) As Double
> >z(1 To 4) As Double
> >sx(1 To 4) As Long '  for 2d projection
> >sy(1 To 4) As Long
> >End Type

> >Public Type building3d
> >key As Integer
> >walls(1 To 4) As plane
> >name As String
> >color As ColorConstants
> >width As Double
> >height As Double
> >length As Double
> >End Type

> >'drawing algorithm....
> >       For kk = 1 To 4
> >        For k = 1 To 4
> >        x(k) = bul3d(i).duvar(kk).x(k)
> >        y(k) = bul3d(i).duvar(kk).y(k)
> >        z(k) = bul3d(i).duvar(kk).z(k)
> >        Call Rotate3D(x(k), y(k), z(k), yaw, pit, rol)
> >        'perspective
> >        x(k) = (((canvas.ScaleWidth / 1) * x(k)) / ((canvas.ScaleWidth /
1)
> >+ z(k))) + 0
> >        y(k) = (((canvas.ScaleHeight / 1) * y(k)) / ((canvas.ScaleHeight
/
> >1) + z(k))) + 0
> >       'origin adjustment and zoom
> >        bul3d(i).duvar(kk).sx(k) = (x(k) * zoomfac + coord.x)
> >        bul3d(i).duvar(kk).sy(k) = (y(k) * zoomfac + coord.y)
> >       Points(k).x = bul3d(i).duvar(kk).sx(k)
> >       Points(k).y = bul3d(i).duvar(kk).sy(k)
> >       Next k
> >       Call Polygon(canvas.hdc, Points(1), NumPoints)  '    API CALLS
> >        Next kk
> >'********************************************

> >thanks
> >Atakan Devrim Pakkan



Tue, 10 Jun 2003 05:12:43 GMT  
 3d hidden surfaces, Z buffer ? good 3d implementation must see this code.
Emm, why don't try using DirectX 3D engine! You just have to trigger the
render/shading method.

If you still want to try by yourself, then you have to sort the plane
(polygon) by the Z coordinate order. After sorting, draw polygon which is
the first and deepest Z coord. With a loop to the end of polygon sort list,
you will see the hiding works. Hopes this help. Oops! the polygon must be
filled with a pattern or same as background color when rendered to screen.

Riza



Quote:

> hi,

> i am working in 3d coord. system.
> I built my plane type elements and formed a box with that 4 planes. But as
i
> rotate the system, some overlappings occur. The planes that should be
behind
> the front ones are not. and vice versa.. I need a hiding algorithm.(i
heard
> z buffering).PLS ASSIST...
> i need a code that hides the planes that are behind others or lines....!!!
> there is a formula but dont know if it is ok or not :
> (z=(x1-x0)*(y2-y0)-(y1-yo)*(x2-xo)   if  z<0 then not visible)
> i think this formula is for triangular shapes  what should be the one for
> planes (4 sides)???

> thanks
> Devrim Pakkan

> www.alargesoft.com

> MY METHOD OF DRAWING AND STORING 3D POINTS...
> '***********************************
> Public Type plane
> x(1 To 4) As Double
> y(1 To 4) As Double
> z(1 To 4) As Double
> sx(1 To 4) As Long '  for 2d projection
> sy(1 To 4) As Long
> End Type

> Public Type building3d
> key As Integer
> walls(1 To 4) As plane
> name As String
> color As ColorConstants
> width As Double
> height As Double
> length As Double
> End Type

> 'drawing algorithm....
>        For kk = 1 To 4
>         For k = 1 To 4
>         x(k) = bul3d(i).duvar(kk).x(k)
>         y(k) = bul3d(i).duvar(kk).y(k)
>         z(k) = bul3d(i).duvar(kk).z(k)
>         Call Rotate3D(x(k), y(k), z(k), yaw, pit, rol)
>         'perspective
>         x(k) = (((canvas.ScaleWidth / 1) * x(k)) / ((canvas.ScaleWidth /
1)
> + z(k))) + 0
>         y(k) = (((canvas.ScaleHeight / 1) * y(k)) / ((canvas.ScaleHeight /
> 1) + z(k))) + 0
>        'origin adjustment and zoom
>         bul3d(i).duvar(kk).sx(k) = (x(k) * zoomfac + coord.x)
>         bul3d(i).duvar(kk).sy(k) = (y(k) * zoomfac + coord.y)
>        Points(k).x = bul3d(i).duvar(kk).sx(k)
>        Points(k).y = bul3d(i).duvar(kk).sy(k)
>        Next k
>        Call Polygon(canvas.hdc, Points(1), NumPoints)  '    API CALLS
>         Next kk
> '********************************************

> thanks
> Atakan Devrim Pakkan



Fri, 13 Jun 2003 00:31:45 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. 3d-demo program in 320x200 256 colour mode - 3d.zip [1/1]

2. ANNOUNCE: Adorn 3D - Create 3D user interfaces

3. Problem with 3D-fonts in 3D-panels

4. 3d graph more precisely a 3D curve plotting

5. 3D Camera rotation around any object in 3D space

6. FS: 4 Box Set of 3d image software plus 4000+ 3d images

7. DirectDraw Buffered Surface for a Primary Surface Flipping Chain

8. 3D Sound Buffer Errors Under Windows 2000

9. Algotithm for hiding in 3D models

10. NEW QB 3d raycaster (best out there)!!!!!!!!!!

11. QB 3d raycaster (best out there)!!!!

12. 3D Polygon Engine, please (better described)

 

 
Powered by phpBB® Forum Software