开发者

How do I color / texture a 3d object dynamically?

I have a 3D model, composed of triangles. What I want to do is, given a point near to the model, I would like to color the model (triangles) to another color, say blue.

Right开发者_如何学Python now, I have a bounding sphere about the model, and when the collision occurs, I just want to approximately color the portions of model from where the collision occurred.

Can someone please suggest me something that I can use and make this happen ?

Thanks


If you just have one or a small number of points to test against, the fastest-to-render method would probably be to write a shader in GLSL that conditionally modifies fragment colors based on world-space distance to your point(s).

An alternative that may be simpler if you've never done GLSL programming would be to use vertex arrays and maintain a map from your triangle vertices to coordinates indexing the vertex arrays; then you can take whatever vertices trigger the collision test and manually modify their associated color data on each frame.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜