Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi - GLScene or FireMonkey Demo example for painting on 3D model

Is there any demo or article about how to paint solid colors on a 3D model using Delphi GLScene component or FireMonkey ?

like image 590
zac Avatar asked Jan 31 '12 11:01

zac


2 Answers

In the GLScene Demos\interface\hfpick, you have an example of painting on an height field.

Painting on a more complex mesh will require to lookup the texture coordinates of the point under the cursor, which depending on how the texture was mapped may be more or less complex.

A quick hack for small textures that will take advantage of the GPU can be to use the texture coordinates as RGB color, you can do that in a fragment shader, returning the u,v into R,G f.i, and the texture index into the B channel. Render that in an off-screen buffer and lookup the color of the point under the cursor, that'll give you the texture & coordinates, and trivial support for 256x256 textures (and even up to 4096x4096 if you use the texture index wisely).

To do it in a mathematically correct way (using the CPU), you'll have to modify the mesh RayCast methods, so that instead of just finding the triangle being hit, it'll also return the texture coordinates of the point being hit.

like image 160
Eric Grange Avatar answered Sep 25 '22 19:09

Eric Grange


This blog article, Visualizing wave interference using FireMonkey, published yesterday, may be of interest.

A couple of screenshots:


(source: embarcadero.com)


(source: embarcadero.com)

like image 45
David Heffernan Avatar answered Sep 23 '22 19:09

David Heffernan