what benefits by mesh?

Anything libgdx related goes here!

what benefits by mesh?

Postby laizhe » Thu Dec 30, 2010 2:59 am

there is no counterpart in opengl ,I wonder what benefits by mesh?
laizhe
 
Posts: 15
Joined: Fri Nov 26, 2010 6:54 am

Re: what benefits by mesh?

Postby consiliens » Thu Dec 30, 2010 4:37 am

Mesh is an abstraction provided by libgdx as a convenience class. Some developers don't want to deal directly with lower level OpenGL ES just to render a Mesh. The benefit of libgdx is that you can opt into the provided classes without giving up the ability to use OpenGL ES directly.
consiliens
 
Posts: 177
Joined: Wed Oct 27, 2010 6:55 am

Re: what benefits by mesh?

Postby mzechner » Thu Dec 30, 2010 1:00 pm

mesh encapsulates vertex arrays and vertex buffer objects transparently for you. It also makes working with shaders a little easier, the VertexAttribute instances you specify in the constructor take a parameter called name iirc so they can be bound automatically to attributes defined in your shader.
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: what benefits by mesh?

Postby laizhe » Thu Dec 30, 2010 1:04 pm

consiliens wrote:Mesh is an abstraction provided by libgdx as a convenience class. Some developers don't want to deal directly with lower level OpenGL ES just to render a Mesh. The benefit of libgdx is that you can opt into the provided classes without giving up the ability to use OpenGL ES directly.


thanks response.
I want use OpenGL ES directly,but i don't find gluLookAt , if replace it with camera’s position?
laizhe
 
Posts: 15
Joined: Fri Nov 26, 2010 6:54 am

Re: what benefits by mesh?

Postby mzechner » Thu Dec 30, 2010 1:07 pm

GLU is not part of OpenGL ES. We do not expose GLU.
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: what benefits by mesh?

Postby NateS » Thu Dec 30, 2010 1:20 pm

The below was stolen from somewhere for an iPhone app I did long ago. You can port it to Java if you can figure out the wonderful ObjectiveC syntax. :)

Code: Select all
- (void) lookAtEyex:(GLfloat)eyex eyey:(GLfloat)eyey eyez:(GLfloat)eyez
   centerx:(GLfloat)centerx centery:(GLfloat)centery centerz:(GLfloat)centerz
   upx:(GLfloat)upx upy:(GLfloat)upy upz:(GLfloat)upz
{
   GLfloat m[16];
   GLfloat x[3], y[3], z[3];
   GLfloat mag;

   // Make rotation matrix.

   // Z vector
   z[0] = eyex - centerx;
   z[1] = eyey - centery;
   z[2] = eyez - centerz;
   mag = sqrtf(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
   if (mag) { // mpichler, 19950515
      z[0] /= mag;
      z[1] /= mag;
      z[2] /= mag;
   }

   // Y vector
   y[0] = upx;
   y[1] = upy;
   y[2] = upz;

   // X vector = Y cross Z
   x[0] = y[1] * z[2] - y[2] * z[1];
   x[1] = -y[0] * z[2] + y[2] * z[0];
   x[2] = y[0] * z[1] - y[1] * z[0];

   // Recompute Y = Z cross X
   y[0] = z[1] * x[2] - z[2] * x[1];
   y[1] = -z[0] * x[2] + z[2] * x[0];
   y[2] = z[0] * x[1] - z[1] * x[0];

   // mpichler, 19950515
   // cross product gives area of parallelogram, which is < 1.0 for
   // non-perpendicular unit-length vectors; so normalize x, y here

   mag = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
   if (mag) {
      x[0] /= mag;
      x[1] /= mag;
      x[2] /= mag;
   }
   mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
   if (mag) {
      y[0] /= mag;
      y[1] /= mag;
      y[2] /= mag;
   }

#define M(row,col) m[col*4+row]
   M(0, 0) = x[0];
   M(0, 1) = x[1];
   M(0, 2) = x[2];
   M(0, 3) = 0.0;
   M(1, 0) = y[0];
   M(1, 1) = y[1];
   M(1, 2) = y[2];
   M(1, 3) = 0.0;
   M(2, 0) = z[0];
   M(2, 1) = z[1];
   M(2, 2) = z[2];
   M(2, 3) = 0.0;
   M(3, 0) = 0.0;
   M(3, 1) = 0.0;
   M(3, 2) = 0.0;
   M(3, 3) = 1.0;
#undef M
   glMultMatrixf(m);

   // Translate eye to origin.
   glTranslatef(-eyex, -eyey, -eyez);
}
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am

Re: what benefits by mesh?

Postby mzechner » Thu Dec 30, 2010 1:29 pm

The Matrix4 class provides you with all that functionality and more. E.g. Matrix4.setToLookAt().
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: what benefits by mesh?

Postby laizhe » Thu Dec 30, 2010 2:08 pm

mzechner wrote:The Matrix4 class provides you with all that functionality and more. E.g. Matrix4.setToLookAt().



This is exactly what I need, Great,thanks.
laizhe
 
Posts: 15
Joined: Fri Nov 26, 2010 6:54 am


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 1 guest