double * weightSum = new0 double[nVertices];
PrimitiveGroup group;
- if(Allocate({ normals = true, tangents = true }, nVertices, displaySystem))
+ if(Allocate({ normals = true, tangents = texCoords != null }, nVertices, displaySystem))
{
Vector3Df * normals = this.normals;
Vector3Df * tangents = this.tangents;
Pointf * texCoords = this.texCoords;
FillBytes(normals, 0, nVertices * sizeof(Vector3Df));
- FillBytes(tangents, 0, 2*nVertices * sizeof(Vector3Df));
+ if(tangents)
+ FillBytes(tangents, 0, 2*nVertices * sizeof(Vector3Df));
for(group = groups.first; group; group = group.next)
{
int c;
weightSum[index] += w;
//numShared[index] ++;
- if(texCoords)
+ if(tangents)
{
uint ix0 = index;
uint prev = v ? i - 1 : c + nIndex-1;
for(c = 0; c<nVertices; c++)
{
float s = (float)(1.0 / weightSum[c]); // numShared[c]
- Vector3Df * n = &normals[c], * t1 = &tangents[2*c], * t2 = &tangents[2*c+1];
+ Vector3Df * n = &normals[c];
n->Scale(n, s), n->Normalize(n);
- t1->Scale(t1, s), t1->Normalize(t1);
- t2->Scale(t2, s), t2->Normalize(t2);
+ if(tangents)
+ {
+ Vector3Df * t1 = &tangents[2*c], * t2 = &tangents[2*c+1];
+ t1->Scale(t1, s), t1->Normalize(t1);
+ t2->Scale(t2, s), t2->Normalize(t2);
+ }
}
delete numShared;
delete weightSum;
pNormals[index] = pVertices[index];
- pTangents[index*2] =
+ if(pTangents)
{
- (float) (sin(theta) * cos(omega - Pi/2));
- (float) sin(omega - Pi/2);
- (float) (cos(theta) * cos(omega - Pi/2));
- };
- pTangents[index*2+1] =
- {
- (float) (sin(theta - Pi/2) * cosOmega);
- (float) sin(omega);
- (float) (cos(theta - Pi/2) * cosOmega);
- };
+ pTangents[index*2] =
+ {
+ (float) (sin(theta) * cos(omega - Pi/2));
+ (float) sin(omega - Pi/2);
+ (float) (cos(theta) * cos(omega - Pi/2));
+ };
+ pTangents[index*2+1] =
+ {
+ (float) (sin(theta - Pi/2) * cosOmega);
+ (float) sin(omega);
+ (float) (cos(theta - Pi/2) * cosOmega);
+ };
+ }
//pTangents[index*2 + 1].CrossProduct(pNormals[index], pTangents[index*2]);
pTexCoords[index] = { (float)l / (w-1), (float)lat / (numLat) };
public class CubeMap : Bitmap
{
public:
- void Load(DisplaySystem displaySystem, const String * names, const String extension, bool oldStyle)
+ bool Load(DisplaySystem displaySystem, const String * names, const String extension, bool oldStyle)
{
int i;
- for(i = 0; i < 6; i++)
+ bool result = true;
+ for(i = 0; result && i < 6; i++)
{
char location[MAX_LOCATION];
Bitmap face = i > 0 ? { } : this;
if(face.Load(location, null, null))
{
face.driverData = driverData;
- displaySystem.driver.MakeDDBitmap(displaySystem, face, true, (i + 1) | (oldStyle << 3));
+ result = displaySystem.driver.MakeDDBitmap(displaySystem, face, true, (i + 1) | (oldStyle << 3));
}
+ else
+ result = false;
if(i > 0)
{
face.driverData = 0;
delete face;
}
}
+ return result;
}
};
{
bool result = false;
D3D8System d3dSystem = displaySystem.driverData;
- if(bitmap.Convert(null, pixelFormat888, null))
+ if(cubeMapFace && bitmap.Convert(null, pixelFormat888, null))
{
IDirect3DTexture8 * texture;
uint w = pow2i(Min(bitmap.width, 512)), h = pow2i(Min(bitmap.height, 512));
{
bool result = false;
D3DSystem d3dSystem = displaySystem.driverData;
- if(bitmap.Convert(null, pixelFormat888, null))
+ if(!cubeMapFace && bitmap.Convert(null, pixelFormat888, null))
{
IDirect3DTexture9 * texture;
uint w = pow2i(Min(bitmap.width, 512)), h = pow2i(Min(bitmap.height, 512));