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

📄 mlrtexture.cpp

📁 机甲指挥官2源代码
💻 CPP
字号:
//===========================================================================//
// Copyright (C) Microsoft Corporation. All rights reserved.                 //
//===========================================================================//

#include "MLRHeaders.hpp"

//#############################################################################
//############################    MLRTexture    ###############################
//#############################################################################

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRTexture::MLRTexture(MemoryStream *stream)
{
	Verify(gos_GetCurrentHeap() == Heap);
	Check_Pointer(this);
	Check_Object(stream);

	hint = 0;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRTexture::MLRTexture(
	MLRTexturePool *tp,
	const char* texName,
	int _instance,
	int handle,
	int _hint
)
{
	Verify(gos_GetCurrentHeap() == Heap);
	thePool = tp;
	textureHandle = handle;

	textureName = texName;

	textureNameHashValue = textureName.GetHashValue();

	instance = _instance;

	textureMatrix = AffineMatrix4D::Identity;
	textureMatrixIsIdentity = true;

	image = thePool->GetImage(textureName);

	hint = _hint;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRTexture::MLRTexture(
	MLRTexturePool *tp,
	GOSImage *_image,
	int handle,
	int _hint
)
{
	Verify(gos_GetCurrentHeap() == Heap);
	thePool = tp;
	textureHandle = handle;

	image = _image;

	textureName = image->GetName();

	textureNameHashValue = textureName.GetHashValue();

	instance = 0;

	textureMatrix = AffineMatrix4D::Identity;
	textureMatrixIsIdentity = true;

	hint = _hint;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLRTexture::TestInstance() const
{
	Verify((*thePool)[textureHandle]);
	Check_Object(image);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRTexture::MLRTexture(const MLRTexture& tex)
{
	Check_Object(&tex);
	Verify(gos_GetCurrentHeap() == Heap);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRTexture::~MLRTexture()
{
	if(NULL==thePool->GetImage(image->GetName()))
	{
		Unregister_Object(image);
		delete image;
	}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRTexture*
	MLRTexture::Make(MemoryStream *stream)
{
	Check_Object(stream);

	gos_PushCurrentHeap(Heap);
	MLRTexture *texture = new MLRTexture(stream);
	gos_PopCurrentHeap();

	return texture;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLRTexture::Save(MemoryStream *stream)
{
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
	MLRTexture::GetImageNumber()
{
	Check_Object(this);
	return ((textureHandle-1) >> (thePool->GetInstanceDepth()));
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
	MLRTexture::GetInstanceNumber()
{
	Check_Object(this);
	return ((textureHandle-1) & ~((1<<thePool->GetInstanceDepth())-1));
}

⌨️ 快捷键说明

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