Exemple #1
0
//---------------------------------------------------------------------------
void OGLGeo::heightmap2(HeightMap &map_in)
{
//高さ地図の描画その2.ポリゴンを使う
PFacet facet1,facet2;
Vertex p00,p01,p10,p11;
double x0,y0,x1,y1;
 for(int j=0;j<map_in.mesh_j-1;j++)
 {
 for(int i=0;i<map_in.mesh_i-1;i++)
 {
  x0=map_in.itox(i);
  x1=map_in.itox(i+1);
  y0=map_in.jtoy(j);
  y1=map_in.jtoy(j+1);
  p00.x=x0;
  p00.y=y0;
  p01.x=x0;
  p01.y=y1;
  p10.x=x1;
  p10.y=y0;
  p11.x=x1;
  p11.y=y1;
   if(
    (map_in.read(&p00.z,i,j))&&
    (map_in.read(&p10.z,i+1,j))&&
    (map_in.read(&p01.z,i,j+1))
    )
   {
   facet1.a=p00;
   facet1.b=p10;
   facet1.c=p01;
   facet1.abgd();
   pfacet(facet1);
   }

   if(
    (map_in.read(&p10.z,i+1,j))&&
    (map_in.read(&p11.z,i+1,j+1))&&
    (map_in.read(&p01.z,i,j+1))
    )
   {
   facet2.a=p10;
   facet2.b=p11;
   facet2.c=p01;
   facet2.abgd();
   pfacet(facet2);
   }

 }
 }
}
Exemple #2
0
//---------------------------------------------------------------------------
void OGLGeo::heightmap3(HeightMap &map_in)
{
//高さ地図の描画.上面のみ
double x0,x1,y0,y1,z0,z1;
 for(int j=0;j<map_in.mesh_j;j++)
 {
 for(int i=0;i<map_in.mesh_i;i++)
 {
  x0=map_in.x0+i*map_in.dx;
  x1=map_in.x0+(i+1)*map_in.dx;
  y0=map_in.y0+j*map_in.dy;
  y1=map_in.y0+(j+1)*map_in.dy;
//  z0=map_in.z0;

   if(map_in.read(&z1,i,j))
   {
    //上面
    glBegin(GL_POLYGON);
    glNormal3d(0,0,1);
    glVertex3d(x0,y0,z1);
    glVertex3d(x1,y0,z1);
    glVertex3d(x1,y1,z1);
    glVertex3d(x0,y1,z1);
    glEnd();
   }
 }
 }
}
Exemple #3
0
//---------------------------------------------------------------------------
void OGLGeo::heightmap2a(HeightMap &map_in, double rangeH, double rangeL)
{
//高さ地図の描画その2A.ポリゴンを使う
//高さによって色を変える
	PFacet facet1,facet2;
Vertex p00,p01,p10,p11;
double x0,y0,x1,y1;
double h_ratio;


for(int j=0;j<map_in.mesh_j-1;j++)
 {
 for(int i=0;i<map_in.mesh_i-1;i++)
 {
  x0=map_in.itox(i);
  x1=map_in.itox(i+1);
  y0=map_in.jtoy(j);
  y1=map_in.jtoy(j+1);
  p00.x=x0;
  p00.y=y0;
  p01.x=x0;
  p01.y=y1;
  p10.x=x1;
  p10.y=y0;
  p11.x=x1;
  p11.y=y1;
   if(
    (map_in.read(&p00.z,i,j))&&
    (map_in.read(&p10.z,i+1,j))&&
    (map_in.read(&p01.z,i,j+1))
    )
   {
   facet1.a=p00;
   facet1.b=p10;
   facet1.c=p01;
   facet1.abgd();
   h_ratio=(facet1.a.z-rangeL)/(rangeH-rangeL);
   if(h_ratio>1)h_ratio=1;
   if(h_ratio<0)h_ratio=0;
//   set_material(0,h_ratio,0,1);
   GL_set_material(1-h_ratio,h_ratio,1-h_ratio,1);
   pfacet(facet1);
   }

   if(
    (map_in.read(&p10.z,i+1,j))&&
    (map_in.read(&p11.z,i+1,j+1))&&
    (map_in.read(&p01.z,i,j+1))
    )
   {
   facet2.a=p10;
   facet2.b=p11;
   facet2.c=p01;
   facet2.abgd();
   h_ratio=(facet1.a.z-rangeL)/(rangeH-rangeL);
   if(h_ratio>1)h_ratio=1;
   if(h_ratio<0)h_ratio=0;
   GL_set_material(1-h_ratio,h_ratio,1-h_ratio,1);
   pfacet(facet2);
   }

 }
 }
}
Exemple #4
0
//---------------------------------------------------------------------------
void OGLGeo::heightmap(HeightMap &map_in)
{
//高さ地図の描画
GLfloat materialTop[]={0.2f,1.0f,0.4f,0.5f};//上面の色
GLfloat materialSide[]={0.9f,0.8f,0.4f,0.5f};//側面

double x0,x1,y0,y1,z0,z1;
 for(int j=0;j<map_in.mesh_j;j++)
 {
 for(int i=0;i<map_in.mesh_i;i++)
 {
  x0=map_in.x0+i*map_in.dx;
  x1=map_in.x0+(i+1)*map_in.dx;
  y0=map_in.y0+j*map_in.dy;
  y1=map_in.y0+(j+1)*map_in.dy;
  z0=map_in.z0;

   if(map_in.read(&z1,i,j))
   {
    //上面
    glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,materialTop);
    glBegin(GL_POLYGON);
    glNormal3d(0,0,1);
    glVertex3d(x0,y0,z1);
    glVertex3d(x1,y0,z1);
    glVertex3d(x1,y1,z1);
    glVertex3d(x0,y1,z1);
    glEnd();

    //側面
    glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,materialSide);
    glBegin(GL_POLYGON);
    glNormal3d(1,0,0);
    glVertex3d(x1,y0,z0);
    glVertex3d(x1,y1,z0);
    glVertex3d(x1,y1,z1);
    glVertex3d(x1,y0,z1);
    glEnd();
    glBegin(GL_POLYGON);
    glNormal3d(-1,0,0);
    glVertex3d(x0,y0,z0);
    glVertex3d(x0,y0,z1);
    glVertex3d(x0,y1,z1);
    glVertex3d(x0,y1,z0);
    glEnd();
    glBegin(GL_POLYGON);
    glNormal3d(0,1,0);
    glVertex3d(x0,y1,z0);
    glVertex3d(x0,y1,z1);
    glVertex3d(x1,y1,z1);
    glVertex3d(x1,y1,z0);
    glEnd();
    glBegin(GL_POLYGON);
    glNormal3d(0,-1,0);
    glVertex3d(x0,y0,z0);
    glVertex3d(x1,y0,z0);
    glVertex3d(x1,y0,z1);
    glVertex3d(x0,y0,z1);
    glEnd();
   }
 }
 }
}