This topic is now archived and is closed to further replies.

Clipping, and other 3D graphics questions.

This topic is 5429 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''m writing a simple 3D engine in javascript and so far have it showing a cube, with backface culling. w,a,s,d controls for moving around o,l looks up and down u,j moves up and down The big problem I have is when the cube is behind you it''s still visible, but reversed. Load up the url, and just walk straight forward until you go through the cube. Would this be because I need to implement frustrum clipping?? I know the idea behind it, but could really do with a good tutorial. So I''d really appreciate it if someone could point me in the right direction If there''s perhaps a quicker way of doing clipping I''m open to suggestions Also I''m doing backface culling by first transforming the polygon, then checking if it''s 2D coordinates are clockwise. Is there any way of doing this in 3D so that I wouldn''t have to transform polygons that wont ever be drawn? Thanks, Robert

Share this post

Link to post
Share on other sites

I've done this for my backface culling:

var visNml=new vector3D(objects[ i ].points[1].x-camera.x,objects[ i ].points[1].y-camera.y,objects[ i ].points[1].z-camera.z);
var vis=dot(objects[ i ].normal,visNml);

So I'm kind of drawing a line from my camera to a polygon face, and then getting the angle between that line and the polygon faces normal.

Which works great

I kind of know how to do the culling. I need 2 planes (for a start), left and right).

\ /
\ /

[x] is my camera and the 2 lines and the planes. I then need to get the dot products:


and ensure that both dot products are higher than 0. Right??

I'm just not too sure of how to do this, particularly how to create these planes.

Any help would be greatly appreciated.

[edited by - robertgamble on January 30, 2003 12:33:16 PM]

Share this post

Link to post
Share on other sites