I’m stuck on Away3d 4 (fp11), and AwayPhysics (fp11).
When running my project the following error appers:
TypeError: Error #1006: value is geen functie.
at cmodule.AwayPhysics::FSM__ZN16btCollisionWorld18addCollisionObjectEP17btCollisionObjectss/work()
at Function/<anonymous>()
at Function/<anonymous>()
at awayphysics.collision.dispatch::AWPCollisionWorld/addCollisionObject()[/Users/timbaas/actionscript3/applications/Blastler/Away3D FP11/awayphysics-core-fp11/src/awayphysics/collision/dispatch/AWPCollisionWorld.as:23]
at Blastler/initGame()[/Users/timbaas/actionscript3/applications/Blastler/src/Blastler.as:154]
at Blastler/onPreloadComplete()[/Users/timbaas/actionscript3/applications/Blastler/src/Blastler.as:79]
As you can see there is an error in addCollisionObject().
The rest of the good is good, before this I used RigidBodies and everything worked smoothly…
When I run an example in the exact same project, the awayphysics.dynamics.constraintsolver classes show a lot of errors. All to do with MemUser functions that do not exist. (_mrf, _mwf, _mw8, etc.)
Strange thing is:
At the beginning of this project I run these examples too and then they worked..
Here a piece of my code:
package
{
import away3d.cameras.Camera3D;
import away3d.containers.ObjectContainer3D;
import away3d.containers.View3D;
import away3d.entities.Mesh;
import away3d.lights.DirectionalLight;
import away3d.loaders.Loader3D;
import away3d.materials.BitmapMaterial;
import away3d.materials.ColorMaterial;
import away3d.materials.MaterialBase;
import away3d.materials.methods.SoftShadowMapMethod;
import away3d.primitives.Cube;
import away3d.primitives.Plane;
import awayphysics.collision.dispatch.AWPCollisionObject;
import awayphysics.collision.shapes.AWPBoxShape;
import awayphysics.collision.shapes.AWPCollisionShape;
import awayphysics.collision.shapes.AWPHeightfieldTerrainShape;
import awayphysics.collision.shapes.AWPStaticPlaneShape;
import awayphysics.dynamics.AWPDynamicsWorld;
import awayphysics.events.AWPEvent;
import com.baco.Preloader;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageQuality;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Vector3D;
public class Blastler extends Sprite
{
private var preloader:Preloader;
private var view:View3D;
private var cam:ObjectContainer3D;
private var camera:Camera3D;
private var light:DirectionalLight;
private var materials:Object;
private var bricks:Vector.<AWPCollisionObject>;
private var physics:AWPDynamicsWorld;
public function Blastler()
{
initView3D( );
initLights( );
initMaterials( );
initScene( );
initGame( );
}
private function initView3D( ):void
{
camera = new Camera3D();
camera.z = -1000;
cam = new ObjectContainer3D();
cam.rotationY = 45;
cam.rotationX = 25;
cam.addChild( camera );
view = new View3D( null, camera );
view.backgroundColor = 0xF6F6F6;
view.antiAlias = 4;
this.addChild( view );
}
private function initLights( ):void
{
light = new DirectionalLight();
light.castsShadows = true;
light.direction = new Vector3D(0,-1,0);
light.y = 400;
}
private function initMaterials( ):void
{
var stone:BitmapMaterial, grass:BitmapMaterial;
grass = new BitmapMaterial( preloader.getObject("grassTexture").bitmapData );
grass.shadowMethod = new SoftShadowMapMethod( light );
materials = { stone:stone, grass:grass };
}
private function initScene( ):void
{
view.scene.addChild( preloader.getModel('terrain') );
view.scene.addChild( light );
}
private function initGame( ):void
{
var ground:Plane;
physics = AWPDynamicsWorld.getInstance();
physics.initWithDbvtBroadphase();
physics.collisionCallbackOn = true;
physics.gravity = new Vector3D(0, -20, 0);
var cm:ColorMaterial = new ColorMaterial(0xf0f0f0);
cm.lights = [ light ];
var ssmm:SoftShadowMapMethod = new SoftShadowMapMethod( light );
cm.shadowMethod = ssmm;
ground = new Plane( cm, 50000, 50000);
var mesh:Mesh;
var shape:AWPCollisionShape;
var body:AWPCollisionObject;
bricks = new Vector.<AWPCollisionObject>();
for (var i:int; i < 3; i++ )
{
mesh = new Cube(materials.grass, 50, 20, 100);
view.scene.addChild(mesh);
shape = new AWPBoxShape(50, 20, 100)
body = new AWPCollisionObject(shape, mesh, 1);
body.y = 100 + i * 120;
physics.addCollisionObject(body);
bricks[bricks.length] = body;
}
this.addEventListener( Event.ENTER_FRAME, gameLoop );
}
private function onBrickCollisionAdded( e:AWPEvent ):void
{
trace ('colliding');
for (var i:int = 0; i < bricks.length; i++ ) {
var mesh:Mesh = Mesh(bricks[i].skin);
if (e.collisionObject == bricks[i]) {
trace( "Collission" );
}
}
}
private function gameLoop( e:Event ):void
{
// cam.rotationY = stage.mouseX - stage.stageWidth/2;
// cam.rotationX = stage.mouseY - stage.stageHeight/2;
// physics.engine.integrate(0.1);
//physics.step(1/60);
cam.rotationY += .5;
view.render();
}
}
}
Hope someone can help me out here!