Google sketchup objects transparent in opengl? - opengl

I have made two objects in googlesketchup.
link1
.On the link you can see a picture of the model. I just made two rectangles and then used push and pull, later I used paint bucket to paint the textures on.
I export this file as .obj and then imported in opengl. The weird thing is that you can see one object through the other object. There is a picture.
link2
Any ideas how to make the objects non-transparent?

It looks to me a depth test problem.
You can notice it by rotating the model view matrix and you will notice that the transparency will follow an odd behavior.
Try to enable the DEPTH test in your code by adding the following code line:
Using C:
glEnable(GL_DEPTH_TEST);
Cheers

Forgot to enable depth testing? (glEnable(GL_DEPTH_TEST);)

Related

Libgdx postprocessing with modelbatch in chain: opengl setting breaks model faces rendering order

I use libgdx library with opengl-gl20 graphics.
I've added some library into rendering chain and it seams this brokes some opengl setting.
Problems:
model faces forgets about their depth in rendering scene;
inner faces are rendered (when outer faces are expected to be rendered).
So my rendered scene looks like:
(source: cs617131.vk.me)
I have no sources for this library and I couldn't debug what is going on inside.
Update after solved:
I found official sources of that compiled strange jar. This library I tried to use is libgdx-contribs postprocessing.
Solution comes at once when I start read api - constructor of the main processor should get parameter depth=true:
new PostProcessor(true/*enable depth!*/, false, true);
Сonclusion:
situation on image shows rendering with disabled depth_buffer.
If you use together libgdx#ModelBatch and libgdx-contribs postprocessing library
you need create main post-processor with parameter depth=true:
new PostProcessor(true/*enable depth!*/, false, true).

irrlicht model loading/animating

I've been trying (for hours now) to get a b3d model loaded, shown and animated properly.
The model has an animation between frames 0 and 45, it was made and painted (the whole kit) in blender as testing model. Only half of the model is shown, it's completely white and it doesn't move.
I've been googling on information on loading b3d into irrlicht and it's animation system, but trying to load texture from the b3d file failed and all other information I incorporated into the program.
Here is the link to the picture of the actual result.
Here is the link to the code (shortened with comments on the insignificant parts).
Did you correctly define 'node'? If not, try this:
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode (smgr->getMesh ("mesh.b3d"));
If you added the node as an IMeshSceneNode the animations will not show. As for the texturing, I believe with irrlicht you must set all textures manually. Try this in the 'if (node)' block:
node->setMaterialTexture (0, driver->getTexture ("texture.bmp"));
Some painting tools doesn't appear on the model when exported via Blender.
You may've used some, try looking up any possible issues with the tools you used on the net.
Also you sure that you light the model ?
That may cause problems too.
I'm in a bit hurry atm couldn't check the code, I may look deeply later.
Hope it solves

Loading a texture in GLM

hey im using GLM(made by nate robins) with SFML and opengl on mingw32 with the IDE as CodeBlocks(windows)
when loading my texture with the GLM from: http://www.3dcodingtutorial.com/Working-with-3D-models/Getting-GLM.html
hey i managed to get rid of the color problem by changing up my code to better load the textures, but now im not able to get the texture to display...
heres the NEW link to my main: http://pastebin.com/gasu1Hux
i have been looking up GLm tutorials but i cant find any correct answers about my texture not displaying at all.....
maybe im missing something?
/////////////////////OLD/////////////////////////////
also i tried the one from devernay.free.fr, but i always get a texture error
(not gonna post because everytime i do, my question gets downed...)
i had gotten a small glitch where my whole model is blue instead of the default gray...
i found out that the GLM library i have doesnt load textures by itself..
so i managed to find a texture loader from 3dcodingtutorial.com
when i load the texture its not put on the model, it just changes its color.
right now im wondering why my model is one single color instead of the texture i setup.
heres some of the code that i used to make the texture and draw the model:
ok heres the main.cpp
sorry wrong paste ._.
the paste has been updated!!
http://pastebin.com/tcwwasb9
The default GL_TEXTURE_ENV_MODE is GL_MODULATE. Make sure you aren't inadvertently setting your color state somewhere, or force the issue with glColor3ub(255,255,255) before you render something with a texture.
EDIT: GL_DECAL is also an option.

How do you determine when an object is drawn on-screen in OpenGL?

I'm extremely new to OpenGL. I'm writing a program that displays flying 3D text on screen. I need to know when certain text string appears (drawn) onto the screen and are visible to the user. The program needs to identify which text strings are displayed. (Note: although my problem deals with text, it could be generalized to any OpenGL object).
At first, I started to think that I could use OpenGL's picking mechanism, but so far I've only seen examples where the selection area is focused on some sort of user interaction. I want to know what objects are displayed on the entire window area. This leads me to think I'm on the wrong track... Am I missing something?
Any suggestions are welcome.
You can use the query objects (specifically those object created using GL_ARB_occlusion_query extension Specification). Those object are used to query how many fragments are rendered using a sequence of OpenGL operations (begin/end, etc...).
Another scheme (software only), is to determine a bounding box for your rendered text, then compute mathematically whether the bounding box is inside the view frustrum (derived from the current perspective used for rendering.
A note: using OpenGL picking doesn't necessary imply the use of gluPickMatrix. You can render you scene "as is", and the query the rendered names (altought picking is deprecated from OpenGL 3).
Query objects are easy to use, and they are lightweight. Picking is another good solution for most hardware, but more schematic than query objects.
hmm, is it actually in 3D? or is it just 2D text on the screen in 2D space? in that case I would just keep track of it manually. how exactly are you drawing your text?
generally the way you do this is with a "frustum check" where you basically just make a volume for the camera and test whether you're 3d objects are inside it or not.
You can try OpenGL's feedback mechanism. In this mode, OpenGL generates fragments and passes them to a feedback buffer. If something is clipped, no fragments will be generated. When the text becomes visible, you will find the corresponding fragment in the fragment buffer.
This link should get you started.
Here is another link, the Question 10.010 seems particularly relevant to what you want.
Run your object coordinates through your projection and modelview matrices to get screen-space coordinates. Compare the X/Y output against your screen extents to figure out if the text is on-screen.

UV Coordinates Not Correct

I am using Cheetah3D if it mattters.
The UV coordinates I am reading in my object made in Cheetah3D are NOT between 0 and 1 like the example model I was provided with the 3DS model object loading code.
Some go above 1 as high as 1.56 or so while others go below 0, as far as -4.56. This is causing extreme abnormalities when trying to map the texture to the object.
Any ideas? Should I contact the Cheetah3D folks or is there a way to fix this in code myself dynamically? (The reason for posting on SO).
Well without seeing screenshots the only thing that comes to mind is that the texture cords should be wrapped but you're clamping them. See the documentation for glTexParameter* on how to change that setting. A screenshot of a SIMPLE model would really help here.