?? hairguides.cpp
字號(hào):
#include "Hair.h"
#include "HairGuides.h"
#include <stdio.h>
HairGuides::HairGuides()
{
pDecal = NULL;
HairList = NULL;
TotalHairs = 0;
// pHairDisplayID = NULL;
HairDisplayID = 0;
}
HairGuides::~HairGuides()
{
DeleteHairList();
}
void HairGuides::DeleteHairList()
{
if (HairList)
delete[] HairList;
}
void HairGuides::Draw()
{
GLuint i;
for (i = 0; i < TotalHairs; i++)
HairList[i].Draw();
}
void HairGuides::SetTextureInfo(Decal *pInput)
{
pDecal = pInput;
}
void HairGuides::SetUpHairList(int skip)
{
if (pDecal)
{
int i = 0;
int j = 0;
GLuint x = 0;
GLuint y = 0;
GLuint temptotal = 0;
GLuint CurrentHair = 0;
int xcount = 1 + pDecal->nPixelTextureWidth / skip;
int ycount = 1 + pDecal->nPixelTextureHeight / skip;
// int xcount = pDecal->nPixelTextureWidth / skip;
// int ycount = pDecal->nPixelTextureHeight / skip;
int xmod = pDecal->nPixelTextureWidth % skip;
int ymod = pDecal->nPixelTextureHeight % skip;
if (xmod)
xcount++;
if (ymod)
ycount++;
temptotal = xcount * ycount;
if ( TotalHairs != temptotal )
{
TotalHairs = temptotal;
DeleteHairList();
HairList = new Hair[TotalHairs];
}
// printf("width = %4d, height = %4d, xcount = %4d, ycount = %4d\n", pDecal->nPixelTextureWidth, pDecal->nPixelTextureHeight, xcount, ycount);
/**/
CurrentHair = 0;
y = 0;
for (j = 0; j < ycount; j++)
{
if (y >= pDecal->nPixelTextureHeight)
y = pDecal->nPixelTextureHeight;
x = 0;
for (i = 0; i < xcount; i++)
{
if (x >= pDecal->nPixelTextureWidth)
x = pDecal->nPixelTextureWidth;
// HairList[CurrentHair].CreateDisplayList(pHairDisplayID);
HairList[CurrentHair].CreateDisplayList(&HairDisplayID);
HairList[CurrentHair].SetTextureInfo(pDecal);
HairList[CurrentHair].SetPixelPos(x, y);
// printf("x, y = %4d, %4d\n", x, y);
x += skip;
CurrentHair++;
}
y += skip;
}
/**/
}
}
void HairGuides::SetPixelSpacing(int spacing)
{
SetUpHairList(spacing);
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -