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.

Changing Pivot in correlation with translation help needed
Vote this thread:


@sashah_t

Posts: 27

NGLNewbie

Wed, Jul 31 2013


I have three cubes. Left, Center, Right, all in a row. Because these three cubes are part of a NGLGroup3D, I can rotate these cubes around a center pivot. When doing this, it appears that the Center cube is spinning in place and that cubes Left and Right are moving around it. This is the desired behavior.

Next, these three cubes can be translated upon the x axis left and right. When I translate to the left, I change the pivot the opposite direction in a manner that, when the Left cube is in the center of the screen, places the pivot point in the center of the Left cube. Now when I rotate, the Left cube appears to spin in place and the Center and Right cubes appear to orbit around it, with the Center cube in a smaller circle and the Right cube in a larger circle. This is also the desired behavior.

Finally, the problem. With the NGLGroup3D centered and the Pivot point centered, I rotate the group along the y axis, causing the Right cube to be to the left of the Center cube and the Left cube to be on the right of the Center cube. With the two cubes reversed, I translate to the left as before. But now, with the Right cube in the center of the screen, as I rotate I see that the pivot has been moved to the Left cube. This should have happened if I had not rotated so that the cubes were backwards. This is the undesired behavior, I wish the pivot were centered in the Right cube rather than the Left cube in this instance.

It appears that translating takes into account the rotation orientation but moving a pivot point does not take the rotation orientation into account. The moving pivot acts as if the group had not been first rotated. How do I fix this?

Code snippets to accompany the story:

- (void)twoFingerPan:(UIPanGestureRecognizer *)recognizer
{
CGPoint translation = [recognizer velocityInView:self.view];
float xValue = 0.0, yValue = 0.0;

xValue = translation.x * .00001 / (_mesh3DGroup.z * 5);
yValue = translation.y * -.00001 / (_mesh3DGroup.z * 5);

_mesh3DGroup.x = xValue;
_mesh3DGroup.y = yValue;
_globalX = xValue;
_globalY = yValue;
}

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touchA;
CGPoint pointA, pointB;

// Rotate gesture.
if ([touches count] == 1)
{
touchA = [[touches allObjects] objectAtIndex:0];
pointA = [touchA locationInView:self.view];
pointB = [touchA previousLocationInView:self.view];

_position.x = (pointA.x - pointB.x);
_position.y = (pointA.y - pointB.y);

_mesh3DGroup.pivot = (NGLvec3){{-_globalX,-_globalY,0}};
_mesh3DGroup.x = 0;
_mesh3DGroup.y = 0;
[_mesh3DGroup rotateRelativeToX:_position.y toY:_position.x toZ:0];
}
}

0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Wed, Jul 31 2013


In response to: @sashah_t

Hi buddy...

What confused explanation...
Couldn't you just "keep it simple"?

I don't know if this is what you're looking for, but here are some pieces of advice:

  1. Think in pivot as a local cross placed in the center {0, 0, 0} of your mesh (if it's centralized when importing). In the screen, it'll have the opposite effect of the translation. For example, if you set the pivot to {-1, 0, 0}, this will have the effect as moving your mesh to {1, 0, 0}.
  2. Pivots is good for working with complex rotations and hierarchies, like bones. If you're not doing something like that, don't play with it. There are better ways, like placing a NGLGroup3D inside other NGLGroup3D instead of playing with pivots.


I don't know if this is what you're looking for, but hope it helps.
0% like this - 0/0

@sashah_t

Posts: 27

NGLNewbie

Wed, Jul 31 2013


In response to: @dineybomfim

I'm sorry the explanation is a bit confusing, the problem is a bit confusing as well.

I forgot to mention the point of this whole thing. The box example was to help explain the problem. Right now I have many meshes that are parts of a whole mechanical construction. One might be a screw, another a wheel, etc. All the meshes are part of one group so that they always stay in a logical order and appear to be one whole machine.

When the user pans to the left, the user expects that the part of the machine that is currently in the view would be rotating at that point. If the pivot were to stay in the center then the part of the machine in the view would fly sideways out of view. So moving the pivot works, on the original orientation.

The main problem is why, if pivot and translate are opposites, does translate understand that the object has been rotated and pivot does not? And is there a mathematical way that I could keep the pivot moving opposite of the translate?
0% like this - 0/0

@sashah_t

Posts: 27

NGLNewbie

Wed, Jul 31 2013


In response to: @sashah_t

In an even simpler sense, I need world movement of pivot point, not local movement. I am already using NGLRotationSpaceWorld, how would I get a similar function on the movement of the pivot?
0% like this - 0/0

@sashah_t

Posts: 27

NGLNewbie

Fri, Aug 9 2013


In response to: @sashah_t

I finally solved this by placing the pivot point at a negative vector of the location of the mesh, so that the pivot point of the mesh is always in the center of the screen.
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Sat, Aug 10 2013


@sashah_t said:


In response to:@sashah_t

I finally solved this by placing the pivot point at a negative vector...


@dineybomfim said:


For example, if you set the pivot to {-1, 0, 0}, this will have the effect as moving your mesh to {1, 0, 0}.


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.