By Jose Parrot
v 1.3, October, 21,
2008
v 1.2, October, 11, 2008
v 1.1, October, 10, 2008
Document version 1.0,
October, 06, 2008
SOL3d is a solidus
modeler and wire-frame renderer.
Introduction
This package was developed
to create wire-frame drawings for line plotter output.
Windows version
I decided to port the
package to Windows, by using .NET environment to allow execution in Windows xp
and Vista computers.
Some improvements were made, as GUI, although maintaining the C style for the
math. This new version is under development, and the menus are in English to
make it easy to all to participate.
Basic principles
The world is defined
by the following convention: positive X axis at your right, positive Z straight
ahead and positive Y up.
As an example, the
box shows the coordinates, to better demonstrate de coordinates system.
The perspective
projection system
The perspective is
determined by the intersection of the vectors from each object’s vertices P to the observer OBS with the Projection Plane.
For each point P(x,y,z) there is a projection point P’(Px,Py). The projection is determined
in 2D coordinates, in the Projection Plane. The 2D system, at the Projection
Plane, has its orign (0,0) in the center of the viewing window.
The center point of
the viewing window in the Projection Plane is the intersection of such plane
with the vector OBS-VIS. Such vector
is perpendicular to the Projection Plane.
DIST is the distance from the observer OBS to the Projection Plane.
In the figures (a)
and (b) below it is shown the vector P-OBS and its intersection P’ with the
Projection Plane, (a) viewing from positive x axis and (b) viewing from the
positive y axis.
Please note the
following conventions:
OBS The observer or
camera
VIS The point
where the observer points to
P The point
in 3D space
P’ The
projected point in 2D space at the Projection Plane
File formats
.DAT
This file describes
the objects (solidus). It uses 16-bit binary numbers, low endian.
N Number of models
(for
each model m from 1 to N)
NP Number
of points (vertices) of the model
(for each point)
X, y, z coordinates
NL Number
of lines
(for each line)
L1, L2 indexes of the vertices of the line
NF Number
of faces
(for each face)
NE Number of edges
(for each edge)
E1 …. ENE = indexes of the lines
.OBS
Text file describing
the observer (camera) path, zoom, tilt.
N number of points
Xo, Yo, Zo coordinates of the points where the camera passes by
Xv, Yv, Zv coordinates of imaginary point where the camera points to
D distance
of the projection plane (zoom effect)
T tilt
angle
The program will
determine a soft path, by calculating a Bezier like path.
Data structure
The data structure
uses a non trivial approach which permits a huge number of objects. Instead of
creating a set of objects (arrays arranged as matrices) it creates a single set
of 3d points, a single set of lines, a single set of faces and a collection of
pointers (arrays arranged as adjacency lists) to those primitives to define the
objects. More details on data structure are found
in this website.
Main targets
SOL3D project aims
finish the porting to Windows, with the following objectives:
The dream
I will be very happy
if this simple application would help students to understand the 3D way of
thinking, to learn 2D and 3D geometry,
Menus
|
|
|
File menu |
Edit menu |
Render menu |
Dialog screenshots
|
|
|
Main dialog. Points
tab |
Lines tab |
Faces tab |
Transform dialog
Wire-frame plotting
Wire-frame plotting,
with hidden line removal
A composite model,
constructed with 64 primitives.
Source code and
binaries
Both DOS C and
Windows C++ versions are available to download. Please look at SOL3D package at
sourceforge.net.
DOS version
The DOS version is
all in Brazilian Portuguese and includes executables.
The code, with the
exception of the graphics calls, is full portable to any C compiler, in any
DOS, Windows or Linux environments.
The only minor
adjusts are in the function argument definition, depending on the compiler and
should be as in the below example:
Old C syntax
functionname()
type variable;
{
/* Function code */
}
Current C/C++ syntax
void functionname(type
variable) // return type must be
declared,
{ // arguments enclosed in
parenthesis
// Function code
}
The few graphics
functions (to set the graphics mode CGA, VGA and line plot) were developed by
my own, in assembler and works well only in DOS machines.
To use it nowadays,
we have two choices: call graphics functions available at the operating system
API (Xwindow, Xfree, GDI, GDI+) or download a graphics toolkit elsewhere.
As the calls are
really very simple, I strongly recommend using the graphics capabilities
available in the operating system SDK.
The C source code
includes output in HPGL language, thus allowing plot it in any line plotter,
like the HP 7475.
You also port it to
Java, in such case with a lot of more efforts.
Windows version
The Windows version
is all in English and includes executables.
The source code is
entirely in Microsoft Visual C++ environment. The code mixes both C and CLR
syntaxes, although both are compatible with the complier.
The porting strategy
was (1) to maintain as much as possible the original code (as it is very
stable) for the core math calculations and for file I/O and (2) to create
entirely new code for the GUI, by using the VC IDE resources, at same time
providing a good and compatible interface, which works perfectly in both
Windows xp and Vista computers.
For that reason, it
needs the .NET 2.0 (or newer) run time dlls.