Presently OpenSCAD doesnt support color render files.
Industry standard seems to be VRML2 and X3D, either color polygons or UV
colors.
I'm thinking of putting together a code which can compare the triangles of
an original colored mesh and the openscad CGAL mesh, find matching vertices
and coincident polygons, and color them based on the input file.
That is where it gets complex, perhaps you can provide advice on different
coincident-polygon comparisons, and potential pitfalls.
First I have to obtain openscad STL and the colored mesh so that they can
exist in the same mesh engine, with a list of triangles and vertices and
colors in arrays.
We already have that within openscad, except that i am a n00b programmer so
i would probably code it on another mesh engine. Then i have to get a VRML2
conversion code. I have to compare every polygon in one mesh to every
polygon in another mesh, to see if they exist on the same plane? If yes, to
see if they overlap as triangles? If they do share the same space then it's
safe to presume that they should be the same color, and thus to color the
entire openscad mesh and save it as VRML2.
Please advise me on the difficulties of the task? :) Is there any reason why
CGAL won't one day implement a similar post processing for colored mesh?
--
View this message in context: http://forum.openscad.org/Working-around-CGAL-color-limitations-mesh-post-processing-tp13698.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Wiki says that X3D is the newest generation of VRML format. Meshlab and
Blender source code perhaps contain good examples of X3D file conversion. I
have found a conversion code for unity3D called unityx3d, so i could
probably do it all in Unity3d in a couple of days, the result would be a bit
impractical.
--
View this message in context: http://forum.openscad.org/Working-around-CGAL-color-limitations-mesh-post-processing-tp13698p13700.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Personally I think this is a stopgap measure until - as they have indicated -
OpenSCAD eventually supports this feature (primarily for multiple
extruders).
So I'd have to say use a simple format to do this and not such a complex
format.
Specifically I suggest obj, or the proposed amf, as an export. But it
depends on what your final use is for this file and what that app needs.
--
View this message in context: http://forum.openscad.org/Working-around-CGAL-color-limitations-mesh-post-processing-tp13698p13703.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
more discussion has been had on amf, 3mf and color in these two posts (at
least):
--
View this message in context: http://forum.openscad.org/Working-around-CGAL-color-limitations-mesh-post-processing-tp13698p13704.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
It sounds a little complicated, I'm not sure if it would work. Where is the
original colored mesh derived from?
I have a version of OpenSCAD which implements rendered color, it use Carve
library so is also quite a bit faster than CGAL, although several useful
features of CGAL are not supported such as hull, minkowski. It can output
multiple STLs (one per color), or an AMF with one color per volume. I would
like to add other formats such as X3D.
To guide development it would be useful to have more use cases. So if you
have any sample models, and what the output mesh is to be used for, please
let me know.
--
View this message in context: http://forum.openscad.org/Working-around-CGAL-color-limitations-mesh-post-processing-tp13698p13706.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Hi Bobc, a carve version sounds ingenous. There is color by vertex and by
polygon and by uvs, i have found that PLY also does color by vertex, it's a
surprise to me, i was just thinking of color by triangle only because it is
a clear contrast. Shapeways seems to only accept vrml2 and x3d files for
color. It's to render any kinds of unions made with different color cubes. i
was hoping to print variations of this code in color:
https://dl.dropboxusercontent.com/u/114667999/randfms.scad
Neon22, yes it's a bit unwieldy x3d given all the xml, ill have to triple my
magnesium supplements prior to reading the specifications doc :D I will have
to read what they say on the discussion page as it sounds confusing. It's
much more difficult for me to understand a programming library to find where
the triangles and indices are kept than to actually write code to compare
all the source file triangles to the rendered file and copy the rendered
file ones so that they are the same as the input colors.
--
View this message in context: http://forum.openscad.org/Working-around-CGAL-color-limitations-mesh-post-processing-tp13698p13709.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
So i am checking this X3D format controversy. So far it's fascinating.
Attempting to save a cube file with different colors on different faces, at
first glance it would be very easy to make an X3D file parser that saves
suitable files from .scad renders:
The X3D header and footer definition code can be only 4-5 lines:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE X3D PUBLIC "http://www.web3d.org/specifications/x3d-3.3.dtd" ""> <X3D> <Scene> <Shape> //some vertex and color arrays, see example1.x3d example1.x3d <http://forum.openscad.org/file/n13748/example1.x3d> </Shape> </Scene> </X3D>color by vertex has to be set to false and there has to be a colorIndex
array, perhaps there has to be multiple materials in the X3D it said.
If you have Blender, you can make a color cube and save as X3D as an example
file, and then copy the beginning and end text into an x3d parsing routing
and write the arrays differently. I don't have blender i would be happy if
someone sends a multi material x3d file.
Afterwards, I found out what X3D is all about. it /can/ save concise 3d
files, and it can also display 3d files in crazy ways in smartphones and web
browsers.
It's an amazing file format, it can contain alot of lighting and scene
information and even do some kinds of extrusion of pentagons and stuff...
I found this amazing page with examples, i am going to attempt to turn this
into a colored cube
http://examples.x3dom.org/example/x3dom_twoSidedMaterial.html and then i
can write x3d parsing program. i write very simple code so anything i do
with triangle indices post processing of an STL should be easy to port to
openSCAD.
From this page of examples http://examples.x3dom.org/simpleExamples.html
i found this
http://examples.x3dom.org/example/x3dom_multiIndex-large.xhtml and this
http://examples.x3dom.org/example/x3dom_vertCols.xhtml ... Amazing file
format. It is equivalent to VRML2 for our 3d kinds of files, they are both
fine formats.
Ok the name X3D is boring, so i will just have to put on my 3dkini and play
some netbool :D
--
View this message in context: http://forum.openscad.org/Working-around-CGAL-color-limitations-mesh-post-processing-tp13698p13748.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Ok i have figured it out... here is an example of color per face cube file,
just have to write in different arrays.
--
View this message in context: http://forum.openscad.org/Working-around-CGAL-color-limitations-mesh-post-processing-tp13698p13749.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Ok i have written an X3D color per face parsing code. It writes color X3D and
i don't have the original colored vertex array from openscad so i can't
color my model as originally intentioned... I have tried instead to color it
by angle of the faces of the elements.
I just worked for 1 hour to understand why there is a difference in the
angles of the normals of triangles that are at the same angle, what
invisible mesh particularity is making my code bug slightly. So my
coloration results are not practical for the moment, i would nearly prefer
to code it directly into openSCAD for a solution. The x3d Export code i have
coded was very straightforwards and saves the files fine every time. All
that is missing is to compare the colors of the input mesh and write them to
the output mesh.
1> i dont know what language OpenSCAD is written in
2> i dont know how private/static/reserved/next to window/void functions
work
3> i don't know what variables to save the input array to, for later
comparison to the output mesh, perhaps i should write it to a .txt file and
read it after CGAL has finised writing, i dont know.
4> Perhaps someone could supply me with a coding framework for openscad
where i have access to the input arrays of objects and their colors, and the
output ones, and from there i can write a code that saves a color x3d file.
http://forum.openscad.org/file/n13756/icos_colors.jpg
here is the x3d file i can save from an openscad .stl output:
MATRICES24620.x3d http://forum.openscad.org/file/n13756/MATRICES24620.x3d
--
View this message in context: http://forum.openscad.org/Working-around-CGAL-color-limitations-mesh-post-processing-tp13698p13756.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Von: ufomorace ant.stewart@yahoo.com
1> i dont know what language OpenSCAD is written in
C++
2> i dont know how private/static/reserved/next to window/void
functions work
I'd say that's not a huge issue, following the examples of
the other exports is quite good enough to get started.
Actually the whole export part needs some refinement as it
currently has some code duplication due to different internal
data structures.
(e.g. https://github.com/openscad/openscad/issues/910,
https://github.com/openscad/openscad/issues/909)
3> i don't know what variables to save the input array to,
for later comparison to the output mesh, perhaps i should
write it to a .txt file and read it after CGAL has finised
writing, i dont know.
I don't understand that part. The current export code simply
writes data directly into a file output stream as it iterates
over the mesh.
See:
https://github.com/openscad/openscad/blob/master/src/export.cc
4> Perhaps someone could supply me with a coding framework
for openscad where i have access to the input arrays of
objects and their colors, and the output ones, and from there
i can write a code that saves a color x3d file.
I'm not sure what coding framework means. Depending on which
Operating System you are working the process differs a bit.
On a recent Linux system, it's probably easiest to follow
the steps from the readme on GitHub as essentially all the
dependencies are available from the distributions.
For Windows, there's a description to set-up a MSYS2 based
development environment in the Manual.
(https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Building_on_Microsoft_Windows)
On MacOS, the dependencies are best compiled separately, I
think, but there are scripts to help with that.
ciao,
Torsten.