A library for simple 3D transformations.
File: |
Simple3D.lib |
Version: |
1.0 |
Author: |
John Master |
Details
Constants
Sub routines
This library is kind of pointless, but you can use it to perform very simple 3D transformations for rendering some oldschool effects. Please see the examples for better understanding. If you want to do more advanced stuff than what's presented in the examples, you probably need to develop this library a bit.
Point array indexes |
||
Name |
Description | |
S3D_X |
3D point x-coordinate. |
|
S3D_Y |
3D point y-coordinate. |
|
S3D_Z |
3D point z-coordinate. |
|
S3D_PX |
Projected x-coordinate. |
|
S3D_PY |
Projected y-coordinate. |
|
S3D_PZ |
Projected z-coordinate. |
Setup |
|||
Name |
Parameters |
Brief description |
|
procedure |
fov#, zMin#, zMax# |
Set view properties. |
|
Transformations |
|||
Name |
Parameters |
Brief description |
|
procedure |
Clear transformation. |
||
procedure |
x#, y#, z# |
Translate. |
|
procedure |
a# |
Rotate around x-axis. |
|
procedure |
a# |
Rotate around y-axis. |
|
procedure |
a# |
Rotate around z-axis. |
|
procedure |
x#, y#, z# |
Scale. |
|
Transformation stack |
|||
Name |
Parameters |
Brief description |
|
procedure |
Push transformation to stack. |
||
procedure |
Pop transformation from stack. |
||
Projection |
|||
Name |
Parameters |
Brief description |
|
procedure |
&dstX, &dstY, x#, y#, z# |
Project a point. |
|
procedure |
&dstX#, &dstY#, &dstZ#, x#, y#, z# |
Project a point. |
|
procedure |
&points#[][] |
Project an array of points. |
procedure S3D_SetView ( fov#, zMin#, zMax# )Set properties of the 3D view. The default view has a 60 degree field of view and a 'zMin' and 'zMax' value of 0.1 and 10.0. The 'zMin' and 'zMax' values doesn't make much sense unless you evolve into doing polygon clipping and such. Simply keep 'zMin' larger than 0 and 'zMax' larger than 'zMin' or stick with the mentioned values.
[ Back ] |
procedure S3D_ClearTransformation ( )Clear the 3D transformation. [ Back ] |
procedure S3D_Translate ( x#, y#, z# )Translate.
[ Back ] |
procedure S3D_RotateX ( a# )Rotate around x-axis.
[ Back ] |
procedure S3D_RotateY ( a# )Rotate around y-axis.
[ Back ] |
procedure S3D_RotateZ ( a# )Rotate around z-axis.
[ Back ] |
procedure S3D_Scale ( x#, y#, z# )Scale along all axis. Note, that for no scaling along an axis, the value to use is 1, not 0.
[ Back ] |
procedure S3D_PushTransformation ( )Push transformation to stack. [ Back ] |
procedure S3D_PopTransformation ( )Pop transformation from stack. [ Back ] |
procedure S3D_Project ( &dstX, &dstY, x#, y#, z# )Project a 3D point, in the current transformation frame, to screen coordinates.
[ Back ] |
procedure S3D_Project_3f ( &dstX#, &dstY#, &dstZ#, x#, y#, z# )Project a 3D point, in the current transformation frame, to screen coordinates. The difference between this function and 'S3D_Project' is that you also get a z-coordinate for the projected point, that you can use for sorting and other things.
[ Back ] |
procedure S3D_Project_3fv ( &points#[][] )This function does the same thing as 'S3D_Project_3f' but on a whole array of 3D points. The array must be a 2D array with (atleast) 6 fields in its second dimension. The first three fields represent the 3D point's x, y and z coordinates, while the next three fields are the resulting projected x, y and z coordinates. You can use the constants S3D_X, S3D_Y and S3D_Z for the 3D point fields, and S3D_PX, S3D_PY and S3D_PZ for the projected point fields.
[ Back ] |
Generated with NLDoc 20140630.