Go to Flash on Tap – FOR FREE!


freeticket

No, I’m not kidding!  Tickets have been donated by an anonymous benefactor for those who have recently lost their job.  If you go and sign up know, you can get your ticket to Flash on Tap absolutely free.  You can read more about this awesome offer here.  There are a limited number of tickets, so be sure to go sign up now if you are interested! It is a great way to network and make some connections and skills that will help you out in the future.

Also, if you are still on the fence about attending Flash on Tap – you really don’t want to miss this one!  Between the awesome workshops, comradory, and presentations, PLUS an awesome venue, this is a must-attend event.  John and I are finishing up our workshop on Papervision3D – which will be covering everything from the bare basics to alot of the tips and tricks even seasoned users of the engine don’t know about – layers, shaders, tricks to avoid doing math, and more! There are some other great workshops on red5, animation, and even getting into iphone development.  Check them all out here!

Hope to see you there!



Flash On Tap – May 28th-30th


2008-08-09_1610.png

Flash on Tap is approaching!  If you haven’t signed up yet – head on over to http://www.flashontap.com and register now for great pricing!  If you aren’t familier with Flash on Tap – its a conference being held in Boston that is a combination of a beer and Flash.  If you are interested in taking some workshops – check out the 1st day of the conference – featuring a good choice of all day workshops that should be very informative, and mostly a lot of fun.  I am doing a conference with John Grden that day on the basics of Papervision3D.  We will be covering everything from the basics of the coordinate system to increasing your FPS with layers.  If you have ever wanted to get a good ground-up walk-through – this would be the time to get it!

There are going to be some awesome speakers – great company – beer if you like it -  and me!  I’ll also be presenting on Papervision3D – though I haven’t narrowed down my exact topic – I’m thinking something along the lines of extending Papervision – showing the basics of some of the cool things that have been done with the Papervision engine, including JigLib and Flar – along with some cool things you can do with the built in classes.  If anyone has a better class idea – or if there is somethings specific you would really like me to cover – let me know!

Anyways – sign up now – it is going to be a lot of fun!



TextArea Images in AIR…


bugs

Haven’t seen them?  Apparently its because they don’t exist.  According to this bug report it was a known issue but not corrected before the last version of AIR was released.  I spent a good amount of time wondering what I was doing wrong before a friend did a search in the bugs list for me – and voila!

So, my first question: does anyone know a work-around for this issue?  The comments recommend using the HTML component, but unfortunately I need a lot of the interactivity that the TextArea offers that the HTML component doesn’t have.  If anyone has an idea let me know.

If anyone of you aren’t sure where to find bugs for the Flash player, you can find them at bugs.adobe.com. I use to never check the bugs list, as most of the problems are ran into when I was just getting into flash was user error – but now it seems that I probably need to spend more time at the bugs list before wasting hours of time late at night trying to figure out why my img tags disappeared.

Anyways – if anyone has an idea – shoot me an email or a comment!  I’ll be your friend!



JigLib – Bust a Cap In Papervision3D


glockshot2

I made my first JigLib Demo!  Check it out.

If you don't know what JigLib is yet, you are really missing out.  Its a great project I'm proud to be the on the team of.  It is a 3D physics engine (currently only for Papervision3D, but has been ported to Sandy/Away).  It is a port from the JigLib engine done in C.  For more information on the project, check out the blog.

I don't really want to give a bottoms up rundown on how jiglib works, so I'm just going to point out a few things that will help you pull off effects like you see in this demo - both from the jiglib point of view, but also from a general pv3d and programming angle.

The Environment

This environment is actually very simple.  I have a bitmap for the floor, a lamp model, and a bitmap for the cubes.  I dynamically tint the cube materials to give it a little more depth and variety.  One thing you will notice is that each cube, and each side of each cube, gets its own material.  If you are wondering why, I did this to allow for the bullet holes to be drawn directly onto the material.  I use a movie material so that it is easy to just add a bitmap into with a specific blend mode, and then forget it.

The environment for JigLib is very similar.  Each cube is simply a "skin" for a class that represents a cube in JigLib.  This class is called "JBox".  You can think of a JBox as simply the "form" of a cube - it has position and rotation, which are transfered to the object that it is skinning.  This it the general way that JigLib works.  There are unique JigLib objects which use DisplayObject3D's in Papervision as a skin.  All transforms done to the JigLib physics object is then reflected on the DisplayObject3D.  JigLib has physics objects for Planes, Cubes (Box) and Spheres.  It also includes logic to generate a car with wheels, using a special wheel class and an extension of the JBox class.

So, each cube is controlled by a JBox - and the floor is a JPlane for them to bounce on.  There were some hit detection problems I was having with the plane, so I also added a JCube underneath the plane to give extra "floor" for the objects to run into.  This is a hack fix, but it seems to help.  Something else you can play with to help collision is the timing used by the physics engine.   A lower speed will mean that things will move slower, and detect more collisions more accurately.

The Gun Shot

The gun shot is made up of a couple different parts.  The gun itself actually "shoots" where it is looking - which is always 2000 in front of the barrel.  The only time this is changed is when a hit is detected on a cube.  When the mouse clicks on a cube, the target is changed to the exact coordinates of the hit.

The Hit

The actual hit is determined by the mouse click.  Take a look at the following code:

Actionscript:
  1. var hitPoint : Number3D = new Number3D(event.renderHitData.x, event.renderHitData.y, event.renderHitData.z);
  2.  
  3. var force:Number3D = new Number3D(hitPoint.x-camera.x, hitPoint.y-camera.y, hitPoint.z-camera.z);
  4. force.normalize();
  5. force.multiplyEq(6280);
  6. var rb:RigidBody = skins[event.displayObject3D];
  7. rb.AddWorldForce(new JNumber3D(force.x, force.y, force.z), new JNumber3D(hitPoint.x, hitPoint.y, hitPoint.z));

hitPoint records where the mouse was clicked in world space.  Remember, this is only called when a cube is clicked.  We then get the difference between that point and the camera, to get our "force" vector.  To make it a constant strength, we simply normalize it (make it a length of 1), then multiply it by the force we want.  We get our RigidBody from the dictionary I store the references in.  Then, we use the function "AddWorldForce" - which takes two JNumber3Ds - the force vector, and the world hit point.  This function will add the force to the object from world space - which saves us having to convert things into local coordinates.

The Bullet Trail

The bullet trail is a seperate class called LineOut.  I called it LineOut since it fades itself out every frame.  Once its invisible, it removes itself from the scene.  To get the start and end points of the Line between the gun, I pass in two objects - the target that is positioned at the hit point, and the the muzzle flash that is positioned over the gun barrel.  Before we can use the muzzle flash position, however, we need to update its world coordinates:

startPoint.world.calculateMultiply((startPoint.parent as DisplayObject3D).world, startPoint.transform);

Once the world matrix is updated with the current transform, we can use the world matrix to define the start point of the line.  I use a segmented line because it looks better - but feel free to play with how many vertices are actually used.

The Bullet Hole

Since we used a seperate bitmap for each side of the cubes, we can alter them individually.  This has more memory overhead, but I think it more than makes up for it by having bullet holes.  The bullet hole position is determined, again, by the renderHitData that is passed when a cube is clicked.  The U and V properties of the renderHitData tell us the "x" and "y" coordinates of the click on the material.  Once we have that, we can simply add a bullet hole bitmap to our movie, and position it correctly:

Actionscript:
  1. var mat:MovieMaterial = event.renderHitData.material as MovieMaterial;
  2. var hole : Bitmap = Sprite(mat.movie).addChild(new bulletAsset()) as Bitmap;
  3. hole.blendMode = "overlay";
  4. hole.x = event.renderHitData.u-hole.width*0.5;
  5. hole.y = event.renderHitData.v-hole.height*0.5;
  6.  
  7. mat.drawBitmap();

We take half the width and height to make sure that the bullet hole is properly centered on the hit point.  One other thing to keep in mind is to define the clipping rect for the movie material when you initially make it.  If you don't, your texture will become skewed if bullet holes go off the edge of the material, changing the size of the texture.

Those are the main parts of the demo - hopefully some things are helpful.  I was hoping to show some fun uses of JigLib - and hopefully spawn some cool ideas in the process.

Here is the Source Code

and

A Link to the Demo



Tails, You Win – 3D Trails In Papervision


2009-02-16_2218

I'm not really sure where the inspiration came from, but I decided to take a stab at doing Motion Trails with Pv3D.  Instead, I ended up with something more like a tail - but left the class name MotionTrail... Anyways - there isn't a whole lot to say on the technique I used here - but I will give a general overview just to save you looking at code.  See the Demo.

The tail is defined by Number3D objects which "chase" each other, with the head node being pinned to the target you are chasing.  Each Number3D, which I've extended into a Trail3D class (its internal - just look in the MotionTrail.as file) - springs after the node ahead of it.  You can control this "springyness" by adjusting the minEase property of the MotionTrail.  The minEase refers to the ease amount of the very last node on the tail - which increases each node up to the head, which has an ease of 1.  So, the lower you set minEase, the slinkier the tail will end up looking.  You can control how many nodes are in the tail by adjusting the "iterations" parameter of the MotionTail class.  You need at least 2.

The tail is actually a triangle strip, which progressively gets smaller the closer to the end it gets.  This 1) lets you use any material you want, and 2)easily adjust the look and feel of the tail all you want. Feel free to override it to affect the width with speed, distance, or any other cool variables you want.  It looked good just tapering so I left it that way.   The triangle strips vertices are adjusted to their corresponding TrailNode, so they always face the camera.  This keeps the tail visible from any direction.  Again, you could change this if you wanted it to be a more obvious flat tail.  My initial idea was to use the delta properties of the adjacent nodes to determine the nodes up vector (find the cross product between the dx/dy/dz values of the nodes on either side of the current node) - but again - I liked how this looks so I left it.

The demo itself just makes use of some bezier curves to keep things moving smoothly.  You will notice the nodes are flocking - but really it is just setting the control point and end point of each node within a certain range - which changes positions when the first object arrives.  You can press "F" to toggle it so that each node has its own unique path.

Anyways - here is the code,

and another look at the demo

enjoy.