2

I'm new to papervision 3d and I created two display objects in basic view.
Here's a part of the code :

...
_stick = new Cube(materials, 50, 5, 500);
_ball = new Sphere(new ColorMaterial(0xfc0000), 80);

In the onRenderTick method, I tried to check whether two objects are hitted

override protected function onRenderTick(event:Event=null):void {
    super.onRenderTick(event);
    _stick.rotationY = stage.mouseX / stage.width * 360;
    _stick.rotationX = stage.mouseY / stage.height * 360;

    if (stick.hitTestObject(this.ball)) {
        trace ("hit");
    }
}

However, stick.hitTestObject always returns false even if the stick really hits the ball as I see in the flash.

Any help is appreciated ~ Thanks!

YeJiabin
  • 1,038
  • 1
  • 9
  • 17
  • 1
    just a note: if you're new to PaperVision3D you should switch to Away3D or even start studying / using the Molehill (Flash Player 11) beta APIs for 3D. PaperVision3D is, for all intents and purposes, dead. – Chunky Chunk Jul 04 '11 at 06:44

1 Answers1

1

A long while back I worked around a similar issue by using an API I found somewhere in P3D that transforms from 3D to 2D (screen) coords. So I added a regular button on top of the 3D visuals, and each frame I moved the button to center on the screen location of the 3D hit area. But this only worked because I didn't need the hit area to transform - I never got "real" 3D hit areas to work in Papervision3D. And since that project is apparently orphaned, I wouldn't suggest spending a great deal of time on it if you can help it.

fenomas
  • 11,131
  • 2
  • 33
  • 57
  • I have done quite a big project with Away3D recently and might i suggest you use away3D in combination with jiglib. Jiglib is a physics-library which is very capable of detecting hittests. I would look into it before you start however, because jiglib doesn't use the default primitives that away3D offers. – Michiel Standaert Jul 04 '11 at 08:39