when the puck collide with the stick, i add central impulse to the puck
sometimes the puck will go through static rigid walls i set in the scene
and this often occurs when the puck moves fast
i am a newbie to AwayPhysics and i think the reason for this is that
the position simulated has already out of walls
but i don’t know how to adjust that
could anyone help me, thanks!!
]]>Today, i updated a Away3D project developped a few month ago.
I was surprised with the bad render of the 3ds objects in the scene. The both side no longer work and rendering is not quality.
Look at the attached file to understand the issue.
At first my Flash project run with Away3D 4.1.5. I have updated to 4.1.6 but the problem persists.
The problem come with the new version of Flash Player in Chrome v14.0 !
//Setup Scene
_scene = new Scene3D();
_camera = new Camera3D();
_view = new View3D();
_view.antiAlias = 4;
_view.scene = _scene;
_view.camera = _camera;
_view.mousePicker = PickingType.RAYCAST_BEST_HIT;
_view.backgroundColor = 0x131313;
//Mesh setting example
mesh = Mesh(e.target.getChildAt(0));
mesh.pickingCollider = PickingColliderType.PB_BEST_HIT;
mesh.mouseEnabled = true;
mesh.shaderPickingDetails = true;
mesh.geometry.convertToSeparateBuffers();
var w:Weld = new Weld();
w.apply(mesh);
var explode:Explode = new Explode();
explode.apply(mesh.geometry);
var material:TextureMaterial = new TextureMaterial(Cast.bitmapTexture(pAmfPiece.textureDiffuseCustomBitmap));
//
material.specularMap = Cast.bitmapTexture(new SpecularMap() as Bitmap);
material.normalMap = Cast.bitmapTexture(new NormalMap() as Bitmap);
material.lightPicker = _lightPicker;
material.bothSides = true;
material.specular = 0.5;
material.gloss = 0.6;
material.ambient = 0.7;
mesh.material = material;
Thanks
]]>what should i do?
]]>
Error #1506: The specified range is invalid.
Anybody know it?
]]>Today, i updated a Away3D project developped a few month ago.
I was surprised with the bad render of the 3ds objects in the scene. The both side no longer work and rendering is not quality.
Look at the attached file to understand the issue.
At first my Flash project run with Away3D 4.1.5. I have updated to 4.1.6 but the problem persists.
//Setup Scene
_scene = new Scene3D();
_camera = new Camera3D();
_view = new View3D();
_view.antiAlias = 4;
_view.scene = _scene;
_view.camera = _camera;
_view.mousePicker = PickingType.RAYCAST_BEST_HIT;
_view.backgroundColor = 0x131313;
//Mesh setting example
mesh = Mesh(e.target.getChildAt(0));
mesh.pickingCollider = PickingColliderType.PB_BEST_HIT;
mesh.mouseEnabled = true;
mesh.shaderPickingDetails = true;
mesh.geometry.convertToSeparateBuffers();
var w:Weld = new Weld();
w.apply(mesh);
var explode:Explode = new Explode();
explode.apply(mesh.geometry);
var material:TextureMaterial = new TextureMaterial(Cast.bitmapTexture(pAmfPiece.textureDiffuseCustomBitmap));
//
material.specularMap = Cast.bitmapTexture(new SpecularMap() as Bitmap);
material.normalMap = Cast.bitmapTexture(new NormalMap() as Bitmap);
material.lightPicker = _lightPicker;
material.bothSides = true;
material.specular = 0.5;
material.gloss = 0.6;
material.ambient = 0.7;
mesh.material = material;
Thanks
]]>I am creating a ball game, where a ball follows a way. The way is a AWPBvhTriangleMeshShape. But unfortunately, the ball jumps up and changes its direction when it is rolling over edges - even if the surface is flat.
I have created a project to reproduce this behaviour. There is a PlaneGeometry and a SphereGeometry. When moving the ball, it starts to jump at the edges of the plane surface.
I have uploaded a movie of the project, where you can see the ball jumps up: http://de.tinypic.com/r/2ibymh5/5
Is this a bug or is there a solution to get rid of this problem? I really need the AWPBvhTriangleMeshShape, as the way is not a straight one.
Here is the code, woul’d be very happy is someone coul’d help me out.
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.geom.Vector3D;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.ui.Keyboard;
import away3d.containers.View3D;
import away3d.debug.AwayStats;
import away3d.entities.Mesh;
import away3d.lights.PointLight;
import away3d.materials.ColorMaterial;
import away3d.materials.lightpickers.StaticLightPicker;
import away3d.primitives.PlaneGeometry;
import away3d.primitives.SphereGeometry;
import awayphysics.collision.shapes.AWPBvhTriangleMeshShape;
import awayphysics.collision.shapes.AWPSphereShape;
import awayphysics.debug.AWPDebugDraw;
import awayphysics.dynamics.AWPDynamicsWorld;
import awayphysics.dynamics.AWPRigidBody;
[SWF(backgroundColor="#000000", frameRate="60", width="600", height="400")]
public class BvhTriangleMesh extends Sprite
{
private var _view : View3D;
private var _light : PointLight;
private var _lightPicker:StaticLightPicker;
private var _physicsWorld : AWPDynamicsWorld;
private var _debugDraw:AWPDebugDraw;
private var _timeStep : Number = 1.0 / 60;
private var _bodySphere:AWPRigidBody;
private var _text:TextField;
private var _textFormat:TextFormat;
public function BvhTriangleMesh()
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init():void{
removeEventListener(Event.ADDED_TO_STAGE, init);
_view = new View3D();
this.addChild(_view);
this.addChild(new AwayStats(_view));
_light = new PointLight();
_light.y = 5000;
_view.scene.addChild(_light);
_lightPicker = new StaticLightPicker([_light]);
_view.camera.lens.far = 20000;
_view.camera.y = 2000;
_view.camera.z = -2000;
_view.camera.rotationX = 40;
// init the physics world
_physicsWorld = AWPDynamicsWorld.getInstance();
_physicsWorld.initWithDbvtBroadphase();
_debugDraw = new AWPDebugDraw(_view, _physicsWorld);
_debugDraw.debugMode = AWPDebugDraw.DBG_NoDebug;
_debugDraw.debugMode = AWPDebugDraw.DBG_DrawCollisionShapes;
addObjects();
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onDownHandler);
}
private function addObjects():void{
var material : ColorMaterial = new ColorMaterial(0xfa6c16);
material.lightPicker = _lightPicker;
var mesh : Mesh;
//Create plane:
var iSeg:uint = 3;
mesh = new Mesh(new PlaneGeometry(20000, 20000, iSeg, iSeg), material);
_view.scene.addChild(mesh);
var triangleShape : AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(mesh.geometry);
var planeBody:AWPRigidBody = new AWPRigidBody(triangleShape, mesh, 0);
planeBody.position = new Vector3D(0, 0, 0);
planeBody.restitution = 0.5;
_physicsWorld.addRigidBody(planeBody);
//Creat shpere:
var sphereShape:AWPSphereShape = new AWPSphereShape(100);
mesh = new Mesh(new SphereGeometry(100), material);
_view.scene.addChild(mesh);
_bodySphere = new AWPRigidBody(sphereShape, mesh, 1);
_bodySphere.friction = .9;
_bodySphere.restitution = 0.9;
_bodySphere.position = new Vector3D(-1000, 600, 0);
_physicsWorld.addRigidBody(_bodySphere);
_textFormat = new TextFormat('Arial', 20, 0xffffff, true);
_text = new TextField();
_text.x = this.width/2;
_text.y = 20;
_text.width = 400;
this.addChild(_text);
}
private function onEnterFrame(e : Event):void{
_physicsWorld.step(_timeStep);
_debugDraw.debugDrawWorld();
_view.render();
_view.camera.position = _bodySphere.position.add(new Vector3D(0, 2000, -2500));
_view.camera.lookAt(_bodySphere.position);
_text.text = "ball.y: " + _bodySphere.position.y.toFixed(3);
_text.setTextFormat(_textFormat);
}
private function onDownHandler(event : KeyboardEvent):void{
var fForce:Number = 1;
if(event.keyCode==Keyboard.UP) _bodySphere.applyCentralImpulse(new Vector3D(0,0,fForce));
if(event.keyCode==Keyboard.DOWN) _bodySphere.applyCentralImpulse(new Vector3D(0,0,-fForce));
if(event.keyCode==Keyboard.LEFT) _bodySphere.applyCentralImpulse(new Vector3D(-fForce,0,0));
if(event.keyCode==Keyboard.RIGHT) _bodySphere.applyCentralImpulse(new Vector3D(fForce,0,0));
}
}
}
]]>
Someone can see and eventually correct this…
Here the source:
http://www.estiva2.altervista.org/Away3D/CarSampleMod1.7z
( the source contains two version of library incuded in the 7z file )
This is important for me… With version 4.1 i can load the right material or/and texture but the physics can’t work…
Thanks in advance
]]>Please help me with this problem:
var mat:ColorMaterial = new ColorMaterial(0x4B871F);
mat.lightPicker = stateLight;
var mesh:Mesh = Mesh(ObjectContainer3D(e.target).getChildAt(0));
//mesh.scale(100);
mesh.material = mat;
//view.scene.addChild(mesh);
var shape:AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(mesh.geometry);
var body:AWPRigidBody = new AWPRigidBody(shape, mesh, 0);
body.scale = new Vector3D(40, 40, 40);
world.addRigidBody(body);
I’m using away4.1.1 and awayphysics-core-fp11-master
Thanks!
]]>
var rigidbodyPiece : Object = new Object();
var l_wall_pos : Vector3D = new Vector3D(-m_asset_wall_offset_x, 0, 0);
var r_wall_pos : Vector3D = new Vector3D(m_asset_wall_offset_x, 0, 0);
m_l_wall_shape = new AWPBoxShape(m_asset_wall_width, m_asset_size.y, m_asset_size.z);
m_r_wall_shape = new AWPBoxShape(m_asset_wall_width, m_asset_size.y, m_asset_size.z);
shape = new AWPCompoundShape();
shape.addChildShape(m_l_wall_shape, l_wall_pos, new Vector3D());
shape.addChildShape(m_r_wall_shape, r_wall_pos, new Vector3D());
rigidbody = new AWPRigidBody(shape, mesh, 10);
rigidbody.gravity = new Vector3D();
super.initRigidbody(rigidbody);
rigidbody.y = WALL_Y_START;
rigidbody.z += 375;
//after tracing through for some reason the low y is
//doubled so at -300 it's actualy -600 with out doubling
//are low it was throwing off the high. The 5 is pull
//the low/high in a little as they dont end up at exact values
m_wall_low_y = WALL_Y_START * 2;
m_wall_high_y = m_wall_low_y + m_asset_slide_distance - 5;
m_wall_low_y += 5;
m_physicsWorld.addRigidBodyWithGroup(rigidbody, SceneObject.GroundFloorGroup, SceneObject.FloorCollisionMask);
m_constraint = new AWPGeneric6DofConstraint(rigidbody, rigidbody.position, new Vector3D());
var low : Vector3D = new Vector3D(rigidbody.x, rigidbody.y, rigidbody.z);
var high : Vector3D = new Vector3D(rigidbody.x, rigidbody.y + m_asset_slide_distance, rigidbody.z);
m_constraint.setLinearLimit(low, high);
m_constraint.setAngularLimit(new Vector3D(0, 0, 0), new Vector3D(0, 0, 0));
m_constraint.getTranslationalLimitMotor().enableMotorY = true;
m_constraint.getTranslationalLimitMotor().targetVelocity = new Vector3D(0, 30, 0);
m_constraint.getTranslationalLimitMotor().maxMotorForce = new Vector3D(0, 10, 0);
//rigidbody.position = new Vector3D(rigidbody.position.x, rigidbody.position.y + m_asset_slide_distance, rigidbody.position.z);
m_physicsWorld.addConstraint(m_constraint, true);