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]

[ul] [*]item [/ul]
[ol] [*]item [/ol]



Embed (videos, code, 3D):

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

Your current vote:

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

How to apply a different texture to the mesh on each drawView calls?
Vote this thread:

Fri, Sep 14 2012

This is the use case:
I have a core video buffer frame of CMSampleBufferRef type.

I could just convert this into a UIImage easily. Then, I want to display this video buffer on a NGLMesh. I've tried to create a texture with this image and then applied it to the material of the mesh.

- (NGLMesh *)planeMesh
NSDictionary *settings = @{ kNGLMeshKeyCentralize: kNGLMeshCentralizeYes, kNGLMeshKeyNormalize: @"1.0" };

NGLMesh *planeMesh = [[NGLMesh alloc] initWithFile:@"plane.obj" settings:settings delegate:self];
NGLMaterial *material = [NGLMaterial material];
planeMesh.material = material;
return planeMesh;

Then inside drawView

- (void)drawView

if (!_plane.visible) {
DLog(@"Play Video");

[_videoPlayerHelper[0] load:@"VuforiaSizzleReel_1.m4v" playImmediately:YES fromPosition:0];

_plane = [self planeMesh];
[_camera addMesh:_plane];

_plane.visible = YES;

NGLTexture *texture = [self videoTextureAtIndex:0 modelViewMatrix:modelViewMatrix targetSize:size];
if (texture != nil) {
NGLMaterial *material = _plane.material;

material.bumpMap = texture;
material.diffuseMap = texture;
material.specularMap = texture;
_plane.material = material;

[_plane compileCoreMesh];

However this resulted in a crash and it doesn't show the image texture, when the plane mesh is rendered. I'm not really sure on how to apply the video texture on the material.

Any ideas?
0% like this - 0/0


Posts: 571


Fri, Sep 14 2012

In response to: @jessearmand

Hello buddy,

Yes, it will probably crash.

1 - Don't use "_plane.material = material;". The material was already set.
2 - Don't use "material.bumpMap = texture;". The bump map must be a normal map using tangent space, which doesn't fit at all on diffuse nor specular. BTW, specular is usually a grey scale map which has luminous information.
3 - Changing the texture is an expensive task right now. We're working on it for the next version. For now, it is very expensive.
0% like this - 0/0

Fri, Sep 14 2012

In response to: @dineybomfim


I do what you told me and it doesn't crash. It seems assigning the NGLTexture to the diffuseMap is not enough?

Then I read another thread, and you said that compileCoreMesh is not necessary? Why is this?
0% like this - 0/0

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.