# Relative motion of each module in 3DS

Since the 3DS model is divided into several parts (modules), now we will study the relative motion of each module, such as the turret rotation of the tank and the helix rotation of the helicopter

Let's take a look at the composition of the helicopter t'heli-l.3ds:

```for(unsigned int i=0;i<gothicModel.pObject.size();i++)
{
pVerts=gothicModel.pObject[i].pVerts;
//Display object name
printf("object%d Name:%s\n",i,gothicModel.pObject[i].strName);
}
```

Object 0 Name: Camera01
Object 1 Name: Chasis03
Object 2 Name: Line01
Object 3 Name: Chasis01
Object 4 Name: Chasis02
Object 5 Name: Chasis05
Object 6 Name: Chasis06
Object 7 Name: Box03
Object 8 name: Chasis
Object 9 Name: rectangle 1

I can't see which is the propeller.

Go to drawModel of CLoad3DS.cpp and increase i value in turn:

```	// Traverse all objects in the model
//for(int i = 7; i < Model.numOfObjects; i++)
int i = 7;
```

The original name of the propeller was Box03.

Next, find the rotation axis (the center of the enclosure):

```//Defining the position of the rotating shaft (center of the propeller)
GLfloat xt1=0.0f,zt1=0.0f;// The propeller rotates around the y-axis, y does not move

NBVector3 *pVerts;      // Object's vertices
pVerts=gothicModel.pObject[i].pVerts;
//Traverse all vertices in an object
for(int j=0;j<gothicModel.pObject[i].numOfVerts;j++)
{
//Compare sizes, leaving minimum and maximum values
t=pVerts->x;
xmin=(t<xmin)?t:xmin;
xmax=(t>xmax)?t:xmax;

t=pVerts->y;
ymin=(t<ymin)?t:ymin;
ymax=(t>ymax)?t:ymax;

t=pVerts->z;
zmin=(t<zmin)?t:zmin;
zmax=(t>zmax)?t:zmax;
pVerts++;//Next vertex
}
//Display object name
//printf("object% d Name:% s\n",i,gothicModel.pObject[i].strName);
//Is the outer half the center
xt1=xmin+(xmax-xmin)/2;//
zt1=zmin+(zmax-zmin)/2;

printf("xt1:%f,\n",xt1);
printf("zt1:%f,\n",zt1);
```

Rotation:

Modify the code of drawModel

```#include "CLoad3DS1.cpp"

void SpinDisplay()
{

glutPostRedisplay();
}
void drawModel(t3DModel Model,bool touming,bool outTex)
{

if(i==7){
glPushMatrix();//Save current state

glTranslatef(xt1,0.0f,zt1);//Move the origin to the center of the propeller
glTranslatef(-xt1,0.0f,-zt1);//Restore to original position

}else if(i==8){
glPopMatrix();//Restore as is
}