Login Action Required

The NinevehGL Forum uses a new concept of "socialized forum" or as we like to say "Tweet Forum".


Here is the deal:
  1. No new registration is required. Just sign in with your Twitter account and authorize the NinevehGL Forum.
  2. Once you’re in, you'll be able to "Follow a Thread", that means every time that thread receive a new post or update you'll receive a mention on your twitter.
  3. Besides, you can enable "Auto Share", then every new post and/or thread you make will be tweeted on your timeline. (By default, auto-share is enabled only for your threads)

Forum Rules:

1. We understand human comunication can become "hot" sometimes. So some insults and bad words ARE allowed. Just don't push too much being an asshole all the time.

2. SPAMMERS are not allowed. There are penalties for this kind of user and they can be banned forever.

3. You can report other users, if you judge necessary. An user reported many times by many people can also be banned forever. However you can also receive penalties for report deliberately for no apparent reason.

If there is a similar thread title, make sure the other one doesn't already have the answer you're looking for.

This forum uses the BBCode (Bulletin Board Code), here are some instructions:

Bold: [b]text[/b]
Italic: [i]text[/i]
Underline: [u]text[/u]

Code: [code]text[/code]
Quote:
[quote=@username]text[/quote]
[quote]text[/quote]

List:
[ul] [*]item [/ul]
[ol] [*]item [/ol]

URL:
[url]http://url.com[/url]
[url=http://url.com]text[/url]

Image:
[img]http://imageurl.com[/img]

Embed (videos, code, 3D):
[embed]http://url.com[/embed]

Welcome to the NinevehGL's world!
NinevehGL is a 3D engine forged with pure Obj-C.
Welcome to the
Forum!
Hello, Guest.

Your current vote:

You can change your vote many times. But it's still one single vote.

No visible textures at all
Vote this thread:


@EventPlatform

Posts: 9

NGLNewbie

Fri, Oct 25 2013


Hi!

I'm trying to load a obj model which accompanied with a mtl file.

Geometry looks perfect, but there are no textures at all.
Enumeration of textures in meshLoadingDidFinish shows that parsing.mesh.material contains all of them.
Each materials diffuseMap (for example) refers to a correct path (files are exists).

Do i have to load each file manually an apply to the model? Or it is supposed that the engine should do that?

Thanks!
0% like this - 0/0

@EventPlatform

Posts: 9

NGLNewbie

Fri, Oct 25 2013


Ok, after investigating contents of each texture i've found out that image was nil.
I did some mods to the loading procedure:

- (NGLTexture*) loadTexture:(NGLTexture*) texture {
if(!texture)
return nil;
if(![NSFileManager.defaultManager fileExistsAtPath:texture.filePath isDirectory:nil])
return nil;
UIImage *image = [UIImage imageWithContentsOfFile:texture.filePath];
NSLog(texture.filePath);
NSLog(NSStringFromCGSize(image.size));
return [NGLTexture texture2DWithImage:image];
}
- (void) meshLoadingDidFinish:(NGLParsing) parsing {
[parsing.mesh lookAtVector:(NGLvec3){0, 1, 0}];
for(NGLMaterial *material in parsing.mesh.material){
material.alphaMap = [self loadTexture:material.alphaMap];
material.ambientMap = [self loadTexture:material.ambientMap];
material.bumpMap = [self loadTexture:material.bumpMap];
material.diffuseMap = [self loadTexture:material.diffuseMap];
material.alphaMap = [self loadTexture:material.alphaMap];
material.emissiveMap = [self loadTexture:material.emissiveMap];
material.reflectiveMap = [self loadTexture:material.reflectiveMap];
material.shininessMap = [self loadTexture:material.shininessMap];
material.specularMap = [self loadTexture:material.specularMap];
}
[parsing.mesh compileCoreMesh];
}
- (void) meshCompilingDidFinish:(NGLParsing) parsing {
_models--;
[_camera addMesh:parsing.mesh];
if(0<_models)
return;
[NGLLight.defaultLight translateToX:_camera.position->x
toY:_camera.position->y
toZ:_camera.position->z];
[self angleValue0:nglDegreesToRadians(100) value1:nglDegreesToRadians(20)];
[_progressView removeFromSuperview];
}


The idea is to load mesh, after that to load textures, and finally when all meshes are compiled then display the scene.
But there are still no textures even when all texture images are loaded.
0% like this - 0/0

@EventPlatform

Posts: 9

NGLNewbie

Fri, Oct 25 2013


Talking to myself again...
After modifying the following part:
- (NGLTexture*) loadTexture:(NGLTexture*) texture {
if(!texture)
return nil;
if(![NSFileManager.defaultManager fileExistsAtPath:texture.filePath isDirectory:nil])
return nil;
return [NGLTexture texture2DWithFile:texture.filePath];
}

I've managed to load everything correctly!
But, ith the following code:
nglGlobalLightEffects(NGLLightEffectsON);

Textures are barely visible.
NGLLightEffectsOFF makes textures to look vivid but makes meshes to look flat :(
Is there a way to tune the scene to keep the light on and to make textures visible?
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Fri, Oct 25 2013


In response to: @EventPlatform

Hello buddy,

Feel free to contact us via email also if you like to check or verify if your code is OK.

There are many concepts here:

  1. Yes, you can think "the texture is not loading", however the point is that by default NinevehGL has the lights ON, which will make far objects from the light looks dark.
  2. Always take a look at your console panel in Xcode, NinevehGL will report you any kind of mistake you made or any missing information, for example: if there is a texture file that was not loaded, if there's a misspelling in the 3D format and many other problems that users can face.
  3. Everytime you made a change in the mesh's material, you must call "compileCoreMesh", instructing NinevehGL to recompile your mesh and upload it again to OpenGL side.
  4. Back to the lights, NinevehGL just support one single main light, you can access it via a singleton interface on NGLLight. You can change its properties like attenuation, color, etc. Of course, as any other NGLObject3D, you can move the light through the scene or animate their properties.


Hope this helps.
0% like this - 0/0

@EventPlatform

Posts: 9

NGLNewbie

Fri, Oct 25 2013


In response to: @dineybomfim

Thanks a lot for the info!
I managed to tune the scene's scale to match the light source settings.
Now everything looks better.
Except semi-transparent areas, they force the renderer to cut polygons behind them, for example, car interior. Probably that's because of wrong 3ds-to-obj export settings...

Still got one question: do i have to load texture images myself?
Or
[[NGLMesh alloc] initWithFile:@"scene.obj" settings:@{kNGLMeshKeyNormalize:@"1"} delegate:self]

will do all the job?
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Sat, Oct 26 2013


In response to: @EventPlatform

Hi,

Yes, the mesh load command will do everything to load your mesh and all the related files within it, that means it'll load the entire material hierarchy, including multi/sub materials, textures, all the related .mtl files, all the related effects files, etc.

About the transparent, just make sure you're using the NinevehGL in the RGBA mode, by default it's in RGB mode, so all the alpha/transparent information is completely ignored.

To do so you must call:

nglGlobalColorFormat(NGLColorFormatRGBA);
nglGlobalFlush();
0% like this - 0/0
Technology

NinevehGL is a 3D engine built right on top of OpenGL ES and it uses all the programmable pipeline power, making it easy for you to create great application with shaders.

Share on


Follow NinevehGL
Fastest way to contact us:

Copyright © 2011 db-in. All rights reserved.