Monday, January 26, 2009

Flash 10, 3D and BSP Tree

Used a Binary Space Partitioning (BSP) Tree to sort the order of the triangles to be drawn on the screen using Flash 10 3D API.

http://psalmhundred.net/experiment/flash3d/coffee_table_bsp/
BSP Tree Component: BSPTree.swc
Updated BSPTree.swc: 01 Feb 2009. Resolved some bugs.
02 Feb 2009. optimised code
24 Feb 2009. changed code. using timer-based instead of loops to add triangles to tree nodes. to avoid script timeout limit.

1) Import package
import dmp.*;
2) Create a BSPTree object
var tree:BSPTree = new BSPTree();
3) Add the vertices and uvt data of the model
tree.add(vertices, uvt);
4) Sort by model composite transform or by camera location
tree.sortByModelTransform(compositeM, outVertices, outUVT);
OR
tree.sortByCameraLoc(cameraLoc, outVertices, outUVT);
5) Transform & project outVertices and outUVT to draw model

Source:
BSP Tree library
BSP Tree sample program

Tuesday, January 20, 2009

Security Error 2148: while loading XML

http://adobeflash.wordpress.com/2007/01/13/error-2148-loading-xml-with-flex2-security-error/

adding the "-use-network=false" argument works in Flex Builder.

hmmm. strange. sometimes, it works without adding the argument.

Monday, January 19, 2009

OBJ to DMP format

A convertor I wrote using Actionscript 3.0 and Flex to convert from OBJ to a custom XML format i used for my students' assignment
link to OBJ format: http://en.wikipedia.org/wiki/Obj
Export from 3D tools, eg.: Maya, to OBJ format
Open the OBJ file in a text editor, eg.: Notepad. Copy and paste the data into this application. Enter the texture filename. and click "Convert"

Tuesday, January 06, 2009

3D in Flash 10

Loaded a COLLADA model from an external DAE file.
Use cursor keys, W,A,S,D and the mouse to manipulate the model.
Flash 10 player required. http://get.adobe.com/flashplayer/
Applied simple clipping, sorting of triangles.
Frame rate will drop when number of triangles is about 1K+.


http://psalmhundred.net/experiment/flash3d/TrianglesApp.html