|
From: Keith W. <kw...@cs...> - 2004-06-30 03:58:40
|
I'm trying to create trimeshes from scratch, by reading descriptions
from a home-grown file format (a terrain file format of my own design,
basically just grayscale extrusion values for a grid of vertices).
Obviously, I need geometry and texture. I have had complete success
with the geometry, it works perfectly. I can make a trimesh easily
enough (using Queeg's QGTriMesh class). However, I want to add a
texture to the trimesh. I don't have any particular affinity for
Nanosaur in this regard but it is the only existing template I have to
work from, so I'm trying to adapt the relevant code.
First of all, aside from the way I show below, is there some other way
to create a texture and then attach it to a trimesh? I'm not sure what
my options are for either creating textures or for associating them with
particular trimeshes.
Second, I am getting the following three errors which suggest I can't
use Nanosaur's method in the first place:
Error : undefined identifier 'Q3MemoryStorage_New'
QGTriMesh.cpp line 140 emoryStorage_New((unsigned
char*)blankTextureArray, textureDim * textureDim * 2);
Error : undefined identifier 'Q3MipmapTexture_New'
QGTriMesh.cpp line 151 TQ3TextureObject texture =
Q3MipmapTexture_New(&mipMap);
Error : undefined identifier 'Q3TextureShader_New'
QGTriMesh.cpp line 152 TQ3SurfaceShaderObject shader =
Q3TextureShader_New(texture);
Here is my code (acting on an existing just-made trimeshdata object.
this code is just added to the QGTriMesh ctor):
unsigned short* blankTextureArray = new unsigned
short[textureDim * textureDim];
TQ3Mipmap mipMap;
mipMap.image = Q3MemoryStorage_New((unsigned
char*)blankTextureArray, textureDim * textureDim * 2);
mipMap.useMipmapping = kQ3False; //Just one layer of
mipmaps (basically a pixmap)
mipMap.pixelType = kQ3PixelTypeRGB16;
mipMap.bitOrder = kQ3EndianBig;
mipMap.byteOrder = kQ3EndianBig;
mipMap.reserved = nil;
mipMap.mipmaps[0].width = textureDim;
mipMap.mipmaps[0].height = textureDim;
mipMap.mipmaps[0].rowBytes = textureDim * 2;
mipMap.mipmaps[0].offset = 0;
TQ3TextureObject texture = Q3MipmapTexture_New(&mipMap);
TQ3SurfaceShaderObject shader = Q3TextureShader_New(texture);
Q3Object_Dispose(texture);
Q3Object_Dispose(mipMap.image);
Q3AttributeSet_Add(mTriMeshData.triMeshAttributeSet,
kQ3AttributeTypeSurfaceShader, &shader);
Q3Object_Dispose(shader);
________________________________________________________________________
Keith Wiley kw...@cs...
http://www.unm.edu/~keithw http://www.mp3.com/KeithWiley
"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
-- Edwin A. Abbott, Flatland
________________________________________________________________________
|