Home > jiglibflash, papervision3d > jiglibflash dae, shading and physics

jiglibflash dae, shading and physics

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:
  1. January 26th, 2009 at 19:24 | #1

    how do u make a DAE collide with a cube or any other objects? say for example this site has some cool low Polly models and want to use them and want o make them collide with other objects.

    http://www.tomtallian.com/

  2. January 26th, 2009 at 19:53 | #2

    @bionical, Well the easiest way is to map the DAE object’s coordinates with those of an object in the physics engine. There are 2 ways to do this in JigLibFlash.
    1. You can assign the DAE as the skin of the jiglibflash object in the same way you do a sphere or a cube. Using PaperVision3D you need to first create a DisplayObject3D and then attach the DAE object to it. Then you can use the DO3D object as the skin of the jiglibgflash object as you would any other.
    2. You can use mapping. So in your render loop you would map the coordinates of your DAE object to the coordinates of your jiglibflash object. Let the engine handle the calculations and then use the 3d renderer to visually display the results. The trick is to make sure your DAE object and the underlying jiglibflash object have similar dimensions so the collisions are realistic. You may need to play around with orientation of the DAE object in relation to the JLF object as well. You might need to apply an offset for example if your DAE is not aligned to the same origin / reference points as your JLF object. ie. you might need to add +20 to your x, to slide it over a little if its not quite lining up.

  1. No trackbacks yet.