# 3DS browser (2) -- improvements (center display)

;

The third method is to be implemented as follows:

The principle is not complicated either. Release the space occupied by t3DModel in memory and analyze the instance gothicLoader of CLoad3DS

Because I'm not familiar with c + + classes, I can say I don't know anything about it. I can only talk about it later. Besides, it really has the same effect. Maybe it's worse. Next time I click it, I have to reload it.

Now let's make a simple improvement:

1. Center on screen:

Add the void zhong(GLvoid) we made earlier here. Since this window is not created by opengl, which magnification should be slightly modified? See the code:

```//Center model
void zhong(GLvoid)
{
//Traverse the object of the model, traverse the vertex of the object, find the minimum and maximum value of X, y and Z, calculate the size, length, width and height of the outer frame of the model
//Then calculate the xyz magnification

float xmin,xmax,ymin,ymax,zmin,zmax,t;
xmin=ymin=zmin=9999999.0;//Set a large value
xmax=ymax=zmax=-9999999.0;//Set a small value

//Traverse all objects in the model
for(unsigned int i=0;i<gothicModel->pObject.size();i++)
{
//printf("number of vertices of the% D object:% d \ n", I, gothicmodel - > pobject [i]. Numofverts);
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
}

}

float xm,ym,zm,b;
xm=xmax-xmin;ym=ymax-ymin;zm=zmax-zmin;//Width (x difference) height (y difference) depth (z difference)

b=1.0/max(max(xm,ym),zm)*10;//Magnification

gothicTrans=gothicTrans=gothicTrans=b;//Set magnification
//Move to center of screen
gothicTrans=-(xmin+(xmax-xmin)/2)*b;
gothicTrans=-(ymin+(ymax-ymin)/2)*b;
gothicTrans=-(zmin+(zmax-zmin)/2)*b-20;

}
```

And put this in:

```					if(bf==true){
gothicModel=&me3ds[i].Model;//Display direction
}
else{

}
zhong();//Here, whether it is newly loaded or not, it needs to be
```
The effect is:     A second click would be much faster

2. Double click instead to click:

Double click hand tired

```          if (LOWORD (wParam) == ID_LIST && HIWORD (wParam) == LBN_SELCHANGE  )// Double click (LBN? Dblclk) - > change Click
```

In terms of rotation, we should also consider the problem of rotation center. Let's add it later

Note:

If there is an error in loading the house ﹣ back.3ds model, click ignore. This should be changed in CLoad3DS.cpp

A modeling friend said: This is the 3ds format of the model built by solidworks! Posted by enfys on Mon, 04 May 2020 18:06:36 -0700