1
1
forked from 0ad/0ad

ran newline stomper; no real changes

This was SVN commit r423.
This commit is contained in:
janwas 2004-06-08 12:10:51 +00:00
parent fec51baee5
commit 8d52add5ea
11 changed files with 165 additions and 142 deletions

View File

@ -9,8 +9,8 @@
#include "precompiled.h"
#include "Patch.h"
#include "MiniPatch.h"
#include "Terrain.h"
#include "MiniPatch.h"
#include "Terrain.h"
///////////////////////////////////////////////////////////////////////////////
// Constructor

View File

@ -94,18 +94,18 @@ static CVector3D SkinPoint(const CVector3D& pos,const SVertexBlend& blend,
// SkinPoint: skin the given point using the given blend and matrix data
static CVector3D SkinPoint(const CVector3D& pos,const SVertexBlend& blend,
const CMatrix3D* bonestates)
{
CVector3D result,tmp;
// must have at least one valid bone if we're using SkinPoint
assert(blend.m_Bone[0]!=0xff);
{
CVector3D result,tmp;
// must have at least one valid bone if we're using SkinPoint
assert(blend.m_Bone[0]!=0xff);
const CMatrix3D& m=bonestates[blend.m_Bone[0]];
m.Transform(pos,result);
result*=blend.m_Weight[0];
const CMatrix3D& m=bonestates[blend.m_Bone[0]];
m.Transform(pos,result);
result*=blend.m_Weight[0];
for (int i=1;i<SVertexBlend::SIZE && blend.m_Bone[i]!=0xff;i++) {
const CMatrix3D& m=bonestates[blend.m_Bone[i]];
const CMatrix3D& m=bonestates[blend.m_Bone[i]];
m.Transform(pos,tmp);
result+=tmp*blend.m_Weight[i];
}
@ -233,7 +233,7 @@ void CModel::GenerateBoneMatrices()
if (prop.m_Point->m_BoneIndex!=0xff) {
proptransform.Concatenate(m_BoneMatrices[prop.m_Point->m_BoneIndex]);
} else {
proptransform.Concatenate(transform);
proptransform.Concatenate(transform);
}
prop.m_Model->SetTransform(proptransform);
}
@ -339,7 +339,7 @@ void CModel::SetTransform(const CMatrix3D& transform)
if (prop.m_Point->m_BoneIndex!=0xff) {
proptransform.Concatenate(m_BoneMatrices[prop.m_Point->m_BoneIndex]);
} else {
proptransform.Concatenate(transform);
proptransform.Concatenate(transform);
}
prop.m_Model->SetTransform(proptransform);
}

View File

@ -4,7 +4,7 @@
#include "ObjectManager.h"
#include "Model.h"
#include "ModelDef.h"
#include "CLogger.h"
#include "CLogger.h"
#include "UnitManager.h"
@ -104,12 +104,12 @@ bool CObjectEntry::BuildModel()
CModel* propmodel=oe->m_Model->Clone();
m_Model->AddProp(proppoint,propmodel);
if (oe->m_WalkAnim) propmodel->SetAnimation(oe->m_WalkAnim);
} else {
LOG(ERROR,"Failed to build prop model \"%s\" on actor \"%s\"\n",(const char*) m_Name,(const char*) prop.m_ModelName);
} else {
LOG(ERROR,"Failed to build prop model \"%s\" on actor \"%s\"\n",(const char*) m_Name,(const char*) prop.m_ModelName);
}
}
} else {
LOG(ERROR,"Failed to matching prop point called \"%s\" in model \"%s\"\n",prop.m_PropPointName,(const char*) modelfilename);
} else {
LOG(ERROR,"Failed to matching prop point called \"%s\" in model \"%s\"\n",prop.m_PropPointName,(const char*) modelfilename);
}
}

View File

@ -12,9 +12,9 @@ class CSkeletonAnim;
class CObjectEntry
{
public:
struct Anim {
// constructor
Anim() : m_Speed(1), m_AnimData(0) {}
struct Anim {
// constructor
Anim() : m_Speed(1), m_AnimData(0) {}
// name of the animation - "Idle", "Run", etc
CStr m_AnimName;

View File

@ -8,23 +8,23 @@
#ifndef _PATCH_H
#define _PATCH_H
///////////////////////////////////////////////////////////////////////////////
// Terrain Constants:
//
// PATCH_SIZE: number of tiles in each patch
const int PATCH_SIZE = 16;
// CELL_SIZE: size of each tile in x and z
const int CELL_SIZE = 4;
// HEIGHT_SCALE: vertical scale of terrain - terrain has a coordinate range of
// 0 to 65536*HEIGHT_SCALE
const float HEIGHT_SCALE = 0.35f/256.0f;
///////////////////////////////////////////////////////////////////////////////
// Terrain Constants:
//
// PATCH_SIZE: number of tiles in each patch
const int PATCH_SIZE = 16;
// CELL_SIZE: size of each tile in x and z
const int CELL_SIZE = 4;
// HEIGHT_SCALE: vertical scale of terrain - terrain has a coordinate range of
// 0 to 65536*HEIGHT_SCALE
const float HEIGHT_SCALE = 0.35f/256.0f;
#include "MiniPatch.h"
#include "RenderableObject.h"
class CTerrain;
class CTerrain;
///////////////////////////////////////////////////////////////////////////////
// CPatch: a single terrain patch, PATCH_SIZE tiles square

View File

@ -10,8 +10,8 @@
#ifndef _TERRAIN_H
#define _TERRAIN_H
#include "Patch.h"
#include "Vector3D.h"
#include "Patch.h"
#include "Vector3D.h"
///////////////////////////////////////////////////////////////////////////////
// CTerrain: main terrain class; contains the heightmap describing elevation

View File

@ -1,62 +1,64 @@
#include "ogl.h"
#include "res/tex.h"
#include "TextureEntry.h"
#include "TextureManager.h"
#include "Texture.h"
#include "CLogger.h"
#include "Renderer.h"
/////////////////////////////////////////////////////////////////////////////////////
// CTextureEntry constructor
CTextureEntry::CTextureEntry(const char* name,int type)
: m_Name(name), m_Bitmap(0), m_Handle(0xffffffff), m_BaseColor(0), m_Type(type), m_BaseColorValid(false)
{
}
/////////////////////////////////////////////////////////////////////////////////////
// LoadTexture: actually load the texture resource from file
void CTextureEntry::LoadTexture()
{
CStr pathname("art/textures/terrain/types/");
pathname+=g_TexMan.m_TerrainTextures[m_Type].m_Name;
pathname+='/';
pathname+=m_Name;
CTexture texture;
texture.SetName(pathname);
if (g_Renderer.LoadTexture(&texture,GL_REPEAT)) {
m_Handle=texture.GetHandle();
} else {
m_Handle=0;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BuildBaseColor: calculate the root color of the texture, used for coloring minimap, and store
// in m_BaseColor member
void CTextureEntry::BuildBaseColor()
{
Handle handle=GetHandle();
g_Renderer.BindTexture(0,tex_id(handle));
// get root color for coloring minimap by querying root level of the texture
// (this should decompress any compressed textures for us),
// then scaling it down to a 1x1 size
// - an alternative approach of just grabbing the top level of the mipmap tree fails
// (or gives an incorrect colour) in some cases:
// - suspect bug on Radeon cards when SGIS_generate_mipmap is used
// - any textures without mipmaps
// we'll just take the basic approach here:
int width,height;
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH,&width);
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_HEIGHT,&height);
unsigned char* buf=new unsigned char[width*height*4];
glGetTexImage(GL_TEXTURE_2D,0,GL_BGRA_EXT,GL_UNSIGNED_BYTE,buf);
gluScaleImage(GL_BGRA_EXT,width,height,GL_UNSIGNED_BYTE,buf,
1,1,GL_UNSIGNED_BYTE,&m_BaseColor);
delete[] buf;
m_BaseColorValid=true;
#include "precompiled.h"
#include "ogl.h"
#include "res/tex.h"
#include "TextureEntry.h"
#include "TextureManager.h"
#include "Texture.h"
#include "CLogger.h"
#include "Renderer.h"
/////////////////////////////////////////////////////////////////////////////////////
// CTextureEntry constructor
CTextureEntry::CTextureEntry(const char* name,int type)
: m_Name(name), m_Bitmap(0), m_Handle(0xffffffff), m_BaseColor(0), m_Type(type), m_BaseColorValid(false)
{
}
/////////////////////////////////////////////////////////////////////////////////////
// LoadTexture: actually load the texture resource from file
void CTextureEntry::LoadTexture()
{
CStr pathname("art/textures/terrain/types/");
pathname+=g_TexMan.m_TerrainTextures[m_Type].m_Name;
pathname+='/';
pathname+=m_Name;
CTexture texture;
texture.SetName(pathname);
if (g_Renderer.LoadTexture(&texture,GL_REPEAT)) {
m_Handle=texture.GetHandle();
} else {
m_Handle=0;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BuildBaseColor: calculate the root color of the texture, used for coloring minimap, and store
// in m_BaseColor member
void CTextureEntry::BuildBaseColor()
{
Handle handle=GetHandle();
g_Renderer.BindTexture(0,tex_id(handle));
// get root color for coloring minimap by querying root level of the texture
// (this should decompress any compressed textures for us),
// then scaling it down to a 1x1 size
// - an alternative approach of just grabbing the top level of the mipmap tree fails
// (or gives an incorrect colour) in some cases:
// - suspect bug on Radeon cards when SGIS_generate_mipmap is used
// - any textures without mipmaps
// we'll just take the basic approach here:
int width,height;
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH,&width);
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_HEIGHT,&height);
unsigned char* buf=new unsigned char[width*height*4];
glGetTexImage(GL_TEXTURE_2D,0,GL_BGRA_EXT,GL_UNSIGNED_BYTE,buf);
gluScaleImage(GL_BGRA_EXT,width,height,GL_UNSIGNED_BYTE,buf,
1,1,GL_UNSIGNED_BYTE,&m_BaseColor);
delete[] buf;
m_BaseColorValid=true;
}

View File

@ -3,51 +3,51 @@
#include "res/res.h"
#include "CStr.h"
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// CTextureEntry: class wrapping a terrain texture object; contains various other required
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// CTextureEntry: class wrapping a terrain texture object; contains various other required
// elements - color of minimap, terrain "group" it belongs to, etc
class CTextureEntry
{
public:
CTextureEntry(const char* name,int type);
// accessor - return texture name
const char* GetName() const { return (const char*) m_Name; }
// accessor - get UI bitmap object
void* GetBitmap() const { return m_Bitmap; }
// accessor - set UI bitmap object
void SetBitmap(void* bmp) { m_Bitmap=bmp; }
// accessor - get texture handle
Handle GetHandle() {
if (m_Handle==0xffffffff) LoadTexture();
return m_Handle;
}
// accessor - get mipmap color
u32 GetBaseColor() {
if (!m_BaseColorValid) BuildBaseColor();
return m_BaseColor;
}
// accessor - return texture type
int GetType() const { return m_Type; }
private:
// load texture from file
void LoadTexture();
// calculate the root color of the texture, used for coloring minimap
void BuildBaseColor();
// filename
CStr m_Name;
// UI bitmap object
void* m_Bitmap;
const char* GetName() const { return (const char*) m_Name; }
// accessor - get UI bitmap object
void* GetBitmap() const { return m_Bitmap; }
// accessor - set UI bitmap object
void SetBitmap(void* bmp) { m_Bitmap=bmp; }
// accessor - get texture handle
Handle GetHandle() {
if (m_Handle==0xffffffff) LoadTexture();
return m_Handle;
}
// accessor - get mipmap color
u32 GetBaseColor() {
if (!m_BaseColorValid) BuildBaseColor();
return m_BaseColor;
}
// accessor - return texture type
int GetType() const { return m_Type; }
private:
// load texture from file
void LoadTexture();
// calculate the root color of the texture, used for coloring minimap
void BuildBaseColor();
// filename
CStr m_Name;
// UI bitmap object
void* m_Bitmap;
// handle to GL texture data
Handle m_Handle;
// BGRA color of topmost mipmap level, for coloring minimap
u32 m_BaseColor;
// above color valid?
u32 m_BaseColor;
// above color valid?
bool m_BaseColorValid;
// "type" of texture - index into TextureManager texturetypes array
int m_Type;

View File

@ -68,13 +68,13 @@ CTextureEntry* CTextureManager::AddTexture(const char* filename,int type)
{
assert((uint)type<m_TerrainTextures.size());
// create new texture entry
CTextureEntry* texentry=new CTextureEntry(filename,type);
// add entry to list ..
m_TerrainTextures[type].m_Textures.push_back(texentry);
return texentry;
// create new texture entry
CTextureEntry* texentry=new CTextureEntry(filename,type);
// add entry to list ..
m_TerrainTextures[type].m_Textures.push_back(texentry);
return texentry;
}
void CTextureManager::DeleteTexture(CTextureEntry* entry)

View File

@ -18,6 +18,7 @@ void CRadioButton::HandleMessage(const SGUIMessage &Message)
switch (Message.type)
{
case GUIM_PRESSED:
{ // janwas added scoping to squelch ICC var decl warning
for (vector_pObjects::iterator it = GetParent()->ChildrenItBegin(); it != GetParent()->ChildrenItEnd(); ++it)
{
// Notice, if you use other objects within the parent object that has got
@ -30,6 +31,7 @@ void CRadioButton::HandleMessage(const SGUIMessage &Message)
//GetGUI()->TEMPmessage = "Check box " + string((const TCHAR*)m_Name) + " was " + (m_Settings.m_Checked?"checked":"unchecked");
break;
}
default:
break;

View File

@ -81,6 +81,25 @@ STMT(\
)
#endif
// useful because VC6 returns 0 on failure, instead of throwing.
// causes calling function to return a negative error code on failure.
#define SAFE_NEW(type, ptr)\
type* ptr;\
try\
{\
ptr = new type();\
}\
catch(std::bad_alloc)\
{\
ptr = 0;\
}\
if(!ptr)\
return ERR_NO_MEM;
enum LibError
{
ERR_INVALID_HANDLE = -1000,