views:

58

answers:

1

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 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

+1  A: 

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.

Ben Karel
brainydexter
Well, if your "point near the model" is a bullet -- do you have a pistol or a machine gun? One bullet in the air at a time, or hundreds? Anyways, trying to reason about performance from first principles is very hard to do. Beyond picking efficient algorithms, the only way to know for sure whether something will be faster or not is to implement it and benchmark.
Ben Karel