Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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

A couple of screenshots:


(source: embarcadero.com)


(source: embarcadero.com)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top