[Papervision3D] drag and drop-function for PV3D Sphere
Miriam Halbersztajn
famhalb at gmx.de
Mon May 25 18:40:16 PDT 2009
Hi everybody!
I finally have succeded that the sphere moves when I drag the mouse.
There is just one thing that is strange. The movement of the sphere is only a tiny little movement, only some milimeters in each direction.
What is the reason and how can I change this?
I created a new simple FlashDevelop project just to test how the dragging works. I added a folder containing this project and the code to this email as a compressed file (New Project.zip) so you are able to run it and see the result.
Sorry that I have sended so many emails today!
Help me please, thanks in advance!
regards
Miriam
-------- Original-Nachricht --------
> Datum: Mon, 25 May 2009 20:29:30 +0200
> Von: "Miriam Halbersztajn" <famhalb at gmx.de>
> An: papervision3d at osflash.org
> Betreff: Re: [Papervision3D] drag and drop-function for PV3D Sphere
> Hi,
>
> Now I tried to integrate the code of John´s great demo in my application,
> but when I run the application and click on the sphere a stack trace opens
> and I get a null-Object error for the variable "currentSphere" at
> location: onPressHandler-function in my InteraktiveSphere-CustomClass.
>
> Why, what do I different to the demo?
>
> My source code is uploaded in this email. Please, can you help me?
> Thanks a lot for any advice!
>
> regards
> Miriam
> -------- Original-Nachricht --------
> > Datum: Sun, 24 May 2009 17:57:35 -0600
> > Von: John Lindquist <johnlindquist at gmail.com>
> > An: papervision3d at osflash.org
> > Betreff: Re: [Papervision3D] drag and drop-function for PV3D Sphere
>
> > Read this for onRenderTick:
> http://pv3d.org/2008/12/06/what-is-basicview/
> > This should help a bit with Plane3D:
> > http://pv3d.org/2008/11/27/plane3d-intersect-poin/
> >
> > I'm still working on an article to talk about all the various ways to
> > interact with pv3d, just haven't found the time to put it all together.
> >
> > On Sun, May 24, 2009 at 5:15 PM, flashback1 <famhalb at gmx.de> wrote:
> >
> > >
> > > John, thank you for this great link!
> > > Yes, this demo does exactly what I want to achieve. But isn´t there a
> > > version with some comments?
> > > I am relatively new to PV3D and for this reason it is a little bit
> hard
> > for
> > > me to understand what is done in this source code without any
> comments.
> > I
> > > would very thank you a lot for a short documentation!!!!
> > > Specially, onRenderTick-function looks very confusing to me....
> > >
> > > Thanks in advance!
> > > regards
> > >
> > > Miriam
> > >
> > >
> > >
> > > Paul Tondeur wrote:
> > > >
> > > > That's a very useful demo on your blog John!
> > > >
> > > > @Miriam, you should check that post out. It seems like that is doing
> > > > exactly where you are looking for.
> > > > The problem in your code is that you are assuming that the x and y
> > > > position of the the sphere matches the x and y position as 2D points
> > > > on your screen. This is in fact far from true. How to translate
> these
> > > > 2D positions to 3D positions is showed in Johns post.
> > > >
> > > > On May 24, 2009, at 11:53 PM, John Lindquist wrote:
> > > >
> > > >> Does this help?
> > > >>
> > > >> http://pv3d.org/2008/12/09/dragging-spheres/
> > > >>
> > > >>
> > > >>
> > > >> On Sun, May 24, 2009 at 2:54 PM, flashback1 <famhalb at gmx.de> wrote:
> > > >>
> > > >> Hi everybody,
> > > >>
> > > >> After solving the previous problem with the eventListener, now I am
> > > >> facing
> > > >> an other one.
> > > >> I tried to implement a function, which enables the user of my
> > > >> application to
> > > >> drag and drop the sphere and position it where ever he wants to in
> > the
> > > >> scene.
> > > >> I wrote a CustomClass InteraktiveSphere and it is extended from
> > > >> Sphere.
> > > >> Every instance of InteraktiveSphere has a Boolean variable
> > > >> "mousePressed" .
> > > >> When a sphere is pressed I call the
> > > >> InteractiveScene3DEvent.OBJECT_PRESS-handler of the
> > > >> InteraktiveSphere-CustomClass and there I set mousePressed=true;.
> > > >>
> > > >> In the Main-Class of my application I create an instance of my
> > > >> InteraktiveSphere-CustomClass called "sphere" : var sphere =new
> > > >> InteraktiveSphere(material);
> > > >>
> > > >> In the onEnterFrame-function of the Main-Class I check whether
> > > >> mousePressed=true. If so then I calculate the distance from the old
> > > >> mouse
> > > >> position to the current mouse position onEnterFrame and save it in
> > > >> variables
> > > >> called "xDistance" and "yDistance".
> > > >> In my OBJECT_RELEASE-handler of my InteraktiveSphere-CustomClass I
> > set
> > > >> mousePressed = false; and update the x and y values of the sphere
> > > >> like this:
> > > >> this.x += xDistance;
> > > >> this.y += yDistance;
> > > >> }
> > > >>
> > > >> Is this the right way to do this? When the application is run I don
> > > >> ´t get
> > > >> any error message but it doesn´t work the way I would like. Drag
> and
> > > >> Drop
> > > >> doesn´t work, but when I click at the sphere it jumps to a new
> > > >> position!
> > > >> Why? Please, help me and thank you in advance! It is really
> > > >> important for
> > > >> me!
> > > >>
> > > >> regards
> > > >> Miriam
> > > >>
> > > >> Here is the code of my InteraktiveSphere-CustomClass:
> > > >>
> > > >> public class InteraktiveSphere extends Sphere
> > > >> {
> > > >>
> > > >> public var mousePressed:Boolean;
> > > >> public var yDistance:Number;
> > > >> public var xDistance:Number;
> > > >>
> > > >>
> > > >> public function
> > > >> InteraktiveSphere(material:MaterialObject3D)
> > > >> {
> > > >> super(material);
> > > >>
> > > >>
> > > >> addEventListener(InteractiveScene3DEvent.OBJECT_PRESS,onPress);
> > > >>
> > > >> addEventListener(InteractiveScene3DEvent.OBJECT_RELEASE,onRelease);
> > > >>
> > > >>
> > > >> }
> > > >>
> > > >> private function
> > > >> onRelease(e:InteractiveScene3DEvent):void{
> > > >>
> > > >> this.mousePressed =false;
> > > >> this.x += xDistance;
> > > >> this.y += yDistance;
> > > >>
> > > >> }
> > > >>
> > > >> private function
> > > >> onPress(e:InteractiveScene3DEvent):void{
> > > >>
> > > >> this.mousePressed=true; }
> > > >> }
> > > >> And here is the code of the onEnterFrame-function in my Main-Class:
> > > >>
> > > >> private function onEnterFrame(evt:Event):void
> > > >> {
> > > >> if(sphere.mousePressed){
> > > >>
> > > >> sphere.yDistance = stage.mouseY - sphere.y;
> > > >> sphere.xDistance = stage.mouseX - sphere.x;
> > > >>
> > > >> }
> > > >>
> > > >>
> > > >> --
> > > >> View this message in context:
> > > >>
> > >
> >
> http://www.nabble.com/possible-to-add-onEnterFrame-Listener-to-a-Papervision3D-Sphere--tp23654047p23697976.html
> > > >> Sent from the Papervision3D mailing list archive at Nabble.com.
> > > >>
> > > >>
> > > >> _______________________________________________
> > > >> Papervision3D mailing list
> > > >> Papervision3D at osflash.org
> > > >> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> > > >>
> > > >> _______________________________________________
> > > >> Papervision3D mailing list
> > > >> Papervision3D at osflash.org
> > > >> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> > > >
> > > >
> > > > _______________________________________________
> > > > Papervision3D mailing list
> > > > Papervision3D at osflash.org
> > > > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> > > >
> > > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://www.nabble.com/possible-to-add-onEnterFrame-Listener-to-a-Papervision3D-Sphere--tp23654047p23699128.html
> > > Sent from the Papervision3D mailing list archive at Nabble.com.
> > >
> > >
> > > _______________________________________________
> > > Papervision3D mailing list
> > > Papervision3D at osflash.org
> > > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> > >
>
> --
> Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate +
> Telefonanschluss für nur 17,95 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02
--
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02
-------------- next part --------------
A non-text attachment was scrubbed...
Name: New Project.zip
Type: application/x-zip-compressed
Size: 114264 bytes
Desc: not available
URL: <http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20090526/09d977d4/attachment-0001.bin>
More information about the Papervision3D
mailing list