|
From: James D. <ja...@ro...> - 2004-08-30 13:01:15
|
On 27-Aug-04, at 6:32 PM, James W. Walker wrote:
> Sounds like a bug, the question is whether it's Quesa's bug or your
> bug. :-) I tried a quick example of a 32-bit non-alpha texture with a
> transparency color, and it looked reasonable. Maybe you could show us
> the code where you set up the texture from the GWorld.
Might be my bug, I don't know.
I'll have to give a bit of explanation on some stuff... the member
mSourceGWorld is a PowerPlant LGWorld, a wrapper around a GWorld. This
particular instance I get from some code I wrote to decompress an image
file from disk, using QuickTime's ImageCompression components. I've
tried against photoshop format files and tiff files. It seems there's
no GIF decoder in the QuickTime I've got here, so I couldn't test with
those. I set the depth of the GWorld elsewhere, and have tried 16, 24
and 32. The only one that seems to take the transparency colour into
account is the 16-bit depth GWorld-based texture.
mImageGroup is a TQ3Object, the same for m_Q3_display_object.
m_Q3_display_object has been initialized in the super class'
constructor.
Below the following code is the function for creating the rectangle and
assigning the texture coordinates, etc.
Here's the code that creates the texture object and assorted other
components:
Rect theBounds;
mSourceGWorld->GetBounds( theBounds );
// Create the texture
PixMapHandle thePixMap = GetGWorldPixMap(
mSourceGWorld->GetMacGWorld() );
TQ3Mipmap mipmap;
mipmap.pixelType = kQ3PixelTypeUnknown;
switch( (*thePixMap)->pixelFormat )
{
case k32RGBAPixelFormat:
mipmap.pixelType = kQ3PixelTypeRGB32;
mipmap.bitOrder = kQ3EndianBig;
mipmap.byteOrder = kQ3EndianBig;
break;
case k32ARGBPixelFormat:
mipmap.pixelType = kQ3PixelTypeARGB32;
mipmap.bitOrder = kQ3EndianBig;
mipmap.byteOrder = kQ3EndianBig;
break;
case k16BE555PixelFormat:
mipmap.pixelType = kQ3PixelTypeRGB16;
mipmap.bitOrder = kQ3EndianBig;
mipmap.byteOrder = kQ3EndianBig;
break;
case k16BE565PixelFormat:
mipmap.pixelType = kQ3PixelTypeRGB16_565;
mipmap.bitOrder = kQ3EndianBig;
mipmap.byteOrder = kQ3EndianBig;
break;
case k24BGRPixelFormat:
mipmap.pixelType = kQ3PixelTypeRGB24;
mipmap.bitOrder = kQ3EndianBig;
mipmap.byteOrder = kQ3EndianLittle;
break;
}
if( mipmap.pixelType == kQ3PixelTypeUnknown )
{
mValid = false;
return;
}
mipmap.reserved = 0;
mipmap.useMipmapping = kQ3False;
mipmap.mipmaps[0].width = theBounds.right - theBounds.left;
mipmap.mipmaps[0].height = theBounds.bottom - theBounds.top;
mipmap.mipmaps[0].rowBytes = (*thePixMap)->rowBytes & 0x3FFF;
mImageGroup = Q3OrderedDisplayGroup_New();
TQ3TransformObject theTransform = Q3RasterizeCameraTransform_New();
Q3Group_AddObjectAndDispose( mImageGroup, &theTransform );
LockPixels( thePixMap );
unsigned char *thePixels = (unsigned char *)GetPixBaseAddr( thePixMap
);
mipmap.image
= Q3MemoryStorage_New( thePixels, mipmap.mipmaps[0].height *
mipmap.mipmaps[0].rowBytes );
UnlockPixels(thePixMap);
TQ3TextureObject textureObject = Q3MipmapTexture_New( &mipmap );
Q3Object_Dispose( mipmap.image );
TQ3TextureObject textureShader = Q3TextureShader_New( textureObject );
Q3Group_AddObjectAndDispose( mImageGroup, &textureShader );
Q3Object_Dispose( textureObject );
Q3Group_AddObject( m_Q3_display_object, mImageGroup );
----
In the following, mRectangle is a TQ3GeometryObject.
Other function:
if( !mValid ) return;
// Create the 3D rectangle and its attributes
float width = (inRect.right - inRect.left);
float height = (inRect.bottom - inRect.top);
TQ3Point3D vertexPoints[4] = { { 0, 0, 0 },
{ width, 0, 0 },
{ width, height, 0 },
{ 0, height, 0 } };
TQ3Param2D vertexUVs[4] = { { 0, 1.0 },
{ 1.0, 1.0 },
{ 1.0, 0 },
{ 0, 0 } };
TQ3ColorRGB transparency = { 0.5, 0.5, 0.5 };
TQ3Vertex3D theVertices[4];
TQ3PolygonData thePolygonData;
int n;
thePolygonData.numVertices = 4;
thePolygonData.vertices = theVertices;
thePolygonData.polygonAttributeSet = 0;
for( n=0; n<4; n++ )
{
thePolygonData.vertices[n].point = vertexPoints[n];
thePolygonData.vertices[n].attributeSet = Q3AttributeSet_New();
if( thePolygonData.vertices[n].attributeSet != 0 )
{
Q3AttributeSet_Add( thePolygonData.vertices[n].attributeSet,
kQ3AttributeTypeTransparencyColor, &transparency );
Q3AttributeSet_Add( thePolygonData.vertices[n].attributeSet,
kQ3AttributeTypeSurfaceUV, &vertexUVs[n] );
}
}
mRectangle = Q3Polygon_New( &thePolygonData );
if( mRectangle != 0 )
{
Q3Group_AddObject( mImageGroup, mRectangle );
}
for( n=0; n<4; n++ )
{
if( thePolygonData.vertices[n].attributeSet != 0 )
{
Q3Object_Dispose( thePolygonData.vertices[n].attributeSet );
}
}
Thanks,
James
|