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

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!

Related

White (maybe uncolored) OBJ in GLSL/C++

Hi I'm working to create a space environment with a ship inside.But after the creation of the skybox (no errors) I put my ship inside but it hasnt colour. It's something like white-black
I did(modeled) the ship with OPENSCAD and after with MESHLAB I exported it into .OBJ format. I load it inside the source code but he hasn't the texture/colour . That my ship in Meshlab :
I need to know only I have to add something about color in the code or it's error in input. What this?
If you need I post the code, but if is somthing normal this error explain me, anyway I'm a little newbie in opengl, so be patient, thank you
EDIT :
Look my .obj file in windows:
And the same project in ubuntu :
What's this difference?
Anyway the openscad code :
module navicella(){
$fn=100;
rotate([0,180,270]){
union(){
rotate([270,180,0]){
rotate([90,0,0])
cylinder(50,7,10,center=true);
intersection(){
translate([0,-25,0])
sphere(10);
translate([0,-25,0])
cube(19,center=true);
}
difference(){
translate([0,35,0])
cube([10,15,15],center=true);
translate([0,40,0])
sphere(13);
}
translate([5,-10,0])rotate([90,0,70])
cube([35,1,15],center=true);
translate([-2,0,0])rotate([90,0,95])
cube([50,1,10],center=true);
translate([0,3,6])rotate([0,-15,90])
cube([40,1,20],center=true);
translate([0,3,-6])rotate([0,15,90])
cube([40,1,20],center=true);
translate([0,-35,0])rotate([90,0,0])
cylinder(10,5,0,center=true);
translate([0,20,0])rotate([0,90,0])
cube([45,1,2],center=true);
translate([0,25,0]) rotate([90,0,0])
cylinder(5,4,7,center=true);
}
}
}
}
navicella();
Looks like you have forgot to disable all used textures that are not used by your model. That is very common mistake (I do it all the time still today).
What is probably happening?
You rendered skybox or any object with textures
So for example GL_CUBE_MAP and or GL_TEXTURE_2D are enabled. Now when you start rendering your mesh that does not contain texture the textures are still enabled. So for every fragment/pixel GL will always sample the last set texture coordinate from last binded texture in all of the enabled texture targets and combine color according to GL settings.
So if you model does not contain texture coordinates GL will use the last set one. That is usually in corner area where black border is ... or you are just in some dark region of texture. Also if you unbind textures that only means you bind default texture 0 which is usually black.
To test/remedy this just callglDisable(GL_....); for all previously used texture targets. If it helps you know where the problem is.
Also if your object contains texture coordinates and texture is not loaded properly (like wrong file name/path) then the result is usually black.
Missing or negative normals while rendering with lighting enabled
Does not looks like it but it could be also the reason. If your model has wrong or no normals then the lighting computation result in wrong lighting. If the object is always dark even if you rotate it the the normals are negated (facing the other way) and you should change the front face for lighting/material or negate the normals.
If the color intensity is changing with rotation then your object has probably no normal and again the last set normal is used (from previous rendering). In such case either compute normals for the object (via cross product) or disable lighting for that object.

OpenGL - texturing mapping 3D object

I have model of skull loaded from .obj file based on this tutorial . As long as I understand texture mapping of cube (make triangle on texture in range of [0,1], select one of six side, select triangle of two triangles on this side and map it with your triangle from texture), I have problem with thinking for any solution to texture mapping my skull. There are few thousands of triangles on it and I think that texture mapping them manually is more than wrong.
Is there any solution for this problem? I'll appreciate any piece of code since it may tell me more than just description of solution.
You can generate your UV coordinates automatically, but this will probably produce badly looking ouput except for very simple textures.
For detailed textures that have eyes, ears, etc., you need to crate your UV coordinates by hand in some 3d modeling tool like is Blender 3d, 3DS Max etc... There is a lot of tutorials all over the internet how to do that. (https://www.youtube.com/watch?v=eCGGe4jLo3M)

Adding a texture on the mesh Libgdx

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.

Using a .x file mesh with textures is overwriting other objects colours?

Im currently writing a puzzle game in c++ directX 9. Not much of it has been a problem however some of my .x files that I am using (using a mesh class that reads them in etc) seems to overwrite the colours of other stuff.
For example I have a green floor and a white pointer, on a level that has a Diglett looking character that has been made in 3ds and textured then exported to .x using panda plugin, other items that are unrelated start to change colour, the green floor is now a lot darker and the white pointer is brown?
Anyone have any ideas? not sure if its texture overflow or something?
The most likely explanation given the information here is that the mesh is changing some state (such as: shaders, diffuse color render/stage states, etc.) when it is drawn. Then your other geometry is affected by those states. You should make sure that any state your geometry depends on is set to what you want it to be before rendering to avoid it being affected by previously changed state.

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.