Terrain.cpp
上传用户:hkb425
上传日期:2007-06-16
资源大小:34191k
文件大小:46k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. // Terrain.cpp: implementation of the CTerrain class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include <stdio.h>
  6. #include "Terrain.h"
  7. #include "Texmanager.h"
  8. #include "GameSetting.h"
  9. #include "cmath.h"
  10. //////////////////////////////////////////////////////////////////////
  11. // Construction/Destruction
  12. //////////////////////////////////////////////////////////////////////
  13. CTerrain::CTerrain()
  14. {
  15. for(int i=0;i<128;i++)
  16. for(int j=0;j<128;j++)
  17. {
  18. Skinmap[i][j].TextureIndex=0;
  19. Skinmap[i][j].TextureOrder=0;
  20. }
  21. for( i=0;i<256;i++)
  22. for(int j=0;j<256;j++)
  23. {
  24.             NormalIndex[i*256+j]=0;
  25. }
  26. }
  27. bool CTerrain::InitTerrain()
  28. {
  29.  CTexManager cTexManager;
  30.  //////////////read blend skin texture
  31.      Blend[0]=cTexManager.GetTextureID(TEX_TERRAIN_SKN1);
  32.      Blend[1]=cTexManager.GetTextureID(TEX_TERRAIN_SKN2);
  33.      Blend[2]=cTexManager.GetTextureID(TEX_TERRAIN_SKN3);
  34.      Blend[3]=cTexManager.GetTextureID(TEX_TERRAIN_SKN4);
  35.  /////////////////////read base skin and cover skin texture
  36.  BaseA[0]=cTexManager.GetTextureID(TEX_TERRAIN_A1);
  37.  BaseA[1]=cTexManager.GetTextureID(TEX_TERRAIN_A2);
  38.  BaseA[2]=cTexManager.GetTextureID(TEX_TERRAIN_A3);
  39.  BaseB[0]=cTexManager.GetTextureID(TEX_TERRAIN_B1);
  40.  BaseB[1]=cTexManager.GetTextureID(TEX_TERRAIN_B2);
  41.  BaseB[2]=cTexManager.GetTextureID(TEX_TERRAIN_B3);
  42.  
  43.      Detail[0]=cTexManager.GetTextureID(TEX_TERRAIN_DETAIL_0);
  44. //   Detail[1]=cTexManager.GetTextureID(TEX_TERRAIN_DETAIL_1);
  45.      
  46.     //////////////////////init terrain skin
  47.     /////construct texture index 
  48. unsigned char index[64][64];
  49. FILE *fp;
  50. fp=fopen(CGameSetting::m_strTextureIndex,"rb");
  51. // fp=fopen("terrains/64_index.BMP","rb");
  52. if(!fp)return false;
  53. fseek(fp,1078,SEEK_SET);
  54. for(int z=63;z>-1;z--)
  55. for(int x=0;x<64;x++)
  56. {
  57. fread(&index[z][x],sizeof(unsigned char),1,fp);
  58. }
  59.     fclose(fp); 
  60.     /////////////////get texture index ,texture order 
  61. for( z=0;z<64;z++)
  62. for(int x=0;x<64;x++)
  63. {
  64. int  name=0;
  65. int addz=z+1;
  66. int addx=x+1;
  67. if(addx==64)addx=0;
  68. if(addz==64)addz=0;
  69. if(index[z][x]>64)    name+=8;
  70. if(index[z][addx]>64)  name+=4;
  71. if(index[addz][addx]>64)name+=2;
  72. if(index[addz][x]>64)  name+=1;
  73. ////////////////////////////////////
  74. if(name==15)//第一种贴图
  75. {   
  76. Skinmap[z][x].TextureIndex=BaseA[rand()%3];
  77.           Skinmap[z][x].TextureOrder=rand()%4;
  78. }
  79. else if(name==0)//第二种贴图
  80. {
  81. Skinmap[z][x].TextureIndex=BaseB[rand()%3];
  82.           Skinmap[z][x].TextureOrder=rand()%4;
  83. }
  84. else  //过渡贴图
  85. {
  86. if(name==8 || name==4 || name==2 || name==1 )
  87. Skinmap[z][x].TextureIndex=Blend[0];
  88. if(name==7 || name==11|| name==13|| name==14)
  89. Skinmap[z][x].TextureIndex=Blend[1];
  90. if(name==12|| name==6 || name==3 || name==9 )
  91. Skinmap[z][x].TextureIndex=Blend[2];
  92. if(name==10|| name==5  )
  93. Skinmap[z][x].TextureIndex=Blend[3];
  94. /////////////////// get order
  95. if(name==8 || name==7 || name==10|| name==12)
  96. Skinmap[z][x].TextureOrder=0;
  97. if(name==4 || name==11|| name==5 || name==6 )
  98. Skinmap[z][x].TextureOrder=1;
  99. if(name==2 || name==13|| name==3 )
  100. Skinmap[z][x].TextureOrder=2;
  101. if(name==1 || name==14|| name==9 )
  102. Skinmap[z][x].TextureOrder=3;
  103. }
  104. }
  105.     //////////////read lodmap.lod
  106. fp=fopen(CGameSetting::m_strLODmap,"rb");
  107. // fp=fopen("terrains/lodmap.lod","rb");
  108. if(!fp)return false;
  109. for( z=255;z>-1;z--)
  110. for(int x=0;x<256;x++)
  111. {
  112. fread(&LODmap[z][x],sizeof(unsigned char),1,fp);
  113. }
  114. ///////////////////////////////////////////////
  115. ///////////////Calculate light normal and lighting color
  116. CMath math;
  117. NORMAL na1,na2,na;
  118. NORMAL nb1,nb2,nb;
  119.     NORMAL normal;
  120. float  xz;
  121. float  xrot,yrot;
  122. for( z=0;z<256;z++)
  123. for(int x=0;x<256;x++)
  124. {
  125. int addz=z+1;   if(addz==256)addz=0;
  126. int subz=z-1;   if(subz==-1)subz=255;
  127. int addx=x+1;   if(addx==256)addx=0;
  128. int subx=x-1;   if(subx==-1)subx=255;
  129. na1=NORMAL(0, float(m_cHmap.m_pTmap[(addz)*256+x] -m_cHmap.m_pTmap[z*256+x] ),6);
  130. na2=NORMAL(6,float(m_cHmap.m_pTmap[z*256+addx] -m_cHmap.m_pTmap[z*256+x] ),0 );
  131. nb1=NORMAL(0, float(m_cHmap.m_pTmap[(subz)*256+x] -m_cHmap.m_pTmap[z*256+x] ),-6);
  132. nb2=NORMAL(-6,float(m_cHmap.m_pTmap[z*256+subx] -m_cHmap.m_pTmap[z*256+x] ),0 );
  133. na=math.GetTwoNormalProduct(na1,na2);
  134. nb=math.GetTwoNormalProduct(nb1,nb2);
  135.             //////////////////////////////////
  136.             normal.nx=na.nx+nb.nx;
  137.             normal.ny=na.ny+nb.ny;
  138.             normal.nz=na.nz+nb.nz;
  139. normal=math.Normalization(normal);
  140.             ///////////////////Init Lighting normal////////
  141. if(normal.ny>1)normal.ny=1;
  142. if(normal.ny<-1)normal.ny=-1;
  143. xrot=asinf(normal.ny)*57.29578f;
  144. xz=(float)sqrt(normal.nx*normal.nx+normal.nz*normal.nz);
  145. yrot=acosf(-normal.nz/xz)*57.29578f;
  146. if(normal.nx>0)yrot=360-yrot;
  147. NormalIndex[z*256+x]=int(xrot/10) * 36+ int(yrot/10);
  148. if(NormalIndex[z*256+x]>359)NormalIndex[z*256+x]=359;
  149.             ///////////////////Init Lighting Color////////
  150. /*
  151. float Aglcos=math.GetTwoVectorAngleCosine(NORMAL(-1.0f,0.5f,1.0f),normal);            
  152. if(Aglcos>0 && Aglcos<=1)ColorIndex[z*256+x]=int(Aglcos*255);
  153. else ColorIndex[z*256+x]=0;*/
  154. }
  155.     ////////// Init Lighting color
  156.             
  157. //////////////////end
  158. return true;
  159. }
  160. void CTerrain::RenderTerrain()
  161. {
  162. numTriangles=0;
  163.     glEnable(GL_DEPTH_TEST);
  164. int uppos=m_cHmap.m_cFrustumCull.m_upPos;
  165. int downpos=m_cHmap.m_cFrustumCull.m_downPos;
  166. for(int z=m_cHmap.m_cFrustumCull.m_pos[uppos].y;z<m_cHmap.m_cFrustumCull.m_pos[downpos].y;z++)
  167. for(int x=m_cHmap.m_cFrustumCull.m_LeftArray[z];x<m_cHmap.m_cFrustumCull.m_RightArray[z];x++)
  168.             RenderTerrainTile( x, z);
  169. m_cHmap.m_numTriangles +=numTriangles;
  170. }
  171. ////////////////////////////////////////////////////////
  172. void CTerrain::RenderTerrainTile(int x,int z)
  173. int level=LODmap[z][x];
  174. if(level==0)return;
  175.     if(level==7 )
  176.        DrawLevel_7(x-128,z-128);
  177.     else if(level==6 )
  178.        DrawLevel_6(x-128,z-128);
  179.     else if(level==5 )
  180.        DrawLevel_5(x-128,z-128);
  181.     else if(level==4)
  182.        DrawLevel_4(x-128,z-128);
  183.     else if(level==3)
  184.        DrawLevel_3(x-128,z-128);
  185.     else if(level==2)
  186.        DrawLevel_3(x-128,z-128);
  187.      else  if(level==1)
  188.        DrawLevel_3(x-128,z-128);
  189. }
  190. void CTerrain::DrawLevel_1(int x,int z)
  191. {
  192.             int rx=x*4;
  193.         int rz=z*4;
  194. int base0=GetPos(x+128,z+128);
  195. // int base1=GetPos(x+128-1,z+128);//m_cHmap.m_pMovemap[(128+z)*256+128+x-1];
  196. int base2=GetPos(x+128,z+1+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x];
  197. int base3=GetPos(x+128+1,z+128+1);//m_cHmap.m_pMovemap[(128+z)*256+128+x+1];
  198. int base4=GetPos(x+128+1,z+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x+1];
  199. int base5=GetPos(x+128,z-1+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x+1];
  200.         float ax,az,bx,bz,cx,cz,dx,dz,ex,ez,fx,fz,gx,gz,hx,hz;
  201.             //////////////////////////// 
  202. glBindTexture(GL_TEXTURE_2D, Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureIndex);
  203. glEnable(GL_TEXTURE_2D);
  204. ////////////Get Texture Order////////////////
  205. switch(Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureOrder)
  206.             {
  207. case 0:
  208.                 ax=0; az=0; bx=1;bz=0;  cx=1;cz=1;  dx=0; dz=1; break;
  209. case 1:
  210.                 ax=1; az=0; bx=1;bz=1;  cx=0;cz=1;  dx=0; dz=0; break;
  211. case 2:
  212.                 ax=1; az=1; bx=0;bz=1;  cx=0;cz=0;  dx=1; dz=0; break;
  213.      case 3:
  214.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;
  215. default :
  216.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;   
  217. }
  218. ex=(ax+bx)*0.5f; ez=(az+bz)*0.5f;
  219.             fx=(bx+cx)*0.5f;    fz=(bz+cz)*0.5f;
  220. gx=(cx+dx)*0.5f;    gz=(cz+dz)*0.5f;
  221. hx=(dx+ax)*0.5f;    hz=(dz+az)*0.5f;
  222. ///////////////////////////////////
  223. //////////////////Left_up
  224. ///////////////////////////////////
  225. glBegin(GL_TRIANGLE_FAN);
  226.             //6
  227. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+256+1]]);
  228. glTexCoord2f((dx+0.5f)*0.5f,(dz+0.5f)*0.5f);
  229.     glVertex3f(float((rx+1)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+256+1] ), float((rz+1)*10+m_cHmap.m_ViewOffsetZ));
  230.             //0
  231. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  232. glTexCoord2f(dx,dz);
  233.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  234.             //5
  235. if(LODmap[128+z][128+x-1]==1)
  236. {
  237.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+256]]);
  238.     glTexCoord2f((dx+hx)*0.5f,(dz+hz)*0.5f);
  239.         glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+256] ), float(rz+1)*10+m_cHmap.m_ViewOffsetZ);
  240. }
  241.             //10
  242. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512]]);
  243. glTexCoord2f(hx,hz);
  244.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512]), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  245. //11
  246.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+1]]);
  247.     glTexCoord2f((hx+0.5f)*0.5f,(hz+0.5f)*0.5f);
  248.         glVertex3f(float((rx+1)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+1] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  249. //12
  250. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  251. glTexCoord2f(0.5f,0.5f);
  252.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  253. //7
  254.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+256+2]]);
  255. glTexCoord2f((gx+0.5f)*0.5f,(gz+0.5f)*0.5f);
  256.     glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+256+2] ), float(rz+1)*10+m_cHmap.m_ViewOffsetZ);
  257.             //2
  258. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+2]]);
  259. glTexCoord2f(gx,gz);
  260.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+2] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  261.             //1
  262. if(LODmap[128+z-1][128+x]==1)
  263. {
  264.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+1]]);
  265.     glTexCoord2f((gx+dx)*0.5f,(gz+dz)*0.5f);
  266.         glVertex3f(float((rx+1)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+1] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  267. }
  268.             //0
  269. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  270. glTexCoord2f(dx,dz);
  271.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  272. glEnd();
  273. ///////////////////////////////////
  274. //////////////////Left_down
  275. ///////////////////////////////////
  276. glBegin(GL_TRIANGLE_FAN);
  277.             //16
  278. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+768+1]]);
  279. glTexCoord2f((ax+0.5f)*0.5f,(az+0.5f)*0.5f);
  280.     glVertex3f(float((rx+1)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+768+1] ), float((rz+3)*10+m_cHmap.m_ViewOffsetZ));
  281.             //10
  282. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512]]);
  283. glTexCoord2f(hx,hz);
  284.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512]), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  285.             //15
  286. if(LODmap[128+z][128+x-1]==1)
  287. {
  288.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+768]]);
  289.     glTexCoord2f((ax+hx)*0.5f,(az+hz)*0.5f);
  290.         glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+768] ), float(rz+3)*10+m_cHmap.m_ViewOffsetZ);
  291. }
  292.             //20
  293. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2]]);
  294. glTexCoord2f(ax,az);
  295.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2]), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  296. //21
  297. if(LODmap[128+z+1][128+x]==1)
  298. {
  299.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2+1]]);
  300.     glTexCoord2f((ax+ex)*0.5f,(az+ez)*0.5f);
  301.         glVertex3f(float((rx+1)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2+1] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  302. }
  303. //22
  304. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2+2]]);
  305. glTexCoord2f(ex,ez);
  306.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2+2] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  307. //17
  308.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+768+2]]);
  309.         glTexCoord2f((ex+0.5f)*0.5f,(ez+0.5f)*0.5f);
  310.         glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+768+2] ), float(rz+3)*10+m_cHmap.m_ViewOffsetZ);
  311. //12
  312. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  313. glTexCoord2f(0.5f,0.5f);
  314.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  315. //11
  316.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+1]]);
  317.     glTexCoord2f((hx+0.5f)*0.5f,(hz+0.5f)*0.5f);
  318.         glVertex3f(float((rx+1)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+1] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  319.             //10
  320. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512]]);
  321. glTexCoord2f(hx,hz);
  322.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512]), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  323. glEnd();
  324. ///////////////////////////////////
  325. //////////////////right_up
  326. ///////////////////////////////////
  327. glBegin(GL_TRIANGLE_FAN);
  328.             //8
  329. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+256+3]]);
  330. glTexCoord2f((cx+0.5f)*0.5f,(cz+0.5f)*0.5f);
  331.     glVertex3f(float((rx+3)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+256+3] ), float((rz+1)*10+m_cHmap.m_ViewOffsetZ));
  332.             //2
  333. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+2]]);
  334. glTexCoord2f(gx,gz);
  335.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+2] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  336. //7
  337.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+256+2]]);
  338.     glTexCoord2f((gx+0.5f)*0.5f,(gz+0.5f)*0.5f);
  339.         glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+256+2] ), float(rz+1)*10+m_cHmap.m_ViewOffsetZ);
  340. //12
  341. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  342. glTexCoord2f(0.5f,0.5f);
  343.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  344.             //13
  345. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+3]]);
  346. glTexCoord2f((fx+0.5f)*0.5f,(fz+0.5f)*0.5f);
  347.     glVertex3f(float((rx+3)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+3] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  348.             //14
  349.         glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4+512]]);
  350.         glTexCoord2f(fx,fz);
  351.             glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4+512] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  352.             //9
  353. if(LODmap[128+z][128+x+1]==1)
  354. {
  355.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4+256]]);
  356.     glTexCoord2f((fx+cx)*0.5f,(fz+cz)*0.5f);
  357.         glVertex3f(float(rx+4)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4+256]), float(rz+1)*10+m_cHmap.m_ViewOffsetZ);
  358. }
  359. //4
  360.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4]]);
  361.     glTexCoord2f(cx,cz);
  362.         glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  363.             //3
  364. if(LODmap[128+z-1][128+x]==1)
  365. {
  366.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+3]]);
  367.     glTexCoord2f((gx+cx)*0.5f,(gz+cz)*0.5f);
  368.         glVertex3f(float((rx+3)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+3] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  369. }
  370.             //2
  371. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+2]]);
  372. glTexCoord2f(gx,gz);
  373.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+2] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  374. glEnd();
  375. ///////////////////////////////////
  376. //////////////////right_down
  377. ///////////////////////////////////
  378. glBegin(GL_TRIANGLE_FAN);
  379.             //18
  380. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+768+3]]);
  381. glTexCoord2f((bx+0.5f)*0.5f,(bz+0.5f)*0.5f);
  382.     glVertex3f(float((rx+3)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+768+3] ), float((rz+3)*10+m_cHmap.m_ViewOffsetZ));
  383. //12
  384. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  385. glTexCoord2f(0.5f,0.5f);
  386.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  387. //17
  388.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+768+2]]);
  389.     glTexCoord2f((ex+0.5f)*0.5f,(ez+0.5f)*0.5f);
  390.         glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+768+2] ), float(rz+3)*10+m_cHmap.m_ViewOffsetZ);
  391. //22
  392. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2+2]]);
  393. glTexCoord2f(ex,ez);
  394.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2+2] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  395.             //23
  396. if(LODmap[128+z+1][128+x]==1)
  397. {
  398.      glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2+3]]);
  399.      glTexCoord2f((ex+bx)*0.5f,(ez+bz)*0.5f);
  400.         glVertex3f(float(rx+3)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2+3]), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  401. }
  402.             //24
  403.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base3]]);
  404.     glTexCoord2f(bx,bz);
  405.     glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base3] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  406.             //19
  407. if(LODmap[128+z][128+x+1]==1)
  408. {
  409.      glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4+768]]);
  410.     glTexCoord2f((bx+fx)*0.5f,(bz+fz)*0.5f);
  411.         glVertex3f(float(rx+4)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4+768]), float(rz+3)*10+m_cHmap.m_ViewOffsetZ);
  412. }
  413.             //14
  414.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4+512]]);
  415.     glTexCoord2f(fx,fz);
  416.     glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4+512] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  417.             //13
  418. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+3]]);
  419. glTexCoord2f((fx+0.5f)*0.5f,(fz+0.5f)*0.5f);
  420.     glVertex3f(float((rx+3)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+3] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  421. //12
  422. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  423. glTexCoord2f(0.5f,0.5f);
  424.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  425. glEnd();
  426. numTriangles+=32;
  427. }
  428. void CTerrain::DrawLevel_2(int x,int z)
  429. {
  430.             int rx=x*4;
  431.         int rz=z*4;
  432. int base0=GetPos(x+128,z+128);
  433. // int base1=GetPos(x+128-1,z+128);//m_cHmap.m_pMovemap[(128+z)*256+128+x-1];
  434. int base2=GetPos(x+128,z+1+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x];
  435. int base3=GetPos(x+128+1,z+128+1);//m_cHmap.m_pMovemap[(128+z)*256+128+x+1];
  436. int base4=GetPos(x+128+1,z+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x+1];
  437. int base5=GetPos(x+128,z-1+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x+1];
  438.         float ax,az,bx,bz,cx,cz,dx,dz,ex,ez,fx,fz,gx,gz,hx,hz;
  439.             //////////////////////////// 
  440. glBindTexture(GL_TEXTURE_2D, Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureIndex);
  441. glEnable(GL_TEXTURE_2D);
  442. ////////////Get Texture Order////////////////
  443. switch(Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureOrder)
  444.             {
  445. case 0:
  446.                 ax=0; az=0; bx=1;bz=0;  cx=1;cz=1;  dx=0; dz=1; break;
  447. case 1:
  448.                 ax=1; az=0; bx=1;bz=1;  cx=0;cz=1;  dx=0; dz=0; break;
  449. case 2:
  450.                 ax=1; az=1; bx=0;bz=1;  cx=0;cz=0;  dx=1; dz=0; break;
  451.      case 3:
  452.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;
  453. default :
  454.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;   
  455. }
  456. ex=(ax+bx)*0.5f; ez=(az+bz)*0.5f;
  457.             fx=(bx+cx)*0.5f;    fz=(bz+cz)*0.5f;
  458. gx=(cx+dx)*0.5f;    gz=(cz+dz)*0.5f;
  459. hx=(dx+ax)*0.5f;    hz=(dz+az)*0.5f;
  460. ///////////////////////////////////
  461. //////////////////Left_up
  462. ///////////////////////////////////
  463. glBegin(GL_TRIANGLE_FAN);
  464.             //6
  465. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+256+1]]);
  466. glTexCoord2f((dx+0.5f)*0.5f,(dz+0.5f)*0.5f);
  467.     glVertex3f(float((rx+1)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+256+1] ), float((rz+1)*10+m_cHmap.m_ViewOffsetZ));
  468.             //0
  469. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  470. glTexCoord2f(dx,dz);
  471.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  472.             //10
  473. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512]]);
  474. glTexCoord2f(hx,hz);
  475.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512]), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  476. //12
  477. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  478. glTexCoord2f(0.5f,0.5f);
  479.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  480.             //2
  481. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+2]]);
  482. glTexCoord2f(gx,gz);
  483.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+2] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  484.             //0
  485. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  486. glTexCoord2f(dx,dz);
  487.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  488. glEnd();
  489. ///////////////////////////////////
  490. //////////////////Left_down
  491. ///////////////////////////////////
  492. glBegin(GL_TRIANGLE_FAN);
  493.             //16
  494. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+768+1]]);
  495. glTexCoord2f((ax+0.5f)*0.5f,(az+0.5f)*0.5f);
  496.     glVertex3f(float((rx+1)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+768+1] ), float((rz+3)*10+m_cHmap.m_ViewOffsetZ));
  497.             //10
  498. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512]]);
  499. glTexCoord2f(hx,hz);
  500.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512]), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  501.             //20
  502. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2]]);
  503. glTexCoord2f(ax,az);
  504.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2]), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  505. //21
  506. //22
  507. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2+2]]);
  508. glTexCoord2f(ex,ez);
  509.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2+2] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  510. //12
  511. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  512. glTexCoord2f(0.5f,0.5f);
  513.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  514.             //10
  515. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512]]);
  516. glTexCoord2f(hx,hz);
  517.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512]), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  518. glEnd();
  519. ///////////////////////////////////
  520. //////////////////right_up
  521. ///////////////////////////////////
  522. glBegin(GL_TRIANGLE_FAN);
  523.             //8
  524. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+256+3]]);
  525. glTexCoord2f((cx+0.5f)*0.5f,(cz+0.5f)*0.5f);
  526.     glVertex3f(float((rx+3)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+256+3] ), float((rz+1)*10+m_cHmap.m_ViewOffsetZ));
  527.             //2
  528. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+2]]);
  529. glTexCoord2f(gx,gz);
  530.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+2] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  531. //12
  532. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  533. glTexCoord2f(0.5f,0.5f);
  534.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  535.             //14
  536.         glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4+512]]);
  537.         glTexCoord2f(fx,fz);
  538.             glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4+512] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  539. //4
  540.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4]]);
  541.     glTexCoord2f(cx,cz);
  542.         glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  543.             //2
  544. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+2]]);
  545. glTexCoord2f(gx,gz);
  546.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+2] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  547. glEnd();
  548. ///////////////////////////////////
  549. //////////////////right_down
  550. ///////////////////////////////////
  551. glBegin(GL_TRIANGLE_FAN);
  552.             //18
  553. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+768+3]]);
  554. glTexCoord2f((bx+0.5f)*0.5f,(bz+0.5f)*0.5f);
  555.     glVertex3f(float((rx+3)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+768+3] ), float((rz+3)*10+m_cHmap.m_ViewOffsetZ));
  556. //12
  557. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  558. glTexCoord2f(0.5f,0.5f);
  559.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  560.       //22
  561. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2+2]]);
  562. glTexCoord2f(ex,ez);
  563.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2+2] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  564.             //24
  565.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base3]]);
  566.     glTexCoord2f(bx,bz);
  567.     glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base3] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  568.             //14
  569.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4+512]]);
  570.     glTexCoord2f(fx,fz);
  571.     glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4+512] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  572. //12
  573. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  574. glTexCoord2f(0.5f,0.5f);
  575.     glVertex3f(float(rx+2)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  576. glEnd();
  577. numTriangles+=16;
  578. }
  579. void CTerrain::DrawLevel_3(int x,int z)
  580. {
  581.             int rx=x*4;
  582.         int rz=z*4;
  583. int base0=GetPos(x+128,z+128);
  584. // int base1=GetPos(x-1+128,z+128);//m_cHmap.m_pMovemap[(128+z)*256+128+x-1];
  585. int base2=GetPos(x+128,z+1+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x];
  586. int base3=GetPos(x+1+128,z+1+128);//m_cHmap.m_pMovemap[(128+z)*256+128+x+1];
  587. int base4=GetPos(x+1+128,z+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x+1];
  588. int base5=GetPos(x+128,z-1+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x+1];
  589.         float ax,az,bx,bz,cx,cz,dx,dz;
  590.             //////////////////////////// 
  591. glBindTexture(GL_TEXTURE_2D, Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureIndex);
  592. glEnable(GL_TEXTURE_2D);
  593. ////////////Get Texture Order////////////////
  594. switch(Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureOrder)
  595.             {
  596. case 0:
  597.                 ax=0; az=0; bx=1;bz=0;  cx=1;cz=1;  dx=0; dz=1; break;
  598. case 1:
  599.                 ax=1; az=0; bx=1;bz=1;  cx=0;cz=1;  dx=0; dz=0; break;
  600. case 2:
  601.                 ax=1; az=1; bx=0;bz=1;  cx=0;cz=0;  dx=1; dz=0; break;
  602.      case 3:
  603.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;
  604. default :
  605.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;   
  606. }
  607. glBegin(GL_TRIANGLE_FAN);
  608. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  609. glTexCoord2f(0.5f,0.5f);
  610.     glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float((rz+2)*10+m_cHmap.m_ViewOffsetZ));
  611. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  612. glTexCoord2f(dx,dz);
  613.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  614.             
  615.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512]]);
  616. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base0+256]]);
  617.     glTexCoord2f((ax+dx)*0.5f,(az+dz)*0.5f);
  618.         glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  619. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2]]);
  620. glTexCoord2f(ax,az);
  621.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2]), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  622.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2+2]]);
  623.     glTexCoord2f((ax+bx)*0.5f,(az+bz)*0.5f);
  624.         glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2+2] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  625. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base3]]);
  626. glTexCoord2f(bx,bz);
  627.     glVertex3f(float(rx+4)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base3] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  628.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4+512]]);
  629. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base4+256]]);
  630.     glTexCoord2f((cx+bx)*0.5f,(cz+bz)*0.5f);
  631.         glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4+512] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  632. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4]]);
  633. glTexCoord2f(cx,cz);
  634.     glVertex3f(float(rx+4)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  635.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+2]]);
  636.     glTexCoord2f((cx+dx)*0.5f,(cz+dz)*0.5f);
  637.         glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+2] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  638. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  639. glTexCoord2f(dx,dz);
  640.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  641. glEnd();
  642. /////////////////////////blend
  643. /*
  644. glBindTexture(GL_TEXTURE_2D, Detail[0]);
  645. glEnable(GL_TEXTURE_2D);
  646. // glBlendFunc(GL_SRC_COLOR,GL_ONE_MINUS_SRC_COLOR);
  647. glBlendFunc(GL_SRC_COLOR,GL_DST_COLOR);
  648. glEnable(GL_BLEND);
  649. glBegin(GL_TRIANGLE_FAN);
  650. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  651. glTexCoord2f(0.5f,0.5f);
  652.     glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float((rz+2)*10+m_cHmap.m_ViewOffsetZ));
  653. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  654. glTexCoord2f(dx,dz);
  655.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  656.             
  657.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512]]);
  658. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base0+256]]);
  659.     glTexCoord2f((ax+dx)*0.5f,(az+dz)*0.5f);
  660.         glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  661. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2]]);
  662. glTexCoord2f(ax,az);
  663.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2]), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  664.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2+2]]);
  665.     glTexCoord2f((ax+bx)*0.5f,(az+bz)*0.5f);
  666.         glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2+2] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  667. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base3]]);
  668. glTexCoord2f(bx,bz);
  669.     glVertex3f(float(rx+4)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base3] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  670.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4+512]]);
  671. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base4+256]]);
  672.     glTexCoord2f((cx+bx)*0.5f,(cz+bz)*0.5f);
  673.         glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4+512] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  674. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4]]);
  675. glTexCoord2f(cx,cz);
  676.     glVertex3f(float(rx+4)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  677.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+2]]);
  678.     glTexCoord2f((cx+dx)*0.5f,(cz+dz)*0.5f);
  679.         glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+2] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  680. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  681. glTexCoord2f(dx,dz);
  682.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  683. glEnd();
  684. glDisable(GL_BLEND);
  685.   */
  686. numTriangles+=8;
  687. }
  688. void CTerrain::DrawLevel_4(int x,int z)
  689. {
  690.             int rx=x*4;
  691.         int rz=z*4;
  692. int base0=GetPos(x+128,z+128);
  693. // int base1=GetPos(x-1+128,z+128);//m_cHmap.m_pMovemap[(128+z)*256+128+x-1];
  694. int base2=GetPos(x+128,z+1+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x];
  695. int base3=GetPos(x+1+128,z+1+128);//m_cHmap.m_pMovemap[(128+z)*256+128+x+1];
  696. int base4=GetPos(x+1+128,z+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x+1];
  697. // int base5=GetPos(x+128,z-1+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x+1];
  698.         float ax,az,bx,bz,cx,cz,dx,dz;
  699.             //////////////////////////// 
  700. glBindTexture(GL_TEXTURE_2D, Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureIndex);
  701. glEnable(GL_TEXTURE_2D);
  702. ////////////Get Texture Order////////////////
  703. switch(Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureOrder)
  704.             {
  705. case 0:
  706.                 ax=0; az=0; bx=1;bz=0;  cx=1;cz=1;  dx=0; dz=1; break;
  707. case 1:
  708.                 ax=1; az=0; bx=1;bz=1;  cx=0;cz=1;  dx=0; dz=0; break;
  709. case 2:
  710.                 ax=1; az=1; bx=0;bz=1;  cx=0;cz=0;  dx=1; dz=0; break;
  711.      case 3:
  712.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;
  713. default :
  714.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;   
  715. }
  716. glBegin(GL_TRIANGLE_FAN);
  717.             //12
  718. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512+2]]);
  719. glTexCoord2f(0.5f,0.5f);
  720.     glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512+2] ), float((rz+2)*10+m_cHmap.m_ViewOffsetZ));
  721.             //0
  722. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  723. glTexCoord2f(dx,dz);
  724.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  725.             //10
  726. if(LODmap[128+z][128+x-1]<4)
  727. {
  728.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+512]]);
  729.     glTexCoord2f((ax+dx)*0.5f,(az+dz)*0.5f);
  730.         glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+512] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  731. }
  732.             //20
  733. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2]]);
  734. glTexCoord2f(ax,az);
  735.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2]), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  736. //22
  737. if(LODmap[128+z+1][128+x]<4)
  738. {
  739.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2+2]]);
  740.     glTexCoord2f((ax+bx)*0.5f,(az+bz)*0.5f);
  741.         glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2+2] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  742. }
  743.             //24
  744. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base3]]);
  745. glTexCoord2f(bx,bz);
  746.     glVertex3f(float(rx+4)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base3] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  747.             //14
  748. if(LODmap[128+z][128+x+1]<4)
  749. {
  750.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4+512]]);
  751. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base4+256]]);
  752.     glTexCoord2f((cx+bx)*0.5f,(cz+bz)*0.5f);
  753.         glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4+512] ), float(rz+2)*10+m_cHmap.m_ViewOffsetZ);
  754. }
  755.             //4
  756. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4]]);
  757. glTexCoord2f(cx,cz);
  758.     glVertex3f(float(rx+4)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  759.             //2
  760. if(LODmap[128+z-1][128+x]<4)
  761. {
  762.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0+2]]);
  763.     glTexCoord2f((cx+dx)*0.5f,(cz+dz)*0.5f);
  764.         glVertex3f(float((rx+2)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0+2] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  765. }
  766. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  767. glTexCoord2f(dx,dz);
  768.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  769. glEnd();
  770. numTriangles+=4;
  771. }
  772. void CTerrain::DrawLevel_5(int x,int z)
  773. {
  774.             int rx=x*4;
  775.         int rz=z*4;
  776. int base0=GetPos(x+128,z+128);
  777. // int base1=GetPos(x-1+128,z+128);//m_cHmap.m_pMovemap[(128+z)*256+128+x-1];
  778. int base2=GetPos(x+128,z+1+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x];
  779. int base3=GetPos(x+1+128,z+1+128);//m_cHmap.m_pMovemap[(128+z)*256+128+x+1];
  780. int base4=GetPos(x+1+128,z+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x+1];
  781.         float ax,az,bx,bz,cx,cz,dx,dz;
  782.             //////////////////////////// 
  783. glBindTexture(GL_TEXTURE_2D, Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureIndex);
  784. glEnable(GL_TEXTURE_2D);
  785. ////////////Get Texture Order////////////////
  786. switch(Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureOrder)
  787.             {
  788. case 0:
  789.                 ax=0; az=0; bx=1;bz=0;  cx=1;cz=1;  dx=0; dz=1; break;
  790. case 1:
  791.                 ax=1; az=0; bx=1;bz=1;  cx=0;cz=1;  dx=0; dz=0; break;
  792. case 2:
  793.                 ax=1; az=1; bx=0;bz=1;  cx=0;cz=0;  dx=1; dz=0; break;
  794.      case 3:
  795.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;
  796. default :
  797.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;   
  798. }
  799. glBegin(GL_TRIANGLE_FAN);
  800. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  801. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base0]]);
  802. glTexCoord2f(dx,dz);
  803.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  804. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2]]);
  805. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base2]]);
  806. glTexCoord2f(ax,az);
  807.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2]), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  808. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base3]]);
  809. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base3]]);
  810. glTexCoord2f(bx,bz);
  811.     glVertex3f(float(rx+4)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base3] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  812. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4]]);
  813. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base4]]);
  814. glTexCoord2f(cx,cz);
  815.     glVertex3f(float(rx+4)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  816. glEnd();
  817. numTriangles+=2;
  818. }
  819. void CTerrain::DrawLevel_6(int x,int z)
  820. {
  821.             int rx=x*4;
  822.         int rz=z*4;
  823. int base0=GetPos(x+128,z+128);
  824. int base1=GetPos(x+128,z+2+128);
  825. int base2=GetPos(x+2+128,z+2+128);
  826. int base3=GetPos(x+2+128,z+128);
  827. int base4=GetPos(x+1+128,z+1+128);
  828. int base5=GetPos(x+128,z+1+128);
  829. int base6=GetPos(x+1+128,z+2+128);
  830. int base7=GetPos(x+2+128,z+1+128);
  831. int base8=GetPos(x+1+128,z+128);
  832.         float ax,az,bx,bz,cx,cz,dx,dz;
  833.             //////////////////////////// 
  834. glBindTexture(GL_TEXTURE_2D, Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureIndex);
  835. glEnable(GL_TEXTURE_2D);
  836. ////////////Get Texture Order////////////////
  837. switch(Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureOrder)
  838.             {
  839. case 0:
  840.                 ax=0; az=0; bx=1;bz=0;  cx=1;cz=1;  dx=0; dz=1; break;
  841. case 1:
  842.                 ax=1; az=0; bx=1;bz=1;  cx=0;cz=1;  dx=0; dz=0; break;
  843. case 2:
  844.                 ax=1; az=1; bx=0;bz=1;  cx=0;cz=0;  dx=1; dz=0; break;
  845.      case 3:
  846.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;
  847. default :
  848.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;   
  849. }
  850. glBegin(GL_TRIANGLE_FAN);
  851.  
  852. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4]]);
  853. glTexCoord2f(0.5f,0.5f);
  854.     glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4] ), float((rz+4)*10+m_cHmap.m_ViewOffsetZ));
  855. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  856. glTexCoord2f(dx,dz);
  857.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  858.    
  859. if(LODmap[128+z][128+x-2]!=7)
  860. {
  861.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base5]]);
  862.     glTexCoord2f((ax+dx)*0.5f,(az+dz)*0.5f);
  863.         glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base5] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  864. }
  865. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base1]]);
  866. glTexCoord2f(ax,az);
  867.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base1]), float(rz+8)*10+m_cHmap.m_ViewOffsetZ);
  868. if(LODmap[128+z+2][128+x]!=7)
  869. {
  870.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base6]]);
  871.     glTexCoord2f((ax+bx)*0.5f,(az+bz)*0.5f);
  872.         glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base6] ), float(rz+8)*10+m_cHmap.m_ViewOffsetZ);
  873. }
  874.        
  875. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2]]);
  876. glTexCoord2f(bx,bz);
  877.     glVertex3f(float(rx+8)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2] ), float(rz+8)*10+m_cHmap.m_ViewOffsetZ);
  878.       
  879. if(LODmap[128+z][128+x+2]!=7)
  880. {
  881.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base7]]);
  882.     glTexCoord2f((cx+bx)*0.5f,(cz+bz)*0.5f);
  883.         glVertex3f(float((rx+8)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base7] ), float(rz+4)*10+m_cHmap.m_ViewOffsetZ);
  884. }
  885.     
  886. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base3]]);
  887. glTexCoord2f(cx,cz);
  888.     glVertex3f(float(rx+8)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base3] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  889.             //2
  890. if(LODmap[128+z-2][128+x]!=7)
  891. {
  892.     glNormal3fv(cNormal.m_3dENormal[NormalIndex[base8]]);
  893.     glTexCoord2f((cx+dx)*0.5f,(cz+dz)*0.5f);
  894.         glVertex3f(float((rx+4)*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base8] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  895. }
  896. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  897. glTexCoord2f(dx,dz);
  898.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  899. glEnd();
  900. numTriangles+=4;
  901. }
  902. void CTerrain::DrawLevel_7(int x,int z)
  903. {
  904.             int rx=x*4;
  905.         int rz=z*4;
  906. int base0=GetPos(x+128,z+128);
  907. // int base1=GetPos(x-1+128,z+128);//m_cHmap.m_pMovemap[(128+z)*256+128+x-1];
  908. int base2=GetPos(x+128,z+2+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x];
  909. int base3=GetPos(x+2+128,z+2+128);//m_cHmap.m_pMovemap[(128+z)*256+128+x+1];
  910. int base4=GetPos(x+2+128,z+128);//m_cHmap.m_pMovemap[(128+z+1)*256+128+x+1];
  911.         float ax,az,bx,bz,cx,cz,dx,dz;
  912.             //////////////////////////// 
  913. glBindTexture(GL_TEXTURE_2D, Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureIndex);
  914. glEnable(GL_TEXTURE_2D);
  915. ////////////Get Texture Order////////////////
  916. switch(Skinmap[GetZpos(x,z)/4][GetXpos(x,z)/4].TextureOrder)
  917.             {
  918. case 0:
  919.                 ax=0; az=0; bx=1;bz=0;  cx=1;cz=1;  dx=0; dz=1; break;
  920. case 1:
  921.                 ax=1; az=0; bx=1;bz=1;  cx=0;cz=1;  dx=0; dz=0; break;
  922. case 2:
  923.                 ax=1; az=1; bx=0;bz=1;  cx=0;cz=0;  dx=1; dz=0; break;
  924.      case 3:
  925.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;
  926. default :
  927.                 ax=0; az=1; bx=0;bz=0;  cx=1;cz=0; dx=1; dz=1; break;   
  928. }
  929. glBegin(GL_TRIANGLE_FAN);
  930. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base0]]);
  931. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base0]]);
  932. glTexCoord2f(dx,dz);
  933.     glVertex3f(float(rx*10)+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base0] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  934. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base2]]);
  935. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base2]]);
  936. glTexCoord2f(ax,az);
  937.     glVertex3f(float(rx)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base2]), float(rz+8)*10+m_cHmap.m_ViewOffsetZ);
  938. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base3]]);
  939. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base3]]);
  940. glTexCoord2f(bx,bz);
  941.     glVertex3f(float(rx+8)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base3] ), float(rz+8)*10+m_cHmap.m_ViewOffsetZ);
  942. glNormal3fv(cNormal.m_3dENormal[NormalIndex[base4]]);
  943. //glColor3fv(cNormal.m_3dEColor[ColorIndex[base4]]);
  944. glTexCoord2f(cx,cz);
  945.     glVertex3f(float(rx+8)*10+m_cHmap.m_ViewOffsetX,  float(m_cHmap.m_pTmap[base4] ), float(rz)*10+m_cHmap.m_ViewOffsetZ);
  946. glEnd();
  947. numTriangles+=2;
  948. }
  949. int  CTerrain::GetPos(int x,int z)
  950. {
  951. return m_cHmap.m_pMovemap[(z)*256+x].zpos*256+m_cHmap.m_pMovemap[(z)*256+x].xpos;
  952. }
  953. int  CTerrain::GetXpos(int x,int z)
  954. {
  955. return m_cHmap.m_pMovemap[(128+z)*256+128+x].xpos;
  956. }
  957. int  CTerrain::GetZpos(int x,int z)
  958. {
  959. return m_cHmap.m_pMovemap[(128+z)*256+128+x].zpos;
  960. }
  961. CTerrain::~CTerrain()
  962. {
  963. for(int i=0;i<4;i++)
  964.     glDeleteTextures(1,&Blend[i]);
  965. for(i=0;i<5;i++)
  966. {
  967. glDeleteTextures(1,&BaseA[i]);
  968. glDeleteTextures(1,&BaseB[i]);
  969. }
  970. }
  971. int CTerrain::GetNumTriangles()
  972. {
  973. return numTriangles;
  974. }