About StarScreen3D v1.0StarScreen3D is a Java Applet 3D project where hundreds of 3D boxes bounce around inside of a larger 3D box. The camera flies through the space, and you can rotate the direction by dragging the mouse with either the left or right buttons.
The program implements the following 3D rasterization techniques:
Depth Sorting using the Painter's Algorithm. Once the boxes are sorted, each face of each box is tested in descending z-depth order via Back-face Culling to see whether or not the face should be rendered. If the face passes the test, then each (x, y, z) point of that face is first translated into camera coordinates and then projected onto the camera's view screen. The camera is defined by an (x, y, z) position, C, with subscript G to indicate the global coordinate system is used:
A point in global coordinates is defined as:
with subscript G indicating the point is relative to the global coordinate system. In order to convert the point into the camera coordinate system, its origin reference must be translated to the camera and then projected onto the camera axes. Translation is accomplished by subtracting the camera position from the point, effectively making the camera the new origin for the point (this yields a vector from the camera to the point with subscript CT indicating that the vector is relative to the camera via translation):
The translated point can be written in matrix form:
The rotation of the camera is defined by three unit vectors that are referenced to the camera as the origin. The z-component of the camera coordinate system points into the view screen, the x-component points to the right, and the y-component points downwards for convenience in projection to the view screen. They make up a local coordinate system Cam that is relative to the camera translated coordinate system via a rotation:
The unit vectors can also be written in matrix form:
The projection of this point onto the camera axes is accomplished by multiplying matrix Mcam by the vector PCT, which is the same as dotting the point with each camera unit vector:
Now that the point has been converted into the camera coordinate system, a projection can be made onto the camera's view screen. The view screen is stored to be a distance VZ in front of the focal point of the camera. If the point in camera coordinates is behind the physical size of the viewer, then the point is not within the Viewable camera space and should be handled accordingly. A point may be translated from camera coordinates to the view screen as follows:
The remaining set of points that make up the surface is translated in the same manner, and an orange covered polyline is then drawn on the screen with a blue outline around it to represent the surface.
where n is the vector surface normal and cz is the camera unit vector in the z-direction (i.e. into the screen), then the surface faces the camera, and that surface will be drawn if its projection lies on the screen.