Cube Testing:

advertisement
3D Object Modeler
Technical Issues
Document Version 0.5
Michael Dunn
Tom Fili
Mingjie Zhu
Vadim Rybak
Olga Kerchentseva
27th February 2004

Converting Mouse pointer coordinates from 2D screen to 3D canvas coordinates.
o It turns out that openGL supports a unproject() function which is responsible
for taking the mouse coordinates and x,y,z values of the canvas by reference.
The function will un-project the 2d mouse coordinates and update the x,y,z
values with the correct 3D coordinates of the canvas.

Since we decided to use C# and the .NET development environment, one of our
difficulties was finding the proper C# wrapper around OpenGL. We found 2 major
ones: csGL and Tao.
o csGL - Initially we considered using csGL, however there are several issues
with it. The major one is that of performance. Since the OpenGL control is
inside a panel object of the .NET framework, one must constantly refresh the
panel in order to see changes made to the canvas. This process of continually
refreshing the panel is a huge performance loss and should be avoided. csGL
also relies on natively compiled dynamically linked C++ libraries.
o Tao – after doing some reading, Tao seems like the best choice because it is
not just a wrapper for C#, but in fact for all the .NET languages. This means
that we now have the flexibility to code pieces of our program in Visual Basic
and other pieces in C#. Further Tao avoids the performance loss which we
experienced in the csGL wrapper. Tao relies on no natively compiled
libraries, so we can take advantage of .NET’s portability.

Another issue which we seem to be having is the problem of representing the custom
polygon object. Since the user will provide the vertices of the faces on the object, this
can cause several problems. For example, what if the user provides 2 faces which are
not touching each other. Then we have to go through the hassle of detecting weather
the polygon is closed in or not.
o A good way to get around that is to force the user to provide faces in order.
After the user provides the first face, he will be forced in the next step to only
provide faces which are attached to the previous one. This way we can avoid
gaps in the polygons without actually having to detect weather the polygon is
popper or not.

Rotation of Shapes:
Rotation of shapes will be done by converting each vertex of the shape into
homogeneous coordinates, in the following fashion:
Vertex (x,y,z) will be put into a matrix data structure:
Then the vertex matrix will be multiplied my one of the following rotation matrices,
depending on which axis the user wants to rotate the shape around. The resulting
matrix will yield the new rotated vertices of the shape. Θ in the rotation matrices
is the angle of rotation which is specified by the user. The rotation matrices are:
Rotation matrix for rotation around the x-axis:
Rotation matrix for rotation around the y-axis:
Rotation matrix for rotation around the z-axis:

Translation of Shapes:
Translation of shapes will be done by converting each vertex of the shape into
homogeneous coordinates, in the following fashion:
Vertex (x,y,z) will be put into a matrix data structure:
The vertex matrix will then be multiplied by the translation matrix. The result of
the multiplication will generate the new translated vertex. The dx, dy and dz in
the translation matrix are the distances in x, y, and z directions by which the user
wants the shape to be translated.
Translation matrix:

Scaling Shapes:
Scaling of shapes will be done by converting each vertex of the shape into
homogeneous coordinates, in the following fashion:
Vertex (x,y,z) will be put into a matrix data structure:
The vertex matrix will then be multiplied by the scale matrix. The result of the
multiplication will generate the new scaled vertex. The sx, sy and sz in the scale
matrix are user specified scaling factors in x, y, and z directions.
Scaling matrix:
Download