Adding a texture on the mesh Libgdx - opengl

I am just starting out with Libgdx and having a problem adding a texture on a mesh. I can't find a working example, so I am asking for a few code snippets demonstrating rendering a mesh with a texture.

If you are using the new 3d api (only in the nightlies builds right now), you should check this: http://blog.xoppa.com/ made by the man who is working on the api right now. From using the model-meshbuilder, to loading models, adding textures and rendering shaders.

Related

OpenGL: drawing lightning source

I am in front a simple issue, but I can't find a way to solve it:
I have the coordinates of a lightning source. I would like to draw a white circle centered on this lightning source.
How can I do that? Is there a opengl function or I should add manually verteces to create a circle?
Thanks
OpenGL does not have primitives like circles. It only has triangles, fundamentally.
Your best options are either to make a regular n-gon where n is large enough to satisfy you, or make the circle geometry part of a texture, and just render a square where some of the coordinates are transparent.
Which is most appropriate depends entirely on context.
Use Blender to create a simple circle mesh. Export to one of the available object files, load it in your app and render. You can use Assimp to load the mesh or write your own loader. You can find a lot of examples online on how to do this.

Assimp Skeletal Animation : Bones associated with a Vertex

I am trying to integrate the Assimp skeletal animation. Following this tutorial for reference.
The change I am trying is to use fixed function pipeline.
Problem: Position, Texture Coordinates and Normal Data is fine, but I cannot figure out how the four bones and the weight data is obtained for each vertex as mentioned in the tutorial.
I think the illustration in the tutorial is quite clear on that:

FBX model's faces (some) are not rendering properly

I've created a basic sphere in Maya and loaded it into my OpenGL project. The problem I'm having is shown below:
As you can see, the sphere is triangulated.
But when the model is loaded into my project, some of the faces aren't rendering properly.
These are my Maya FBX export settings (checked):
General Options
- Default file extensions
- Preserve references
Current Preset
- User defined
Geometry
- Smooth Mesh
Convert NURBS surface to:
- Software Render Mesh
- Referenced Containers Content
Embed Media
- Embed Media
Units
- Automatic
Axis Conversion
- Up Axis: Y
UI
- Show Warning Manager
- Generate Log Data
FBX File Format
- Type: Binary
- Version: FBX 2013
Any ideas as to why this is happening? I'm using FBX SDK 2013.
EDIT:
Didn't realize at the time of posting that the white triangles (labeled "bad triangles") appear due to a simple light rendering. But he extended bar on the right is the actual problem.
Saw your question on my youtube video.
It looks to me like some of your triangles are being culled out on the extended bar. Maybe some of the triangles on the bar have incorrect winding? Something to check for. Check the winding on the triangles and play around with the opengl cull face.
as for the shading, I've seen something resembling this before. It looks like you may need to enable smooth shading, instead of flat shading. Try calling glShadeModel(GL_SMOOTH);
Also try calling glDisable(GL_TEXTURE_2D). If a texture is enabled and appropriate texture coordinates are not given, it can result in weird flat shaded triangles like you're seeing.
The only other possibility I can think of is just that your normals are not properly set up. Here are a few reasons this could be happening:
You did not properly export the normals.
You did not properly import the normals into your vertex buffer objects, or however you cache the information
Your shaders (assuming you're not using immediate mode) are not reading or processing then normals correctly.
Hope this helps. Good luck!

3D spheres and adding textures in OpenGL

I have been asked to do 3D sphere and adding textures to it so that it looks like different planets in the Solar System. However 3ds max was not mentioned as mandatory.
So, how can I make 3D spheres using OpenGL and add textures to it? using glutsphere or am I suppose to do it some other method and how to textures ?
The obvious route would be gluSphere (note, it's glu, not glut) with gluQuadricTexture to get the texturing done.
I am not sure if glutSolidSphere has texture coordinates (as far as I can remeber they were not correct, or not existant). I remember that this was a great resource to get me started on the subject though:
http://paulbourke.net/texture_colour/texturemap/
EDIT:
I just remembered that subdividing an icosahedron gives a better sphere. Also texture coordinates are easier to implement that way:
see here:
http://www.gamedev.net/topic/116312-request-for-help-texture-mapping-a-subdivided-icosahedron/
and
http://www.sulaco.co.za/drawing_icosahedron_tutorial.htm
and
http://student.ulb.ac.be/~claugero/sphere/

OpenGL Texture Mapping

I am new to game programming and graphics programming. However, I eagerly wish to learn, so I have begun building a game engine with OpenGL.
I have implemented all of the basic graphical features, and now I want to add texture support for my triangle meshes.
The only tutorials I can find for texture mapping is for a single polygon - how do I define a texture that wraps around the entire mesh?
I am loading the meshes from .3ds files using lib3ds (http://code.google.com/p/lib3ds/). Do .3ds file carry some texture coordinate data or something?
Here's a page showing an example of reading out the texture coordinates:
http://newsgroups.derkeiler.com/Archive/Comp/comp.graphics.api.opengl/2005-07/msg00168.html
However, not all 3ds files contain texture information - see warning in:
http://www.groupsrv.com/computers/about186619.html
If your models are much more complex than cubes, you use a UV map to translate the 3-dimensional surface of your model into a flat image for texture mapping.
Looks like this thread on gamedev has an example of how to extract what 3DS calls "texels" as well as materials.