Jump to content

  • Log In with Google      Sign In   
  • Create Account


jiapei100

Member Since 17 Jan 2008
Offline Last Active Feb 25 2013 05:01 PM
-----

Posts I've Made

In Topic: How to check "some user's topics"?

27 April 2010 - 04:47 PM


Thank you.
I found it. Thanks ...

Best Regards
JIA

In Topic: Extract a texture from a random shape

19 August 2009 - 12:27 AM


Hi, Nanoha:

Thank you very much for your response.

Ok, let me re-describe my requirement.


Provided a convex shape A, which is composed by 100 triangles: A1, A2, ... A100; and RGB values of the 10,000 pixels inside this convex shape A have been extracted.

Now, I adjusted some of the shape vertexes, which brings me a new shape B, which is composed by another 100 triangles: B1, B2, B100. These triangles are sequentially corresponding to the above 100 triangles A1, A2... A100 .

Now, I would like to do a warp over the whole shape from A to B.
(I think until now, OpenGL can do it. )

Finally, I would like to extract (interpolate or extrapolate) the RGB values of the corresponding 10,000 pixels inside shape B. (of course, if you show on the screen, there might be less or more pixels within shape B, but I just wonder whether there is a way in OpenGL, which may not let me do my own interpolationi or extrapolation)



I'm not sure whether OpenGL has a fuction like "warp", but I happened to find in Java Advanced Image, there is a "Warp" class.


I believe the following code might finish this warp task. (however, can we just don't display it to save the time??)


glBegin(GL_TRIANGLES);
for (i=0; i<NbOfTriangles; i++) {
Vertex = Triangle[i].getVertexes();
glTexCoord2f( ??, ??);
glVertex3f( Vertex[0].x, Vertex[0].y, Vertex[0].z );

glTexCoord2f( ??, ??);
glVertex3f( Vertex[1].x, Vertex[1].y, Vertex[1].z );

glTexCoord2f( ??, ??);
glVertex3f( Vertex[2].x, Vertex[2].y, Vertex[2].z );
}
glEnd();


(Oh, yes, BTW, what should glTexCoord2f( ??, ??); refer to ?? )


Anyway, if we can do the warp using OpenGL speedily, how can we finally extracted those 10,000 pixels' RGB value? I really hope OpenGL has a very very fast method (function) to deal with this texture extraction.

Looking forward to your reply. If my description is still not clear, please do let me know.

Best Regards
JIA







In Topic: Extract a texture from a random shape

16 August 2009 - 11:58 AM


Thanks for your kind and detailed reply. Thank you !!

Let me give a simple example due to my requirement.

A single triangle T1 is now warped into another one T2.

I sampled 1000 pixels inside triangle T1 and after warping, I still would like to have 1000 corresponding pixels within triangle T2, and those pixels' RGB values are going to be used for further calculation. Is that possible be done directly by OpenGL Render To Texture technology?

If no, I've got to the interpolation one pixel after another.

By the way, I don't even need the screen to show what's inside the triangle. I mean, to display everything on the screen is not a must, in order to save the computation time. In another word, I only need a kind of warp by calculation, rather than by display. I was suggested that using OpenGL should bring me faster speed, but I have been wondering how come?

Can you please give me some more explanation? Thanks

Best Regards
JIA

In Topic: Extract a texture from a random shape

15 August 2009 - 06:57 PM


Hi, All:

Sorry for my stupidity.

May I ask some further questions?

1) yes, to use the technology named "Render To Texture" seems to be the correct way out. However, can anybody give me a simple instruction, what is a "texture" defined in OpenGL? Is it just a "string"? Or a vector of RGB values? or something else like a data structure?

2) If a "texture" is a vector of RGB, which is attached to what's going to be rendered on the screen, will this "texture" be a fix size vector over all frames? Or, this "texture" size may change when the rendered image changes?

Thank you very much.

Best Regards
JIA

In Topic: Extract a texture from a random shape

12 August 2009 - 01:53 PM


My God, so many talents already replied!!

Thank you so much !!!

Yes, I'd love to make things clearer.


My shape is composed by around 100 triangles, and we can even simplify this issue, the shape composed by 100 triangles is a convex shape.

I'd love to know what are the pixel intensities of an image, with this shape, and store all pixel intensities in sequence (row by row, left to right) for later calculation.

That is my purpose. It looks like glReadPixels should work.

However, you mentioned that glReadPixels is to read the pixel value on the screen. How about if I don't display it (for speed issue) ? Is it possible for me to still read the pixels' RGB value without wasting the time on display this image ?


Finally, thank all for your prompt and kind reply. Seriously thanks!!!!

Cheers
JIA Pei

PARTNERS