static LWUV *createUVs(ObjectAccess *acc, LWObjectID obj, LWPoint *normals, LWTexture *tex) { int num_points; pntID i; LWPoint *temp_p, *temp_normals; LWUV *temp_uvs; temp_normals=normals; num_points = (*acc->pointCount)(obj); if( !(temp_uvs = malloc(sizeof(LWUV)*num_points)) ) return temp_uvs; for(i=0;i<num_points;i++) { temp_p = (*acc->pointGet)(obj,i); //temp_p->y = -temp_p->y; /* Changed the following two lines. Can't increment temp_uvs if we're going to use it as the return value. EW 28 Jan 00 TextureUV(tex,temp_p,temp_uvs,temp_normals); temp_uvs++; */ TextureUV(tex,temp_p,&temp_uvs[i],temp_normals); temp_normals++; } return temp_uvs; }
void LandscapeRenderer::BuildUVArray(SurfaceMap2D <double> *_heightMap) { if (m_verts.Size() <= 0) return; int nextUVId = 0; float factorX = 1.0 / _heightMap->m_cellSizeX; float factorZ = 1.0 / _heightMap->m_cellSizeY; for (int i = 0; i < m_strips.Size(); ++i) { LandTriangleStrip *strip = m_strips[i]; int const numVerts = strip->m_numVerts; for (int j = 0; j < numVerts; ++j) { Vector3 const &vert = m_verts[strip->m_firstVertIndex + j].m_pos; float u = vert.x * factorX; float v = vert.z * factorZ; m_verts[nextUVId++].m_uv = TextureUV(u, v); } } AppDebugAssert(nextUVId == m_verts.NumUsed()); }