Tag Archives: away3D

GPU render mode hell, and how we barely got out of it alive.

Hello everyone, Tam here!

I’m going to recount the story of one of the projects I’ve been working on in the past few months, and how it all went downhill from the very beginning.
Oh don’t worry though. This is not a fancy post-mortem for the biggest game of the year, but its my first so I’ve got at least something to smile about.
In fact in order to be able to write this article let me pull up a happy image just for you and me, and then let’s jump right in.

Friends-With-You_Happy_Rainbow-01

Continue reading GPU render mode hell, and how we barely got out of it alive.

Playing with Cadet Editor 3D and AwayPhysics

The 3D part is a bit in stand-by this last weeks on the Citrus Engine, because I’m polishing the engine for the V3 which should be out this week!

I’ve never clearly introduced AwayPhysics in the Citrus Engine, so it’s the day! The idea is to have a similar pre-built platformer objects that we already have with Box2D and Nape but with AwayPhysics this time for 3D stuff! This work and Away3D support will evolve during the V3.

Now that 3D views and physics are supported, it’s time to give a look on which tool we can use as a 3D game Level Editor. At first, I thought to Prefab. This is the best tool to create a scene with Away3D, importing assets, add lights… But too complex for a simple level design, I mean : hey the Citrus Engine is not a concurrent to Unity3D (which I started to learn thanks to this awesome tutorial) 😀 Its 3D physics part is just here to create basic 3D game / puzzle. Also the level editor has to support object creation (physics object), this isn’t obvious with Prefab.
Then I gave a look to Cadet Editor, the 3D editor is very easy to handle. You can create quickly sphere, cube and plane objects, add lights… That’s the right tool to see what can be done!

Continue reading Playing with Cadet Editor 3D and AwayPhysics

The Citrus Engine meets Away3D

Some days ago, I was thinking that my next post would be the annoucement of the Citrus Engine V3 stable release. Since Starling and Nape are well integrated in the engine and the API very stable, I didn’t see any new big features coming. Oh in fact, I imagined one : 3D support. This one was crazy, and now it is real! Welcome to the first 2D & 3D Flash game engine!

I’m not familiar with 3D. Last year I had a quick look with ThreeJS and then ported it in Away3D. That was my only experience with 3D until now, so don’t hesitate to correct me and to offer some suggestions. That’s lots of new stuff to learn, and that’s pretty exciting!
Also if you have links to free arts/assets Away3D friendly, share please 🙂

For the impatients, here is the demo! Note the Away3D support needs lots of work yet. Click on the red square to add boxes (I was a bit lazy to make a correct button). Use the mouse to move the camera, and right/left/down/space keys for the Hero.
I use Box2D for the physics (it could be Nape), to see the Box2D debug view press tab to open the console and write :

set box2D visible true

All the source code is available on GitHub (with samples) and on GoogleCode (engine code only). The Away3D part will evolve a lot in the next month, the 2D stuff is very stable to use!

Continue reading The Citrus Engine meets Away3D

Getting started with Away3D for FP11

It was about time to start working on 3D with flash. I was already looking at Papervision3D some years ago, but I have never worked with. Then I’ve followed differents 3D engine like Sandy, Five3D, and Away3D.

Now that Stage3D and FP11 are out, it is time to start working with 3D in flash. However, it’s funny that my first try on a 3D Engine was made with a JS engine : Three.js
So in this post I just adapt my previous 3D example made with Three.js and WebGL and see how it runs with Away3D.

Finally I have chosen Away3D instead of those 3D engine for FP11 : minko, alternativa, flare3D, and adobe proscenium because it is free and has a great community support.

The quick demo.

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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package {
 
	import away3d.cameras.Camera3D;
	import away3d.containers.ObjectContainer3D;
	import away3d.containers.Scene3D;
	import away3d.containers.View3D;
	import away3d.debug.AwayStats;
	import away3d.lights.DirectionalLight;
	import away3d.materials.ColorMaterial;
	import away3d.materials.methods.FilteredShadowMapMethod;
	import away3d.primitives.Cube;
 
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Vector3D;
 
	[SWF(backgroundColor="#FFFFFF", frameRate="60", width="1000", height="650")]
 
	/**
	 * @author Aymeric
	 */
	public class Main extends Sprite {
 
		private const _ORIGINE:Vector3D = new Vector3D(0, 0, 0);
		private const _NBR_ELEMENTS:uint = 250;
 
		private var _camera:Camera3D;
		private var _scene:Scene3D;
		private var _view:View3D;
		private var _container:ObjectContainer3D;
 
		private var _tab:Vector.<Cube>;
 
		private var _formOneElement:Boolean;
 
		private var _diffX:int, _diffY:int, _diffZ:int;
 
		public function Main() {
 
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
 
			_scene = new Scene3D();
			_camera = new Camera3D();
			_view = new View3D();
			_view.antiAlias = 2;
			_view.backgroundColor = 0xEEEEEE;
			_view.camera = _camera;
			_view.scene = _scene;
 
			addChild(_view);
			addChild(new AwayStats(_view, false));
 
			_container = new ObjectContainer3D();
			_scene.addChild(_container);
 
			var light:DirectionalLight = new DirectionalLight(-1, -1, 1);
			light.color = 0xFFFFFF;
			light.castsShadows = true;
 
			_container.addChild(light);
			light.x = -15000;
			light.y = -15000;
			light.z = -15000;
 
			_camera.lookAt(_container.position);
 
			_tab = new Vector.<Cube>();
 
			var cube:Cube;
			var colorMaterial:ColorMaterial;
			for (var i:uint = 0; i < _NBR_ELEMENTS; ++i) {
 
				colorMaterial = new ColorMaterial(Math.random() * 0xFFFFFF);
				colorMaterial.lights = [light];
				colorMaterial.shadowMethod = new FilteredShadowMapMethod(light);
 
				cube = new Cube(colorMaterial, 50, 50, 50);
				_container.addChild(cube);
 
				if (i == 0)
					cube.x = Math.random() * 1000;
				else
					cube.x = (Math.random() > 0.5) ? Math.random() * 1000 : -Math.random() * 1000;
				cube.y = (Math.random() > 0.5) ? Math.random() * 1000 : -Math.random() * 1000;
				cube.z = (Math.random() > 0.5) ? Math.random() * 1000 : -Math.random() * 1000;
 
				_tab.push(cube);
			}
 
			_formOneElement = false;
 
			addEventListener(Event.ENTER_FRAME, _ef);
			stage.addEventListener(Event.RESIZE, _resize);
 
			_resize();
		}
 
		private function _ef(evt:Event):void {
 
			if (!_formOneElement) {
 
				if (_tab[0].x < 1000) {
 
					for each (var cube:Cube in _tab) {
 
						_diffX = 0 - cube.x;
						_diffY = 0 - cube.y;
						_diffZ = 0 - cube.z;
 
						cube.x -= _diffX * 0.05;
						cube.y -= _diffY * 0.05;
						cube.z -= _diffZ * 0.05;
					}
 
				} else {
					_formOneElement = true;
				}
 
			} else {
 
				if (_tab[0].x > 2) {
 
					for each (var cubeOne:Cube in _tab) {
 
						_diffX = 0 - cubeOne.x;
						_diffY = 0 - cubeOne.y;
						_diffZ = 0 - cubeOne.z;
 
						cubeOne.x += _diffX * 0.05;
						cubeOne.y += _diffY * 0.05;
						cubeOne.z += _diffZ * 0.05;
					}
 
				} else {
					_formOneElement = false;
				}
 
			}
 
			_view.camera.x = 3 * (stage.mouseX - stage.stageWidth * 0.5);
			_view.camera.y = 3 * (stage.mouseY - stage.stageHeight * 0.5);
			_view.camera.lookAt(_ORIGINE);
 
			_view.render();
		}
 
		private function _resize(evt:Event = null):void {
			_view.width = stage.stageWidth;
			_view.height = stage.stageHeight;
		}
	}
}

Zip file.