Hi,
Before all, thanks for the great job in away3d.
I'm currently working on project where the user can walk through a
room and can click on object for create some box on their face.
I've used the hotel room example for the first part and have success
(after some little change).
Then i have put some onMouseDown event on my object and i've success
in creating some Cube on their face.
But here come the complicated thing :
- the cubes created are not well paste on the face of object model, i
mean the coordinate are good ( mouse3DEvent.sceneX,...;) but the
rotation is not good
here the code i used when click on object :
private function onDownBox(pEvt:MouseEvent3D ):void
{
var fac:Face = (pEvt.drawpri as
DrawTriangle).faceVO.face;
trace( pEvt.sceneX );
trace( fac.normal );
var cube:Cube = new Cube();
cube.width = 100;
cube.height = 100;
cube.depth = 10;
cube.x = pEvt.sceneX ;
cube.y = pEvt.sceneY ;
cube.z = pEvt.sceneZ ;
cube.rotationX *= fac.normal.x;
cube.pushback = true;
cube.ownCanvas = true;
cube.renderer = Renderer.CORRECT_Z_ORDER as
IPrimitiveConsumer;
var mat:ColorMaterial = new ColorMaterial(0xFF0000);
cube.cubeMaterials = new CubeMaterialsData( {
front:mat, back:mat,
left:mat, right:mat, top:mat, bottom:mat } );
scene.addChild( cube );
cube.addOnMouseDown( onClickCube );
}
In others words, on certain face the cube is oriented correctly but on
other face it make a cube with a depth of 100.
For this first trouble i think i have to use the normal of the face
clicked for correctly adding the cube "on the face" of the object
clicked, but i'm too bad in mathematic to have success in this step.
If someone can show me the way !
Then a second trouble is that all the cube created are not correctly z
ordering and are always visible, even throught the object clicked it
self.
Thanks for your help.