Ich habe den fehler eingekreist:
Nur da brauche ich wirklich Hilfe!
void CBumpmapMgr::RenderLight(int light)
{
// get a ptr to the light in question
bumplight_t* pLight = &m_aBumpedScenes[light];
if (!pLight->enabled)
return;
// calculate the movewith
if (pLight->moveWithEnt)
{
// first, adjust the light's position by any change that the movewith entity has undergone
pLight->pos = pLight->origPos + (pLight->moveWithEnt->origin - pLight->entOrigPos);
// rotate the light around the movewith entity by any change in its angles
Vector anglesChange = pLight->moveWithEnt->angles - pLight->entOrigAngles;
Vector newPos = pLight->pos - pLight->moveWithEnt->origin;
newPos = RotateZ(newPos, -anglesChange.y);
newPos = RotateY(newPos, -anglesChange.x);
newPos = RotateX(newPos, -anglesChange.z);
newPos = newPos + pLight->moveWithEnt->origin;
pLight->pos = newPos;
}
float styleStrength = (float)(g_LightStyles[pLight->style][(int)(gpGlobals->time * 10) % strlen(g_LightStyles[pLight->style])] - 'a') / ('z' - 'a');
if (styleStrength == 0)
return;
// bind the right fragment program and set the parameters
cgGLBindProgram(m_fp_Bump);
cgGLSetParameter1f(m_parm_BumpLightStrength, pLight->strength * styleStrength);
cgGLSetParameter3fv(m_parm_BumpLightColour, pLight->colour);
// bind the normalisation cube map to tex unit 1
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_RECTANGLE_NV);
glDisable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, m_uiNormCubeMap);
// bind the attenuation map to tex unit 2
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_3D_EXT);
glBindTexture(GL_TEXTURE_3D_EXT, m_uiAttenuationMap);
// normal maps will be bound to tex unit 0
glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_RECTANGLE_NV);
glEnable(GL_TEXTURE_2D);
// create a bunch of variables
model_t* pWorld = gEngfuncs.GetEntityByIndex(0)->model; // worldspawn model
msurface_t** pSurf = pWorld->marksurfaces; // ptr to array of surfaces
glpoly_t* pPoly;
Vector N, T, B, L, L2, V, V1, V2, V3, E1, E2, AttenCoords;
TexNormalMaps_It texID;
glShadeModel(GL_SMOOTH);
// go through each surface
for (int i = 0; i < pWorld->nummarksurfaces; i++)
{
// This is a semi-hack to use the pre-calculated visibilty info. We don't have access
// to what the current visframe is, but we can assume that the surfaces with the highest
// visframe are those which are currently being rendered. If the visframe changes, then
// there might be more overdraw for one frame, but this isn't noticeable.
//
// To stop surfaces being rendered twice (which is disastrous, since we are using additive
// blending) we set the visframe to the negative value of itself once we've rendered the surface.
// If we then find a surface that has a negative visframe, we know that we've already
// rendered that one.
if (pSurf[i]->visframe > 0 && pSurf[i]->visframe >= m_iLargestVisFrame)
{
m_iLargestVisFrame = pSurf[i]->visframe;
pPoly = pSurf[i]->polys;
float* vert = pPoly->verts[0];
// find the normal map corresponding to this surface's texture (use the flat map if there isn't one)
texID = m_aNormalMaps.find(pSurf[i]->texinfo->texture->gl_texturenum);
if (CVAR_GET_FLOAT("bm_allflat") == 1 || texID == m_aNormalMaps.end())
glBindTexture(GL_TEXTURE_2D, m_uiFlatSurfaceNorm);
else
glBindTexture(GL_TEXTURE_2D, texID->second);
// tangent and binormal simply come from the UV vectors
T = pSurf[i]->texinfo->vecs[0];
B = pSurf[i]->texinfo->vecs[1];
T = T.Normalize();
B = B.Normalize();
// We must now calculate the normal of the surface. We can't cross-product the tangent and binormal,
// as we can't guarantee which way the normal will be facing (textures can be mirrored both ways).
// So, we must calculate it by doing the cross product of two edge vectors. However, we can't just
// choose any old edge vectors, since some turn out to be colinear, which gives bogus normals.
// The solution is to go through each vertex until we find two edge vectors that aren't colinear.
V1 = Vector(vert[0], vert[1], vert[2]);
V2 = Vector(vert[VERTEXSIZE], vert[VERTEXSIZE+1], vert[VERTEXSIZE+2]);
E1 = (V1 - V2).Normalize();
bool bFound = false;
for (int j = 2; j < pPoly->numverts; j++)
{
V3 = Vector(vert[VERTEXSIZE*j], vert[VERTEXSIZE*j + 1], vert[VERTEXSIZE*j + 2]);
E2 = (V1 - V3).Normalize();
if (fabs(fabs(DotProduct(E1, E2))-1) > 0.01f) // vectors aren't colinear (dp 1 = equal, dp -1 = opposite) - check for > epsilon to account for FP error
{
N = -1 * CrossProduct(E1, E2).Normalize(); // we can use these edge vectors to calculate the normal
bFound = true;
break;
}
}
if (!bFound)
N = -1 * CrossProduct(E1, (V1 - Vector(vert + VERTEXSIZE*2)).Normalize()).Normalize();
// render this surface
glBegin(GL_POLYGON);
for (int v = 0; v < pPoly->numverts; v++, vert+=VERTEXSIZE)
{
// Since we can't use a vertex program, we have to calculate the light vector here. We first
// calculate the light vector in world space, and then transform it into tangent space
// by doing the equivalent of multiplying it by the TBN matrix, and finally scale it into the range [0,1].
V = Vector(vert);
L = pLight->pos - V;
L2.x = DotProduct(T, L)*0.5 + 0.5;
L2.y = -DotProduct(B, L)*0.5 + 0.5; // for some reason, the y component of the light vector must be flipped - probably a by-product of the normal maps being flipped on loading
L2.z = DotProduct(N, L)*0.5 + 0.5;
// We also have to calculate the coordinates in the attenuation texture
AttenCoords = (L / (pLight->radius * 2)) + Vector(0.5,0.5,0.5);
// send the data to OGL
glTexCoord2f(vert[3], 1 - vert[4]); // the normal maps get flipped on loading, for some reason - reverse that here
glMultiTexCoord3fvARB(GL_TEXTURE1_ARB, L2);
glMultiTexCoord3fvARB(GL_TEXTURE2_ARB, AttenCoords);
glVertex3fv(vert);
}
glEnd();
}
// set the negative visframe to say we've rendered this surface
if (pSurf[i]->visframe > 0)
pSurf[i]->visframe = -pSurf[i]->visframe;
}
// go back and make all visframes positive again, so that HL can render the map properly
for (i = 0; i < pWorld->nummarksurfaces; i++)
{
if (pSurf[i]->visframe < 0)
pSurf[i]->visframe = -pSurf[i]->visframe;
}
glActiveTextureARB(GL_TEXTURE2_ARB);
glDisable(GL_TEXTURE_3D_EXT);
glActiveTextureARB(GL_TEXTURE0_ARB);
}
als ich disses stück entfert hatte war der fehler weg. waren nur 39 "Nichtaufgeloestes externes Symbol" ist aber klar da es gefehlt hat.
kann mir bitte jemand sagen was ich noch ändern muss...