Creating 3D polygons from 2D input

0 views
Skip to first unread message

Lucas Golden

unread,
Nov 23, 2009, 10:55:23 AM11/23/09
to o3d-d...@googlegroups.com
Hey Everyone,

I've developed a Flex App that allows a user to draw a 2D shape then have that shape converted to 3D in  O3D.  I'm having a problem with the O3D part and figuring out exactly which primitive to use.

Since they are non-normal polygons (not just a square or rectangle),  the Box primitive is out.

The only primitive that I found that even takes a co-ordinate system is the "createPrism" primitive.  It gets close to what I need, however, since it doesn't like points concave from origin point, it does some weird stuff.

Also, if I reverse the order that I feed it the co-ordinates (i.e. if I draw my shape counter-clockwise as opposed to clockwise), the shape itself is inverted.


This is the code I'm using:
/////////////////
       var shapeTrans= g_pack.createObject('o3d.Transform');
        shapeTrans.name = "shapeTrans";
        shapeTrans.parent = root;
       
        var myShape= o3djs.primitives.createPrism(g_pack, material,shapeArray,6);

        shapeTrans.addShape(myShape);
////////////////


Are there any alternatives to createPrism that may work better using co-ordinates?

Thanks!
Luke

Gregg Tavares

unread,
Nov 24, 2009, 2:56:22 AM11/24/09
to o3d-d...@googlegroups.com

createPrism is just written in JavaScript in o3djs/primitives.js so you are free to modify it or make your own.

You can create your own geometry anyway you like. For example you could modify primitives.js and add your own functions. Or, you could copy the code out of primitives.js to your own code. Or, you could look at how the higher-level functions in primitives work and make your own function the uses the lower-level functions in primitives similar to how the higher-level functions in primitives work. Or you could look at the hellocube example which creates its own geometry instead of using the o3djs.primitives functions.

I hope one of those options is helpful.


Primitives.js
http://src.chromium.org/viewvc/chrome/trunk/src/o3d/samples/o3djs/primitives.js?revision=32596&content-type=text%2Fplain

Hello cube examples:
http://o3d.googlecode.com/svn/trunk/samples/hellocube.html
http://o3d.googlecode.com/svn/trunk/samples/hellocube-textures.html

 

Thanks!
Luke

--

You received this message because you are subscribed to the Google Groups "O3D-discuss" group.
To post to this group, send email to o3d-d...@googlegroups.com.
To unsubscribe from this group, send email to o3d-discuss...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/o3d-discuss?hl=.

Reply all
Reply to author
Forward
0 new messages