Recent

Author Topic: Model elements pickable ?  (Read 5516 times)

scons

  • Full Member
  • ***
  • Posts: 141
Model elements pickable ?
« on: February 10, 2016, 08:09:24 pm »
Hi

I don't have the opengl option installed yet, but I was wondering if it is possible to pick elements from the 3d-model to give it another color, add some extra properties and then export the model attributes to a list to print ?

Does the imported wrl-model keep all the attributes it had before it was imported ?

Thanks
Windows 10-64bit Lazarus 2.0.12 + FPC 3.2.0

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Model elements pickable ?
« Reply #1 on: February 11, 2016, 12:56:39 am »
I think the preferred way to mouse-pick something in 3D-space is to do some manual triangle math. Calculate a ray (straight line) from cursor position towards infinity, and find all the triangles that it intersects. Pick the intersect point closest to camera.

If you want to study some existing source of nxPascal, here (also nxMath3D.pas):
https://github.com/Zaflis/nxpascal/blob/master/src/nxModel.pas#L872
There are some ready demos too that use picking.

I don't know what wrl format is, but OBJ file and few others split model's faces into groups. For most functions only triangles are valid. If they are polygons or quads, convert to tri first.

scons

  • Full Member
  • ***
  • Posts: 141
Re: Model elements pickable ?
« Reply #2 on: February 14, 2016, 09:30:26 am »
Ok thanks.

Since I'm still a beginner, I will wait a few weeks before trying that I think, and keep practicing. But it's good to know it is possible !
Windows 10-64bit Lazarus 2.0.12 + FPC 3.2.0

BlueIcaro

  • Hero Member
  • *****
  • Posts: 791
    • Blog personal
Re: Model elements pickable ?
« Reply #3 on: February 14, 2016, 10:33:10 pm »
I think the preferred way to mouse-pick something in 3D-space is to do some manual triangle math. Calculate a ray (straight line) from cursor position towards infinity, and find all the triangles that it intersects. Pick the intersect point closest to camera.

If you want to study some existing source of nxPascal, here (also nxMath3D.pas):
https://github.com/Zaflis/nxpascal/blob/master/src/nxModel.pas#L872
There are some ready demos too that use picking.

I don't know what wrl format is, but OBJ file and few others split model's faces into groups. For most functions only triangles are valid. If they are polygons or quads, convert to tri first.
Hi, are you still working un nxpascal?

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Model elements pickable ?
« Reply #4 on: February 19, 2016, 12:26:20 am »
Sadly i've not had time to. For game making i mostly moved to Unity. It's got so many features i couldn't even imagine making into engine. It is open source in github though, if someone wants to continue or help.

Cyr

  • Newbie
  • Posts: 6
Re: Model elements pickable ?
« Reply #5 on: May 28, 2016, 05:18:10 pm »
As for me the best decision was been the using of Castle Game Engine. It is very simple using of picking objects. https://github.com/castle-engine/castle-engine/blob/master/examples/3d_rendering_processing/listen_on_x3d_events.lpr - code for selecting object.

 

TinyPortal © 2005-2018