Recent

Author Topic: How to display truncated objects using GLScene  (Read 4201 times)

FangQ

  • Full Member
  • ***
  • Posts: 134
How to display truncated objects using GLScene
« on: January 17, 2018, 05:38:01 pm »
I am writing a rendering program using GLScene and Lazarus. The objects being displayed are basic shapes - boxes, spheres, cylinders etc.

Right now, I can display all objects. I am trying to figure out a way to truncate the 3D objects using a bounding box.

a screenshot of one of the scenes is attached. you can see the sphere extends above the bounding box (a TGLCube object, inside a DummyCube). I am wondering if there is a setting to allow truncation (or Boolean) of the objects.

Although I set all objects transparent, I was hoping to see intersection lines between objects, currently, GLScene does not seem to give me those intersections. Is this supported in this library? (I am using GLScene 1.4)

thanks

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: How to display truncated objects using GLScene
« Reply #1 on: January 19, 2018, 07:04:33 am »
You should understand, that rendering and physics - are two separate things. OpenGL is just renderer, like GDI for example - it can draw primitives and nothing more, so it doesn't support CSG out of box - it's up to you to implement it.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

FangQ

  • Full Member
  • ***
  • Posts: 134
Re: How to display truncated objects using GLScene
« Reply #2 on: January 19, 2018, 06:27:26 pm »
You should understand, that rendering and physics - are two separate things. OpenGL is just renderer, like GDI for example - it can draw primitives and nothing more, so it doesn't support CSG out of box - it's up to you to implement it.

thanks for the reply. I guess I should reword my question a little bit, what I meant to ask was if there are functions/tools in glScene to allow ray-tracing based scene rendering.

after googling for a while, I found the closest thing to my question was the "raycast" example under the samples/collision folder.  see the second from bottom of this page:

http://glscene.pbworks.com/w/page/6437572/doc_demoscollisions

I tried that example, it worked, it gives what I wanted, but right now, looks like this can only be rendered on a separate canvas (TPaintBox) and not in real time.

regarding truncation of a bounding box, I haven't found any thing yet in glscene.


Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: How to display truncated objects using GLScene
« Reply #3 on: January 20, 2018, 12:19:38 pm »
thanks for the reply. I guess I should reword my question a little bit, what I meant to ask was if there are functions/tools in glScene to allow ray-tracing based scene rendering.

after googling for a while, I found the closest thing to my question was the "raycast" example under the samples/collision folder.  see the second from bottom of this page:

http://glscene.pbworks.com/w/page/6437572/doc_demoscollisions

I tried that example, it worked, it gives what I wanted, but right now, looks like this can only be rendered on a separate canvas (TPaintBox) and not in real time.

regarding truncation of a bounding box, I haven't found any thing yet in glscene.
Raytrace is too slow. From what you've said, I've understood, that you need CSG, i.e. Constructive Solid Geometry. This isn't hard to be implemented manually. Old games, such as Quake, were doing it in real time.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

dicepd

  • Full Member
  • ***
  • Posts: 163
Re: How to display truncated objects using GLScene
« Reply #4 on: January 21, 2018, 03:25:17 pm »
There is a demo of a cube being subtracted from a tessellated star in real time in the examples, though I cannot for the life of me remember which one. This should be the example to go for.
« Last Edit: January 21, 2018, 03:30:08 pm by dicepd »
Lazarus 1.8rc5 Win64 / Linux gtk2 64 / FreeBSD qt4

FangQ

  • Full Member
  • ***
  • Posts: 134
Re: How to display truncated objects using GLScene
« Reply #5 on: January 25, 2018, 09:19:30 pm »
There is a demo of a cube being subtracted from a tessellated star in real time in the examples, though I cannot for the life of me remember which one. This should be the example to go for.

@MR.Madguy and @dicepd, thank you both for the helpful replies. following the suggestions, I was able to locate the referred example under Samples/Lazarus/meshes/CSG.  the function is

Code: Pascal  [Select][+][-]
  1. CSG_Operation(Mesh1, Mesh2 ,CSG_Union,MeshOutput,'1','2');
  2.  

to perform a boolean operation on two mesh objects (of triangular patches).

this is pretty close, however, right now, I am using only basic geometries (TGLSphere, TGLGrid, ...), I am not sure yet how to convert the basic geometry objects to TMeshObject. Even those when I set the rendering style to pmLine, I can see a basic geometry have a triangular surface, however, I don't think they are derived from one or another, so I can not cast them to meshes.

I will keep on looking in this direction. If anyone know how to perform CSG on basic geometry in glScene, I will be happy to learn. thanks

dicepd

  • Full Member
  • ***
  • Posts: 163
Re: How to display truncated objects using GLScene
« Reply #6 on: January 25, 2018, 09:22:58 pm »
Most objects have a GetTriangles method. Mainly used for transfer to GL but can be used as mesh.
Lazarus 1.8rc5 Win64 / Linux gtk2 64 / FreeBSD qt4

dicepd

  • Full Member
  • ***
  • Posts: 163
Re: How to display truncated objects using GLScene
« Reply #7 on: January 25, 2018, 09:28:03 pm »
Or if you want to have a go at building your own mesh some pointers in a demo I made here,
https://forum.lazarus.freepascal.org/index.php/topic,38081.0.html
Lazarus 1.8rc5 Win64 / Linux gtk2 64 / FreeBSD qt4

 

TinyPortal © 2005-2018