Author Topic: how to obtain selected triangle  (Read 4341 times)

Offline tony-kun

  • byte
  • *
  • Posts: 7
    • View Profile
how to obtain selected triangle
« on: February 22, 2009, 12:00:57 am »
Hi! I will get fun starting a 3d game project. jcpt is the first engine am trying and looks very nice all this. Not worrying about the 3d stuff and filling textures so easly is so great.. But one thing I miss is obtaining the original triangle of a 2d position in the screen. Something like:

int idTriangle = Interact2D.getTriangleID(r);

off course triangles when adding them they should have an unique global id in addittion to just a local to the object.

May be am missing something. Otherwise, how do you know which face of an object the user points to?

A drastic solution could be definind an object for every face. But I don't think that's normal.

Many thanks for any help.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: how to obtain selected triangle
« Reply #1 on: February 22, 2009, 08:22:08 am »
Interact2D.pickPolygon(...) returns the polygon's ID. With that, you can use the PolygonManager to access texture-, normal- and transformed 3D coordinates of that polygon. Maybe that helps.

Offline tony-kun

  • byte
  • *
  • Posts: 7
    • View Profile
Re: how to obtain selected triangle
« Reply #2 on: February 22, 2009, 03:34:29 pm »
Hi, as I understand polygon is what get displayed at the end, a portion of the triangle, and may be even all of his vertices are new.
May be if I had a function that tell me if a polygon is aproximately inside the coords I give... that could suffice, altough would be a bit inexact. Is there something like that?

I suposse you don't give the id of the original triangles because some optimization.

Thanks.

Offline tony-kun

  • byte
  • *
  • Posts: 7
    • View Profile
Re: how to obtain selected triangle
« Reply #3 on: February 22, 2009, 03:52:33 pm »
Aaah may be I can do really exactly what I said, great. Anyway thanks for any aditional help.

Offline tony-kun

  • byte
  • *
  • Posts: 7
    • View Profile
Re: how to obtain selected triangle
« Reply #4 on: February 23, 2009, 04:33:43 am »
am sorry the flood already. Actually I can use what you said too.

the polygons used by jpct are always convex? or not?

thanks.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: how to obtain selected triangle
« Reply #5 on: February 23, 2009, 07:18:34 am »
the polygons used by jpct are always convex? or not?
They are always triangles... ;D