Get a pixel color from and object 3d texture?

Started by Ulrick, November 11, 2010, 05:28:01 PM

Previous topic - Next topic

Ulrick

Hi Egon,

I cannot find information regarding this matter on the forum, so I write this.

Is there a way to get a pixel color from an Object3D? It would be nice to have it when colliding two object, get the color of the collision point and/or some points with a coordinate system.

Thanks in advance,

Ulrick

EgonOlsen


Ulrick

What about something like this?

SimpleVector Point22D =  Interact2D.project3D2D(camera, FrameBuffer, PointOfImpact);

int IntColor=FrameBuffer.getPixel(Point22D.x, Pint22D.y); //   this function is just missing, but would be usefull. The getPixels
                                                                             //   just take too long and get too many             
                                                                             //   not-required data.

RGBColor PixColor = new RGBColor(  (IntColor>> 16) & 255, (IntColor>> 8) & 255, IntColor & 255);

Iti shouldn't be difficult to write a function like the getPixel (x,y) that will be faster than the getPixels().

With that, it should be possible to get it nearly right.

What do you think?

Thanks,

Ulrick

EgonOlsen

#3
Every read from gpu's memory is slow, even if you just read one pixel. But that's not the point. The problem is, that this will work only if the collision point is actually visible on screen. That's a very special case. In most cases, one of the collision partners or some other entity will hide the actual collision point, so you would get a more or less random colored point.
Another problem is that the color in the framebuffer doesn't reflect the original color of the texture, because it's influenced by lighting, filtering...
Maybe the better question is, what problem you are actually facing that you want to solve this way? Maybe there's another solution to that than this way!?

Ulrick

#4
Yes,

you are right, probably is better explain my case.

what I would like to do is to implement a particle system that creates "dirt" when a surface is hit by (i.e.) a missile.

In that case, would be nice to have some particle present a portion of the texture of the original Object been hit.

Is there a way to implement it? As I cannot find a way to get the texture used by an object and as I cannot get portion of it, what could be a nice solution for this kind of issue?

Thanks a lot Egon,

Ulrick

UPDATE:

No solution for this ?

Thanks Egon

EgonOlsen

You can get the texture of an object by using the PolygonManager...however, i wouldn't worry too much about this. IMHO, a basic dirt texture that blends nicely with the object's texture should do fine.

Ulrick

Ok, thanks, but just a consideration.

What if you have a plane where you have water, snow, rocks, dirts and green? What should you take into account when moving "dirts"?

Thanks,

Ulrick