Is there any demo or article about how to paint solid colors on a 3D model using Delphi GLScene component or FireMonkey ?
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.
This blog article, Visualizing wave interference using FireMonkey, published yesterday, may be of interest.
A couple of screenshots:
(source: embarcadero.com)
(source: embarcadero.com)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With