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.

Recognize touch on parts of mesh
Vote this thread:

Sun, Sep 1 2013


Hi guys!

First of all thanks for this nice framework!

I have a question:

I want to display a 3D Mesh which has different parts. E.g. a car.

Is there the possibility to recognize, which part of the car has been touched on?

I want to change the color of a part when it get's touched.
E.g. if I touch on the wheel of the car, the wheel changes the color and the rest of the car stayes the same.

Thank you!!
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Mon, Sep 2 2013


In response to: @IsaMunich1

Hi,

There are two concepts involved in here:

  1. Each car part must be separated in such way that it matches an exclusive NGLSurface to it. This shouldn't be made manually, instead, the 3D file should already has the desired parts break apart in sub groups.
  2. There is no Touch API yet in NinevehGL. However thanks to some users of our community you can try this plugin: http://nineveh.gl/community/forum/open_collision_library_for_ninevehgl
0% like this - 0/0

Tue, Sep 3 2013


In response to: @dineybomfim

Thank you for yours answer!

Unfortunately the link http://mynameisadam.net/AEGLEngine.zip doesn't work for me. Is it possible that it doesn't exist anymore?

Thanks!
0% like this - 0/0

Tue, Sep 3 2013


In response to: @dineybomfim

And for your first part:

I thought about changing the .mtl file with changing the source images for my object. So I load the String from the .mtl file and change the image name, I want to change in the String and then I save it again. But then reloading is not possible for me without an error and I think that this way is not the way I have to change the texture, because on top of this I have not found a way to make the path to the .mtl file relative to my project.

How can I for example (without the tap recognition) change one side of the example cube of the example project of this framework?

As I mentioned, I wanted to do it this way:


NSError * error;
NSString * stringFromFile;
NSString * stringFilepath = @"/PathToTheProject/Resources/3D/Cube/cube.mtl";
stringFromFile = [[NSString alloc] initWithContentsOfFile:stringFilepath
encoding:NSUTF8StringEncoding
error:&error];
if (!stringFromFile) {
NSLog(@"%@", [error localizedDescription]);
}

NSLog(@"This is the string from the file: " @"%@", stringFromFile);

// after this there is the name "cube_test.jpg" everywhere in the .mtl file instead of "cube_front.jpg", a "cube_test.jpg" file exists in my project
stringFromFile = [stringFromFile stringByReplacingOccurrencesOfString:@"front"
withString:@"test"];
NSLog(@"This is the string after changing: " @"%@", stringFromFile);

//save again
NSError *error2 = nil;
[stringFromFile writeToFile:stringFilepath atomically:YES encoding:NSUTF8StringEncoding error:&error2];

if (error2 != nil) {
NSLog(@"%@", [error localizedDescription]);
}


Thank you!
0% like this - 0/0

Tue, Sep 3 2013


Update:

Now I watched Lesson 9 of the Tutorials and managed to change the color of the cube without changing something in the files:


NGLMaterial *material = [NGLMaterial material];
material.diffuseMap = [NGLTexture texture2DWithFile:@"cube_test.jpg"];

_mesh.material = material;

[_mesh compileCoreMesh];


But now I have the problem, that all of the cube-sides are in the other color, but I want only one side to change.

How does this work?

Is this the way of having one 3D object with different parts, or how do you mean this?

Thank you!
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Wed, Sep 4 2013


In response to: @IsaMunich1

Hi,

This example os setting a single NGLMaterial is the simplest case. Usually a NGLMesh from 3D file will have multiple materials. So you its "material" property returns a NGLMaterialMulti can navigate through all material.

The "multi" classes in NinevehGL is always a collection that implements the iterator and enumerator pattern. So you can loop through sub materials (NGLMaterial). You can also retrieve one specific material by its "identifier" or "name".

http://nineveh.gl/docs/Classes/NGLMaterialMulti.html

You don't need to set the materials again, just make the changes you want in the desired materials. After that, call the "compileCoreMesh".

Of course you can also create NGLMaterialMulti manually by your own, but it requires also a NGLSurfaceMulti, which is not good to work manually.
0% like this - 0/0

Wed, Sep 4 2013


In response to: @dineybomfim

Thanks for your answer!

Do you think you could give me an example of the changing material please? E.g. change the front to "cube_test.jpg" and the rest stays the same?

I have tried this:
 
NGLMaterial *test = [NGLMaterial material];
test.diffuseMap = [NGLTexture texture2DWithFile:@"cube_test.jpg"];

NGLMaterial *back = [NGLMaterial material];
back.diffuseMap = [NGLTexture texture2DWithFile:@"cube_back.jpg"];
NGLMaterial *right = [NGLMaterial material];
right.diffuseMap = [NGLTexture texture2DWithFile:@"cube_right.jpg"];
NGLMaterial *left = [NGLMaterial material];
left.diffuseMap = [NGLTexture texture2DWithFile:@"cube_left.jpg"];
NGLMaterial *bottom = [NGLMaterial material];
bottom.diffuseMap = [NGLTexture texture2DWithFile:@"cube_bottom.jpg"];
NGLMaterial *top= [NGLMaterial material];
top.diffuseMap = [NGLTexture texture2DWithFile:@"cube_top.jpg"];

NGLMaterialMulti *materialMulti = [[NGLMaterialMulti alloc] initWithMaterials:
back, test, right, left, bottom, top, nil];

_mesh.material = materialMulti;

[_mesh compileCoreMesh];



But unfortunately it didn't work..

Thank you!!!
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Wed, Sep 4 2013


In response to: @IsaMunich1

Yes, it'll not work like that.

As I said, to set the entire NGLMaterialMulti manually you must also set the NGLSurfaceMulti, which involves knowing the mesh structure (a painful job that you should never do manually, this is for what 3D modeling softwares are to).

My advice is to take a cube that already have its faces separated in groups. (BTW, the 3D cube file within the NinevehGL lessons has it).

Then you do:

NGLMaterial *frontFace = [[_mesh material] materialWithName:@"facesNameYouSetOn3DSoftware"];
frontFace.diffuseMap = [NGLTexture texture2DWithFile:@"cube_front.jpg"];

[_mesh compileCoreMesh];

That's all.
0% like this - 0/0

Fri, Sep 6 2013


In response to: @dineybomfim

Thanks a lot!

Now the changing of the texture works :).

If someone else wants to use it, you have to add a cast to the code.


NGLMaterial *frontFace = [(NGLMaterialMulti *)[_mesh material] materialWithName:@"facesNameYouSetOn3DSoftware"];
frontFace.diffuseMap = [NGLTexture texture2DWithFile:@"cube_front.jpg"];

[_mesh compileCoreMesh];


Thanks!
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Sat, Sep 7 2013


In response to: @IsaMunich1

Well, try to contact the user directly: @adameisfeld
0% like this - 0/0

Sun, Sep 8 2013


In response to: @dineybomfim

Thanks!

Unfortunately it is not possible for me to reach him, because his website is not online anymore and I tried it via facebook, but I think he hasn't read it...

Do you think, it would be possible for you to share the code with me?

0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Mon, Sep 9 2013


In response to: @IsaMunich1

Sorry, I don't have it.
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.