Stars and Clouds in Away 3D 4.0

September 6th, 2012 by Bryson Whiteman

Shortly after I posted my tutorial on creating a Starfield with Away 3D Lite I tried to see how much I could improve performance with Away 3D 4.0, which was Flash 11 and in Beta stage at the time. I got caught up with finishing Donut Get! and working on Unity stuff and forgot about making a post about the demo. Here’s a post about that Away 3D 4.0 demo I made.

This was inspired by playing Kid Icarus on 3DS. During the flying segments, you’re always flying through clouds which is a great effect. I think they do something similar to this, where the clouds are 3d slices of a cloud which you pass through.

I created the clouds with noise. To get “3D slices” I used a 3d Perlin noise generator by Ron Valstar. The regular Flash noise class lets you generate noise on X and Y axis, this allows you to move in the Z axis to create slices.


View the tutorial demo here: http://blog.sokay.net/stuff/starfield2/

I used Sprite3Ds for the cloud slices, hoping that that would allow me to use a greater amount of cloud slices. In this demo I’m using 12 separate Sprite3D instances. It takes a while to generate the noise at the beginning, I don’t think this noise generator anywhere near as fast as Flash’s internal one unfortunately. I spent a long ass time adjusting the Generator and settled on this result which I felt was looking pretty good, rather than just settling for something that was fast to generate.

Sprite3D displays like a billboard/plane in 3D space that is always pointed towards the camera. The problem with Sprite3D is that it’s displayed as a point in space, and if the point isn’t within the camera viewport, it doesn’t display at all. You can see this issue as you rotate the camera to the side. I tried a list minute fix to change it to planes but I couldn’t get the planes to display. It may have something to do with the scale of the scene, the slices are like 15,000 width. Not spending any time trying to figure it out so good luck with it if you wanna try!
(more…)

Simple Starfield with Away 3D Lite

March 27th, 2012 by Bryson Whiteman

[Check out our Away 3D 4.0 update to this post -- Stars and Clouds in Away 3D 4.0]

This is a tutorial based on the simple starfield I created during the loading screen for our recently released game, Rush Hour Plus. I created it in Flash with Away 3D Lite.

This can make a good effect for flying through stars in space, cool particles for action sequences, pixies in an enchanted forest, lotta different things if you put your mind to it!

Here’s the starfield used for the loading screen for Rush Hour Plus .

View the tutorial demo here: http://blog.sokay.net/stuff/starfield/

I wanted to give a little motion to the loading screen with adding too much weight to the filesize (only like 30KB) so I opted for creating this starfield with Away 3D Lite.

Download Away 3D Lite from their repository. Their site has an old version which doesn’t include the Sprite3D class. Get it latest version here:

https://github.com/away3d/away3dlite-core-fp10

And here is the source for the main chunk of it, the StarField class:

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
public class StarField extends BasicTemplate
{

private var starCount:int = 200;
private var stars:Vector.;

private var starArt:BitmapData; // in this tutorial we'll create a bitmapData from scratch

private var rotateSpeed:int = 1;
private var rotateDirection:String = "none";

public function StarField()
{
mouseChildren = false;
mouseEnabled = false;
}

override protected function onInit():void
{
trace("on init");
debug = false; // setting to false hides debug info in template class

//create bitmapData for our material, 4x4 and white! (0xffffff)
starArt = new BitmapData(4,4,false,0xFFFFFF);

// create an Away3D Material with that bitmapData, this is the image used for our particles!

//var starMaterial:BitmapMaterial = new BitmapMaterial(new starArt().bitmapData); // use this if you decide to import an asset
var starMaterial:BitmapMaterial = new BitmapMaterial(starArt);

// create a Vector array to the size of "starCount"
stars = new Vector.(starCount , true);

// start filling the Vector with Sprite3D objects!
for (var i:int = 0; i < starCount; i++) {

var star:Sprite3D = new Sprite3D();
star.material = starMaterial;
star.width = 4;
star.height = 4;

star.alignmentType = AlignmentType.VIEWPOINT; // I forgot what this does... haha! look it up!

star.x = -400 + (Math.random() * 800);
star.y = -500 + (Math.random() * 800);
star.z = -1000 + (Math.random() * (1000 + 800));

scene.addSprite(star);

stars[i] = star;
}

// offset the stars a bit to make them look pretty like!

//scene.rotationY = 0; // reverse direction
//scene.rotationY = 180; // towards screen

scene.rotationY = 160; // nice dynamic, over the shoulder angle
scene.rotationX = 10;

}

// sets the rotation to look in a certain direction

public function lookForward(): void {
scene.rotationY = 180;
scene.rotationX = 0;
}

public function lookBackward(): void {
scene.rotationY = 0;
scene.rotationX = 0;
}

public function lookLeft(): void {
scene.rotationY = -90;
scene.rotationX = 0;
}

public function lookRight(): void {
scene.rotationY = 90;
scene.rotationX = 0;
}

// set a rotation direction with the keys

public function rotateLeft() : void {
rotateDirection = "left";
}

public function rotateRight() : void {
rotateDirection = "right";
}

public function rotateUp() : void {
rotateDirection = "up";
}

public function rotateDown() : void {
rotateDirection = "down";
}
public function rotateNone() : void {
rotateDirection = "none";
}

// this onPreRender function fires every frame, thanks to our nift Away3d template file!

override protected function onPreRender():void
{

for (var i:int = 0; i < stars.length; i++) {

var star:Sprite3D = stars[i];

star.z += 20; // stars move forward on Z-axis every frame

if (star.z > 800) {
star.z = -1000; // when stars move past limit of 800, set them back to -1000 so they loop forever!
}

}

// handle rotations!
if (rotateDirection == "left") {
scene.rotationY += rotateSpeed;
} else if (rotateDirection == "right") {
scene.rotationY -= rotateSpeed;
}
if (rotateDirection == "up") {
scene.rotationX += rotateSpeed;
} else if (rotateDirection == "down") {
scene.rotationX -= rotateSpeed;
}

}

}

The class uses the Away3D BasicTemplate class, which sets up the view and basic scene super quickly. I believe there’s also a FastTemplate class, but for some reason it doesn’t work with Sprite3Ds so watch out for that! And by default the BasicTemplate has a debug function built in, so you have to switch it off. The BasicTemplate is good for setting up something quick! But I’d rather setup something myself ideally.

It creates 200 Sprite3D objects, which use a white 4×4 square of BitmapData for its texture. Those are then scattered randomly in 3D space and on each frame it pushes them forward 20 units. I added in some keyboard controls so you can mess around with it (arrows and WASD).

Download the source here:

The source can be run from an FLA (CS4 format and AS3) or you can execute it as a Flex Actionscript Project (just make sure to include the lib folder as source, and swc folder).

I hope this helps!

Away3D is a huge improvement over Papervision. I still haven’t done any animated character demos with it but we’ll see if I ever get around to it!

——–
For code styling, I’m using the CodeColorer plugin. Very nifty!

New Game: Rush Hour

November 23rd, 2009 by Christopher J. Rock

Just finished my first game since going solo and it went pretty well. It’s a pretty simple top-down shooter. I wanted to test myself with a 1 week schedule, but ended up taking 2 weeks.

Rush Hour

I’ve put it on Flash Game License. This is the first time I try out their service, but I’ve only heard good things. I’ll put a link up after the game’s live.

The soundtrack was done by my brother, Jonathan Rock. After the game’s out, I’ll put the music here for download.

(more…)

My open source Papervision game demo

September 22nd, 2008 by Bryson Whiteman


Friendly Integration: click here to play

I’m releasing the source code for a Papervision3D game I was putting together. This project was meant to be an interactive visual for a party my friend threw last weekend, Friendly Integration. This game was meant to be projected onto a wall and controlled with a DDR pad for each player. There were also plans to have additional panels that could be stepped on that changed the “theme” of the game.

(more…)

TraceManager (AS2) Update

August 20th, 2008 by Christopher J. Rock

Long, long ago, I posted about my old TraceManager class for supreme debugging, but it was flawed! Hans from ObjectPainters was kind enough to comment with a link to a similar project he had put together. His did not have as much sophistication in its data tracing, but it did have a “FunctionWrapper.” His FuncitonWrapper could modify existing functions in run-time (so you don’t have to) allowing his tracing capabilities to be applied to any function without requiring the programmer to modify actual class files.

Hans was right about the usefulness of a function wrapper, but I didn’t feel like getting into it . . . until now. A couple days ago I brought up my old TraceManager and decided it was time to revamp it.

//Wrap class
traceManager.wrapClass(testClass , “testClass”)
//Run class function
var diff:Number = testClass.Subtract(6 , 3 , “trace:Infinity”)

The testClass.Subtract() function above was not capable of producing sophisticated trace data until the traceManager.wrapClass modified it and every other function in the testClass class.

I’ve taken Hans’ proposal one step further, by creating a ClassWrapper (using the undocumented ASSetPropFlags) that will automatically apply tracing capabilities to all functions within a given class instance. Finally, I feel the TraceManager to be a tool that all actionscripters could use in any project:

TraceManager.zip

I’ve added those 2 new functions, modified formatting a bit, and made a few other slight adjustments. If you used the previous version you probably will barely notice the differences outside of the 2 new wrapper functions. For a review on the basic ideas check out the original post. Now I give you an example of a trace out and will explain use of the new wrappers. (more…)

NorthStar: Intro to Pathfinding around Irregular Polygons

July 23rd, 2008 by Christopher J. Rock

NorthStar is my new pathfinder for use with arbitrary, irregular polygons. CHECK IT OUT. Drag around the green and red circles. The green one is used as the start point and the red is the end

A couple months ago I decided I would begin working toward my long time dream of producing a real-time strategy game. I actually finished NorthStar and had this written a few weeks later, but I’m only posting now because I’ve been hard at work with the rest of the game! Now working on unit logic along with a new Sokay project (more on that later) and editing a new film (later still), so I been a little busy. Expect Demos.

I planned on basing the RTS engine on some of my previous work with physics (perhaps that sounds strange, but it makes sense). Step one was coming up with a pathfinder.

(more…)

The Eco Zoo – Amazing 3D Flash Website

June 6th, 2008 by Bryson Whiteman

Earlier I found this amazing 3d interactive site in a thread on Flashkit. Completely breathtaking. Needless to say, I couldn’t wait to make a post about this one!

The Eco Zoo website
The Eco Zoo

This is the best executed 3d Flash site I’ve seen so far. Just check it out. Apparently this isn’t created with any open source 3d engine out there, it’s a custom engine by this guy.

3D on the web is sort of a gimmick right now, as Flash itself was seen as a gimmick in the past (i.e. your site wasn’t cool unless it had a Flash intro). All it really takes is some progressive individuals to define what’s possible with the advances of the medium — beyond spinning cubes and globes. Right now I see opportunities to tell stories in new and exciting ways. I’m hoping to take design elements from motion graphics and create interactive visual masterpieces. Couldn’t you imagine CartoonNetwork.com as a fully interactive playground? Kids would love that stuff. How come we aren’t seeing that yet??

Papervision Animated Character Demo

May 25th, 2008 by Bryson Whiteman

I found this Papervision demo while searching for a method of character animation.


Clint Hannaford’s Papervision Character demo

This demo impressed the hell out of me. It was proof that 3d character animation could be awesome in Flash. I’ve been dabbling in Papervision stuff lately. It’s an extra layer of complication on top of AS3 but the payoff is worth it. I created a model in Maya, textured it, and loaded it into Flash and made it interactive. Unbelievable…

For animation, I figured I could either setup some complicated character rig by separating the character at the joints and linking the pieces together. Setting all of that up and creating a system to animate the keyframes would be much to time consuming. renderhjs, from the Flashkit forum, was creating his own custom system of animating the character in the 3d software and exporting the animation frame by frame and playing through the keyframes. I don’t exactly have time to figure that out either so I found Clint’s post searching Google in distress.

Clint explained to me that his character demo uses .md2 format, from Quake 2. It’s similar to, if not the same as, renderhjs’ method of character animation. He linked to this Papervision md2 parser and recommended that I try loading in some Quake 2 models and seeing how it works.