Author Topic: [problem] detect object in target scope FPS  (Read 3204 times)

Offline zerofox

  • byte
  • *
  • Posts: 15
    • View Profile
[problem] detect object in target scope FPS
« on: March 12, 2013, 09:03:12 am »
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!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: [problem] detect object in target scope FPS
« Reply #1 on: March 12, 2013, 01:09:29 pm »
Does it has to be exact?

Offline zerofox

  • byte
  • *
  • Posts: 15
    • View Profile
Re: [problem] detect object in target scope FPS
« Reply #2 on: March 13, 2013, 12:32:47 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: [problem] detect object in target scope FPS
« Reply #3 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.

Offline zerofox

  • byte
  • *
  • Posts: 15
    • View Profile
Re: [problem] detect object in target scope FPS
« Reply #4 on: March 14, 2013, 07:18:17 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: [problem] detect object in target scope FPS
« Reply #5 on: March 14, 2013, 03:11:29 pm »
Do you have some screen shot?