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.

Rotate object around camera
Vote this thread:


@kent013

Posts: 7

NGLNewbie

Thu, Jul 25 2013


Hi, I'm wondering around for a solution to rotate object around camera.

My camera is placed at 0, 0, 0.
And my object is placed at 0, 1, 0.

I've wrote several patterns of code but I couldn't archived to do it.

[embed]
[arrowMesh_ setPivot:nglVec3Make(0.0f, 0.0f, 0.0f)];
arrowMesh_.rotateZ = 90;
[/embed]

I thought that this code rotates an object around the specified pivot... but it didn't. The object just rotates its own center...

How do I rotate object around camera?
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Thu, Jul 25 2013


In response to: @kent013

Hi,

By default, the pivot is already 0, 0, 0. Remember that the Pivot is a local space reference, not a global. So setting it to 0 will not achieve what you want. You should set it 0, 0,-1. The-1 is the relative position of your object in relation to your camera. Besides, you will not rotate it in Z, but in Y, with small increments inside the render cycle. For example:

mesh.rotateY += 2.0f;


Well, anyway, this is a way of thinking, however I don't like, you're changing the pivot with the wrong reason.

The best way to achieve what you want is just changing the X and Z position of your object, making a very simple 2D orbit equation inside the render cycle, like this:


angle += 0.1;
mesh.x = cosf(angle);
mesh.z = sinf(angle);

0% like this - 0/0

@kent013

Posts: 7

NGLNewbie

Thu, Jul 25 2013


@dineybomfim said:


In response to:@kent013
Well, anyway, this is a way of thinking, however I don't like, you're changing the pivot with the wrong reason.

The best way to achieve what you want is just changing the X and Z position of your object, making a very simple 2D orbit equation inside the render cycle, like this:


angle = 0.1;
mesh.x= cosf(angle);
mesh.z= sinf(angle);




Thank you for your reply!
I just done what I wanted.
This is a huge clue to understand what I have to do...
Thx!
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.