Archive

Archive for January, 2009

jiglibflash dae, shading and physics

January 25th, 2009 richard mattka 2 comments

jlf_demo2Ok sounds a little mixed bag I know, but really I wanted to get a few ideas up.  In this demo I am loading a DAE, applying shading to my funky material coated ball and also doing some fun math with the 2 objects as they relate to each other. So the bit that took me a while to track down was the shading of material on a sphere. I thought maybe I was to use the CompositeMaterial class, but alas, that did not work and seems better suited to mesh, color cominations then MovieMaterials or BitmapMaterials with shading. Some cruising through the shaders classes though relvealed the answers:


var ballMat:MovieAssetMaterial=new MovieAssetMaterial("paws_mat");

ballMat.tiled=true;

var ballShader : GouraudShader = new GouraudShader(mylight, 0xFFFFFF,0x404040);

 

 

var ballShadedMat:ShadedMaterial = new ShadedMaterial(ballMat, ballShader);

As for the DAE, it was a straight forward load as usual in PV3D and then capturing the load event for the DAE file. Then I was able to add it to the scene. What I did however was mapped it to the positions of my funky shaded sphere to allow it to sit on top. Yeah it looks kinda nuts right now, but it will become the basis for a sweet character shortly. To give it a little extra cool it also leans a little with the speed of the ball, the faster it moves the more it slides around on top. All the goodness about positions and velocities can be found by accessing the CurrentState of a body in the physics model. Give me a buzz if you need more details. Peace.

Categories: jiglibflash, papervision3d Tags:

creating a room in jiglibflash

January 22nd, 2009 richard mattka 11 comments

 

jiglib_room1

 

Alright, so I finally got a few hours to nail down my first demo with jiglibflash. This one shows a room with 4 walls and a floor to contain the ball. I left in some “debris” to knock around. This could be the basics for a racquet ball game or similar. The set up is pretty straight forward. I grabbed the current rev from here which was rev 25. I read through as much of the class code as I could quickly get my head around and dove in. 

 

Space bar to jump, arrows to move ball around.

So the first thing to realize when setting up walls is that the code is well a little funky.

plane3.MoveTo(new JNumber3D(-250, 300,0),JMatrix3D.rotationY(90  * Math.PI/180));

Ok so whats this do? Well, this is using the MoveTo method of the JPlane class to position in the world. (Yeah the syntax could use some help). So there are 2 tricks:

  1. the second parameter of MoveTo uses the SetOrientation method which expects a JMatrix3D value. Some examples are JMatrix3D.IDENTITY and then various rotations (rotationX,rotationY,rotationZ) The thing to remember is these are radians. The easiest way to convert degress to radians is: degrees * (Math.PI /180)So step 1, get the walls oriented correctly. You need 2 rotated about the X-axis and 2 rotated about the Y.
  2. position objects for the first parameter by their centers.  In my example above you see, I have set that wall to be the wall on the left at -250 on the x and at 0 on the Z. The opposite wall is at 250 on the x and 0 on the Z.

That’s about it, nothing too fancy; my version of a quick hello jiglibgflash.

Categories: jiglibflash, papervision3d Tags:

Joining jiglibflash: 3D Physics for AS3

January 19th, 2009 richard mattka 2 comments

jlf_screencapI am excited to announce I am joining the new jiglibflash team, to help develop a solid new 3D Physics Engine for Flash.

 The moment I embarked on the Flash 3D adventure I began hunting for a decent physics engine to couple with the already amazing PaperVision3D . I immediately jumped into Box2D and APE and started hammering away with those. My initial experiments in PaperHockey3D were a lot of fun and the 2D engines worked great. If you need to couple with a 2D physics engine I’d strongly recomend the Box2D model for max flexibility or APE for ease of use (although I think this dead or dying now). 

But wait a sec… I thought this was all about 3D, so where were the 3D physics engines. Well, at first there was exactly none that I could find for Flash. Then WOW came out which was built on the APE engine. You can google and find lots of write ups on WOW. 

So now comes jiglibflash, a port of the popular jiglib physics engine. I’ll be writting loads about this over the coming weeks as I dive into the code and start churning out demos. Look forward to sharing as I go.

Categories: jiglibflash, papervision3d Tags: