2010-11-08

3d description language

2010-11-08

Xah wrote:
> i've been wondering about that. Specifically, for my needs, i really
> need a lang like povray that lets me program (say in python) to
> generate the povray sphere box lighting etc positions and sizes, to
> generate a picture. Usually for math illustration purposes.
>
> • 〈Illustrating Geometry with POV-Ray〉http://xahlee.org/3d/illus_geometry.html
>
> however, for my need i don't really need realism rendering alone with
> its waiting for the picture.
>
> also, i really want real-time viewing and animation than static
> images. (see  http://xahlee.org/3d/viz.html)
>
> so, in past few years, i've been somewhat looking. Am pretty sure
> these days Blender or perhaps others has scripting that that really
> does what i need much better that POV-Ray. That is, a language that
> describe geometry primitives that can be rendered, but i don't really
> need fancy rendering like ray-tracing, but more or less just
> projection and dynamic interaction....
>
> for example, let's say i have a sphere of radius 1 at position {2,3,4}
> and  a box of side length 1 ot {2.5,2, 2}. Then, suppose my camera
> (view point) is at {-1,3,2} looking in the direction of origin.

namekuseijin wrote:
> yes, but you can't "code" in those with the same ease as with pov's
> SDL.
>
> in povray SDL:
>
> sphere { 1 <2,3,4> }
> box { -1,1 translate <2.5,2,> }
> camera { location <-1,3,2> look_at 0 }
> // some light, will ya?
> ligh_source { <1,1,-1>*10 1 }
>
> in python using Blender API:
>
> cam = bpy.data.scenes[0].camera
> cam.location = (-1,2,3)
>
> that just adjusts the current scene camera location to your desired
> location.  I don't even know how to do the rest, like even locking its
> focus to the origin, let alone adding the primitives... if the log in
> 2.55 is of any use, the operation to add a sphere is:
>
> bpy.ops.mesh.primitive_uv_sphere_add(segments=32, rings=16, size=1,
> view_align=False, enter_editmode=False, location=(-1.35352, -2.99709,
> 0), rotation=(0, 0, 0), layer=(True, False, False, False, False,
> False, False, False, False, False, False, False, False, False, False,
> False, False, False, False, False))
>
> sucks, huh?  Blender is a wonderful tool for artists, not much for
> programmers or math-types.

humm...

maybe it's time to ask stackoverflow for a definitive answer about this.

i find it hard to believe there's no lang that describe 3D primitives.

actually, there's Mathematica
• 〈Introduction To Mathematica's 3D Graphics Format〉
http://xahlee.org/3d/mma.html

and there's a LOT for 2D (svn, flash, there's a js lib i recently learned but forgot the name).

for 3D, there's google's
http://code.google.com/p/o3d/

which is very promising, but i haven't spent time on yet.

but i was really hoping in Blender too... given its status, i think it's trivial to create a primitive descriptive lang similar to POV-Ray, and my guess is that it's already there...

> > My question is, those who blender experience, whether blender could
> > practically be used like POV-Ray since i don't really need POV-Ray's
> > rendering but need all the blender's interactivity etc features.
>
> if you need interactivity, you don't need scripting with python
> either.  Just use the menus and options.  That's the way to use
> Blender, since its geared at artists.
>
> here's my best attempt ever at something artistic with Blender:
>
> http://blenderartists.org/forum/showthread.php/190197-Stereo-Fruits

the best i've done is a cube. lol.

btw, do you know how to in POV-Ray to make the rendering outline only? e.g. like those of technical drawing. i.e. similar to showing just wireframe, but taking out all the wires only showing the object edge, and also hide internal or other parts that's can't be seen.

Xah ∑ http://xahlee.org/ ☄



On Nov 9, 1:36 am, namekuseijin wrote:
> On Nov 8, 11:54 pm, Xah Lee wrote:
>
> > about Blender not able to take a scene description file for creating
> > simple geometric objects, i'm still not sure. There's also the .obj
> > file, and recently collada file format, and vrml, and possibly there's
> > import utility that takes pov files. So, it's likely one can just use
> > python to create objects in these files. Also, besides Blender,
> > there's quite a few other free 3D modelers... am sure one of them can
> > do it.
>
> > ... also, Second Life is about to support importing mesh using collada
> > format.
>
> > am sure that for someone working in this area... there's easy route to
> > create 3D scenes by using python or any lang to generate a file of
> > highlevel dsecription 3d primitives similar to pov's format, then just
>
> hmm, .obj and collada are file formats for raw meshes.  That means you
> would use python to generate meshes vertex by vertex.  In that case,
> even a stupid call like:
>
> bpy.ops.mesh.primitive_uv_sphere_add(segments=32, rings=16, size=1,
> view_align=False, enter_editmode=False, location=(-1.35352, -2.99709,
> 0), rotation=(0, 0, 0), layer=(True, False, False, False, False,
> False, False, False, False, False, False, False, False, False, False,
> False, False, False, False, False))
>
> is higher level than that...
>
> I still very much prefer sphere { location radius }, though...
>
> you could certainly hid it away like:
>
> def sphere( loc=(0,0,0), radius = 1 ):
>     return bpy.ops.mesh.primitive_uv_sphere_add(segments=32, rings=16,
> size=radius*2,
> view_align=False, enter_editmode=False, location=loc, rotation=(0, 0,
> 0), layer=(True, False, False, False, False,False, False, False,
> False, False, False, False, False, False, False,
> False, False, False, False, False))
>
> and for the other primitives as well...

yes. but the point is it is trivial to write a functions to generate primitives as vertexes.

so, you can write

def sphere(center, radius, meshdensity) = {...}

On Nov 9, 1:36 am, namekuseijin wrote:
> On Nov 8, 11:54 pm, Xah Lee wrote:
>
> > about Blender not able to take a scene description file for creating
> > simple geometric objects, i'm still not sure. There's also the .obj
> > file, and recently collada file format, and vrml, and possibly there's
> > import utility that takes pov files. So, it's likely one can just use
> > python to create objects in these files. Also, besides Blender,
> > there's quite a few other free 3D modelers... am sure one of them can
> > do it.
>
> > ... also, Second Life is about to support importing mesh using collada
> > format.
>
> > am sure that for someone working in this area... there's easy route to
> > create 3D scenes by using python or any lang to generate a file of
> > highlevel dsecription 3d primitives similar to pov's format, then just
>
> hmm, .obj and collada are file formats for raw meshes.  That means you
> would use python to generate meshes vertex by vertex.  In that case,
> even a stupid call like:
>
> bpy.ops.mesh.primitive_uv_sphere_add(segments=32, rings=16, size=1,
> view_align=False, enter_editmode=False, location=(-1.35352, -2.99709,
> 0), rotation=(0, 0, 0), layer=(True, False, False, False, False,
> False, False, False, False, False, False, False, False, False, False,
> False, False, False, False, False))
>
> is higher level than that...
>
> I still very much prefer sphere { location radius }, though...
>
> you could certainly hid it away like:
>
> def sphere( loc=(0,0,0), radius = 1 ):
>     return bpy.ops.mesh.primitive_uv_sphere_add(segments=32, rings=16,
> size=radius*2,
> view_align=False, enter_editmode=False, location=loc, rotation=(0, 0,
> 0), layer=(True, False, False, False, False,False, False, False,
> False, False, False, False, False, False, False,
> False, False, False, False, False))
>
> and for the other primitives as well...

yes. but the point is it is trivial to write a function to generate primitives as vertexes.

so, you can write

def sphere(center, radius, meshdensity) = {...}

def rectangle(center, sideLength1, sideLength2,sideLength3, meshdesity) = {...}

def cone(vertex, height, orientation, angle) = {...}

def parametricSurface(formula, uRange, vRange, steps) = {...}

etc. trivially.

Then, you create your scene by calling these functions. Then, they print to a mesh format file. Then, call another app or using the 3D modeler's scripting lang to import this .obj or collada file into the 3D modeler, then you have it.

all this can be done easily... perhaps with AutoHotkey so one doesn't even need to use the mouse.

Xah


On Nov 9, 12:50 pm, namekuseijin wrote:
> On 9 nov, 18:06, Xah Lee wrote:
>
> > On Nov 8, 11:49 am, namekuseijin wrote:
>
> > > there are some very tricky tricks to do that, like this:
>
> > >http://tuabiht.chez-alice.fr/PovEdge_Site/PovEdge.html
>
> > wrote a article about this.
>
> > • 〈Outline Rendering of 3D Models (POV-Ray)〉http://xahlee.org/3d/outline_rendering.html
>
> "I think the fact POV-Ray cannot do it is just a particular historical
> or idiosyncratic reason."
>
> it's like I said before:  povray uses true math primitives as
> described by math equations.  There are no edges or faces to compute
> or hide:  just math surfaces that are either intersected or not by
> light rays (line segments).  All raytracers do it that way, but some
> specialize only in coarse and limited mesh-based geometry.  Povray
> supports meshes, though, which is why PovEdge works:  everything in
> PovEdge scenes is made out of meshes, even spheres or cubes, and thus
> the povedge macro can calculate edges and such needed info.

the fact POV-Ray use math equations as opposed to meshes to represent its 3d primitives doesn't matter. Again, it's just how POV-Ray came to be, it's particular idiosyncracy, its feature set, data structure and algorithm choices, implementation decisions. Doesnt matter what modeling tech a 3d app uses, may it be math equation or polygons or nurbs or other variations. The goal is to render the output image using uniform color for all visible surface. (aka outline rendering; cartoon style)

btw, Second Life can do it, and i think isn't the Zelda on Nintendo Cube done in a cartoon style? (thin it was around 2004?) so, clearly the technology to render 3d modeles as outline (flat cartoon illustrations) in real time is already a solved problem. Having just wrote that, i think any 3D field pro can simply tell us how to do it.

> > do u have a real name namejuseijin? makes people more comfortable
> > citing you.
>
> Namekuseijin At Gmail Dot Com
>
> :)
>
> shouldn't we be doing this by mail?  I'm sure Lispers are not
> amused...

they are certainly amused. All this can be done in lisp. And, isn't there some 3d modeler using lisp? there's autolisp... :) and the famous SICP book uses algorithmic art as one of its main subject in i think chapter 2.

the 3d modeler Wings is written in Erlang... oops wait, that's not lisp.

Xah

No comments:

Post a Comment