RGBAColor at coordinate xyz

Hi all, i’m new about JME.

I want to ask you if i can obtain the RGBAColor about a particular collision point.

So far i obtain the contact point of collision, and then its geometry and its material. With that i obtain the color parameter of material. My problem is this: if materiel isn’t solid color but have a lot of shades how can i obtain the color at the contatc point?

thank you very much for any help.

… and Merry christmas :slight_smile:

I suppose you could access the vertex buffers and mess around some. If I were you I’d make a UV-map of some sort that takes the collision point and reads the texture based on that, or you’d have to do a lot of weird calculations at each collision.

I have a color map system in my grass, but it’s way easier because I only have to worry about xz “collision” coordinates, and no rotation and scale.

The current render buffer is that image, so you can simply check the pixels on that level, either in a shader or in a processor.

@ androlo: thank you for the suggestion.

@ normen: but if i use the current render buffer i can obtain a pixel with x-y-z coordinate?

thank you vary much

No, it would only give you what’s rendered on screen… not any arbitrary point. So it would depend on what you are checking collisions for. A screen ray, you might get away with it. Otherwise…

What you want to do is non-trivial, actually… and I don’t know of a good use-case for why someone would want to.

At best, as androlo mentions you could poke around in the vertex and texture coordinate buffers and do some math yourself… though it makes a lot of assumptions about how the textures are applied and what shader is being used.

There is nothing built into JME to do this because it’s never needed and it’s kind of impossible in the general case (there is no way to predict what a shader will render for a given point without running the shader).

basically, i’m implementing a kinect simulator. I have a 3d environment and i have to get two matrix: one about distance (and i have already do it) and one about RGB color of any points that the camera cuts. The second matrix is my problem.

So you think that the only way is to use vertex and texture?

thanks again

So you only want the colors that are visible in the camera? That’s easier.

yes, but also with coordinate. For example point at coordinate: (x:1.5, y:2.3, z:4,5) RGBcolor : (0, 1, 0). it’s easy?

If you know the point position on the screen and the depth then you can calculate the 3D coordinate. And the color is then the color of the pixel in the frame buffer. If you know the 3D point then you can figure out where it is on screen and the color is the color of the pixel in the frame buffer.

You only have to do complicated stuff if you need to get the color of pixels that are not on the screen (ie: off screen or the back of some object… or behind some object) but it sounds like that is not necessary in your case.

ok I think I understood, in the next days when I have time I will do some test. I’ll write again here if i have problems.

thank you very much for your help and happy new year

well, i have obtained the point position on the screen relative to a world point, but now i have not found the frame buffer for pixel color, can you help me? thank you very much

I don’t know if there is a more efficient way, but if it were me then I’d look at how ScreenShotAppState captures the screen and work from there.

Yes i found this solution me too, but i don’t understand how to use ScreenShotappState, do you have an example?

thank you very much and good year

@marco88 said:
Yes i found this solution me too, but i don't understand how to use ScreenShotappState, do you have an example?
thank you very much and good year

Please do not double-post. Usage of the app state is outlined in the manual.

ok i’m sorry

I’m sorry i see this manual: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:screenshots?s[]=screenshot&s[]=key, but i haven’t found how i can change the keyinput