0

在我的项目中,我必须旋转一个 OBJ 文件。我有恒定的支点。我得到了水平旋转。现在我必须垂直旋转我的 OBJ 文件。我得出结论,必须改变角度本身。给出在那个恒定的枢轴点垂直旋转的想法。

我的轴心点是 teapotNode_.rotationAxis = CC3VectorMake(0.1, 1, 0.3);

-(void)rightButtonPressed {

float angle;    
teapotNode_.rotationAxis = CC3VectorMake(0.1, 1, 0.3);
angle +=2.0;

director_.running = YES;//Redirector object    
if (director_.frameInterval == 2)
{
    director_.running = NO;

}        
}

-(void)leftButtonPressed {

float angle;    
teapotNode_.rotationAxis = CC3VectorMake(0.1, 1, 0.3);
angle -=2.0;       

director_.running = YES;//Redirector object    
if (director_.frameInterval == 2)
{
    director_.running = NO;

}        
}

-(void)topButtonPressed {

float angle;    
teapotNode_.rotationAxis = CC3VectorMake(0.1, 0, 0); ***//changed the Pivot point.***
angle +=2.0;            **//how to calculate the Top Down angle.**
director_.running = YES;//Redirector object    
if (director_.frameInterval == 2)
{
    director_.running = NO;

}        
}
4

1 回答 1

0

我在这个 rend-ios 项目中找到了自己的答案https://github.com/antonholmquist/rend-ios 。

实际上问题是在单击左右按钮时旋转正常工作,就像顶部和底部旋转也正常工作。但是当我从右到上/下单击时,对象正在旋转但它闪烁。

解决方案是:

Globally declared:

float x=0.0;
float y=0.0;
float z=0.0;
float angle;
float xangle;
float yangle;


-(void)rightButtonPressed {

x=0;  y=1;  z=0;             //ROTATE OBJECT IN Y-AXIS(Y=1 & X=0)
yAngle+=2.0;                 //GET ANGLE OF OBJECT ROTATION IN Y-AXIS (ANTI CLOCKWISE)
angle +=2.0;
teapotNode_.rotationAxis = CC3VectorMake(x,y,z);
teapotNode_.rotation = CC3VectorMake(0, yAngle, 0);
director_.running = YES;//Redirector object    
if (director_.frameInterval == 2)
{
    director_.running = NO;

}        
}

-(void)leftButtonPressed {
x=0;  y=1;  z=0;             //ROTATE OBJECT IN Y-AXIS(Y=1 & X=0)
yAngle-=2.0;                 //GET ANGLE OF OBJECT ROTATION IN Y-AXIS (CLOCKWISE)
angle -=2.0;
teapotNode_.rotationAxis = CC3VectorMake(x,y,z);
teapotNode_.rotation = CC3VectorMake(0, yAngle, 0);    

director_.running = YES;//Redirector object    
if (director_.frameInterval == 2)
{
    director_.running = NO;

}        
}

-(void)topButtonPressed {

//Existing
/*float angle;
  teapotNode_.rotationAxis = CC3VectorMake(0.1, 0, 0); //Changed the Pivot point. 
  angle +=2.0;                                         //how to calculate the Top Down angle. 
*/

//Modified
x=1;  y=0;  z=0;             //ROTATE OBJECT IN Y-AXIS(Y=0 & X=1)
xAngle+=2.0;                 //GET ANGLE OF OBJECT ROTATION IN Y-AXIS (Top Down)
angle +=2.0;
teapotNode_.rotationAxis = CC3VectorMake(x,y,z);
teapotNode_.rotation = CC3VectorMake(xangle, 0, 0);

director_.running = YES;//Redirector object    
if (director_.frameInterval == 2)
{
    director_.running = NO;

}        
}
于 2013-08-27T05:13:40.117 回答