How to rotate a model in Release 2.0?

Community support forum for the ARToolKit Professional v4.x for iOS SDK.

Moderator: ARToolKit developers

Forum rules
Ensure that any material you post to this forum complies with Apple's iOS SDK License terms.

How to rotate a model in Release 2.0?

Postby noelrocha » Thu Apr 28, 2011 9:51 am

Hi Guys,

Im trying to rotate my model with no lucky.

I've tried using two ways:

Using "glRotatef(gDrawRotateAngle, 0.0f, 1.0f, 0.0f);". It makes the model rotate, but it rotates until get out of the screen and get back in the other side. Using glRotatef doesn't works well in Release 1.0 neither Release 2.0

The following code works in Release 1.0, but doesn't in Release 2.0

in ARView.m method drawView I've added:
Code: Select all
   float *currentPose;
   float newPose[16];   
   currentPose = [arViewController.virtualEnvironment objectPose:0]; 
   EdenMathRotateMatrix(newPose, currentPose, DTOR*gDrawRotateAngle, 0.0f, 1.0f, 0.0f);
   [arViewController.virtualEnvironment setObjectPose:0 matrix:newPose];


in VirtualEnvironment I've added:
Code: Select all
- (void) setObjectPose:(int)objectIndex matrix:(float *)T{
    memcpy(((VEObject*)[objects objectAtIndex:objectIndex]).pose.T, T, sizeof(float) * 16);
}

- (float *)objectPose:(int)objectIndex {
    return (((VEObject*)[objects objectAtIndex:objectIndex]).pose.T);
}



any hint?

Thanks in advanced,

Noel
User avatar
noelrocha
 
Posts: 20
Joined: Tue Mar 29, 2011 9:50 pm

Re: How to rotate a model in Release 2.0?

Postby noelrocha » Fri Apr 29, 2011 11:27 am

I've tried to copy the example in ARApp that rotates the cube, but it doesn't work well.

Using glTranslate and glRotatef works, but the rotation ray is huge and the model get out of the screen.

Thanks,

Noel
User avatar
noelrocha
 
Posts: 20
Joined: Tue Mar 29, 2011 9:50 pm

Re: How to rotate a model in Release 2.0?

Postby noelrocha » Tue May 03, 2011 12:37 pm

Im still trying to rotate my model in the Release 2.0.

doesnt nobody else have this issue before?
User avatar
noelrocha
 
Posts: 20
Joined: Tue Mar 29, 2011 9:50 pm

Re: How to rotate a model in Release 2.0?

Postby philip_lamb » Wed May 04, 2011 3:54 am

Hi Noel,

In release 2.0, the way updates work is changed. Now, during VirtualEnvironment's init, it registers the VEObject classes/subclasses with NSNotification "ARMarkerUpdatedPoseNotification". So each time a new pose is calculated, "markerUpdatedPose" is called in the VEObject. The default implentation in VEObject.m just copies the pose from the notifying object into itself by calling setPose.

So if you want to also allow the object to be rotated independently relative to the marker, you could modify the markerUpdatedPose method, something like this:
Code: Select all
- (void) markerUpdatedPose:(NSNotification *)notification
{
    ARPose newPose;

    EdenMathRotateMatrix(newPose.T, [((ARMarker *)[notification object]) pose].T, DTOR*gDrawRotateAngle, 0.0f, 1.0f, 0.0f);
    [self setPose:newPose];
}
User avatar
philip_lamb
Site Admin
 
Posts: 506
Joined: Thu Mar 09, 2006 8:35 pm

Re: How to rotate a model in Release 2.0?

Postby kohdesmond » Thu Jun 09, 2011 11:49 pm

What shall i do in order to allow the model to rotate??
kohdesmond
 
Posts: 24
Joined: Thu Apr 28, 2011 10:09 pm


Return to ARToolKit for iOS

Who is online

Users browsing this forum: No registered users and 0 guests

cron