mesh/object exporter for flash

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2007   #1
mesh/object exporter for flash

hey!

I found a nice 3d engine for flash on the web and thought about programming an exporter.
what I got so far are the vertex coords.

the flash syntax is this one (a pyramid in this case):
// Define the object co-ordinate arrays, based on a standard Cartesian coordinate system
var XCoords = [0,100,100,-100,-100];
var YCoords = [-200,100,100,100,100];
var ZCoords = [0,-100,100,100,-100];
// Imagine this as a 'join-the-dots' type of array. Each entry points to an index into the Screen arrays. Each pair represents a single line. For instance '0,1' represents a line from point '0' to point '1'.
var Lines = [0,1,0,2,0,3,0,4,1,2,2,3,3,4,4,1];

The problem is to connect the vertices with lines. I don't know how to get the edges/connections!

I attached the maxscript I got so far...
Attached Files
File Type: zip mesh2flash.zip (912 Bytes, 4 views)
 
Old 07 July 2007   #2
I think you would want to use the edge visibily of the mesh to define the lines. Otherwise just create 3 lines for each triangle. (or 4 for quads).
__________________
ThinkingMedia is a Visual Effects Studio in Toronto.
Be sure to follow me on Twitter
Watch our Tutorials on Sidefx Houdini


 
Old 07 July 2007   #3
mhhh.... it helped a bit! thx

a simple box should have this (was included in 3d engine):
var Lines = [0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7];

when I export a box I get:
var Lines = [0,2,3,1,4,5,7,6,0,1,5,4,1,3,7,5,3,2,6,7,2,0,4,6];

my function:
Code:
-- LINES format "var Lines = [" to:out_file num_faces = tmesh.numfaces vis_faces = #() for f = 1 to num_faces do ( theF = 1 face = getFace tmesh f ec = 1 for a = 1 to 3 do ( if (getEdgeVis tmesh f a) == true then ( vis_faces[ec] = face[a] ec += 1 ) ) vis_face_verts = "" for l = 1 to vis_faces.count do ( vis_face_verts = (vis_faces[theF] as integer - 1) as string + "," + (vis_faces[l] as integer - 1) as string ) format "%" vis_face_verts to:out_file if f != num_faces then ( format "," to:out_file ) theF += 1 ) format "];" to:out_file


looks really cmplicated, I know
but it's late here in germany and I am very tired...

Last edited by nomed : 07 July 2007 at 11:25 AM.
 
Old 07 July 2007   #4
I don't find an answer

what I try to do is:
- find all faces (triangles)
- for each face get the visible edges
- write an array for the connections (vertex to vertex)


it does not work

Last edited by nomed : 07 July 2007 at 11:52 AM.
 
Old 07 July 2007   #5
Quote:
Originally Posted by nomed
a simple box should have this (was included in 3d engine):
var Lines = [0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7];

when I export a box I get:
var Lines = [0,2,3,1,4,5,7,6,0,1,5,4,1,3,7,5,3,2,6,7,2,0,4,6];


Your first example has the list of edges sorted from least to most, and organized. Where as the second line as them in the winding order found in the geometry.

I think the second line is perfectly valid. If I re-order some of the edge (I won't do all, because that to much work). You would get this.

var lines = [0,1,0,2,2,0];

As you can see, the triangle that uses vertexs 0,1,2 are represented in the exported box correctly. I assume the other triangles are as well.

I did not review your source code, because your varialble names are hard to read. Also the syntax coloring makes it hard to read.
__________________
ThinkingMedia is a Visual Effects Studio in Toronto.
Be sure to follow me on Twitter
Watch our Tutorials on Sidefx Houdini


 
Old 07 July 2007   #6
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:09 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.