Projective texture

Hi everybody !



Is there a way to do projective texturing with jME ?

I mean, project an image onto a scene from a projector, and not a shadow.



Thanks

Sure, but is there sample code for it?  No, I'm afraid not.

Ok, so perhaps I can finally participate to the jME project, then  :slight_smile:



Any advice ?

Get familiar with the ins and outs of TextureRenderer before you delve into it.

If I understand well what the TextureRenderer do, it allows me to create a texture based on the view from the scene given by a camera.



This solution seems too complex for what I want to do since I just want to project a texture on a grid without calculating the texture coordinates (it's hard because the decal can be rotated and scaled).

With the TextureRenderer, it seems that I should render my texture on a trimesh, put my TextureRenderer's camera onto it and take a snapshot.



Am i wrong ?  :?

Actually I was thinking of a depth buffer approach, but mrcoder reminded me via IM that you can use texgen and EYE_LINEAR, assuming we had support for that in jME.  Good news: He's looking at adding support for it. :slight_smile:

That’s cool !  :lol:



I was hoping to use this same solution I found in http://www.ii.uni.wroc.pl/~anl/cgfiles/Sig99AdvOpenGLnotes/node80.html but I didn’t know how to do it with jME.



Thanks guys !

And for others people who are intersted by the subject :



http://www.opengl.org/resources/code/samples/glut_examples/advanced/advanced.html and look at the projtex project.

Just another question  :expressionless: :



How can I render this kind of OpenGL code with jME ?


glEnable(GL_STENCIL_TEST);
  glStencilFunc(GL_ALWAYS, 1, 1);
  glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
  glDepthFunc(GL_LESS);

  glPushMatrix();
  glColor3f(1.f, 0.f, 0.f);
  glTranslatef(0.f, 0.f, -10.f);
  glScalef(5.f, 5.f, 5.f);
  glRotatef((GLfloat) angle, 0.f, 1.f, 0.f);
  glEnable(GL_NORMALIZE);
  glutSolidDodecahedron();
  glDisable(GL_NORMALIZE);
  glPopMatrix();

  glStencilFunc(GL_EQUAL, 1, 1);
  glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
  glDepthFunc(GL_ALWAYS);

  glPushMatrix();
  glTranslatef(0.f, 0.f, -10.f);
  glRotatef((GLfloat) angle, 0.f, 1.f, 0.f);
  glRotatef(58.285f, 0.f, 1.f, 0.f);
  glTranslatef(0.f, 0.f, -7.265f);
  glColor3f(0.f, 1.f, 0.f);
  decal_poly();
  glPopMatrix();

  glDisable(GL_STENCIL_TEST);



I can handle the use of a StencilState and the creation of Trimesh  :), but I don't know how to order the rendering commands to obtain this kind of structure!

you just need to break it down a bit. something like:

  • a dodecahedron placed in space with a solid color and with a stencilstate and a zbufferstate
  • a decal_poly(whatever that is geometrically) placed in space with a solid color and a stencilstate and a zbufferstate



    then just add them to the node hierarchy…perhaps also need to set renderqueuemode to queue_skip and add them in the correct order…





    as for the projective texturing, you need some settings not implemented in jme, like setting texture generation to eye_linear etc. last night i started to implement that so it should be in with a projective texturing test before the weekend…

ok…checked in a TestProjectedTexture and some stuff that were needed to make it happen.



will take some time to make some textureprojection class later for easier usage(as well as make the environment modes more user configurable in the core)



cheers…



Mr.Coder your coolness factor just went up two fold.  :stuck_out_tongue:

haha i wish!  8)

Very nice.

Wow, that's just awesome.

oki, to make using it a bit easier i created a class ProjectedTextureUtil that the test now uses instead of doing it all locally…



also added another projector to the test to show how easy it is…

THANK YOU  :lol:



It is exactly what I wanted to do !



You are a master  8)

no problem at all! i'm working on those classes anyways to get shadowmaps up and running…so beware of added bugs as we go along s :wink:

it's me that should thank you for testing/bugreporting!

Just a little thing about the ProjectedTextureUtil code :



I used a square texture and it was projected with a 45

do you have any screeshot and code to show?