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.

Indices and Structures property on a loaded NGLMesh are nil
Vote this thread:


@greensamuelm

Posts: 4

NGLNewbie

Sun, May 20 2012


Amazing engine, really impressed with the functionality, and the straight Objective-C makes things easy as cake to understand!

Now on to my problem. I am loading a custom mesh from a collada (.dae) file. This mesh loads and draws in my project with no issues. I am currently trying to access the underlying vertices for the mesh to help with integration to a physics engine. I am attempting to access the mesh's properties from within the delegate method when a mesh has completed loading. Unfortunately the memory for both of these properties shows as nil. (0x00000000). Am I misunderstanding the use of these properties?

Also would is this framework open source, or would it be possible to take a peek at any of the source? I find this is incredibly useful when learning a new framework. Thanks again for all the hard work you put in to NinevehGL!
100% like this - 1/1

@dineybomfim

Posts: 571

NGLAdmin

Sun, May 20 2012


In response to: @greensamuelm

Hello dude,

Good question!

This is a great opportunity to talk about the approach using OpenGL ES 2.0.

Usually with the old OpenGL ES 1.1 and others the people are used to always access the vertex data directly in the CPU. However this is a very expensive process and should be avoided at any cost with OpenGL ES 2.0.

This is the beauty of the programmable pipeline. You don't need to know anything about the vertex data in the CPU, it has a high cost to memory and to processor. So OpenGL ES 2.0 has the buffers, a very optimized and compressed format to hold data for GPU processing. This is why NinevehGL doesn't hold any information about the vertices nor indices after the Loading Process complete.

So, how to deal with per-vertex operations?

Using Shaders!

The shader and its language was exactly created for that goal. When you want to create per-vertex changes, effects, skeletons, kinematics, cameras, lenses or any other change on vertices you should create a custom shader to deal with these changes directly in the GPU.

With NinevehGL you probably know how simple is to create custom shaders. You just need few lines and don't even need to create a pair of Vertex and Fragment shaders, you can create only that one you need. Use NGLShaders or NGLShadersMulti for that.

Of course using shaders requires another way to think about your problem and also has its own limitations of the Shader Language, however remember it was made exactly for this kind of situation. So let's use it.
0% like this - 0/0

@greensamuelm

Posts: 4

NGLNewbie

Sun, May 20 2012


In response to: @dineybomfim

Thanks for the quick response!

I understand that the mesh info doesn't stick around after the loading process, but I'm hoping to hook in to the model loader and create some objects with my physics library. I don't think this will be possible inside of the shader.

Is there any way to have the mesh element info stick around after creation, or can I hook in to the progress delegate method and possible access the vertex info there?

Basically I have a simple mesh that I would like to create collision objects from. The mesh is loading perfectly and displaying without issue. But I need to use (only) the vertex info to create some simple collision shapes.

Thanks again for all your effort, and the quick response. Really impressed.
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Sun, May 20 2012


In response to: @greensamuelm

I see your point.

But just like Apple push us developer to always use new features and give up the old ones, we have to do the same. All the physics engine today are from the old school, using a loot of the CPU processing.

Expensive tasks on the CPU are from far discouraged by us and by Khronos group.

There is a very fast physics engine called Box2D, despite the name, it's also for 3D stuff. Its high performance is achieved because it uses only the bounding box information to deal with physics. The bounding box information is available to the CPU even after the Loading Process. So this is a choice.

But the best one still being to create a new way to think. Migrating away from the CPU.
0% like this - 0/0

@greensamuelm

Posts: 4

NGLNewbie

Sun, May 20 2012


In response to: @dineybomfim

I definitely understand the point that you are making with offloading as many tasks as possible to the GPU. I certainly won't be accessing vertices every frame, but I do need to access all vertices one time, when the mesh is loaded.

As it is now, I am integrating a third party collada loader so I can read the verts and create bounding boxes for each set of polys in my mesh. I'm certain that this task would be MUCH easier if I had access to the underlying data loaded by the engine.

If we are not meant to access these values at all (from the CPU), what is the purpose of the indices and structures properties on NGLMesh? Maybe that would point me in the right direction.

0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Mon, May 21 2012


In response to: @greensamuelm

Are you just looking for the bounding box info?
If so, the bounding box is a public information and you can access it at any time in any NGLObject3D. I'm not sure if the online version has it, but you can require the lastest version over the contact page.

About the indices and structures, they probably will become an "(Internal only)" methods. This is a very common pattern in Obj-C, as many UIkit classes have methods you can't call directly, just override (for example the loadView) always calling its super.

You can try a small workaround to get this information. Create a subclass of NGLMesh and override the get methods for "indices" and "structures". After starting the Loading Process, they will be called once, at that time, the vertex data will be there.

But again, these methods will become an "(Internal only)", so it's not a good idea create your application depending on them. Consider a contact asking for the lastest version that includes bounding box.

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

@greensamuelm

Posts: 4

NGLNewbie

Mon, May 21 2012


In response to: @dineybomfim

This did the trick! Overriding these two getters, I was able to copy the information off to more permanent buffers and complete my task.

Thanks again for the solid framework, and the quick response.
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.