亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? cwaterroutine.cpp

?? 用vc編寫出類似于JAVA應(yīng)用中的水紋、火焰以及熔漿效果
?? CPP
字號(hào):
// WaterRoutine.cpp: implementation of the CWaterRoutine class.
//
//////////////////////////////////////////////////////////////////////

#include "CWaterRoutine.h"

#include <math.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#define random( min, max ) (( rand() % (int)((( max ) + 1 ) - ( min ))) + ( min ))

CWaterRoutine::CWaterRoutine()
{
	m_iHeightField1 = NULL;
	m_iHeightField2 = NULL;

	m_iWidth = 0;
	m_iHeight = 0;

	m_bDrawWithLight = TRUE;
	m_iLightModifier = 1;
	m_iHpage = 0;
	m_density = 5;
}

CWaterRoutine::~CWaterRoutine()
{
	// Cleanup
	if(m_iHeightField1 != NULL)
		delete [] m_iHeightField1;
	if(m_iHeightField2 != NULL)
		delete [] m_iHeightField2;

	m_iHeightField1 = NULL;
	m_iHeightField2 = NULL;
}
void CWaterRoutine::Create(int iWidth,int iHeight)
{
	if(m_iHeightField1 != NULL)
		delete [] m_iHeightField1;
	if(m_iHeightField2 != NULL)
		delete [] m_iHeightField2;

	// Create our height fields
	m_iHeightField1 = new int[(iWidth*iHeight)];
	m_iHeightField2 = new int[(iWidth*iHeight)];

	// Clear our height fields
	memset(m_iHeightField1,0,(iWidth*iHeight)*sizeof(int));
	memset(m_iHeightField2,0,(iWidth*iHeight)*sizeof(int));

	m_iWidth = iWidth;
	m_iHeight = iHeight;

	// Set our page to 0
	m_iHpage = 0;

}
void CWaterRoutine::FlattenWater()
{
	// Clear our height fields
	memset(m_iHeightField1,0,(m_iWidth*m_iHeight)*sizeof(int));
	memset(m_iHeightField2,0,(m_iWidth*m_iHeight)*sizeof(int));
}
void CWaterRoutine::Render(DWORD* pSrcImage,DWORD* pTargetImage)
{
	// Yes they have to be the same size...(for now)
	if(m_bDrawWithLight == FALSE)
	{
		DrawWaterNoLight(m_iHpage,pSrcImage,pTargetImage);
	}
	else
	{
		DrawWaterWithLight(m_iHpage,m_iLightModifier,pSrcImage,pTargetImage);
	}
	CalcWater(m_iHpage,m_density);


	m_iHpage ^= 1;

}
void CWaterRoutine::CalcWater(int npage, int density)
{
  int newh;
  int count = m_iWidth + 1;
  int *newptr;
  int *oldptr;

  // Set up the pointers
  if(npage == 0)
  {
	newptr = &m_iHeightField1[0];
	oldptr = &m_iHeightField2[0];
  }
  else
  {
	newptr = &m_iHeightField2[0];
	oldptr = &m_iHeightField1[0];
  }

  int x, y;

  // Sorry, this function might not be as readable as I'd like, because
  // I optimized it somewhat.  (enough to make me feel satisfied with it)

  for (y = (m_iHeight-1)*m_iWidth; count < y; count += 2)
  {
    for (x = count+m_iWidth-2; count < x; count++)
    {

// This does the eight-pixel method.  It looks much better.

      newh          = ((oldptr[count + m_iWidth]
                      + oldptr[count - m_iWidth]
                      + oldptr[count + 1]
                      + oldptr[count - 1]
                      + oldptr[count - m_iWidth - 1]
                      + oldptr[count - m_iWidth + 1]
                      + oldptr[count + m_iWidth - 1]
                      + oldptr[count + m_iWidth + 1]
                       ) >> 2 )
                      - newptr[count];


      newptr[count] =  newh - (newh >> density);
/*
// This is the "sludge" method...
      newh = (oldptr[count]<<2)
           +  oldptr[count-1-m_iWidth]
           +  oldptr[count+1-m_iWidth]
           +  oldptr[count-1+m_iWidth]
           +  oldptr[count+1+m_iWidth]
           + ((oldptr[count-1]
           +   oldptr[count+1]
           +   oldptr[count-m_iWidth]
           +   oldptr[count+m_iWidth])<<1);

      newptr[count] = (newh-(newh>>6)) >> density;
*/
    }
  }
}
void CWaterRoutine::SmoothWater(int npage)
{
  int newh;
  int count = m_iWidth + 1;

  int *newptr;
  int *oldptr;

  // Set up the pointers
  if(npage == 0)
  {
	newptr = &m_iHeightField1[0];
	oldptr = &m_iHeightField2[0];
  }
  else
  {
	newptr = &m_iHeightField2[0];
	oldptr = &m_iHeightField1[0];
  }


  int x, y;

  // Sorry, this function might not be as readable as I'd like, because
  // I optimized it somewhat.  (enough to make me feel satisfied with it)

  for(y=1; y<m_iHeight-1; y++)
  {
    for(x=1; x<m_iWidth-1; x++)
    {
// This does the eight-pixel method.  It looks much better.

      newh          = ((oldptr[count + m_iWidth]
                      + oldptr[count - m_iWidth]
                      + oldptr[count + 1]
                      + oldptr[count - 1]
                      + oldptr[count - m_iWidth - 1]
                      + oldptr[count - m_iWidth + 1]
                      + oldptr[count + m_iWidth - 1]
                      + oldptr[count + m_iWidth + 1]
                       ) >> 3 )
                      + newptr[count];


      newptr[count] =  newh>>1;
      count++;
    }
    count += 2;
  }
}

void CWaterRoutine::CalcWaterBigFilter(int npage, int density)
{
  int newh;
  int count = (2*m_iWidth) + 2;

  int *newptr;
  int *oldptr;

  // Set up the pointers
  if(npage == 0)
  {
	newptr = &m_iHeightField1[0];
	oldptr = &m_iHeightField2[0];
  }
  else
  {
	newptr = &m_iHeightField2[0];
	oldptr = &m_iHeightField1[0];
  }

  int x, y;

  // Sorry, this function might not be as readable as I'd like, because
  // I optimized it somewhat.  (enough to make me feel satisfied with it)

  for(y=2; y<m_iHeight-2; y++)
  {
    for(x=2; x<m_iWidth-2; x++)
    {
// This does the 25-pixel method.  It looks much okay.

      newh        = (
                     (
                      (
                       (oldptr[count + m_iWidth]
                      + oldptr[count - m_iWidth]
                      + oldptr[count + 1]
                      + oldptr[count - 1]
                       )<<1)
                      + ((oldptr[count - m_iWidth - 1]
                      + oldptr[count - m_iWidth + 1]
                      + oldptr[count + m_iWidth - 1]
                      + oldptr[count + m_iWidth + 1]))
                      + ( (
                          oldptr[count - (m_iWidth*2)]
                        + oldptr[count + (m_iWidth*2)]
                        + oldptr[count - 2]
                        + oldptr[count + 2]
                        ) >> 1 )
                      + ( (
                          oldptr[count - (m_iWidth*2) - 1]
                        + oldptr[count - (m_iWidth*2) + 1]
                        + oldptr[count + (m_iWidth*2) - 1]
                        + oldptr[count + (m_iWidth*2) + 1]
                        + oldptr[count - 2 - m_iWidth]
                        + oldptr[count - 2 + m_iWidth]
                        + oldptr[count + 2 - m_iWidth]
                        + oldptr[count + 2 + m_iWidth]
                        ) >> 2 )
                     )
                    >> 3)
                    - (newptr[count]);


      newptr[count] =  newh - (newh >> density);
      count++;
    }
    count += 4;
  }
}

void CWaterRoutine::HeightBlob(int x, int y, int radius, int height, int page)
{
  int rquad;
  int cx, cy, cyq;
  int left, top, right, bottom;

  int *newptr;
  int *oldptr;

  // Set up the pointers
  if(page == 0)
  {
	newptr = &m_iHeightField1[0];
	oldptr = &m_iHeightField2[0];
  }
  else
  {
	newptr = &m_iHeightField2[0];
	oldptr = &m_iHeightField1[0];
  }

  rquad = radius * radius;

  // Make a randomly-placed blob...
  if(x<0) x = 1+radius+ rand()%(m_iWidth-2*radius-1);
  if(y<0) y = 1+radius+ rand()%(m_iHeight-2*radius-1);

  left=-radius; right = radius;
  top=-radius; bottom = radius;

  // Perform edge clipping...
  if(x - radius < 1) left -= (x-radius-1);
  if(y - radius < 1) top  -= (y-radius-1);
  if(x + radius > m_iWidth-1) right -= (x+radius-m_iWidth+1);
  if(y + radius > m_iHeight-1) bottom-= (y+radius-m_iHeight+1);


  for(cy = top; cy < bottom; cy++)
  {
    cyq = cy*cy;
    for(cx = left; cx < right; cx++)
    {
      if(cx*cx + cyq < rquad)
        newptr[m_iWidth*(cy+y) + (cx+x)] += height;
    }
  }

}

void CWaterRoutine::HeightBox (int x, int y, int radius, int height, int page)
{
  int cx, cy;
  int left, top, right, bottom;
  int *newptr;
  int *oldptr;

  // Set up the pointers
  if(page == 0)
  {
	newptr = &m_iHeightField1[0];
	oldptr = &m_iHeightField2[0];
  }
  else
  {
	newptr = &m_iHeightField2[0];
	oldptr = &m_iHeightField1[0];
  }

  if(x<0) x = 1+radius+ rand()%(m_iWidth-2*radius-1);
  if(y<0) y = 1+radius+ rand()%(m_iHeight-2*radius-1);

  left=-radius; right = radius;
  top=-radius; bottom = radius;

  // Perform edge clipping...
  if(x - radius < 1) left -= (x-radius-1);
  if(y - radius < 1) top  -= (y-radius-1);
  if(x + radius > m_iWidth-1) right -= (x+radius-m_iWidth+1);
  if(y + radius > m_iHeight-1) bottom-= (y+radius-m_iHeight+1);

  for(cy = top; cy < bottom; cy++)
  {
    for(cx = left; cx < right; cx++)
    {
        newptr[m_iWidth*(cy+y) + (cx+x)] = height;
    }
  }

}


void CWaterRoutine::WarpBlob(int x, int y, int radius, int height, int page)
{
  int cx, cy;
  int left,top,right,bottom;
  int square;
  int radsquare = radius * radius;
  int *newptr;
  int *oldptr;

  // Set up the pointers
  if(page == 0)
  {
	newptr = &m_iHeightField1[0];
	oldptr = &m_iHeightField2[0];
  }
  else
  {
	newptr = &m_iHeightField2[0];
	oldptr = &m_iHeightField1[0];
  }
//  radsquare = (radius*radius) << 8;
  radsquare = (radius*radius);

  height /= 64;

  left=-radius; right = radius;
  top=-radius; bottom = radius;

  // Perform edge clipping...
  if(x - radius < 1) left -= (x-radius-1);
  if(y - radius < 1) top  -= (y-radius-1);
  if(x + radius > m_iWidth-1) right -= (x+radius-m_iWidth+1);
  if(y + radius > m_iHeight-1) bottom-= (y+radius-m_iHeight+1);

  for(cy = top; cy < bottom; cy++)
  {
    for(cx = left; cx < right; cx++)
    {
      square = cy*cy + cx*cx;
//      square <<= 8;
      if(square < radsquare)
      {
//        Height[page][WATERWID*(cy+y) + cx+x]
//          += (sqrt(radsquare)-sqrt(square))*height;
        newptr[m_iWidth*(cy+y) + cx+x]
          += int((radius-sqrt(square))*(float)(height));
      }
    }
  }
}

void CWaterRoutine::SineBlob(int x, int y, int radius, int height, int page)
{
  int cx, cy;
  int left,top,right,bottom;
  int square, dist;
  int radsquare = radius * radius;
  float length = float((1024.0/(float)radius)*(1024.0/(float)radius));
  int *newptr;
  int *oldptr;

  // Set up the pointers
  if(page == 0)
  {
	newptr = &m_iHeightField1[0];
	oldptr = &m_iHeightField2[0];
  }
  else
  {
	newptr = &m_iHeightField2[0];
	oldptr = &m_iHeightField1[0];
  }

  if(x<0) x = 1+radius+ rand()%(m_iWidth-2*radius-1);
  if(y<0) y = 1+radius+ rand()%(m_iHeight-2*radius-1);


//  radsquare = (radius*radius) << 8;
  radsquare = (radius*radius);

//  height /= 8;

  left=-radius; right = radius;
  top=-radius; bottom = radius;


  // Perform edge clipping...
  if(x - radius < 1) left -= (x-radius-1);
  if(y - radius < 1) top  -= (y-radius-1);
  if(x + radius > m_iWidth-1) right -= (x+radius-m_iWidth+1);
  if(y + radius > m_iHeight-1) bottom-= (y+radius-m_iHeight+1);

  for(cy = top; cy < bottom; cy++)
  {
    for(cx = left; cx < right; cx++)
    {
      square = cy*cy + cx*cx;
      if(square < radsquare)
      {
        dist = int(sqrt(square*length));
        newptr[m_iWidth*(cy+y) + cx+x]
          += (int)((cos(dist)+0xffff)*(height)) >> 19;
      }
    }
  }
}

void CWaterRoutine::DrawWaterNoLight(int page,DWORD* pSrcImage,DWORD* pTargetImage)
{

//  int ox, oy;
  int dx, dy;
  int x, y;
  DWORD c;

  int offset=m_iWidth + 1;

  int *ptr = &m_iHeightField1[0];

  for (y = (m_iHeight-1)*m_iWidth; offset < y; offset += 2)
  {
    for (x = offset+m_iWidth-2; offset < x; offset++)
    {
      dx = ptr[offset] - ptr[offset+1];
      dy = ptr[offset] - ptr[offset+m_iWidth];

	  //Shading = dx;?
	  // Water draw method?
//      c = BkGdImage[offset + WATERWID*(dy>>3) + (dx>>3)];
	  c = pSrcImage[offset + m_iWidth*(dy>>3) + (dx>>3)];

     // If anyone knows a better/faster way to do this, please tell me...
//      temp[offset] = (c < 0) ? 0 : (c > 255) ? 255 : c;
	  pTargetImage[offset] = c;

      offset++;
      dx = ptr[offset] - ptr[offset+1];
      dy = ptr[offset] - ptr[offset+m_iWidth];
//    c = BkGdImage[offset + m_iWidth*(dy>>3) + (dx>>3)];
	  c = pSrcImage[offset + m_iWidth*(dy>>3) + (dx>>3)];
	  pTargetImage[offset] = c;
//      temp[offset] = (c < 0) ? 0 : (c > 255) ? 255 : c;
 
    }
  }
}

void CWaterRoutine::DrawWaterWithLight(int page, int LightModifier,DWORD* pSrcImage,DWORD* pTargetImage)
{

//  int ox, oy;
  int dx, dy;
  int x, y;
  DWORD c;

  int offset=m_iWidth + 1;
  long lIndex;
  long lBreak = m_iWidth*m_iHeight;

  int *ptr = &m_iHeightField1[0];


  for (y = (m_iHeight-1)*m_iWidth; offset < y; offset += 2)
  {
    for (x = offset+m_iWidth-2; offset < x; offset++)
    {
      dx = ptr[offset] - ptr[offset+1];
      dy = ptr[offset] - ptr[offset+m_iWidth];

	  lIndex = offset + m_iWidth*(dy>>3) + (dx>>3);
	  if(lIndex < lBreak && lIndex > 0)
	  {
		  c = pSrcImage[lIndex];// - (dx>>LightModifier);
		  // Now we shift it by the dx component...
		  // 
		  c = GetShiftedColor(c,dx);

 		  pTargetImage[offset] = c;
 	  }

      offset++;
      dx = ptr[offset] - ptr[offset+1];
      dy = ptr[offset] - ptr[offset+m_iWidth];

	  lIndex = offset + m_iWidth*(dy>>3) + (dx>>3);
	  if(lIndex < lBreak && lIndex > 0)
	  {
		  c = pSrcImage[lIndex];// - (dx>>LightModifier);
		  c = GetShiftedColor(c,dx);
	//      temp[offset] = (c < 0) ? 0 : (c > 255) ? 255 : c;
		  pTargetImage[offset] = c;
	  }
 
    }
  }
 
}
inline COLORREF CWaterRoutine::GetShiftedColor(COLORREF color,int shift)
{
	long R;
	long G;
	long B;
	int ir;
	int ig;
	int ib;

	R = GetRValue(color)-shift;
	G = GetGValue(color)-shift;
	B = GetBValue(color)-shift;

	ir = (R < 0) ? 0 : (R > 255) ? 255 : R;
	ig = (G < 0) ? 0 : (G > 255) ? 255 : G;
	ib = (B < 0) ? 0 : (B > 255) ? 255 : B;

	return RGB(ir,ig,ib);
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合久久99| 亚洲精品成人悠悠色影视| 日韩一二三四区| 欧美日韩国产bt| 69堂成人精品免费视频| 欧美色综合网站| 欧美日韩国产色站一区二区三区| 欧美性生活一区| 欧美色国产精品| 91精品国产色综合久久不卡蜜臀 | 国产ts人妖一区二区| 激情综合五月天| 激情另类小说区图片区视频区| 韩国欧美一区二区| 国产成人免费av在线| 99久久夜色精品国产网站| 色偷偷成人一区二区三区91| 欧美亚洲动漫精品| 7777精品伊人久久久大香线蕉完整版 | 尤物在线观看一区| 亚洲福利国产精品| 日韩黄色在线观看| 国产永久精品大片wwwapp| 成人精品免费看| 色8久久人人97超碰香蕉987| 欧美性极品少妇| 日韩午夜电影在线观看| 久久综合久久综合亚洲| 国产精品进线69影院| 亚洲一区二区三区四区五区黄 | 亚洲国产视频a| 蜜臀av在线播放一区二区三区| 国内成人精品2018免费看| 国产成人一区在线| 欧美性生活大片视频| 欧美成人a视频| 国产精品三级电影| 婷婷综合在线观看| 韩国三级中文字幕hd久久精品| 成人va在线观看| 欧美日本不卡视频| 国产日韩欧美精品综合| 夜夜夜精品看看| 黄色精品一二区| 在线中文字幕一区二区| 欧美一级日韩免费不卡| 国产精品乱子久久久久| 肉色丝袜一区二区| 成人h动漫精品| 欧美一区二区三区的| 国产精品美女久久福利网站| 午夜激情一区二区三区| 成人一区二区视频| 91精品国产综合久久国产大片| 国产精品视频线看| 蜜乳av一区二区| 91色在线porny| 久久综合九色综合久久久精品综合| 亚洲欧洲精品一区二区三区不卡| 美女视频一区二区三区| 色婷婷一区二区三区四区| 久久久久亚洲蜜桃| 三级久久三级久久| 91免费观看视频在线| 日韩亚洲电影在线| 亚洲一区在线视频| 成人午夜视频网站| 精品欧美乱码久久久久久1区2区| 一区二区免费看| 大尺度一区二区| 欧美成人a∨高清免费观看| 亚洲一级二级在线| 成人av资源在线| 精品国产91亚洲一区二区三区婷婷| 亚洲综合无码一区二区| 国产精品亚洲а∨天堂免在线| 欧美猛男gaygay网站| 中文字幕一区二区视频| 国产风韵犹存在线视精品| 欧美久久久久久蜜桃| 一级做a爱片久久| 波多野结衣亚洲| 国产欧美精品日韩区二区麻豆天美| 日韩不卡免费视频| 欧美在线不卡一区| 亚洲女同ⅹxx女同tv| 成人精品国产福利| 国产精品嫩草99a| 国产mv日韩mv欧美| 亚洲国产精品激情在线观看| 精彩视频一区二区三区| 日韩午夜激情免费电影| 免费观看91视频大全| 欧美高清hd18日本| 亚洲成人精品一区| 欧美精选午夜久久久乱码6080| 亚洲伊人伊色伊影伊综合网| 91免费在线视频观看| 亚洲欧洲日韩av| 99精品1区2区| 亚洲九九爱视频| 91成人在线精品| 亚洲国产cao| 欧美日韩国产综合久久| 亚洲妇熟xx妇色黄| 制服视频三区第一页精品| 日韩精品成人一区二区三区| 69堂成人精品免费视频| 蜜桃传媒麻豆第一区在线观看| 日韩西西人体444www| 美腿丝袜一区二区三区| 久久嫩草精品久久久精品一| 国产伦精品一区二区三区免费 | 国产色婷婷亚洲99精品小说| 国产乱码精品一区二区三区忘忧草 | voyeur盗摄精品| 日韩美女精品在线| 欧美综合久久久| 日韩影视精彩在线| 日韩美女视频在线| 国产综合一区二区| 中文字幕精品三区| 色婷婷久久久久swag精品| 性做久久久久久久免费看| 7777精品伊人久久久大香线蕉 | 色婷婷综合久久久| 午夜精彩视频在线观看不卡| 欧美一个色资源| 国产不卡视频一区| 一区二区三区在线观看网站| 制服丝袜亚洲色图| 国产福利一区二区三区视频在线| 国产三级精品三级在线专区| 99re这里只有精品视频首页| 亚洲一区二区三区爽爽爽爽爽| 91精品国产免费| 成人综合日日夜夜| 亚洲香肠在线观看| 欧美成人猛片aaaaaaa| 高清成人免费视频| 亚洲午夜在线电影| 欧美精品一区二区久久久| 99re6这里只有精品视频在线观看| 亚洲一区在线观看免费 | 亚洲精品中文字幕在线观看| 欧美一区二区三区视频在线 | 欧美日韩一区二区三区不卡 | 欧美成人欧美edvon| av高清久久久| 青椒成人免费视频| 亚洲桃色在线一区| 日韩欧美在线1卡| 91视频一区二区三区| 美女尤物国产一区| 亚洲精品中文字幕在线观看| 欧美成人a在线| 欧美亚洲国产一区二区三区| 精品亚洲欧美一区| 亚洲一级二级三级在线免费观看| 久久九九影视网| 欧美日韩一二区| 波多野结衣亚洲| 久88久久88久久久| 亚洲国产乱码最新视频| 国产视频一区不卡| 在线成人av网站| 99久精品国产| 国产乱码一区二区三区| 日韩黄色片在线观看| 亚洲婷婷国产精品电影人久久| 日韩欧美久久一区| 欧美性xxxxxxxx| 成人av在线一区二区三区| 麻豆精品视频在线观看视频| 亚洲日本一区二区三区| 久久精品夜夜夜夜久久| 日韩视频永久免费| 欧美丝袜丝nylons| 色综合天天综合网天天看片| 国产一区二区三区四| 免费在线欧美视频| 午夜私人影院久久久久| ...xxx性欧美| 国产婷婷色一区二区三区四区| 日韩欧美国产午夜精品| 欧美日韩日本视频| 欧日韩精品视频| 色婷婷av一区二区三区之一色屋| 成人午夜在线免费| 国产精一品亚洲二区在线视频| 免费观看日韩av| 免费人成在线不卡| 午夜精品在线看| 亚洲大型综合色站| 亚洲一区二区三区四区的| 亚洲精品国久久99热| 亚洲三级在线免费| 亚洲视频香蕉人妖| 亚洲欧美另类小说视频| 亚洲女子a中天字幕|