Collisions aren’t working (Value is not a function), Adding example creates error in constraintsolver classes.. 

Software: Away3D 4.x

Tim Baas, Newbie
Posted: 18 December 2011 04:53 PM   Total Posts: 7

I’m stuck on Away3d 4 (fp11), and AwayPhysics (fp11).

When running my project the following error appers:

TypeErrorError #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.= -1000;
   
   
cam = new ObjectContainer3D();
   
cam.rotationY 45;
   
cam.rotationX 25;
   
cam.addChildcamera );
   
   
view = new View3Dnullcamera );
   
view.backgroundColor 0xF6F6F6;
   
view.antiAlias 4;
   
   
this.addChildview );
  
}
  
  
private function initLights( ):void
  {
   light 
= new DirectionalLight();
   
light.castsShadows true;
   
light.direction = new Vector3D(0,-1,0);
   
light.400;
  
}
  
  
private function initMaterials( ):void
  {
   
var stone:BitmapMaterialgrass:BitmapMaterial;

   
grass = new BitmapMaterialpreloader.getObject("grassTexture").bitmapData );
   
grass.shadowMethod = new SoftShadowMapMethodlight );
   
   
materials { stone:stonegrass:grass };
  
}
  
  
private function initScene( ):void
  {
   view
.scene.addChildpreloader.getModel('terrain') );
   
view.scene.addChildlight );
  
}
  
  
private function initGame( ):void
  {
   
var ground:Plane;
   
   
physics AWPDynamicsWorld.getInstance();
   
physics.initWithDbvtBroadphase();
   
physics.collisionCallbackOn true;
   
physics.gravity = new Vector3D(0, -200);
   
   var 
cm:ColorMaterial = new ColorMaterial(0xf0f0f0);
   
cm.lights [ light ];
   
   var 
ssmm:SoftShadowMapMethod = new SoftShadowMapMethodlight );
   
cm.shadowMethod ssmm;
   
   
ground = new Planecm5000050000);

   var 
mesh:Mesh;
   var 
shape:AWPCollisionShape;
   var 
body:AWPCollisionObject;
   
   
bricks = new Vector.<AWPCollisionObject>();
   
   for (var 
i:int3i++ ) 
   
{
    mesh 
= new Cube(materials.grass5020100);
    
view.scene.addChild(mesh);
    
    
shape = new AWPBoxShape(5020100)
    
body = new AWPCollisionObject(shapemesh1);
    
body.100 120;
    
physics.addCollisionObject(body);
    
bricks[bricks.length] body;
   
}
   
   this
.addEventListenerEvent.ENTER_FRAMEgameLoop );
  
}
  
  
private function onBrickCollisionAddede:AWPEvent ):void
  {
   trace 
('colliding');
   for (var 
i:int 0bricks.lengthi++ ) {
    
var mesh:Mesh Mesh(bricks[i].skin);
    if (
e.collisionObject == bricks[i]{
     trace
"Collission" );
    
}
   }
  }
  
  
private function gameLoope: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!

   

Tim Baas, Newbie
Posted: 18 December 2011 07:41 PM   Total Posts: 7   [ # 1 ]

I’ve got the Examples to work again, but the value-is-not-a-function-error still appears.. It’s really strange, I’m doing exactly the same as the example..

Thanks in advance!

   

Tim Baas, Newbie
Posted: 19 December 2011 11:11 AM   Total Posts: 7   [ # 2 ]

Copied all the code from the example strait into the project, and guess what.. It workes like a charm, so from here I can move on.. Still curious what went wrong though..

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X