⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hairguides.cpp

📁 hair solusion, c&#226 cs ádasda
💻 CPP
字号:
#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);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -