POV-Ray : Newsgroups : povray.general : How do you convert POV-Ray CSG shapes into other 3D formats? Server Time
2 Nov 2024 03:15:56 EDT (-0400)
  How do you convert POV-Ray CSG shapes into other 3D formats? (Message 1 to 10 of 24)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Reuben Pearse
Subject: How do you convert POV-Ray CSG shapes into other 3D formats?
Date: 3 Feb 2010 16:25:34
Message: <4b69e9ce$1@news.povray.org>
Hi everyone,

Is there a way to convert POV-Ray's internal representation of a 3D 
shape (i.e. one constructed using CSG) into another 3D format - perhaps 
mesh or mesh2?

Would it possible to write a POV-Ray macro to scan the surface of an 
object and create mesh2 type co-ordinates (would the trace function be 
able to do this?)

I'm just thinking it would be nice to be able to easily convert POV-Ray 
models to other formats :-)

Thanks in advance

Reuben
reu### [at] pearsecouk


Post a reply to this message

From: Alain
Subject: Re: How do you convert POV-Ray CSG shapes into other 3D formats?
Date: 3 Feb 2010 16:37:00
Message: <4b69ec7c$1@news.povray.org>

> Hi everyone,
>
> Is there a way to convert POV-Ray's internal representation of a 3D
> shape (i.e. one constructed using CSG) into another 3D format - perhaps
> mesh or mesh2?
>
> Would it possible to write a POV-Ray macro to scan the surface of an
> object and create mesh2 type co-ordinates (would the trace function be
> able to do this?)
>
> I'm just thinking it would be nice to be able to easily convert POV-Ray
> models to other formats :-)
>
> Thanks in advance
>
> Reuben
> reu### [at] pearsecouk

You are not the first one to think of that.
There are macros that can convert most objects into a mesh equivalent.
The most notable is one to convert an isosurface into a mesh.


Alain


Post a reply to this message

From: Warp
Subject: Re: How do you convert POV-Ray CSG shapes into other 3D formats?
Date: 3 Feb 2010 17:27:35
Message: <4b69f857@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:
> You are not the first one to think of that.
> There are macros that can convert most objects into a mesh equivalent.
> The most notable is one to convert an isosurface into a mesh.

  AFAIK the best algorithm to convert an isosurface into a mesh is the
so-called marching triangles algorithm (it's better than other tesselation
algorithms because it is able to create more and smaller triangles in high
curvature places and less and larger triangles in low-curvature places, and
avoids extremely thin triangles; I think it also handles sharp edges much
better than other algorithms, although I'm not completely sure of this).
The same algorithm could probably be used with more or less success with
CSG objects as well (although they have some pitfalls that isosurfaces
don't have, as CSG objects need to be traced, which introduces its own
problems, while isosurfaces just need to be evaluated).

  However, I have never heard of anyone actually going through the trouble
of implementing the marching triangles algorithm for POV-Ray. So no such
luck there.

-- 
                                                          - Warp


Post a reply to this message

From: Thomas de Groot
Subject: Re: How do you convert POV-Ray CSG shapes into other 3D formats?
Date: 4 Feb 2010 03:58:17
Message: <4b6a8c29$1@news.povray.org>
"Reuben Pearse" <reu### [at] pearsecouk> schreef in bericht 
news:4b69e9ce$1@news.povray.org...
> I'm just thinking it would be nice to be able to easily convert POV-Ray 
> models to other formats :-)
>

In addition to those macros converting isosurfaces to mesh2 mentioned by 
Alain and Warp, Moray is also able to convert csg objects into meshes, which 
you can then either edit internally or export to Poseray and/or any other 
modeller for fine tuning. The conversion is not always perfect but enough 
for many cases. Be aware however that it is not possible to import directly 
pov-ray csg object into Moray. You will have to build them first in Moray.

Thomas


Post a reply to this message

From: Urs Holzer
Subject: Re: How do you convert POV-Ray CSG shapes into other 3D formats?
Date: 4 Feb 2010 07:30:38
Message: <4b6abdee$1@news.povray.org>
Hi

> Is there a way to convert POV-Ray's internal representation of a 3D
> shape (i.e. one constructed using CSG) into another 3D format -
> perhaps mesh or mesh2?

There are some C++ libraries that can do CSG using meshes:
GTS: http://gts.sourceforge.net/
OpenCSG: http://www.opencsg.org/
As far as I know, the second one cheats using some OpenGL features, 
whereas the first one really generates a mesh. Unfortunately, they are 
C++ libraries only, so you have to write your own application for your 
task. Together with an implementation of the marching triangles 
algorithm (as mentioned by Warp), you could do nearly everything:

First convert all primitives to isosurfaces. (Is that possible?) Then 
convert them to meshes. Finally do the CSG using the GTS.

It is really time that someone implements a Povray to Mesh converter 
which works for most scenes. Unfortunately, I do not have the time to 
start such a project.

Greetings
Urs


Post a reply to this message

From: Reuben Pearse
Subject: Re: How do you convert POV-Ray CSG shapes into other 3D formats?
Date: 7 Feb 2010 17:26:51
Message: <4B6F3E31.4060408@pearse.co.uk>
Thanks for the comments so far.

After a quick look around I found this site that talks about the CAT() 
macro. This seems to do something similar in that is scans a "CSG" 
object. See the following for more details:
http://www.persistencia.org/CATHELP/CAT.html

I also found the following previous thread discussing this subject:
http://news.povray.org/povray.newusers/thread/%3Cweb.4acb6d8f90192b14fedfeaac0@news.povray.org%3E/

Are there any other macros/utilities/converters that I should be aware of?

Thanks in advance

Reuben


Warp wrote:
> Alain <aze### [at] qwertyorg> wrote:
>> You are not the first one to think of that.
>> There are macros that can convert most objects into a mesh equivalent.
>> The most notable is one to convert an isosurface into a mesh.
> 
>   AFAIK the best algorithm to convert an isosurface into a mesh is the
> so-called marching triangles algorithm (it's better than other tesselation
> algorithms because it is able to create more and smaller triangles in high
> curvature places and less and larger triangles in low-curvature places, and
> avoids extremely thin triangles; I think it also handles sharp edges much
> better than other algorithms, although I'm not completely sure of this).
> The same algorithm could probably be used with more or less success with
> CSG objects as well (although they have some pitfalls that isosurfaces
> don't have, as CSG objects need to be traced, which introduces its own
> problems, while isosurfaces just need to be evaluated).
> 
>   However, I have never heard of anyone actually going through the trouble
> of implementing the marching triangles algorithm for POV-Ray. So no such
> luck there.
>


Post a reply to this message

From: Warp
Subject: Re: How do you convert POV-Ray CSG shapes into other 3D formats?
Date: 8 Feb 2010 01:56:47
Message: <4b6fb5ae@news.povray.org>
Reuben Pearse <reu### [at] pearsecouk> wrote:
> After a quick look around I found this site that talks about the CAT() 
> macro. This seems to do something similar in that is scans a "CSG" 
> object. See the following for more details:
> http://www.persistencia.org/CATHELP/CAT.html

  Creating smaller objects inside one larger object is a completely different
(and far more trivial) thing than tesselating an object (ie. converting it
into a triangle mesh).

-- 
                                                          - Warp


Post a reply to this message

From: scott
Subject: Re: How do you convert POV-Ray CSG shapes into other 3D formats?
Date: 9 Feb 2010 06:27:19
Message: <4b714697@news.povray.org>
>  However, I have never heard of anyone actually going through the trouble
> of implementing the marching triangles algorithm for POV-Ray. So no such
> luck there.

I started to implement it in POV from some paper, but when different parts 
of the mesh needed to join back up again it never worked properly.  I 
couldn't figure out from the paper how to fix this, so gave up.  Attached is 
about as good as I got meshing a sphere using the algorithm (the next few 
steps after this started to screw up big time).


Post a reply to this message


Attachments:
Download 'marching triangles.jpg' (76 KB)

Preview of image 'marching triangles.jpg'
marching triangles.jpg


 

From: Warp
Subject: Re: How do you convert POV-Ray CSG shapes into other 3D formats?
Date: 9 Feb 2010 10:35:06
Message: <4b7180aa@news.povray.org>
scott <sco### [at] scottcom> wrote:
> I started to implement it in POV from some paper, but when different parts 
> of the mesh needed to join back up again it never worked properly.  I 
> couldn't figure out from the paper how to fix this, so gave up.  Attached is 
> about as good as I got meshing a sphere using the algorithm (the next few 
> steps after this started to screw up big time).

  That indeed demonstrates (some of) the strengths of the marching triangles
algorithm: There are no thin triangles, and all the triangles are distributed
rather evenly.

  It would be pretty useful if someone could get it to work fully.

-- 
                                                          - Warp


Post a reply to this message

From: Alain
Subject: Re: How do you convert POV-Ray CSG shapes into other 3D formats?
Date: 9 Feb 2010 14:18:59
Message: <4b71b523@news.povray.org>

>> However, I have never heard of anyone actually going through the trouble
>> of implementing the marching triangles algorithm for POV-Ray. So no such
>> luck there.
>
> I started to implement it in POV from some paper, but when different
> parts of the mesh needed to join back up again it never worked properly.
> I couldn't figure out from the paper how to fix this, so gave up.
> Attached is about as good as I got meshing a sphere using the algorithm
> (the next few steps after this started to screw up big time).
>
>
>

You try to connect each points to 6 other points.

You need to allow points to connect to less than 6 neigours. For the 
sphere, some points only connect to 5 others. Fore some other shapes, it 
can go down to 4 or 3 points. In some cases, a point may need to connect 
to 7 or even 8 or more points.

Try setting some angle or distance thresshold.


Alain


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.