hey fabrice okay now there are no more errors ... it was an syntax problem. But the collisionmap isnt still working. nothing happens when walking over the "red" area = ( where can be the mistake? the y position of the cube doesnt matter right? what about the offset position of the map? ist it necessary to set it?
best regards On 9 Jul., 11:33, le_unam <[email protected]> wrote: > hey fabrice thank you ... well i tried to make an easy example for > collision map. i created a cube, which is followed by the camera and a > plane with the texture of the collisionmap for easy understanding. but > i still get an error ... maybe you can check my code for syntax > problems. it would be very nice. > > code -------------------------------------------------------------- > > package > { > import away3d.cameras.SpringCam; > import away3d.containers.*; > import away3d.core.base.Object3D; > import away3d.core.clip.FrustumClipping; > import away3d.core.math.Number3D; > import away3d.core.render.Renderer; > import away3d.core.utils.Cast; > import away3d.extrusions.CollisionMap; > import away3d.materials.*; > import away3d.primitives.*; > > import flash.display.DisplayObjectContainer; > import flash.display.BitmapData; > import flash.display.MovieClip; > import flash.events.Event; > import flash.events.KeyboardEvent; > import flash.ui.Keyboard; > > [SWF(width="800", height="600", frameRate="30", quality="LOW", > backgroundColor="0xFFFFFF")] > public class colltest extends MovieClip > { > private var myScene:Scene3D; > private var myCamera:SpringCam; > private var myClipping:FrustumClipping; > private var myCube:Cube; > private var myView:View3D; > private var myCollision:BitmapData; > private var myCollisonmap:CollisionMap; > > private var keyIsDown:Boolean = false; > private var keyHandler:Number = 0; > > private var myBoden:Plane; > > public function colltest() > { > initEngine(); > initObjects(); > initEventListeners(); > } > > public function initEngine() > { > myScene = new Scene3D; > myCamera = new SpringCam; > myClipping = new FrustumClipping; > > myView = new View3D( { scene:myScene, > camera:myCamera, > clipping:myClipping, renderer:Renderer.CORRECT_Z_ORDER, > x:stage.stageWidth / 2, y:stage.stageHeight / 2 } ); > addChild(myView); > > myScene.addChild(myCamera); > > myCube = new Cube( { width:1, > height:1, depth:1 } ); > myScene.addChild(myCube); > > myCamera.zoom = 10; > myCamera.focus = 100; > myCamera.mass = 10; > myCamera.damping = 10; > myCamera.stiffness = 10; > myCamera.target = myCube; > myCamera.lookAt(myCube.position); > myCamera.lookOffset = new Number3D(0, 0, 100); > myCamera.positionOffset = new Number3D(0, 0, 50); > > myCollision = new > BitmapData(Cast.bitmap(cmap)); > myCollisionmap = new > CollisionMap(myCollision, 1, 1); > > myCollisionmap.setColorEvent(0xFF0000, "red", onCollision); > > myView.render(); > } > > public function initObjects() > { > var myMaterial:BitmapMaterial = new > BitmapMaterial(Cast.bitmap(cmap)); > myBoden = new Plane ( { > material:myMaterial, width:1000, height: > 1000, y: -stage.stageWidth / 2 } ); > myScene.addChild(myBoden); > } > > public function onCollision() > { > trace("berührt"); > } > > public function initEventListeners() > { > addEventListener(Event.ENTER_FRAME, > initEnterFrame); > > stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown); > > stage.addEventListener(KeyboardEvent.KEY_UP, keyUp); > } > > public function keyDown(e:KeyboardEvent):void > { > keyIsDown = true; > keyHandler = e.keyCode; > } > > public function keyUp(e:KeyboardEvent):void > { > keyIsDown = false; > } > > public function initEnterFrame(e:Event):void > { > if (keyIsDown) > { > switch(keyHandler) > { > case > 65: myCube.moveLeft(20); break; > case > 68: myCube.moveRight(20); break; > case > 87: myCube.moveForward(20); break; > case > 83: myCube.moveBackward(20); break; > } > } > > myCollisionmap.read(myCube.x, > -myCube.z); > > myCamera.view; > myView.render(); > } > } > > } > > codeend ------------------------------------------------------- > > maybe i forgot something to import? i dont know .... do you see any > errors? > if i comment the lines of collisonmap out ... i can walk over the > plane with the collisionmap texture. > > greetings manuel > > On 9 Jul., 10:22, Fabrice3D <[email protected]> wrote: > > > > i spend so much time for this now, but it doesnt work = ( > > > If you expect some guidance, you have to tell bits more. > > > reading at your previous questions, these were as3/synthax related issues. > > wrong params to constructors or wrong types.. > > > Are you still stuck with the same issues? > > > Fabrice
