FYI : 
http://wsvdmeer.blogspot.com/2009/11/away3d-2d-collision-detection-update.html


On 24 nov, 14:48, wsvdmeer <[email protected]> wrote:
> Hey Colouredfunk,
>
> Thanks for the code snippet i implemented it in the usermap class :).
>
> On 24 nov, 10:52, colouredfunk <[email protected]> wrote:
>
>
>
> > Hey wsvdmeer,
>
> > The project is far from finished unfortunately... I'll try and put
> > something online soon. It's going to be a interactive museum, that's
> > the plan anyway :)
>
> > FYI, I did change another of your classes the other,  added support
> > for the usermap to calculate positions other than the middle, so 3d
> > objects can be anywhere in the scene..
>
> > public function offSet(x:Number, y:Number):void {
> >      _offsetX = x*-1
> >      _offsetY = y*-1
>
> > }
>
> > var xpos:Number = ((_originalPoint.x+_offsetX)  / (_originalWidth /
> > _bitmapData.width)) + _bitmapData.width / 2;
> > var ypos:Number = -((_originalPoint.y+_offsetY) / (_originalHeight /
> > _bitmapData.height)) + _bitmapData.height / 2;
>
> > Cheers
>
> > On Nov 17, 1:55 pm, wsvdmeer <[email protected]> wrote:
>
> > > Hey Colouredfunk,
>
> > > Good to here i could help you out:)
> > > I  think the problem with the offset of the map has to do with the
> > > model your using, my target is a standard cone and everything works
> > > wel.
> > > My class does nothing with the dimensions of the target so thecollisionis 
> > > registered from the absolute center of the target that
> > > could also be the cause of your problem.
> > > If you have ideas about new features for the classes i'm all ears :).
> > > And if your project is done and online somewhere i would love to see
> > > it.
>
> > > Greetz WS
>
> > > On 17 nov, 14:43, colouredfunk <[email protected]> wrote:
>
> > > > Sorry for the delay in my reply, I managed to get a cold from
> > > > somewhere (probably working to hard)... All better now though :)
>
> > > > The problem was with cameraPosition = camera.position, it was being
> > > > set to thecollisionposition, rather than the point just before the
> > > >collisiontook place.
>
> > > > Although I had it all in the same order as you, it just wasn't working
> > > > for some strange reason. But when I put the camera movements into a
> > > > separate method..Bingo it worked. I'm still not completely convinced
> > > > this is what was causing the problem, it now works and I'm not going
> > > > to spill more blood getting to the bottom of it. :)
>
> > > > I can't thank you enough for helping me out!
>
> > > > Your classes seem solid, and I didn't need to change them to get it to
> > > > work, it was more of the integration process... I did however update
> > > > your FirstPersonCamera class, as I wanted the camera look to respond
> > > > to a mouse click event, with each click relative to the current camera
> > > > pan and tilt. I can send that over if you are interesting?
>
> > > > Integration aside, there is one problem I had thinking about it; and
> > > > that's getting thecollisionmap to reflect the correct position of
> > > > the camera relative to the 3D space. I solved the problem by changing
> > > > the position of where the model was in 3Ds Max before exporting it to
> > > > a 3DS file. The two positions between the 2D and 3D world started to
> > > > line up when the model is in the middle, but I still had to offset it
> > > > slightly to get it to match perfectly.
>
> > > > Have you had any problems like this? I've got quite a few rooms to do,
> > > > and that trial and error process of lining-up, to a long time. So I
> > > > wonder what the definitive solution is for that?
>
> > > > Thanks again!
>
> > > > On Nov 13, 2:09 pm, wsvdmeer <[email protected]> wrote:
>
> > > > > This should work:
>
> > > > > private functionr render():void {
>
> > > > >     //Look
> > > > >     if (move){
> > > > >         camera.look()
> > > > >     }
>
> > > > >     //Move
> > > > >     if (_controls.moveForward) {
> > > > >         camera.moveForward (+_controls.zspeed);
> > > > >     }
> > > > >     if (_controls.moveBackward) {
> > > > >         camera.moveBackward(- _controls.zspeed);
> > > > >     }
> > > > >     if (_controls.moveLeft) {
> > > > >          camera.moveLeft(- _controls.xspeed);
> > > > >     }
> > > > >     if (_controls.moveRight) {
> > > > >          camera.moveRight (+_controls.xspeed);
> > > > >     }
>
> > > > >     //Collision
> > > > >     userMap.originalPosition = camera.position
> > > > >     if (_controls.moving) {
> > > > >         player2d.x = userMap.position.x
> > > > >         player2d.y = userMap.position.y
> > > > >     }
>
> > > > >      //Place camera
> > > > >      camera.y = -20
> > > > >      cameraPosition = camera.position
>
> > > > >       //Update controls
> > > > >       _controls.update()
>
> > > > >       //Render
> > > > >       view.render();
>
> > > > > }
>
> > > > > On 13 nov, 14:17, colouredfunk <[email protected]> wrote:
>
> > > > > > haha no worries, it's ealisy done at the moment..
>
> > > > > > I've tried what you said, but still keeps on walking.... :s
>
> > > > > > On Nov 13, 1:02 pm, wsvdmeer <[email protected]> wrote:
>
> > > > > > > Hehe no posted the answer of one of your older questions:P sorry 
> > > > > > > for
> > > > > > > confusing you
>
> > > > > > > On 13 nov, 14:00, colouredfunk <[email protected]> 
> > > > > > > wrote:
>
> > > > > > > > Sorry do you mean take out :
>
> > > > > > > >   if (_controls.moveForward) {
> > > > > > > >                                         camera.moveForward
> > > > > > > > (+_controls.zspeed);
> > > > > > > >                                         }
> > > > > > > >                                         if 
> > > > > > > > (_controls.moveBackward) {
> > > > > > > >                                         camera.moveBackward(-
> > > > > > > > _controls.zspeed);
> > > > > > > >                                         }
> > > > > > > >                                         if (_controls.moveLeft) 
> > > > > > > > {
> > > > > > > >                                         camera.moveLeft(-
> > > > > > > > _controls.xspeed);
> > > > > > > >                                         }
> > > > > > > >                                         if 
> > > > > > > > (_controls.moveRight) {
> > > > > > > >                                         camera.moveRight
> > > > > > > > (+_controls.xspeed);
> > > > > > > >                                         }
>
> > > > > > > > when I do this, the camera does move on keypress...
>
> > > > > > > > Sorry to be a paid
>
> > > > > > > > On Nov 13, 12:54 pm, wsvdmeer <[email protected]> wrote:
>
> > > > > > > > > Hey Colouredfunk,
>
> > > > > > > > > Just keep your camera at one point:
>
> > > > > > > > > function render(event:Event):void{
> > > > > > > > > camera.look()
> > > > > > > > > camera.y = 300
> > > > > > > > > controls.update()
> > > > > > > > > view.render()
>
> > > > > > > > > }
>
> > > > > > > > > On 13 nov, 13:04, colouredfunk <[email protected]> 
> > > > > > > > > wrote:
>
> > > > > > > > > > Hey, I've just realised if I look down with the mouse then 
> > > > > > > > > > navigate
> > > > > > > > > > forward, the camera will actually move downwards through 
> > > > > > > > > > the floor...
> > > > > > > > > > Don't know why it's doing that, as your using the 
> > > > > > > > > > MoveForward methods,
> > > > > > > > > > so it should calculate it accordingly ...?...
>
> > > > > > > > > > On Nov 13, 11:26 am, colouredfunk 
> > > > > > > > > > <[email protected]> wrote:
>
> > > > > > > > > > > genius!!! Dude, you are seriously a life saver :)
>
> > > > > > > > > > > I'll let you know how I get on :)
>
> > > > > > > > > > > On Nov 13, 11:09 am, wsvdmeer <[email protected]> 
> > > > > > > > > > > wrote:
>
> > > > > > > > > > > > Hey colouredfunk,
>
> > > > > > > > > > > > I just put up a new tutorial for my firspersoncamera and
> > > > > > > > > > > > firstpersoncontrols 
> > > > > > > > > > > > classes:http://wsvdmeer.blogspot.com/2009/11/away3d-firstperson-movement-and-...
>
> > > > > > > > > > > > If you use these classes in combination with 
> > > > > > > > > > > > mycollisionclass you
> > > > > > > > > > > > can set the controls.zspeed and controls.xpseed to 0 
> > > > > > > > > > > > oncollision.
> > > > > > > > > > > > I constantly keep track of the object i'm moving and 
> > > > > > > > > > > > save it's
> > > > > > > > > > > > position in a Number3D for example:
>
> > > > > > > > > > > > var cameraPosition:Number3D = new Number3D()
> > > > > > > > > > > > cameraPosition = camera.position
>
> > > > > > > > > > > > If acollisionoccures i reset the camera to it's old 
> > > > > > > > > > > > position
> > > > > > > > > > > > (cameraPosition):
>
> > > > > > > > > > > > so the code would look like this:
>
> > > > > > > > > > > > function onCollision(event:CollisionEvent):void{
> > > > > > > > > > > > controls.xspeed = 0
> > > > > > > > > > > > controls.yspeed = 0
> > > > > > > > > > > > camera.position = cameraPosition
>
> > > > > > > > > > > > }
>
> > > > > > > > > > > > Hope this helps :D
>
> > > > > > > > > > > > On 13 nov, 11:43, colouredfunk 
> > > > > > > > > > > > <[email protected]> wrote:
>
> > > > > > > > > > > > > Yeah JUST finished getting it working :)  I think the 
> > > > > > > > > > > > > problem was not
> > > > > > > > > > > > > having the object in 3ds Max in the middle of the 
> > > > > > > > > > > > > scene...... I still
> > > > > > > > > > > > > have to have it offset slightly, but I got it working 
> > > > > > > > > > > > > through a bit of
> > > > > > > > > > > > > trial and error!
>
> > > > > > > > > > > > > Thanks so much for creating a class for it, really 
> > > > > > > > > > > > > helping me out
> > > > > > > > > > > > > here :)
>
> > > > > > > > > > > > > I've now got to sort out the camera reaction to the 
> > > > > > > > > > > > > collisions :s
>
> > > > > > > > > > > > > Any tips ? :o
>
> > > > > > > > > > > > > Thanks again
>
> > > > > > > > > > > > > On Nov 13, 10:13 am, wsvdmeer <[email protected]> 
> > > > > > > > > > > > > wrote:
>
> > > > > > > > > > > > > > Hey colouredfunk,
>
> > > > > > > > > > > > > > Did it work?
>
> > > > > > > > > > > > > > On 12 nov, 15:46, wsvdmeer <[email protected]> 
> > > > > > > > > > > > > > wrote:
>
> > > > > > > > > > > > > > > Hey colouredfunk,
>
> > > > > > > > > > > > > > > I adjusted the UserMap
>
> ...
>
> meer lezen »

Reply via email to