[problem] detect object in target scope FPS

Started by zerofox, March 12, 2013, 09:03:12 AM

Previous topic - Next topic

zerofox

Hi guys,

i'm trying to create FPS game like sniper shooter game. I stumble a problem to detect an object is within the scope of sniper. The sniper's scope is actually just an image that overlays on the view atop of the surfaceview in my layout.

anyone can help how to detect if the object is within the scope? i dont need a code, maybe some pointer how to do it or maybe jpct lib have an built in method to do this.Thanks!

EgonOlsen


zerofox

Hi Egon, it's doesnt have to be exact, i just need to know the way how to detect object within the scope. something that i have in mind is to create invisible box positioning in the center of scope so if an object collide with this invisible box i guess the object is within the scope. but maybe there some other way to do it. can you share how you would do this?

EgonOlsen

If you know the coordinates of the scope in 2d, you could do some checks in 2d. You can get the 2d coordinate of the object's center from http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Interact2D.html#projectCenter3D2D(com.threed.jpct.FrameBuffer, com.threed.jpct.Object3D). You could something similar for any other 3d coordinate too. Maybe that's sufficient...at least it's simple and fast.

zerofox

Quote from: EgonOlsen on March 13, 2013, 08:16:03 AM
If you know the coordinates of the scope in 2d, you could do some checks in 2d. You can get the 2d coordinate of the object's center from http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Interact2D.html#projectCenter3D2D(com.threed.jpct.FrameBuffer, com.threed.jpct.Object3D). You could something similar for any other 3d coordinate too. Maybe that's sufficient...at least it's simple and fast.


cool, i see there is package Interact2D for a static function to project 3d to 2d coords screen space, i didnt look it first on the docs! lol. this will do thanks.

but i stumble another problem hope you can give me another hint  ;D
so i'm using bones for the 3dobject, i want to draw square line to the object if the object is within scope.
my first attempt is to blitz dot string with the result min and max vector of calcBoundingBox (method from ninja-bone-example). but the min vector and max dot vector is somehow does not positioning perfectly on the object...am i doing the right thing?

EgonOlsen