Tom Krcha's FlashRealtime

Hey amigo!
I am Tom Krcha, Gaming Evangelist at Adobe. These are my notes


Videotutorial: Beginning with Alternativa 3D

May 10th, 2011

If you are beginning with 3D in Flash, this videotutorial might come handy. Enjoy!

Alternativa 3D is one the popular 3D engines for Flash.

Alternativa 3D Platform Engine and Flash

Also if you are looking for the text version of this tutorial - check First steps with 3D in Flash article.

How To Rotate A Cube In 3D With Matrix

April 4th, 2011

Another simple trick to avoid locks when rotating objects in 3D.

Goal: rotate a cube in all axes and avoid axes to switch.

See the problem in a video:

1. Consider following scenario (WRONG):

Demo | Full source code

protected function init():void{
	box = new Box(200,200,200,2,2,2);
	box.setMaterialToAllFaces(new FillMaterial(0xFF0000,1,1));;
}
 
protected function onMouseMove(event:MouseEvent):void{
	if(!isDragging)
		return;
 
	var deltaX:int = lastX - event.stageX;
	var deltaY:int = lastY - event.stageY;
 
	lastX = event.stageX;
	lastY = event.stageY;
 
// IMPORTANT PART
	box.rotationZ += deltaX*Math.PI/180;
	box.rotationY += deltaY*Math.PI/180;
 
	camera.render();
}

When you use rotationZ and rotationY together you will find that by rotating the cube you switch axes and at the end you rotate different axes than you wanted at the beginning.

2. Solution: rotate with Matrix

Demo | Full source code

protected function init():void{
	box = new Box(200,200,200,2,2,2);
	box.setMaterialToAllFaces(new FillMaterial(0xFF0000,1,1));;
}
 
protected function onMouseMove(event:MouseEvent):void{
	if(!isDragging)
		return;
 
	var deltaX:int = lastX - event.stageX;
	var deltaY:int = lastY - event.stageY;
 
	lastX = event.stageX;
	lastY = event.stageY;
 
// IMPORTANT PART
	var matrix:Matrix3D = box.matrix;
 
	matrix.appendRotation(deltaX,new Vector3D(0,0,1));
	matrix.appendRotation(-deltaY,new Vector3D(1,0,0));
 
	box.matrix = matrix;
 
	camera.render();
}

See correct version - rotating a cube with:

Also if you have a different solution - don’t hesitate to share it. I am pretty sure, there are more ways to do this.

Just a little update

February 12th, 2011

Dear readers, friends and followers. I just wanted to give you a quick heads up of what I was recently doing and where am I heading to.

South East Asia

In January I travelled through South East Asia and served 8 events in 7 cities and 6 countries (Bali, Jakarta, Singapore, Kuala Lumpur, Manila, Hong Kong and Bangkok). It was really great to spend some time with local Flash communities and I have to say - it’s great bunch of people - well, but that’s always with Flash folks ,)

If you are in the area, you might want to follow these folks on Twitter just in case you want to get involved, speak at events or just come to UG (User Group) meetings and discuss things.

Adobe Asia/Pacific Evangelist:
Paul Burnett

Jakarta:
Ahmad Fathi Hadi (Flash UG manager)


Photo: Adobe Camp Jakarta (organization team)

Singapore:
Stefano Virgilli (Video UG manager)
Shunjie Hu (Flash UG manager)

Kuala Lumpur:
Chua Cheeseng (Flash UG manager)

Manila:
Rey Mendoza (Adobe UG Philippines)
Carlos Nazareno (Phlashers)
John Imbong (Phlashers)
Melch Valimento
Michelle Santos


Photo: Flash Camp Manila, reeeally packed!

See 360 picture of me speaking at Flash Camp Manila (by Rey Mendoza)

Hong Kong:
Vicker Leung (Flash UG manager)

Bangkok:
Kajorn Bhirakit (Adobe UG manager)
Peter Moelgaard

What’s next? Gaming!

You probably read the post by Lee Brimelow: My New Focus On Flash Gaming, well if you did not, we have the formed new team with focus on gaming and I am in. I will be still covering the things I do now, but in upcoming months you can expect from me tutorials around 3D, multiplayer gaming, Facebook integration and in the next half of the year even more interesting topics. I am personally looking forward to it a lot. And if you have a new game in Flash, idea to write about and so on, just send it my way. Also I will be at Flash Gaming Summit 2011, Game Developers Conference 2011 in San Francisco and speaking at FITC Amsterdam 2011. If you are coming and wanna meet, ping me. Next tutorials about 3D in Flash coming soon. Stay tuned!

3D video in Flash Player (like in a cinema)

November 8th, 2010

I think this is one of the news, which got a little bit lost in all the MAX news.

Next to awesome StageVideo, which can run 1080p video ~0% CPU on Windows desktop PC and 8-10% CPU on new MacBook Air, which can display even 4K video, we had a demo preview at the Adobe Booth, where you could watch a real 3D movie running in a preview of possible future Flash Player.

3dvideo
Well, as you can see it’s hard to take a picture of 3D video, I guess, you just need to believe me, but pssst, it’s reeeally stunning! :)
Read the rest of this entry »

Flash gets GPU-accelerated 3D! MAX Racer with P2P multiplayer

October 26th, 2010

The revolution is here and the world is never be the same!

Last couple months were just exciting like never before. We’ve been working with guys from Alternativa Platform and Mythos Labs on 3D racing demo with realtime multiplayer over P2P. The game is set to Los Angeles, where popular developers’ conference Adobe MAX takes place right now.

The game uses the new set of GPU-accelerated 3D APIs - currently codenamed Molehill (see Adobe Labs page). You will be able to get your hands on this API in the first half of 2011.

Multiplayer demo - controlling with three computers

MAX Racer Teaser by Alternativa

Check this video to see how it looks like, when playing with friends all over the world:

Implementing the P2P multiplayer

My role in this game was to implement realtime multiplayer over P2P API, which I have to say works just fluently. We have tried playing the game through internet over 2000 km (from Prague in Czech Republic to Perm in Russia) and I had the feeling like we were sitting next room and playing over LAN.

P2P = Getting the best latency possible
Direct connections in P2P is the best possible method to keep your latency as lowest as possible. With direct connections, you can be sure, that the data packets will be delivered, so the transmission is fully reliable. (Note: this is not the case of Posting, Directed Routing and Multicast, where it’s best effort delivery)

When we talk about the programming logic, you basically setup one outgoing stream and 2,3 or 5 (depends on the number of players) incoming streams.
P2P Direct connections

Then you get something, what we call Full Mesh. This P2P architecture makes sure, that all data between the players is delivered in the smallest time possible.
P2P Full Mesh

We also ran into couple challenges in multiplayer, it’s not enough to transfer only direction changes (like forward, back, left, right), you also have to transfer a real position to sync on position. This will still make it a little bit choppy, because of massive use of physics and rendering speed. So the solution was to implementing interpolations, which is similar to smoothing. If you are at the Adobe MAX, make sure you drop on my session on Tuesday - Building P2P Multiplayer Games. I will also write more article in the future on how to solve this.

Hooking up Game Controllers
Yes, yes, yes, yes! We are working on adding the support of game controllers in Flash Player in the future. I hooked-up MAX Racer with a steering wheel USB controller and I have to say, it was pretty easy to do. I am pretty sure, you will love it and I can’t wait to see more Facebook realtime games with controllers online.

More info MAX Racer

If you want to check more info about the MAX Racer, watch this video by Thibault Imbert (PM for Flash Player).

Game Screenshots

Look at that details. Yeah, and we are rendering this in 60fps running 1920×1080.

Art was done by Mythos Labs. Kudos for the great job guys!

Credits
I just wanted to give a credit to Todd Wahoske and team from Mythos Labs for these great graphics and to Alternativa Platform guys - Vladimir Babushkin, Mikhail Fominykh, Anton Volkov and Alex Karpovich.
Finally I have to say that it was a great pleasure to work with guys on this game!

Flash on!