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.

Centralize a NGLGroup3D
Vote this thread:


@sashah_t

Posts: 27

NGLNewbie

Wed, Jul 31 2013


I would like to centralize a NGLGroup3D. How would I do this?

Also, using kNGLMeshCentralize on the mesh is not an option. I have a group of many meshes and they fit together in a specific way. If I centralize each one they of course end up in the center of the screen, piled on top of one another in a bizarre heap.

Why, you may ask, is the group not already centralized? We received these meshes from a customer in step file form and the customer was not kind enough to centralize them. We can go back to the originals and try to do that first if we must, but I would love to find a way to centralize the NGLGroup3D instead. It would save a lot of work.

So, is this possible? Thanks!
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Thu, Aug 1 2013


In response to: @sashah_t

Well...

You'll need to make a work around.
Bounding box is what you're looking for.

You take the bouding box after the loading finish. Calculate the center of that box and make the necessary translation to place the bouding box in the center of the screen.

Each mesh has its own bouding box.
If you're using a NGLGroup3D, maybe you'll need to call a hidden method to update the bounding box of the group (yes, this is bug, it should calculate it automatically instead).


[myGroup performSelector:@selector(defineBoundingBox)];
0% like this - 0/0

@sashah_t

Posts: 27

NGLNewbie

Thu, Aug 1 2013


In response to: @dineybomfim

Hi again,


This feels like it could be the answer, but I am having trouble executing it.
The line you gave above is indeed helpful for making the bounding box behave, thank you.

I calculated the center of the bounding box using
CGPoint boxCenter = CGPointMake((_mesh3DGroup.boundingBox.volume[6].x - _mesh3DGroup.boundingBox.volume[5].x)/2, (_mesh3DGroup.boundingBox.volume[4].y - _mesh3DGroup.boundingBox.volume[5].y)/2);


And I have tried several solutions to move the box to the center of the screen with no luck.

1. I tried to compare it to the screen center, but the two are apparently on a different scale so
CGPoint screenCenter = CGPointMake((self.view.frame.size.width / 2), (self.view.frame.size.height / 2));
[_mesh3DGroup translateRelativeToX:screenCenter.x - boxCenter.x toY:screenCenter.y - boxCenter.y toZ:0];
did not work at all.

2. I tried just moving the center point to zero on the bounding box calculations using
[_mesh3DGroup translateRelativeToX:-boxCenter.x toY:-boxCenter.y toZ:0];
but this seems to move the group even if it is already centered.

3. I tried using the difference between the min and max values for the bounding box
[_mesh3DGroup translateToX:(_mesh3DGroup.boundingBox.aligned.min.x - _mesh3DGroup.boundingBox.aligned.max.x) toY:(_mesh3DGroup.boundingBox.aligned.min.y - _mesh3DGroup.boundingBox.aligned.max.y) toZ:(_mesh3DGroup.boundingBox.aligned.min.z - _mesh3DGroup.boundingBox.aligned.max.z)];


4. I tried to set all translations to zero
[_mesh3DGroup translateToX:0 toY:0 toZ:0];
which had no effect at all on the mesh.

I don't think I fully understand how to correlate between the center of the bounding box and the center of the ipad screen. Could you give me further guidance on this matter?

I hope I am not going about this all wrong. Thanks again!
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Mon, Aug 5 2013


In response to: @sashah_t

Hello buddy,

You're doing almost everything right, except one thing, in your case, I don't believe you should use the "volume". You should use the "aligned" property and get the min/max properties.

They will instruct you about the maximum and minimum values in all the coordinates. So you can get max.x and min.x to find the the middle value.
100% like this - 1/1
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.