comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: graphics formats, triangulisation & coordinate systems
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: graphics formats, triangulisation & coordinate systems [message #36221] Thu, 28 August 2003 11:44 Go to next message
nasalmon is currently offline  nasalmon
Messages: 33
Registered: August 2003
Member
"Rick Towler" <rtowler@u.washington.edu> wrote in message news:<bijb5t$27n4$1@nntp6.u.washington.edu>...
> "Neil" wrote in message ...
>
>> Does anyone know how i can convert files in the 3DS format into the
>> OBJ format, or have a code that can do this. This are many object in
>> 3DS format but i want to manipulate verticies and polygons, so i need
>> to access the raw data.
>
> This really isn't a conversion, you simply need to read the .3ds files and
> extract the relevant data. The other day I almost wrote a .dlm for IDL that
> would read .3ds files but although that exercise would have been fun I
> couldn't justify the time. Instead I used a utility to dump .3ds files to
> ASCII. Google for "3dsrdr.c".
>
> Another option is to use the freeware 3d modeling package OpenFX to read
> your .3ds files and export them as .dxf. IDL can read .dxf files.
>
>
>> I also need to convert all polygons to triangles, is there a simple
>> triangulisation code i can use. I work in IDL so could this code be
>> used in the conversion. To take care of reflections i need to ensure
>> all surface are plane by definition, so i would like to convert all
>> otherwise polygons to triangles
>
> What polygons? How are they defined? If they are the polygons contained in
> your .3ds files then they are already defined as a collection of triangles
> by the vertices and connectivity data.
>
>
>> Which is the best coordinate system to operate in for computer
>> graphics, right-handed or left-handed. I am inclinded to use a
>> right-hand coord system as most maths books use this.
>>
>> Also if i chose a particular system should i chose the z-coordinate as
>> away (towards) the viewer or up (down). In know it is simple to
>> convert, but i just want to use the same conventions as the majority
>> of users.
>
> You don't need to make these decisions as the people who wrote openGL and
> IDL did it for you. Right handed, positive Z pointing towards the viewer,
> positive rotation is counter-clockwise.
>
> -Rick


Rick,

many thanks for you helpful comments. As for polygons other than
triangles, i was wanting a code that could read files that had say
rectangles, pentagons, hexagons or what ever might exist out there.
Not being such a specialist in this area, i am not really aware of how
common other type of polygons are in this graphics business. However,
for me to deal with reflections i would prefer something that had a
plane surface by definition. Are polygons in graphics always
triangles?

Isnt there a routine in IDL called "tessellation" that i can use to
triangulise polygons of an object?

I also see a coordinate system being RH, but with x being towards the
right, y being away from the viewer and z being upwards, and in fact
started to right my code in that convention. Such a coordinate system
seems easier to visulise. However, now i'm thinking possibly i should
change to RH with z azis coming towards the viewer. Shouldnt be too
much trouble at this early stage.

I really want a code which is compatable with other formats as
possible. I was also planning on putting the orgin at the viewer's
position. If i do that with RH with z coming toward the viewer, all z
values for objects in the scene are negative. Still i suppose that
does not matter provided you have all your coordinate transformation
correct.

I am convinced RH coordinate is probably best, but which direction
should be best for the z-axis?

Thank you again for you comments.

Neil
Re: graphics formats, triangulisation & coordinate systems [message #36247 is a reply to message #36221] Wed, 27 August 2003 15:24 Go to previous messageGo to next message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
"Neil" wrote in message ...

> Does anyone know how i can convert files in the 3DS format into the
> OBJ format, or have a code that can do this. This are many object in
> 3DS format but i want to manipulate verticies and polygons, so i need
> to access the raw data.

This really isn't a conversion, you simply need to read the .3ds files and
extract the relevant data. The other day I almost wrote a .dlm for IDL that
would read .3ds files but although that exercise would have been fun I
couldn't justify the time. Instead I used a utility to dump .3ds files to
ASCII. Google for "3dsrdr.c".

Another option is to use the freeware 3d modeling package OpenFX to read
your .3ds files and export them as .dxf. IDL can read .dxf files.


> I also need to convert all polygons to triangles, is there a simple
> triangulisation code i can use. I work in IDL so could this code be
> used in the conversion. To take care of reflections i need to ensure
> all surface are plane by definition, so i would like to convert all
> otherwise polygons to triangles

What polygons? How are they defined? If they are the polygons contained in
your .3ds files then they are already defined as a collection of triangles
by the vertices and connectivity data.


> Which is the best coordinate system to operate in for computer
> graphics, right-handed or left-handed. I am inclinded to use a
> right-hand coord system as most maths books use this.
>
> Also if i chose a particular system should i chose the z-coordinate as
> away (towards) the viewer or up (down). In know it is simple to
> convert, but i just want to use the same conventions as the majority
> of users.

You don't need to make these decisions as the people who wrote openGL and
IDL did it for you. Right handed, positive Z pointing towards the viewer,
positive rotation is counter-clockwise.

-Rick
Re: graphics formats, triangulisation & coordinate systems [message #36251 is a reply to message #36247] Wed, 27 August 2003 13:47 Go to previous messageGo to next message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Neil,
triangulation can be a complex subject. I though the web site
http://www-2.cs.cmu.edu/~quake/triangle.html was rather informative. There
is even some FORTRAN code to get the job done!

Haje

--


"Neil" <nasalmon@onetel.net.uk> wrote in message
news:74039481.0308271207.5525accd@posting.google.com...
> Does anyone know how i can convert files in the 3DS format into the
> OBJ format, or have a code that can do this. This are many object in
> 3DS format but i want to manipulate verticies and polygons, so i need
> to access the raw data.
>
> I also need to convert all polygons to triangles, is there a simple
> triangulisation code i can use. I work in IDL so could this code be
> used in the conversion. To take care of reflections i need to ensure
> all surface are plane by definition, so i would like to convert all
> otherwise polygons to triangles
>
> Which is the best coordinate system to operate in for computer
> graphics, right-handed or left-handed. I am inclinded to use a
> right-hand coord system as most maths books use this.
>
> Also if i chose a particular system should i chose the z-coordinate as
> away (towards) the viewer or up (down). In know it is simple to
> convert, but i just want to use the same conventions as the majority
> of users.
>
> Many thanks,
>
> Neil
Re: graphics formats, triangulisation & coordinate systems [message #36310 is a reply to message #36221] Thu, 28 August 2003 16:34 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
"Neil" wrote in message ...
> "Rick Towler" wrote in message >...
>> "Neil" wrote in message ...

>>> I also need to convert all polygons to triangles, is there a simple
>>> triangulisation code i can use. I work in IDL so could this code be
>>> used in the conversion. To take care of reflections i need to ensure
>>> all surface are plane by definition, so i would like to convert all
>>> otherwise polygons to triangles
>>
>> What polygons? How are they defined? If they are the polygons
contained in
>> your .3ds files then they are already defined as a collection of
triangles
>> by the vertices and connectivity data.
>>

> many thanks for you helpful comments. As for polygons other than
> triangles, i was wanting a code that could read files that had say
> rectangles, pentagons, hexagons or what ever might exist out there.
> Not being such a specialist in this area, i am not really aware of how
> common other type of polygons are in this graphics business. However,
> for me to deal with reflections i would prefer something that had a
> plane surface by definition.

> Are polygons in graphics always triangles?

At some point, yes (more or less). It all depends on your 3d graphics API.
I say more or less because the "popular" 3d APIs OpenGL and DirectX eat
triangles for breakfast, lunch and dinner. (they also eat "quads" which are
triangle pairs.) You could build your own 3d software based rendering
system where you passed objects comprised of any type 2d polygon to your
renderer but if you are planning on doing that in IDL you must be a
masochist.

IDL's object graphics is an object oriented interface to openGL, IDL style.
Crack open the documentation and have a look. Ronn Kling has a book "Power
Graphics with IDL" which is a beginners guide to object graphics and is a
good book to have on hand. You can pick it up at his website:
www.kilvarock.com


> Isnt there a routine in IDL called "tessellation" that i can use to
> triangulise polygons of an object?

Yes, and this is what you would need to do if you had, say, a mesh comprised
of octagons. But I think that a mesh like this would be pretty rare. Since
most graphics applications are built on openGL or DirectX everthing is
eventually decomposed into tris. Often, the earlier you do that, the
better.


> I also see a coordinate system being RH, but with x being towards the
> right, y being away from the viewer and z being upwards, and in fact
> started to right my code in that convention. Such a coordinate system
> seems easier to visulise. However, now i'm thinking possibly i should
> change to RH with z azis coming towards the viewer. Shouldnt be too
> much trouble at this early stage.

Regardless of any coordinate systems you devise, to display anything using
object graphics you'll need to work with a RH coordinate system with +Z
pointing towards the viewer. While many other coord systems exist, this is
what has been adopted by OpenGL and IDL.


> I really want a code which is compatable with other formats as
> possible.

Hummmmm. Don't know what you mean...


> I was also planning on putting the orgin at the viewer's
> position. If i do that with RH with z coming toward the viewer, all z
> values for objects in the scene are negative. Still i suppose that
> does not matter provided you have all your coordinate transformation
> correct.

Before you wrestle with this too much, have a look at my camera object. It
is an "improved" viewing system for object graphics. Set it up and point it
at your subjects. You don't have to worry so much about the technical
details of setting up the view.

http://www.acoustics.washington.edu/~towler/

I have a major update that I'll be posting in the next few days (I am
working on the docs now.) It abstracts the view even more and I *hope* it
will be even easier to use but you can get started with the old version.


> I am convinced RH coordinate is probably best, but which direction
> should be best for the z-axis?

Again, if you are going to be visualizing your results in IDL you'll need to
work with a RH coordinate system with +Z pointing towards the viewer.


All this talk of a coordinate systems and reflections.... What are you
trying to do? Pardon my assumption but it seems that you are just getting
starting with 3d graphics and IDL's object graphics. If so, you really
don't need to worry about this too much. IDL/openGL handles creating
normals, lighting and the other details. You just supply the vertices and
connectivity (as tris or quads). Unless you are creating procedural texture
maps or meshes I can't think of a reason to lose sleep over these things
beyond knowing the coordinate system so you can place your objects in the
world correctly.

Good luck!

-Rick
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Assoc and byteorder keywords
Next Topic: working with IDLtoAVI.dlm

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:37:29 PDT 2025

Total time taken to generate the page: 0.00659 seconds