Tom Krcha's FlashRealtime

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


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!

MAX Racer Remote Device Controller in AIR for Android

November 25th, 2010

Quick heads-up my friends. When we first demoed MAX Racer, we have previewed initial support for USB Steering Wheel, etc. This support is a sneak peek feature in Flash Player, not available right now.

This really needs you have one of these devices at home. So we were thinking about more lightweight way of controlling the game and device or mobile phone is ideal for this.

I’ve built a little app in Flex Mobile “Hero” for AIR for Android, that controls the game by sending accelerometer, speed info, brake and so on using local P2P connection over WIFI.

Check the video how it works:

Read the rest of this entry »

Building P2P Multiplayer Games at Adobe MAX 2010

November 12th, 2010

The recording of my session from Adobe MAX 2010, where I briefly explain some tips and tricks I’ve learned during MAX Racer development.

Link to session recording (better view, with navigation)

Available on Adobe TV as well:

Slides (PDF) available for download here.

Libraries and other sources will follow.

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 »