Script.it .Nam Myoho Renghe Kyo.

[Lab] Diving into Stage3D

It has been a while since my last post, but i am back!
Since Adobe gave the Flash community a big F*** You with their ******** Javascript engine, i gave up on flash.
I am not doing Javascript or even getting close to that script because it is just a BIG step back from mature OO languages.
Not that AS3 is super mature, but at least it has a descent OO structure and such.
Thus i was lost for a couple of months. Left in the dark and guessing which language or techniques i should choose to do besides AS3.

OpenGL.
Not wanting to do JS or some bulls*** like that, i decided to put my focus on OpenGL. Just focus on real 3D and the stuff that belongs to that environment.
I started with Processing, where you can code some simplified version of OpenGL. Processing is a good tool to start learning the basics of OpenGL. So when i understood
the basics i went to JOGL ( Java OpenGL ) which goes a bit more indepth on the subject than Processing. The next logical step would be to try OpenGL in the C++ / C# / Objective C languages. Setting up a window and the GL renderers and such.
All of the above techniques give me great joy to work with, BUT…..
Yes theres a but…
Almost all of them dont really work as well on the web as flash does.

Going into Stage3D
So…. i made the descission to move back to AS3 and try Stage3D with all my new knowledge.
For learning purposes i started on my own 3D engine ( codename OMEGA3D ). This way i would have to cover most subjects and get a good knowledge and understanding of what is actually happening under the hood.

Here are my tries so far.
Mouse Over a demo to activate it, Mouse Out to deactivate.



Primitives Demo:
This pimitives demo shows the basic primitives.
This is a good starting point, you will learn about registers, geometry, textures and displaying those all on screen.

This movie requires Flash Player 9



OBJ File Demo:
In every 3D engine it is important to have some way to import models. This saves alot of hardcoding meshes and headaches.
The simplest format you can get is the .OBJ format. Obj files are simple text files with lists of vertex positions, normals, uv coordinates and face indexes.
From this you can easily make a mesh that can be used in Stage3D. This demo uses a OBJMesh with a directional light.

* This demo has a ‘KeyCamera’. Use your arrow keys to move it

This movie requires Flash Player 9



Terrain Demo:
It is always nice to have a Terrain Generator inside your engine. Making fly-overs or even game levels can be a lot of work. If you have some way of making landscapes rapidly you can save some time and spend it on the more important stuff, like game logic and such. My terrain generator uses a heightmap of which this terrain is being generated.
h-map










* This demo has a ‘KeyCamera’. Use your arrow keys to move it

This movie requires Flash Player 9



BillBoard Demo:
Sometimes you want to have complex shapes in your game / application like a tree or a bush.
Its very tedious to make a mesh of a small bush or even a tree with alot of branches. You can imagine that the poly count on such models
is very high, thus it costs alot of power to render it to the screen. A technique that is often used to overcome this kinds of problems is called Billboarding.
Billboarding is a technique that adjusts an object’s orientation so that it “faces” some target, usually the camera.
Thus if a camera changes position, the billboarding element will rotate itself accordingly.
So if we have a small plane with a texture of a bush or a tree on it… we can keep facing this plane towards the camera. The camera will never look at its sides.
Thus the ‘viewer’ will have the idea the bush is somewhat “3d”.

* This demo has a ‘KeyCamera’. Use your arrow keys to move it!

This movie requires Flash Player 9



BlendModes Demo:
In every piece of 3D software you ll notice that blending is a big part of the way your materials are show on screen.
Do they need to be transparent or do they need to enhance each other etc etc.
In this demo i tried to combine different blendmodes on different materials.
The stars and the suns in this demo have a BlendFactor.SOURCE_COLOR, BlendFactor.ONE ( depth testing is set to false )
The Head ( OBJ file Mesh ) has a default BlendFactor ( depth testing is set to true )
To combine to different meshes in a scene with different blendModes and depthtesting was very instructive to do and gave me a little ” AHHHHHA!” moment.

* This demo has a ‘KeyCamera’. Use your arrow keys to move it!

This movie requires Flash Player 9

So far my engine supports:
- Materials ( shaders + textures )
+ BitmapMaterial
+ ColorMaterial
+ LightMaterial

- Meshes ( geometries + transforms )
+ Sphere, Cube, Plane, Cillinder, Torus
+ OBJ

- Lights
+ Directional lighting

- Cameras
+ Static camera
+ Key camera ( supports keyboard inputs and movement )

This is an ongoing project so i guess more will come!

And remember …
Keep the fun and play in your work!

Ciao
Rackdoll.

Creative Commons License
The [Lab] Diving into Stage3D by Script.it, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Netherlands License.

Comments are closed.


Categories
Archives
LinkedIn
R. Kollau