Techblog

Tech Blog

Our latest geek adventures!

Archive for the ‘CAD’ Category

20 January Papervision3D forum

On request of many: Papervision3D now has a forum : http://forum.papervision3d.org/

Read more at the Papervision3D blog.

No Comments - Tags: ,

23 November Alchemy – first looks

Adobe has recently released a preview version of Alchemy. From their site:

Welcome the preview release of codename “Alchemy.” Alchemy is a research project that allows users to compile C and C++ code that is targeted to run on the open source ActionScript Virtual Machine (AVM2). The purpose of this preview is to assess the level of community interest in reusing existing C and C++ libraries in Web applications that run on Adobe® Flash® Player and Adobe AIR®.

So, what does this mean? This means that we can use existing C/C++ code and compile that down to AS3. Initially I though that this implied a hefty increase in code execution speed, but as all is compiled down to AS3 this is not true in most cases. Code will only run faster if you ’stay’ on the C-side and only return to ‘AS3′ when your C code is done processing. The reason is that AS3 method-calls are sloooow (params need to be ‘unboxed’ etc.)! When in C this slowness doesn’t occur and hence execution speed will be faster (Adobe claims a potential speed increase by a factor 2 to 10 I beleive). Wow! That of course made me wonder whether Alchemy would be usefull for 3D engines like Papervision3D, more soon! :-)

Branden Hall did a nice writeup on Alchemy explaining above better then me.

I couldn’t resist myself and started off immediately with something I always wanted to code for our 3D engine: Polygon Triangulation with support for holes.

I installed the Alchemy Toolkit, got the Flex 3.2 SDK and got some C code from the Department of Computer Science, UNC Chapel Hill.

Setting up the toolkit was bit tricky, but with help from this page I finally succeeded to get my environment right (OSX). Then I hit ‘make’ and presto! Got my swc! Download the swc and sample code or view a live example.

Some notes on swc usage:
1] ‘outer’ polygons must be defined anti-clockwise
2] ‘inner’ polygons (holes) must be defined clock-wise

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// import
import cmodule.triangulation.CLibInit;
 
// initialize
var loader:CLibInit = new CLibInit;
var lib:Object = loader.init();
 
// @vertices is an array of XY-pairs: [ [], [x0, y0], [x1, y1], ...]
//                NOTE: @vertices[0] should always be [] 
// @contours is an array containing the number of points of each polygon
//                => [4, 3, 3, 3] indicates 4 polygons with the first poly having 4 points, the second 3, etc.
// @ncontours is the number of polygons (in our example: 4)
//
// @return An array of indices into the vertices array in form: [ [p0, p1, p2], [p0, p1, p2], ...]
var indices : Array = lib.triangulate( vertices, contours, ncontours );

Here’s the relevant C code which was simply added to tri.c :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
static AS3_Val triangulate(void* self, AS3_Val args)
{
	int ncontours = 0;
	int ccount;
	int npoints, first, last, n, nmonpoly;
	register int i;
	int op[SEGSIZE][3], ntriangles;
	AS3_Val dataVal;
	AS3_Val contourVal;
	AS3_Val retVal;
	AS3_Val temp;
 
	/* initialze the AS3 values */
	dataVal = AS3_Undefined();
	contourVal = AS3_Undefined();
	retVal = AS3_Undefined();
	temp = AS3_Undefined();
 
	//parse the arguments.
	AS3_ArrayValue( args, "AS3ValType, AS3ValType, IntType", &dataVal, &contourVal, &ncontours );
 
	//if no argument is specified
	if(dataVal == NULL || contourVal == NULL || ncontours <= 0)
	{
		AS3_Trace( AS3_String("Invalid input data!") );
		return AS3_Null();
	}
 
	ccount = 0;
	i = 1;
 
	while (ccount < ncontours)
   	{
		int j;
		int k;
		//fscanf(infile, "%d", &npoints);
 
		npoints = AS3_IntValue( AS3_Get(contourVal, AS3_Int(ccount)) );
 
		first = i;
		last = first + npoints - 1;
		for (j = 0, k = 1; j < npoints; j++, i++, k += 2)
		{
			//fscanf(infile, "%lf%lf", &seg[i].v0.x, &seg[i].v0.y);
			temp = AS3_Get(dataVal, AS3_Int(i) );
 
			seg[i].v0.x = AS3_NumberValue( AS3_Get(temp, AS3_Int(0)) );
			seg[i].v0.y = AS3_NumberValue( AS3_Get(temp, AS3_Int(1)) );
 
			if (i == last)
			{
				seg[i].next = first;
				seg[i].prev = i-1;
				seg[i-1].v1 = seg[i].v0;
			}
			else if (i == first)
			{
				seg[i].next = i+1;
				seg[i].prev = last;
				seg[last].v1 = seg[i].v0;
			}
			else
			{
				seg[i].prev = i-1;
				seg[i].next = i+1;
				seg[i-1].v1 = seg[i].v0;
			}
 
			seg[i].is_inserted = FALSE;
		}
 
		ccount++;
	}
 
	n = i - 1;
	initialise(n);
	construct_trapezoids(n);
	nmonpoly = monotonate_trapezoids(n);
	ntriangles = triangulate_monotone_polygons(n, nmonpoly, op);
 
	retVal = AS3_Array("AS3ValType", NULL);
 
	for (i = 0; i < ntriangles; i++)
   	{
		AS3_Val data = AS3_Array("IntType, IntType, IntType", op[i][0], op[i][1], op[i][2] );
 
		AS3_Set(retVal, AS3_Int(i), data);
	}
 
	return retVal;
}
 
//entry point for code
int main()
{
	//define the methods exposed to ActionScript
	//typed as an ActionScript Function instance
	AS3_Val echoMethod = AS3_Function( NULL, echo );
	AS3_Val triMethod = AS3_Function( NULL, triangulate );
 
	// construct an object that holds references to the functions
	AS3_Val result = AS3_Object( "echo: AS3ValType", echoMethod );
	AS3_SetS(result, "triangulate", triMethod);
 
	// Release
	AS3_Release( echoMethod );
	AS3_Release( triMethod );
 
	// notify that we initialized -- THIS DOES NOT RETURN!
	AS3_LibInit( result );
 
	// should never get here!
	return 0;
}

14 Comments - Tags:

5 December Papervision3D 2.0 : Public Alpha Release

Posted by Tim in CAD, Papervision3D

Drumroll!
Papervision3D 2.0 (alpha) was just released! Ralph Hauwert did the bulk of the work, with me standing by as a second brain trying to solve the issues we struggled with last few days. There’s lots of bugs to be fixed of course, but check out the new stuff:

- viewports
- shaded materials (flat, gouraud, phong, bump etc.)
- frustum culling
- ascollada : import Collada files using the ASCollada library.
- animation
- more!


Get the code using SVN.

Okay, now i’ll get some sleep!

No Comments -

21 August Magic Carpet – APE

APE (Actionscript Physics Engine) is a free AS3 open source 2D physics engine for use in Flash and Flex, released under the MIT License. APE is written and maintained by Alec Cove.

Manuel Bua created a Magic Carpet using Papervison3D and APE. Best of all: source included!

Check the video Manuel made:

No Comments -

14 August Introducing ASCOLLADA

I’m happy to introduce ascollada, a AS3 library for reading Collada files.

The library is geared towards Papervision3D but should work with any 3D-engine like Away3D or Sandy.

The library currently features:

  1. simple models
  2. material loading (watch your paths!)
  3. biped animation

Please note that the library is still in its very early stages and most likely will contain bugs.

So, get the code and try it out! And… please report bugs!

You can get the code using SVN:

http://ascollada.googlecode.com/svn/trunk/as3/trunk/

Papervision3D users can opt to use the ascollada branch of PV3D’s svn:

http://papervision3d.googlecode.com/svn/trunk/branches/ascollada/

There are some examples in the examples directory to get you going.

Read the rest of this entry »

6 Comments -

3 April Export CAD to Flash: CAD2FLASH

Posted by Jeroen in CAD, Flash+ActionScript

Over time we have developed our own technique to convert 2D CADdrawings (DWG & DXF) to SVG and Flash (SWF). Flash is vectorbased just like CAD and can be used for easy webviewing of all sorts of technical drawings.

Check out an online demo of the Suite75 conversion webservice.

Click on the Select DWG button to convert a CADfile from your computer (if you don’t have a drawing available download this sampleDWG)
After you have selected the file, it will be uploaded to the server for a realtime conversion and the results are sent back to the browser so you can see the CADfile in a flash interface.
or see a sample of a converted drawing : SWF or SVG

This conversiontool has the following features

- Preserving linewidhts and styles
- Maintains layerinformation
- Skinnable by using seperate interface files

2 Comments -

30 April CADviewer for Groove

Posted by Jeroen in CAD, Collaboration

The Suite75 CADviewer is an useful tool for all Groove users who work with CAD-files. The tool lets you review 2D CAD-drawings alone or realtime with other space members.

When “navigate together” is on, a space-member will see the same drawing as you. When a member zooms or pans the drawing, all other joined members will zoom/pan along in real-time. Collaborative viewing is fast because Groove stores all files locally.
Existing layers can be switched on and off and Xref drawings are supported.

The tool works together with the Groove filestool. It scans all the filestools in that particular Groovespace for compatible visiofiles and displays them in a treeview in the Visioviewertool. By clicking on the files in the treeview you can display the files. By clicking on the navigate together in the tool you have realtime collaborative capabilities for multiple members in the space.

The CADViewer is based on the Suite75 Shared Viewing Framework and offers real-time shared viewing of DWG/DXF files within a Groove Shared Space. This Framework is designed for a variety of viewers to be used within Groove. Any viewer based on this framework will have functionality like:

-Fast and secure standalone or realtime shared file-viewing
-Auto discovery of all viewable files within a Groove Shared Space.
-Save comments to a Discussion Tool
-Print the current view to any printer

The CADViewer was a free tool for Groove 2.5 , promoting the use of Groove within a design process and showcasing the possibilities of solutions provided by Suite75 for the building industry.

UPDATE :The development of the CADviewer tool has stopped and the tool will NOT be updated in the future

No Comments -

18 August Flash to PDF,SWG or X3D

Posted by Jeroen in CAD, Flash+ActionScript

No Comments -

14 May Realtime 3D collaboration

The Architect0r tool for Groove is a simple 2D/3D design tool. You can draw volumes of different sizes and colours over 5 vertical levels in a 2D interface and can view the results realtime in a 3D viewer giving you instant feedback.

It is primarily developed to be used in the early stages of a design process to quickly set up series of layout variants for the design of a building, city plan or an interior design but due to the generic character of the tool it can be used for many different purposes.

Based on Groove, the Architect0r is allowing a group of people to zoom, pan, rotate and even design together in real-time.

Designs can be saved within a Groove space or exported to DXF/DWG format so they can be viewed with the Suite75 CADviewer Tool for Groove or used in almost any CAD software.

The Architect0r was a free tool for Groove 2.0, promoting the use of Groove within a design process and showcasing the possibilities of solutions provided by Suite75 for the building industry. The development of this tool has stopped. There will be NO updates in the future

No Comments -