ghostObject not aligned correctly with container

Software: Away3D 4.x

hoksha the bald, Newbie
Posted: 06 May 2014 05:29 AM   Total Posts: 5

Hello,

I am still a beginner with Away3D and I am still playing with sample programs to grasp the basic concepts before creating my game.
I am using citrus engine compiled with awayphysics-core-fp11-master and away3d-core-fp11-master.
I am modifying the car sample to load a 3D character model which was used in AwayBuilder tutorial instead.
The character appears floating above the ground with very noticeable distance.
I turned debug view on and it appears that the cylinder ghost object is not aligned correctly with the character, how can I fix this?
I attached a screen shot and here is the code.

private function _onCarResourceComplete(event:LoaderEvent):void {

 
var container:ObjectContainer3D ObjectContainer3D(event.target);
 (
view as Away3DView).viewRoot.addChild(container);
 
container.visible true;
 var 
mesh:Mesh;

 var 
carMaterial:TextureMaterial = new TextureMaterial(new BitmapTexture(new CarSkin().bitmapData));
 
carMaterial.lightPicker _lightPicker;
 for (var 
i:uint 0container.numChildren; ++i{
  mesh 
Mesh(container.getChildAt(i));
  
mesh.geometry.scale(10);
 
}

 Bounds
.getObjectContainerBounds(container);
 
 var 
shape AWPCapsuleShape = new AWPCapsuleShape(Bounds.widthBounds.height);
 var 
ghostObject AWPGhostObject = new AWPGhostObject(shapecontainer);
 
ghostObject.collisionFlags |= AWPCollisionFlags.CF_CHARACTER_OBJECT;
 
ghostObject.addEventListener(AWPEvent.COLLISION_ADDEDcharacterCollisionAdded);
 
 
carBody = new AWPKinematicCharacterController(ghostObject200);
 
 
_awayPhysics.world.addCharacter(carBody);
 
carBody.warp(new Vector3D(010, -500));

Any help will be greatly appreciated, thanks for advance.

 

Image Attachments
collision_cylinder.jpg
   

hoksha the bald, Newbie
Posted: 06 May 2014 02:13 PM   Total Posts: 5   [ # 1 ]

I think I got the reason of the problem.
I think that the pivot of the model is at it’s feet, but the pivot of the cylinder ghost object is at it is middle and that is the reason of the offset.

I tried changing container.pivotPoint, but with no luck.

Any help is greatly appreciated.

   

hoksha the bald, Newbie
Posted: 06 May 2014 05:14 PM   Total Posts: 5   [ # 2 ]

I solved it by adjusting the mesh position inside the container. It is pretty awkward approach, any better ideas?

private function _onCarResourceComplete(event:LoaderEvent):void {

 
var container:ObjectContainer3D ObjectContainer3D(event.target);
 (
view as Away3DView).viewRoot.addChild(container);
 
container.visible true;
 
container.scale(10);
 
 var 
mesh:Mesh;
 
Bounds.getObjectContainerBounds(container);
 
 for (var 
i:uint 0container.numChildren; ++i{
  mesh 
Mesh(container.getChildAt(i));   mesh.positi Vector3D(0Bounds.height/200));
 
}
 
 trace
("bounds: " Bounds.width "," Bounds.height "," Bounds.depth);
 
trace("pivotPoint: " container.pivotPoint."," container.pivotPoint."," container.pivotPoint.z);
 
 
//container.translateLocal(new Vector3D(0, 1, 0), -Bounds.height / 4);
 
 
var materia:ColorMaterial = new ColorMaterial(0xfa6c16);
 
materia.lightPicker _lightPicker;
 
mesh = new Mesh(new CubeGeometry(Bounds.depthBounds.height/2Bounds.width), materia);
 (
view as Away3DView).viewRoot.addChild(mesh);
 
 var 
shape AWPCapsuleShape = new AWPCapsuleShape(Bounds.widthBounds.height/2);
 var 
ghostObject AWPGhostObject = new AWPGhostObject(shapecontainer);  ghostObject.collisi AWPCollisionFlags.CF_CHARACTER_OBJECT;
 
ghostObject.addEventListener(AWPEvent.COLLISION_ADDEDcharacterCollisionAdded);
 
 
carBody = new AWPKinematicCharacterController(ghostObject200);
 
 
_awayPhysics.world.addCharacter(carBody);
 
carBody.warp(new Vector3D(1500Bounds.height+1000, -500));  mesh.positi Vector3D(1500Bounds.height+1000, -500);
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X