Am Montag, 21. Mai 2007 schrieb Dennis Schridde: > Am Sonntag, 20. Mai 2007 schrieb The Watermelon: > > On 5/20/07, Dennis Schridde <[EMAIL PROTECTED]> wrote: > > > Am Sonntag, 20. Mai 2007 schrieb The Watermelon: > > > > On 5/20/07, Per Inge Mathisen <[EMAIL PROTECTED]> wrote: > > > > > On 5/19/07, Kamaze <[EMAIL PROTECTED]> wrote: > > > > > > I would be suprised if you find a common file format which > > > > > > supports connectors. > > > > > > > > > > Common or not, Quake III's MD3 file format supports connectors. It > > > > > also supports animations, which we also need. However, like most > > > > > formats, it stores triangles, instead of polygons (quads) like PIE > > > > > files do. > > > > > > > > > > We cannot change the 3D data format as long as we need a program to > > > > > post-process the 3D data, and we do not yet have a replacement for > > > > > PIE-slicer. > > > > > > > > > > - Per > > > > > > > > yes,the triangle is one of the problems,I think pumpkin created their > > > > > > own > > > > > > > 3d format simply because the 3dmax? format didnt meet their/warzone's > > > > needs.With the pie float point support added,we should be able to > > > > make 'lossless' pie-import script/program for other mainstream 3d > > > > formats > > > > > > like > > > > > > > blender's. > > > > > > > > Anyways,updated the patch devurandom adapted: > > > > > > > > 1.removed the changes to pie_matrix.h,since it's a mistake/old > > > > revision merge problem > > > > > > r1305 > > > > 1.removed the commented-out memcpy > > 2.removed Vector3d and changed all instances of Vector3d back to Vector3f > > r1315 > Solved a few merging problems and tried to reduce the number of changes.
r1316 Resolved conflicts. vertexPos and position seems to be mixed up sometimes... (Eg. both .sx and .x are turned into vertexPos.x)
Index: src/structure.c =================================================================== --- src/structure.c (revision 1313) +++ src/structure.c (working copy) @@ -3956,7 +3956,8 @@ { UDWORD widthScatter,breadthScatter; UDWORD percentDamage, emissionInterval, iPointsToAdd, iPointsRequired; - Vector3i dv; + Vector3i dv; + Vector3i tmpVector3i; ASSERT( psBuilding != NULL, "structureUpdate: Invalid Structure pointer" ); @@ -4078,7 +4079,8 @@ UDWORD pointIndex; pointIndex = rand()%(psBuilding->sDisplay.imd->npoints-1); - point = &(psBuilding->sDisplay.imd->points[pointIndex]); + tmpVector3i = Vector3fToVector3i(psBuilding->sDisplay.imd->points[pointIndex]); + point = &tmpVector3i; position.x = psBuilding->x + point->x; realY = MAKEINT((structHeightScale(psBuilding) * point->y)); position.y = psBuilding->z + realY; Index: src/display3d.c =================================================================== --- src/display3d.c (revision 1316) +++ src/display3d.c (working copy) @@ -256,7 +256,7 @@ //UDWORD averageHeight; /* temporary buffer used for flattening IMDs */ -static Vector3i alteredPoints[iV_IMD_MAX_POINTS]; +static Vector3f alteredPoints[iV_IMD_MAX_POINTS]; //number of tiles visible UDWORD visibleXTiles; @@ -733,11 +733,6 @@ else if(playerZTile+i > (SDWORD)(mapHeight-1) ) edgeY = mapHeight-1; - tileScreenInfo[i][j].x = world_coord(j-terrainMidX); - tileScreenInfo[i][j].y = 0;//map_TileHeight(edgeX,edgeY); - tileScreenInfo[i][j].z = world_coord(terrainMidY-i); - tileScreenInfo[i][j].sz = pie_RotateProject((Vector3i*)&tileScreenInfo[i][j].x, (Vector2i*)&tileScreenInfo[i][j].sx); - if (pie_GetFogEnabled()) { tileScreenInfo[i][j].light.argb = 0xff030303; @@ -745,7 +740,7 @@ } else { - tileScreenInfo[i][j].light.argb = lightDoFogAndIllumination( mapTile(edgeX, edgeY)->illumination, rx - tileScreenInfo[i][j].x, rz - world_coord(i - terrainMidY), &specular ); + tileScreenInfo[i][j].light.argb = lightDoFogAndIllumination( mapTile(edgeX, edgeY)->illumination, rx - tileScreenInfo[i][j].vertexPos.x, rz - world_coord(i - terrainMidY), &specular ); } if( playerXTile+j < -1 || @@ -766,14 +761,14 @@ psTile = mapTile(playerXTile+j, playerZTile+i); /* Get a pointer to the tile at this location */ - tileScreenInfo[i][j].x = world_coord(j-terrainMidX); + tileScreenInfo[i][j].vertexPos.x = world_coord(j - terrainMidX); if (TERRAIN_TYPE(psTile) == TER_WATER) { tileScreenInfo[i][j].bWater = TRUE; } - tileScreenInfo[i][j].y = map_TileHeight(playerXTile+j, playerZTile+i); - tileScreenInfo[i][j].z = world_coord(terrainMidY-i); + tileScreenInfo[i][j].vertexPos.y = map_TileHeight(playerXTile+j, playerZTile+i); + tileScreenInfo[i][j].vertexPos.z = world_coord(terrainMidY - i); /* Is it in the centre and therefore worth averaging height over? */ if ( i > MIN_TILE_Y && @@ -781,7 +776,7 @@ j > MIN_TILE_X && j < MAX_TILE_X ) { - averageCentreTerrainHeight += tileScreenInfo[i][j].y; + averageCentreTerrainHeight += tileScreenInfo[i][j].vertexPos.y; numTilesAveraged++; } realX = playerXTile+j; @@ -827,38 +822,36 @@ PushedDown = TRUE; shiftVal = WATER_DEPTH + environGetData(playerXTile+j, playerZTile+i) * 1.5f; altVal = 0;//environGetValue(playerXTile+j,playerZTile+i); - tileScreenInfo[i][j].y -= shiftVal + altVal; + tileScreenInfo[i][j].vertexPos.y -= shiftVal + altVal; // And darken it. TileIllum = (UBYTE)(TileIllum * 0.75f); } - tileScreenInfo[i][j].sz = pie_RotateProject((Vector3i*)&tileScreenInfo[i][j], (Vector2i*)&tileScreenInfo[i][j].sx); - - tileScreenInfo[i][j].light.argb = lightDoFogAndIllumination(TileIllum, rx - tileScreenInfo[i][j].x, rz - world_coord(i-terrainMidY), &specular); - + tileScreenInfo[i][j].position.z = pie_RotateProject((Vector3i*)&tileScreenInfo[i][j].vertexPos, (Vector2i*)&tileScreenInfo[i][j].position); + tileScreenInfo[i][j].light.argb = lightDoFogAndIllumination(TileIllum, rx - tileScreenInfo[i][j].vertexPos.x, rz - world_coord(i - terrainMidY), &specular); tileScreenInfo[i][j].specular.argb = specular; // If it's any water tile.. if(IsWaterTile) { // If it's the main water tile then bring it back up because it was pushed down for the river bed calc. - tmp_y = tileScreenInfo[i][j].y; + tmp_y = tileScreenInfo[i][j].vertexPos.y; if (PushedDown) { //TextNum == WaterTileID) { - tileScreenInfo[i][j].y += (shiftVal + 2*altVal); + tileScreenInfo[i][j].vertexPos.y += shiftVal + 2*altVal; } // Transform it into the wx,wy mesh members. - tileScreenInfo[i][j].wz = pie_RotateProject((Vector3i*)&tileScreenInfo[i][j], (Vector2i*)&tileScreenInfo[i][j].wx); + tileScreenInfo[i][j].waterPos.z = pie_RotateProject((Vector3i*)&tileScreenInfo[i][j].vertexPos, (Vector2i*)&tileScreenInfo[i][j].waterPos); tileScreenInfo[i][j].wlight.argb = lightDoFogAndIllumination( - TileIllum, rx - tileScreenInfo[i][j].x, rz - world_coord(i-terrainMidY), &specular); - tileScreenInfo[i][j].water_height = tileScreenInfo[i][j].y; - tileScreenInfo[i][j].y = tmp_y; + TileIllum, rx - tileScreenInfo[i][j].vertexPos.x, rz - world_coord(i - terrainMidY), &specular); + tileScreenInfo[i][j].water_height = tileScreenInfo[i][j].vertexPos.y; + tileScreenInfo[i][j].vertexPos.y = tmp_y; } else { // If it was'nt a water tile then need to ensure wx,wy are valid because // a water tile might be sharing verticies with it. - tileScreenInfo[i][j].wx = tileScreenInfo[i][j].sx; - tileScreenInfo[i][j].wy = tileScreenInfo[i][j].sy; - tileScreenInfo[i][j].wz = tileScreenInfo[i][j].sz; - tileScreenInfo[i][j].water_height = tileScreenInfo[i][j].y; + tileScreenInfo[i][j].waterPos.x = tileScreenInfo[i][j].vertexPos.x; + tileScreenInfo[i][j].waterPos.y = tileScreenInfo[i][j].vertexPos.y; + tileScreenInfo[i][j].waterPos.z = tileScreenInfo[i][j].vertexPos.z; + tileScreenInfo[i][j].water_height = tileScreenInfo[i][j].vertexPos.y; } } } @@ -899,9 +892,9 @@ tileIJ[i][j].i = i; tileIJ[i][j].j = j; //get distance of furthest corner - zMax = MAX(tileScreenInfo[i][j].sz, tileScreenInfo[i+1][j].sz); - zMax = MAX(zMax, tileScreenInfo[i+1][j+1].sz); - zMax = MAX(zMax, tileScreenInfo[i][j+1].sz); + zMax = MAX(tileScreenInfo[i][j].position.z, tileScreenInfo[i+1][j].position.z); + zMax = MAX(zMax, tileScreenInfo[i+1][j+1].position.z); + zMax = MAX(zMax, tileScreenInfo[i][j+1].position.z); tileIJ[i][j].depth = zMax; if( (UDWORD)i > mapHeight || (UDWORD)j > mapWidth ) { @@ -1725,7 +1718,7 @@ SDWORD rotation; UDWORD brightness, specular; Vector3i dv; - Vector3i *vecTemp; + Vector3f *vecTemp; BOOL bForceDraw = ( !getRevealStatus() && psFeature->psStats->visibleAtStart); int shadowFlags = 0; @@ -1961,7 +1954,7 @@ Vector3i dv; SDWORD i; iIMDShape *lImd = NULL, *imd = NULL; - Vector3i *temp = NULL; + Vector3f *temp = NULL; BOOL bHitByElectronic = FALSE; iIMDShape *pRepImd; REPAIR_FACILITY *psRepairFac = NULL; @@ -2026,7 +2019,7 @@ SDWORD strHeight; // Get a copy of the points - memcpy( alteredPoints, imd->points, imd->npoints * sizeof(Vector3i) ); + memcpy( alteredPoints, imd->points, imd->npoints * sizeof(Vector3f) ); // Get the height of the centre point for reference strHeight = psStructure->z;//map_Height(structX,structY) + 64; @@ -2466,7 +2459,7 @@ { Vector3i dv; SDWORD x, y, r; - Vector3i *temp = NULL; + Vector3f *temp = NULL; // SDWORD centreX, centreZ; SDWORD buildingBrightness, specular; //store the frame number for when deciding what has been clicked on @@ -2536,7 +2529,7 @@ SDWORD rotation; Vector3i dv; UDWORD i; - Vector3i *temp; + Vector3f *temp; UDWORD buildingBrightness, specular; // HACK to be able to use static shadows for walls // We just store a separate IMD for each direction @@ -2699,8 +2692,8 @@ /* renderShadow: draws shadow under droid */ void renderShadow( DROID *psDroid, iIMDShape *psShadowIMD ) { - Vector3i dv; - Vector3i *pVecTemp; + Vector3i dv; + Vector3f *pVecTemp; SDWORD shadowScale; UDWORD brightness, specular; // SDWORD centreX, centreZ; @@ -4028,20 +4021,20 @@ { bWaterTile = tileScreenInfo[i][j].bWater; - tileZ = (bWaterTile ? tileScreenInfo[i][j].wz : tileScreenInfo[i][j].sz); + tileZ = (bWaterTile ? tileScreenInfo[i][j].waterPos.z : tileScreenInfo[i][j].position.z); if(tileZ<=nearestZ) { - quad.coords[0].x = (bWaterTile ? tileScreenInfo[i][j].wx : tileScreenInfo[i][j].sx); - quad.coords[0].y = (bWaterTile ? tileScreenInfo[i][j].wy : tileScreenInfo[i][j].sy); + quad.coords[0].x = (bWaterTile ? tileScreenInfo[i][j].waterPos.x : tileScreenInfo[i][j].position.x); + quad.coords[0].y = (bWaterTile ? tileScreenInfo[i][j].waterPos.y : tileScreenInfo[i][j].position.y); - quad.coords[1].x = (bWaterTile ? tileScreenInfo[i][j+1].wx : tileScreenInfo[i][j+1].sx); - quad.coords[1].y = (bWaterTile ? tileScreenInfo[i][j+1].wy : tileScreenInfo[i][j+1].sy); + quad.coords[1].x = (bWaterTile ? tileScreenInfo[i][j+1].waterPos.x : tileScreenInfo[i][j+1].position.x); + quad.coords[1].y = (bWaterTile ? tileScreenInfo[i][j+1].waterPos.y : tileScreenInfo[i][j+1].position.y); - quad.coords[2].x = (bWaterTile ? tileScreenInfo[i+1][j+1].wx : tileScreenInfo[i+1][j+1].sx); - quad.coords[2].y = (bWaterTile ? tileScreenInfo[i+1][j+1].wy :tileScreenInfo[i+1][j+1].sy); + quad.coords[2].x = (bWaterTile ? tileScreenInfo[i+1][j+1].waterPos.x : tileScreenInfo[i+1][j+1].position.x); + quad.coords[2].y = (bWaterTile ? tileScreenInfo[i+1][j+1].waterPos.y :tileScreenInfo[i+1][j+1].position.y); - quad.coords[3].x = (bWaterTile ? tileScreenInfo[i+1][j].wx: tileScreenInfo[i+1][j].sx); - quad.coords[3].y = (bWaterTile ? tileScreenInfo[i+1][j].wy: tileScreenInfo[i+1][j].sy); + quad.coords[3].x = (bWaterTile ? tileScreenInfo[i+1][j].waterPos.x: tileScreenInfo[i+1][j].position.x); + quad.coords[3].y = (bWaterTile ? tileScreenInfo[i+1][j].waterPos.y: tileScreenInfo[i+1][j].position.y); /* We've got a match for our mouse coords */ if(inQuad(&pt,&quad)) @@ -4146,7 +4139,7 @@ "flattenImd: too many points in the PIE to flatten it" ); /* Get a copy of the points */ - memcpy(alteredPoints,imd->points,imd->npoints*sizeof(Vector3i)); + memcpy(alteredPoints, imd->points, imd->npoints * sizeof(Vector3f)); /* Get the height of the centre point for reference */ centreHeight = map_Height(structX,structY); @@ -4372,41 +4365,61 @@ /* Check for rotations and flips - this sets up the coordinates for texturing */ flipsAndRots(tileNumber & ~TILE_NUMMASK); - tileScreenInfo[i+0][j+0].tu = (UWORD)(psP1->x + offset.x); - tileScreenInfo[i+0][j+0].tv = (UWORD)(psP1->y + offset.y); + tileScreenInfo[i+0][j+0].tu = (float)(psP1->x + offset.x); + tileScreenInfo[i+0][j+0].tv = (float)(psP1->y + offset.y); - tileScreenInfo[i+0][j+1].tu = (UWORD)(psP2->x + offset.x); - tileScreenInfo[i+0][j+1].tv = (UWORD)(psP2->y + offset.y); + tileScreenInfo[i+0][j+1].tu = (float)(psP2->x + offset.x); + tileScreenInfo[i+0][j+1].tv = (float)(psP2->y + offset.y); - tileScreenInfo[i+1][j+1].tu = (UWORD)(psP3->x + offset.x); - tileScreenInfo[i+1][j+1].tv = (UWORD)(psP3->y + offset.y); + tileScreenInfo[i+1][j+1].tu = (float)(psP3->x + offset.x); + tileScreenInfo[i+1][j+1].tv = (float)(psP3->y + offset.y); - tileScreenInfo[i+1][j+0].tu = (UWORD)(psP4->x + offset.x); - tileScreenInfo[i+1][j+0].tv = (UWORD)(psP4->y + offset.y); + tileScreenInfo[i+1][j+0].tu = (float)(psP4->x + offset.x); + tileScreenInfo[i+1][j+0].tv = (float)(psP4->y + offset.y); /* The first triangle */ - memcpy(&vertices[0], &tileScreenInfo[i+0][j+0], sizeof(PIEVERTEX)); - memcpy(&vertices[1], &tileScreenInfo[i+0][j+1], sizeof(PIEVERTEX)); + vertices[0].vertexPos = Vector3iToVector3f(tileScreenInfo[i+0][j+0].vertexPos); + vertices[0].u = tileScreenInfo[i+0][j+0].tu; + vertices[0].v = tileScreenInfo[i+0][j+0].tv; + vertices[0].light = tileScreenInfo[i+0][j+0].light; + vertices[0].specular = tileScreenInfo[i+0][j+0].specular; + + vertices[1].vertexPos = Vector3iToVector3f(tileScreenInfo[i+0][j+1].vertexPos); + vertices[1].u = tileScreenInfo[i+0][j+1].tu; + vertices[1].v = tileScreenInfo[i+0][j+1].tv; + vertices[1].light = tileScreenInfo[i+0][j+1].light; + vertices[1].specular = tileScreenInfo[i+0][j+1].specular; + if (onWaterEdge) { - vertices[0].sy = tileScreenInfo[i+0][j+0].water_height; - vertices[1].sy = tileScreenInfo[i+0][j+1].water_height; + vertices[0].vertexPos.y = tileScreenInfo[i+0][j+0].water_height; + vertices[1].vertexPos.y = tileScreenInfo[i+0][j+1].water_height; } if (TRI_FLIPPED(psTile)) { - memcpy(&vertices[2], &tileScreenInfo[i+1][j+0], sizeof(PIEVERTEX)); + vertices[2].vertexPos = Vector3iToVector3f(tileScreenInfo[i+1][j+0].vertexPos); + vertices[2].u = tileScreenInfo[i+1][j+0].tu; + vertices[2].v = tileScreenInfo[i+1][j+0].tv; + vertices[2].light = tileScreenInfo[i+1][j+0].light; + vertices[2].specular = tileScreenInfo[i+1][j+0].specular; + if (onWaterEdge) { - vertices[2].sy = tileScreenInfo[i+1][j+0].water_height; + vertices[2].vertexPos.y = tileScreenInfo[i+1][j+0].water_height; } } else { - memcpy(&vertices[2], &tileScreenInfo[i+1][j+1], sizeof(PIEVERTEX)); + vertices[2].vertexPos = Vector3iToVector3f(tileScreenInfo[i+1][j+1].vertexPos); + vertices[2].u = tileScreenInfo[i+1][j+1].tu; + vertices[2].v = tileScreenInfo[i+1][j+1].tv; + vertices[2].light = tileScreenInfo[i+1][j+1].light; + vertices[2].specular = tileScreenInfo[i+1][j+1].specular; + if (onWaterEdge) { - vertices[2].sy = tileScreenInfo[i+1][j+1].water_height; + vertices[2].vertexPos.y = tileScreenInfo[i+1][j+1].water_height; } } @@ -4417,27 +4430,47 @@ /* The second triangle */ if (TRI_FLIPPED(psTile)) { - memcpy(&vertices[0], &tileScreenInfo[i+0][j+1], sizeof(PIEVERTEX)); + vertices[0].vertexPos = Vector3iToVector3f(tileScreenInfo[i+0][j+1].vertexPos); + vertices[0].u = tileScreenInfo[i+0][j+1].tu; + vertices[0].v = tileScreenInfo[i+0][j+1].tv; + vertices[0].light = tileScreenInfo[i+0][j+1].light; + vertices[0].specular = tileScreenInfo[i+0][j+1].specular; + if (onWaterEdge) { - vertices[0].sy = tileScreenInfo[i+0][j+1].water_height; + vertices[0].vertexPos.y = tileScreenInfo[i+0][j+1].water_height; } } else { - memcpy(&vertices[0], &tileScreenInfo[i+0][j+0], sizeof(PIEVERTEX)); + vertices[0].vertexPos = Vector3iToVector3f(tileScreenInfo[i+0][j+0].vertexPos); + vertices[0].u = tileScreenInfo[i+0][j+0].tu; + vertices[0].v = tileScreenInfo[i+0][j+0].tv; + vertices[0].light = tileScreenInfo[i+0][j+0].light; + vertices[0].specular = tileScreenInfo[i+0][j+0].specular; + if (onWaterEdge) { - vertices[0].sy = tileScreenInfo[i+0][j+0].water_height; + vertices[0].vertexPos.y = tileScreenInfo[i+0][j+0].water_height; } } - memcpy(&vertices[1], &tileScreenInfo[i+1][j+1], sizeof(PIEVERTEX)); - memcpy(&vertices[2], &tileScreenInfo[i+1][j+0], sizeof(PIEVERTEX)); + vertices[1].vertexPos = Vector3iToVector3f(tileScreenInfo[i+1][j+1].vertexPos); + vertices[1].u = tileScreenInfo[i+1][j+1].tu; + vertices[1].v = tileScreenInfo[i+1][j+1].tv; + vertices[1].light = tileScreenInfo[i+1][j+1].light; + vertices[1].specular = tileScreenInfo[i+1][j+1].specular; + + vertices[2].vertexPos = Vector3iToVector3f(tileScreenInfo[i+1][j+0].vertexPos); + vertices[2].u = tileScreenInfo[i+1][j+0].tu; + vertices[2].v = tileScreenInfo[i+1][j+0].tv; + vertices[2].light = tileScreenInfo[i+1][j+0].light; + vertices[2].specular = tileScreenInfo[i+1][j+0].specular; + if ( onWaterEdge ) { - vertices[1].sy = tileScreenInfo[i+1][j+1].water_height; - vertices[2].sy = tileScreenInfo[i+1][j+0].water_height; + vertices[1].vertexPos.y = tileScreenInfo[i+1][j+1].water_height; + vertices[2].vertexPos.y = tileScreenInfo[i+1][j+0].water_height; } @@ -4447,14 +4480,14 @@ /* Outline the tile if necessary */ if(!onWaterEdge && terrainOutline) { - iV_Line(tileScreenInfo[i+0][j+0].sx, tileScreenInfo[i+0][j+0].sy, - tileScreenInfo[i+0][j+1].sx, tileScreenInfo[i+0][j+1].sy, 255); - iV_Line(tileScreenInfo[i+0][j+1].sx, tileScreenInfo[i+0][j+1].sy, - tileScreenInfo[i+1][j+1].sx, tileScreenInfo[i+1][j+1].sy, 255); - iV_Line(tileScreenInfo[i+1][j+1].sx, tileScreenInfo[i+1][j+1].sy, - tileScreenInfo[i+1][j+0].sx, tileScreenInfo[i+1][j+0].sy, 255); - iV_Line(tileScreenInfo[i+1][j+0].sx, tileScreenInfo[i+1][j+0].sy, - tileScreenInfo[i+0][j+0].sx, tileScreenInfo[i+0][j+0].sy, 255); + iV_Line(tileScreenInfo[i+0][j+0].position.z,tileScreenInfo[i+0][j+0].position.y, + tileScreenInfo[i+0][j+1].position.z,tileScreenInfo[i+0][j+1].position.y,255); + iV_Line(tileScreenInfo[i+0][j+1].position.z,tileScreenInfo[i+0][j+1].position.y, + tileScreenInfo[i+1][j+1].position.z,tileScreenInfo[i+1][j+1].position.y,255); + iV_Line(tileScreenInfo[i+1][j+1].position.z,tileScreenInfo[i+1][j+1].position.y, + tileScreenInfo[i+1][j+0].position.z,tileScreenInfo[i+1][j+0].position.y,255); + iV_Line(tileScreenInfo[i+1][j+0].position.z,tileScreenInfo[i+1][j+0].position.y, + tileScreenInfo[i+0][j+0].position.z,tileScreenInfo[i+0][j+0].position.y,255); } if(!onWaterEdge && bOutlined) @@ -4514,44 +4547,56 @@ offset.x = tileTexInfo[tileNumber & TILE_NUMMASK].xOffset * 64; offset.y = tileTexInfo[tileNumber & TILE_NUMMASK].yOffset * 64; - tileScreenInfo[i+0][j+0].tu = (UWORD)(offset.x + 1); - tileScreenInfo[i+0][j+0].tv = (UWORD)(offset.y); + tileScreenInfo[i+0][j+0].tu = (float)(offset.x + 1); + tileScreenInfo[i+0][j+0].tv = (float)(offset.y); - tileScreenInfo[i+0][j+1].tu = (UWORD)(offset.x + 63); - tileScreenInfo[i+0][j+1].tv = (UWORD)(offset.y); + tileScreenInfo[i+0][j+1].tu = (float)(offset.x + 63); + tileScreenInfo[i+0][j+1].tv = (float)(offset.y); - tileScreenInfo[i+1][j+1].tu = (UWORD)(offset.x + 63); - tileScreenInfo[i+1][j+1].tv = (UWORD)(offset.y + 31); + tileScreenInfo[i+1][j+1].tu = (float)(offset.x + 63); + tileScreenInfo[i+1][j+1].tv = (float)(offset.y + 31); - tileScreenInfo[i+1][j+0].tu = (UWORD)(offset.x + 1); - tileScreenInfo[i+1][j+0].tv = (UWORD)(offset.y + 31); + tileScreenInfo[i+1][j+0].tu = (float)(offset.x + 1); + tileScreenInfo[i+1][j+0].tv = (float)(offset.y + 31); - memcpy(&vertices[0], &tileScreenInfo[i+0][j+0], sizeof(PIEVERTEX)); - vertices[0].sy = tileScreenInfo[i+0][j+0].water_height; + vertices[0].vertexPos = Vector3iToVector3f(tileScreenInfo[i+0][j+0].vertexPos); + vertices[0].vertexPos.y = tileScreenInfo[i+0][j+0].water_height; + vertices[0].u = tileScreenInfo[i+0][j+0].tu; + vertices[0].v = tileScreenInfo[i+0][j+0].tv; vertices[0].light = tileScreenInfo[i+0][j+0].wlight; vertices[0].light.byte.a = WATER_ALPHA_LEVEL; + vertices[0].specular = tileScreenInfo[i+0][j+0].specular; - memcpy(&vertices[1], &tileScreenInfo[i+0][j+1], sizeof(PIEVERTEX)); - vertices[1].sy = tileScreenInfo[i+0][j+1].water_height; + vertices[1].vertexPos = Vector3iToVector3f(tileScreenInfo[i+0][j+1].vertexPos); + vertices[1].vertexPos.y = tileScreenInfo[i+0][j+1].water_height; + vertices[1].u = tileScreenInfo[i+0][j+1].tu; + vertices[1].v = tileScreenInfo[i+0][j+1].tv; vertices[1].light = tileScreenInfo[i+0][j+1].wlight; vertices[1].light.byte.a = WATER_ALPHA_LEVEL; + vertices[1].specular = tileScreenInfo[i+0][j+1].specular; - memcpy(&vertices[2], &tileScreenInfo[i+1][j+1], sizeof(PIEVERTEX)); - vertices[2].sy = tileScreenInfo[i+1][j+1].water_height; + vertices[2].vertexPos = Vector3iToVector3f(tileScreenInfo[i+1][j+1].vertexPos); + vertices[2].vertexPos.y = tileScreenInfo[i+1][j+1].water_height; + vertices[2].u = tileScreenInfo[i+1][j+1].tu; + vertices[2].v = tileScreenInfo[i+1][j+1].tv; vertices[2].light = tileScreenInfo[i+1][j+1].wlight; vertices[2].light.byte.a = WATER_ALPHA_LEVEL; + vertices[2].specular = tileScreenInfo[i+1][j+1].specular; pie_SetDepthOffset(-1.0); pie_DrawTexTriangle(vertices, &waterRealValue); + memcpy(&vertices[1], &vertices[2], sizeof(PIEVERTEX)); - memcpy(&vertices[1], &vertices[2], sizeof(PIEVERTEX)); - memcpy(&vertices[2], &tileScreenInfo[i+1][j+0], sizeof(PIEVERTEX)); - vertices[2].sy = tileScreenInfo[i+1][j+0].water_height; + vertices[2].vertexPos = Vector3iToVector3f(tileScreenInfo[i+1][j+0].vertexPos); + vertices[2].vertexPos.y = tileScreenInfo[i+1][j+0].water_height; + vertices[2].u = tileScreenInfo[i+1][j+0].tu; + vertices[2].v = tileScreenInfo[i+1][j+0].tv; vertices[2].light = tileScreenInfo[i+1][j+0].wlight; vertices[2].light.byte.a = WATER_ALPHA_LEVEL; + vertices[2].specular = tileScreenInfo[i+1][j+0].specular; pie_DrawTexTriangle(vertices, &waterRealValue); @@ -4560,9 +4605,6 @@ } - - -// ------------------------------------------------------------------------------------- UDWORD getSuggestedPitch( void ) { UDWORD worldAngle; @@ -5331,6 +5373,7 @@ { PIEVERTEX pts[3]; Vector3i each; + Vector3i tmpVector3i; Vector3i *point; UDWORD pointIndex; SDWORD realY; @@ -5350,12 +5393,13 @@ rx = player.p.x & (TILE_UNITS-1); rz = player.p.z & (TILE_UNITS-1); - pts[0].sx = vec.x + rx; - pts[0].sy = vec.y; - pts[0].sz = vec.z - rz; + pts[0].vertexPos.x = vec.x + rx; + pts[0].vertexPos.y = vec.y; + pts[0].vertexPos.z = vec.z - rz; pointIndex = rand()%(psStructure->sDisplay.imd->npoints-1); - point = &(psStructure->sDisplay.imd->points[pointIndex]); + tmpVector3i= Vector3fToVector3i(psStructure->sDisplay.imd->points[pointIndex]); + point = &tmpVector3i; each.x = psStructure->x + point->x; realY = MAKEINT((structHeightScale(psStructure) * point->y)); @@ -5374,12 +5418,13 @@ rx = player.p.x & (TILE_UNITS-1); rz = player.p.z & (TILE_UNITS-1); - pts[1].sx = vec.x + rx; - pts[1].sy = vec.y; - pts[1].sz = vec.z - rz; + pts[1].vertexPos.x = vec.x + rx; + pts[1].vertexPos.y = vec.y; + pts[1].vertexPos.z = vec.z - rz; pointIndex = rand()%(psStructure->sDisplay.imd->npoints-1); - point = &(psStructure->sDisplay.imd->points[pointIndex]); + tmpVector3i = Vector3fToVector3i(psStructure->sDisplay.imd->points[pointIndex]); + point = &tmpVector3i; each.x = psStructure->x + point->x; realY = MAKEINT((structHeightScale(psStructure) * point->y)); @@ -5392,9 +5437,9 @@ rx = player.p.x & (TILE_UNITS-1); rz = player.p.z & (TILE_UNITS-1); - pts[2].sx = vec.x + rx; - pts[2].sy = vec.y; - pts[2].sz = vec.z - rz; + pts[2].vertexPos.x = vec.x + rx; + pts[2].vertexPos.y = vec.y; + pts[2].vertexPos.z = vec.z - rz; // set the colour colour = UBYTE_MAX; @@ -5409,16 +5454,16 @@ pts[1].light.argb = 0xff000000; pts[2].light.argb = 0xff000000; - pts[0].tu = 0; - pts[0].tv = 0; + pts[0].u = 0; + pts[0].v = 0; pts[0].specular.argb = colour; - pts[1].tu = 0; - pts[1].tv = 0; + pts[1].u = 0; + pts[1].v = 0; pts[1].specular.argb = 0; - pts[2].tu = 0; - pts[2].tv = 0; + pts[2].u = 0; + pts[2].v = 0; pts[2].specular.argb = 0; Index: src/display3d.h =================================================================== --- src/display3d.h (revision 1313) +++ src/display3d.h (working copy) @@ -125,10 +125,11 @@ // Expanded PIEVERTEX. typedef struct { // PIEVERTEX. - SDWORD x, y, z; UWORD tu, tv; PIELIGHT light, specular; + Vector3i vertexPos; float tu, tv; PIELIGHT light, specular; + // position + Vector3i position; // Extra data for water. - SDWORD sx, sy, sz; - SDWORD wx, wy, wz; + Vector3i waterPos; SDWORD water_height; PIELIGHT wlight; UBYTE drawInfo; Index: lib/ivis_common/ivisdef.h =================================================================== --- lib/ivis_common/ivisdef.h (revision 1313) +++ lib/ivis_common/ivisdef.h (working copy) @@ -125,9 +125,9 @@ Uint32 flags; Sint32 zcentre; int npnts; - Vector3i normal; + Vector3f normal; VERTEXID *pindex; - iVertex *vrt; + fVertex *vrt; iTexAnim *pTexAnim; // warning.... this is not used on the playstation version ! } iIMDPoly; @@ -142,9 +142,9 @@ int npolys; // After BSP this number is not updated - it stays the number of pre-bsp polys int nconnectors; // After BSP this number is not updated - it stays the number of pre-bsp polys - Vector3i *points; + Vector3f *points; iIMDPoly *polys; // After BSP this is not changed - it stays the original chunk of polys - not all are now used,and others not in this array are, see BSPNode for a tree of all the post BSP polys - Vector3i *connectors; // After BSP this is not changed - it stays the original chunk of polys - not all are now used,and others not in this array are, see BSPNode for a tree of all the post BSP polys + Vector3f *connectors; // After BSP this is not changed - it stays the original chunk of polys - not all are now used,and others not in this array are, see BSPNode for a tree of all the post BSP polys int ntexanims; iTexAnim **texanims; Index: lib/ivis_common/piedef.h =================================================================== --- lib/ivis_common/piedef.h (revision 1313) +++ lib/ivis_common/piedef.h (working copy) @@ -127,7 +127,7 @@ #endif typedef union {PIELIGHTBYTES byte; UDWORD argb;} PIELIGHT; typedef struct {UBYTE r, g, b, a;} PIEVERTLIGHT; -typedef struct {SDWORD sx, sy, sz; UWORD tu, tv; PIELIGHT light, specular;} PIEVERTEX; +typedef struct {Vector3f vertexPos; float u, v; PIELIGHT light, specular;} PIEVERTEX; typedef struct {SWORD x, y, w, h;} PIERECT; //screen rectangle typedef struct {SDWORD texPage; SWORD tu, tv, tw, th;} PIEIMAGE; //an area of texture @@ -170,6 +170,10 @@ extern void pie_GetResetCounts(SDWORD* pPieCount, SDWORD* pTileCount, SDWORD* pPolyCount, SDWORD* pStateCount); +extern Vector3i Vector3fToVector3i(Vector3f v); + +extern Vector3f Vector3iToVector3f(Vector3i v); + void pie_BeginLighting(float x, float y, float z); void pie_EndLighting(void); void pie_RemainingPasses(void); Index: lib/ivis_common/pietypes.h =================================================================== --- lib/ivis_common/pietypes.h (revision 1313) +++ lib/ivis_common/pietypes.h (working copy) @@ -49,7 +49,8 @@ typedef struct { float x, y, z; } Vector3f; typedef struct { Vector3i p, r; } iView; -typedef struct { Sint32 x, y, z, u, v; Uint8 g; } iVertex; +typedef struct { Vector3i vertexPos; float u, v; Uint8 g; } iVertex; +typedef struct { Vector3f vertexPos; float u, v; Uint8 g; } fVertex; typedef struct { Uint8 r, g, b; } iColour; typedef iColour iPalette[256]; Index: lib/ivis_common/imdload.c =================================================================== --- lib/ivis_common/imdload.c (revision 1313) +++ lib/ivis_common/imdload.c (working copy) @@ -221,7 +221,7 @@ char *pFileData = *ppFileData; int cnt; int i, j; //, anim; - Vector3i p0, p1, p2, *points; + Vector3f p0, p1, p2, *points; iIMDPoly *poly; int nFrames,pbRate,tWidth,tHeight; @@ -247,9 +247,9 @@ poly->flags=flags; poly->npnts=npnts; - poly->pindex = (VERTEXID *) malloc(sizeof(VERTEXID) * poly->npnts); + poly->pindex = (VERTEXID *)malloc(sizeof(VERTEXID) * poly->npnts); - if ((poly->vrt = (iVertex *) malloc(sizeof(iVertex) * poly->npnts)) == NULL) { + if ((poly->vrt = (fVertex *)malloc(sizeof(fVertex) * poly->npnts)) == NULL) { iV_Error(0xff,"(_load_polys) [poly %d] memory alloc fail (vertex struct)",i); return FALSE; } @@ -284,7 +284,7 @@ p2.y = points[poly->pindex[poly->npnts-1]].y; p2.z = points[poly->pindex[poly->npnts-1]].z; - pie_SurfaceNormal3iv(&p0,&p1,&p2,&poly->normal); + pie_SurfaceNormal3fv(&p0,&p1,&p2,&poly->normal); //iV_DEBUG3("normal %d %d %d\n",poly->normal.x,poly->normal.y,poly->normal.z); } else { poly->normal.x = poly->normal.y = poly->normal.z = 0; @@ -330,8 +330,8 @@ if (poly->vrt && (poly->flags & iV_IMD_TEX)) { for (j=0; j<poly->npnts; j++) { - Sint32 VertexU, VertexV; - if (sscanf(pFileData, "%d %d%n", &VertexU, &VertexV, &cnt) != 2) { + float VertexU, VertexV; + if (sscanf(pFileData, "%f %f%n", &VertexU, &VertexV, &cnt) != 2) { iV_Error(0xff,"(_load_polys) [poly %d] error reading tex outline",i); return FALSE; } @@ -356,16 +356,16 @@ char *pFileData = *ppFileData; int cnt; int i; - Vector3i *p; - int lastPoint,match,j; - SDWORD newX,newY,newZ; + Vector3f *p; + int lastPoint, match, j; + float newX, newY, newZ; p = s->points; lastPoint = 0; for (i = 0; i < s->npoints; i++) { - if (sscanf(pFileData, "%d %d %d%n", &(newX), &(newY), &(newZ), &cnt) != 3) { + if (sscanf(pFileData, "%f %f %f%n", &newX, &newY, &newZ, &cnt) != 3) { iV_Error(0xff,"(_load_points) file corrupt -K"); return FALSE; } @@ -428,9 +428,9 @@ static BOOL _imd_load_points( char **ppFileData, iIMDShape *s ) { int i ; - Vector3i *p; - Sint32 tempXMax, tempXMin, tempZMax, tempZMin, extremeX, extremeZ; - Sint32 xmax, ymax, zmax; + Vector3f *p; + float tempXMax, tempXMin, tempZMax, tempZMin, extremeX, extremeZ; + float xmax, ymax, zmax; double dx, dy, dz, rad_sq, rad, old_to_p_sq, old_to_p, old_to_new; double xspan, yspan, zspan, maxspan; Vector3f dia1, dia2, cen; @@ -439,7 +439,7 @@ //load the points then pass through a second time to setup bounding datavalues - s->points = p = (Vector3i *) malloc(sizeof(Vector3i) * s->npoints); + s->points = p = (Vector3f *)malloc(sizeof(Vector3f) * s->npoints); if (p == NULL) { return FALSE; } @@ -549,10 +549,8 @@ zmax = MAX(s->zmax, -s->zmin); s->radius = MAX(xmax, (MAX(ymax, zmax))); + s->sradius = sqrtf( xmax*xmax + ymax*ymax + zmax*zmax); - - s->sradius = (SDWORD)sqrtf( xmax*xmax + ymax*ymax + zmax*zmax); - // START: tight bounding sphere // set xspan = distance between 2 points xmin & xmax (squared) @@ -639,8 +637,8 @@ s->ocen.x = (Sint32) cen.x; s->ocen.y = (Sint32) cen.y; s->ocen.z = (Sint32) cen.z; - s->oradius = (Sint32) rad; - iV_DEBUG2("radius, sradius, %d, %d\n", s->radius, s->sradius); + s->oradius = (float) rad; + iV_DEBUG2("radius, sradius, %f, %f\n",s->radius,s->sradius); iV_DEBUG4("SPHERE: cen,rad = %d %d %d, %d\n", s->ocen.x, s->ocen.y, s->ocen.z, s->oradius); // END: tight bounding sphere @@ -653,10 +651,10 @@ char *pFileData = *ppFileData; int cnt; int i; - Vector3i *p; - SDWORD newX,newY,newZ; + Vector3f *p; + float newX, newY, newZ; - if ((s->connectors = (Vector3i *) malloc(sizeof(Vector3i) * s->nconnectors)) == NULL) + if ((s->connectors = (Vector3f *)malloc(sizeof(Vector3f) * s->nconnectors)) == NULL) { iV_Error(0xff,"(_load_connectors) MALLOC fail"); return FALSE; @@ -666,7 +664,7 @@ for (i=0; i<s->nconnectors; i++, p++) { - if (sscanf(pFileData,"%d %d %d%n",&(newX),&(newY),&(newZ),&cnt) != 3) + if (sscanf(pFileData, "%f %f %f%n", &newX, &newY, &newZ, &cnt) != 3) { iV_Error(0xff,"(_load_connectors) file corrupt -M"); return FALSE; Index: lib/ivis_common/pieclip.c =================================================================== --- lib/ivis_common/pieclip.c (revision 1313) +++ lib/ivis_common/pieclip.c (working copy) @@ -66,56 +66,57 @@ static void pie_ClipUV(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip, Sint32 t) { - clip->tu = s1->tu + ((t * (s2->tu - s1->tu)) >> iV_DIVSHIFT); - clip->tv = s1->tv + ((t * (s2->tv - s1->tv)) >> iV_DIVSHIFT); - clip->sz = s1->sz + ((t * (s2->sz - s1->sz)) >> iV_DIVSHIFT); - clip->light.byte.r = s1->light.byte.r + ((t * (s2->light.byte.r - s1->light.byte.r)) >> iV_DIVSHIFT); - clip->light.byte.g = s1->light.byte.g + ((t * (s2->light.byte.g - s1->light.byte.g)) >> iV_DIVSHIFT); - clip->light.byte.b = s1->light.byte.b + ((t * (s2->light.byte.b - s1->light.byte.b)) >> iV_DIVSHIFT); - clip->light.byte.a = s1->light.byte.a + ((t * (s2->light.byte.a - s1->light.byte.a)) >> iV_DIVSHIFT); + clip->u = s1->u + t * (s2->u - s1->u) / iV_DIVMULTP; + clip->v = s1->v + t * (s2->v - s1->v) / iV_DIVMULTP; + + clip->vertexPos.z = s1->vertexPos.z + t * (s2->vertexPos.z - s1->vertexPos.z) / iV_DIVMULTP; + clip->light.byte.r = s1->light.byte.r + t * (s2->light.byte.r - s1->light.byte.r) / iV_DIVMULTP; + clip->light.byte.g = s1->light.byte.g + t * (s2->light.byte.g - s1->light.byte.g) / iV_DIVMULTP; + clip->light.byte.b = s1->light.byte.b + t * (s2->light.byte.b - s1->light.byte.b) / iV_DIVMULTP; + clip->light.byte.a = s1->light.byte.a + t * (s2->light.byte.a - s1->light.byte.a) / iV_DIVMULTP; } static int pie_ClipXT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip) { - int n = 1, dx; + int n = 1, dx = 0; Sint32 t; - if (s2->sx >= s1->sx) { - if (s1->sx < psRendSurface->clip.left) { - if (s2->sx <= psRendSurface->clip.left) + if (s2->vertexPos.x >= s1->vertexPos.x) { + if (s1->vertexPos.x < psRendSurface->clip.left) { + if (s2->vertexPos.x <= psRendSurface->clip.left) return 0; - dx = s2->sx - s1->sx; + dx = s2->vertexPos.x - s1->vertexPos.x; if (dx != 0) - clip->sy = s1->sy + (s2->sy - s1->sy) * (psRendSurface->clip.left - s1->sx) / dx; + clip->vertexPos.y = s1->vertexPos.y + (s2->vertexPos.y - s1->vertexPos.y) * (psRendSurface->clip.left - s1->vertexPos.x) / dx; else - clip->sy = s1->sy; + clip->vertexPos.y = s1->vertexPos.y; - clip->sx = psRendSurface->clip.left; + clip->vertexPos.x = psRendSurface->clip.left; // clip uv - t = ((clip->sx - s1->sx)<<iV_DIVSHIFT) / dx; + t = (clip->vertexPos.x - s1->vertexPos.x) * iV_DIVMULTP / dx; pie_ClipUV(s1, s2, clip, t); } else *clip = *s1; - if (s2->sx > psRendSurface->clip.right) { - if (s1->sx > psRendSurface->clip.right) + if (s2->vertexPos.x > psRendSurface->clip.right) { + if (s1->vertexPos.x > psRendSurface->clip.right) return 0; clip++; - dx = s2->sx - s1->sx; + dx = s2->vertexPos.x - s1->vertexPos.x; if (dx != 0) - clip->sy = s2->sy - (s2->sy - s1->sy) * (s2->sx - psRendSurface->clip.right) / dx; + clip->vertexPos.y = ((SDWORD)s2->vertexPos.y - (s2->vertexPos.y - s1->vertexPos.y) * (s2->vertexPos.x - psRendSurface->clip.right) / dx); else - clip->sy = s2->sy; + clip->vertexPos.y = s2->vertexPos.y; - clip->sx = psRendSurface->clip.right; + clip->vertexPos.x = psRendSurface->clip.right; // clip uv - t = ((clip->sx - s1->sx)<<iV_DIVSHIFT) / dx; + t = (clip->vertexPos.x - s1->vertexPos.x) * iV_DIVMULTP / dx; pie_ClipUV(s1, s2, clip, t); n = 2; @@ -123,42 +124,43 @@ return n; } else { - if (s1->sx > psRendSurface->clip.right) { + if (s1->vertexPos.x > psRendSurface->clip.right) { - if (s2->sx >= psRendSurface->clip.right) return 0; + if (s2->vertexPos.x >= psRendSurface->clip.right) + return 0; - dx = s1->sx - s2->sx; + dx = s1->vertexPos.x - s2->vertexPos.x; if (dx != 0) - clip->sy = s1->sy - (s1->sy - s2->sy) * (s1->sx - psRendSurface->clip.right) / dx; + clip->vertexPos.y = s1->vertexPos.y - (s1->vertexPos.y - s2->vertexPos.y) * (s1->vertexPos.x - psRendSurface->clip.right) / dx; else - clip->sy = s1->sy; + clip->vertexPos.y = s1->vertexPos.y; - clip->sx = psRendSurface->clip.right; + clip->vertexPos.x = psRendSurface->clip.right; // clip uv - t = ((clip->sx - s1->sx)<<iV_DIVSHIFT) / dx; + t = (clip->vertexPos.x - s1->vertexPos.x) * iV_DIVSHIFT / dx; pie_ClipUV(s1, s2, clip, t); } else { *clip = *s1; } - if (s2->sx < psRendSurface->clip.left) { - if (s1->sx < psRendSurface->clip.left) + if (s2->vertexPos.x < psRendSurface->clip.left) { + if (s1->vertexPos.x < psRendSurface->clip.left) return 0; clip++; - dx = s1->sx - s2->sx; + dx = s1->vertexPos.x - s2->vertexPos.x; if (dx != 0) - clip->sy = s2->sy + (s1->sy - s2->sy) * (psRendSurface->clip.left - s2->sx) / dx; + clip->vertexPos.y = s2->vertexPos.y + (s1->vertexPos.y - s2->vertexPos.y) * (psRendSurface->clip.left - s2->vertexPos.x) / dx; else - clip->sy = s2->sy; + clip->vertexPos.y = s2->vertexPos.y; - clip->sx = psRendSurface->clip.left; + clip->vertexPos.x = psRendSurface->clip.left; // clip uv - t = ((clip->sx - s1->sx)<<iV_DIVSHIFT) / dx; + t = (clip->vertexPos.x - s1->vertexPos.x) * iV_DIVSHIFT / dx; pie_ClipUV(s1, s2, clip, t); n = 2; @@ -172,48 +174,49 @@ int n = 1, dy; Sint32 t; - if (s2->sy >= s1->sy) { + if (s2->vertexPos.y >= s1->vertexPos.y) { - if (s1->sy < psRendSurface->clip.top) { + if (s1->vertexPos.y < psRendSurface->clip.top) { - if (s2->sy <= psRendSurface->clip.top) return 0; + if (s2->vertexPos.y <= psRendSurface->clip.top) + return 0; - dy = s2->sy - s1->sy; + dy = s2->vertexPos.y - s1->vertexPos.y; if (dy != 0) - clip->sx = s1->sx + (s2->sx - s1->sx) * (psRendSurface->clip.top - s1->sy) / dy; + clip->vertexPos.x = s1->vertexPos.x + (s2->vertexPos.x - s1->vertexPos.x) * (psRendSurface->clip.top - s1->vertexPos.y) / dy; else - clip->sx = s1->sx; + clip->vertexPos.x = s1->vertexPos.x; - clip->sy = psRendSurface->clip.top; + clip->vertexPos.y = psRendSurface->clip.top; // clip uv - t = ((clip->sy - s1->sy)<<iV_DIVSHIFT) / dy; + t = (clip->vertexPos.y - s1->vertexPos.y) * iV_DIVSHIFT / dy; pie_ClipUV(s1, s2, clip, t); } else { *clip = *s1; } - if (s2->sy > psRendSurface->clip.bottom) + if (s2->vertexPos.y > psRendSurface->clip.bottom) { - if (s1->sy > psRendSurface->clip.bottom) + if (s1->vertexPos.y > psRendSurface->clip.bottom) { return 0; } clip++; - dy = s2->sy - s1->sy; + dy = s2->vertexPos.x - s1->vertexPos.x; if (dy != 0) { - clip->sx = s2->sx - (s2->sx - s1->sx) * (s2->sy - psRendSurface->clip.bottom) / dy; + clip->vertexPos.x = s2->vertexPos.x - (s2->vertexPos.x - s1->vertexPos.x) * (s2->vertexPos.y - psRendSurface->clip.bottom) / dy; } else { - clip->sx = s2->sx; + clip->vertexPos.x = s2->vertexPos.x; } - clip->sy = psRendSurface->clip.bottom; + clip->vertexPos.y = psRendSurface->clip.bottom; - t = ((clip->sy - s1->sy)<<iV_DIVSHIFT) / dy; + t = (clip->vertexPos.y - s1->vertexPos.y) * iV_DIVSHIFT / dy; pie_ClipUV(s1, s2, clip, t); n = 2; @@ -222,48 +225,51 @@ return n; } else { - if (s1->sy > psRendSurface->clip.bottom) + if (s1->vertexPos.y > psRendSurface->clip.bottom) { - if (s2->sy >= psRendSurface->clip.bottom) return 0; + if (s2->vertexPos.y >= psRendSurface->clip.bottom) + return 0; - dy = s1->sy - s2->sy; + dy = s1->vertexPos.y - s2->vertexPos.y; if (dy != 0) - clip->sx = s1->sx - (s1->sx - s2->sx) * (s1->sy - psRendSurface->clip.bottom) / dy; + clip->vertexPos.x = s1->vertexPos.x - (s1->vertexPos.x - s2->vertexPos.x) * (s1->vertexPos.y - psRendSurface->clip.bottom) / dy; else - clip->sx = s1->sx; + clip->vertexPos.x = s1->vertexPos.x; - clip->sy = psRendSurface->clip.bottom; + clip->vertexPos.y = psRendSurface->clip.bottom; // clip uv - t = ((clip->sy - s1->sy)<<iV_DIVSHIFT) / dy; + t = (clip->vertexPos.y - s1->vertexPos.y) * iV_DIVSHIFT / dy; pie_ClipUV(s1, s2, clip, t); } else { *clip = *s1; } - if (s2->sy < psRendSurface->clip.top) + if (s2->vertexPos.y < psRendSurface->clip.top) { - if (s1->sy < psRendSurface->clip.top) + if (s1->vertexPos.y < psRendSurface->clip.top) { return 0; } clip++; - dy = s1->sy - s2->sy; + dy = s1->vertexPos.y - s2->vertexPos.y; if (dy != 0) { - clip->sx = s2->sx + (s1->sx - s2->sx) * (psRendSurface->clip.top - s2->sy) / dy; - } else { - clip->sx = s2->sx; + clip->vertexPos.x = s2->vertexPos.x + (s1->vertexPos.x - s2->vertexPos.x) * (psRendSurface->clip.top - s2->vertexPos.y) / dy; } + else + { + clip->vertexPos.x = s2->vertexPos.x; + } - clip->sy = psRendSurface->clip.top; + clip->vertexPos.y = psRendSurface->clip.top; - t = ((clip->sy - s1->sy)<<iV_DIVSHIFT) / dy; + t = (clip->vertexPos.y - s1->vertexPos.y) * iV_DIVSHIFT / dy; pie_ClipUV(s1, s2, clip, t); n = 2; @@ -287,7 +293,7 @@ if (i==(npoints-1)) p1 = &points[0]; - if ((p0->sx == 1<<15) || (p0->sy == -1<<15))//check for invalid points jps19aug97 + if ((p0->vertexPos.x == iV_DIVMULTP) || (p0->vertexPos.y == -iV_DIVMULTP))//check for invalid points jps19aug97 return 0; n1 += pie_ClipXT(p0,p1,&xclip[n1]); @@ -318,21 +324,21 @@ UDWORD i; numPreY = 0; - if( (v1->sx > LONG_TEST) || (v1->sy > LONG_TEST) ) + if( (v1->vertexPos.x > LONG_TEST) || (v1->vertexPos.y > LONG_TEST) ) { /* bomb out for out of range points */ return(0); } numPreY += pie_ClipXT(v1,v2,&xClip[numPreY]); - if( (v2->sx > LONG_TEST) || (v2->sy > LONG_TEST) ) + if( (v2->vertexPos.x > LONG_TEST) || (v2->vertexPos.y > LONG_TEST) ) { /* bomb out for out of range points */ return(0); } numPreY += pie_ClipXT(v2,v3,&xClip[numPreY]); - if( (v3->sx > LONG_TEST) || (v3->sy > LONG_TEST) ) + if( (v3->vertexPos.x > LONG_TEST) || (v3->vertexPos.y > LONG_TEST) ) { /* bomb out for out of range points */ return(0); Index: lib/framework/types.h =================================================================== --- lib/framework/types.h (revision 1313) +++ lib/framework/types.h (working copy) @@ -61,7 +61,7 @@ #ifndef WZ_OS_WIN -typedef int BOOL; +typedef int BOOL; // FIXME Should be uint8_t and defined for Windows as well. typedef struct { Index: lib/ivis_opengl/piematrix.c =================================================================== --- lib/ivis_opengl/piematrix.c (revision 1316) +++ lib/ivis_opengl/piematrix.c (working copy) @@ -474,14 +474,14 @@ BOOL pie_Clockwise(iVertex *s) { - return (((s[1].y - s[0].y) * (s[2].x - s[1].x)) <= - ((s[1].x - s[0].x) * (s[2].y - s[1].y))); + return (((s[1].vertexPos.y - s[0].vertexPos.y) * (s[2].vertexPos.x - s[1].vertexPos.x)) <= + ((s[1].vertexPos.x - s[0].vertexPos.x) * (s[2].vertexPos.y - s[1].vertexPos.y))); } BOOL pie_PieClockwise(PIEVERTEX *s) { - return (((s[1].sy - s[0].sy) * (s[2].sx - s[1].sx)) <= - ((s[1].sx - s[0].sx) * (s[2].sy - s[1].sy))); + return (((s[1].vertexPos.y - s[0].vertexPos.y) * (s[2].vertexPos.x - s[1].vertexPos.x)) <= + ((s[1].vertexPos.x - s[0].vertexPos.x) * (s[2].vertexPos.y - s[1].vertexPos.y))); } Index: lib/ivis_opengl/piefunc.c =================================================================== --- lib/ivis_opengl/piefunc.c (revision 1313) +++ lib/ivis_opengl/piefunc.c (working copy) @@ -76,14 +76,14 @@ pie_SetTexturePage(-1); pie_SetRendMode(REND_ALPHA_FLAT); //PIE verts - pieVrts[0].sx = v[1].x; - pieVrts[0].sy = v[1].y; + pieVrts[0].vertexPos.x = (float)v[1].x; + pieVrts[0].vertexPos.y = (float)v[1].y; //cull triangles with off screen points - pieVrts[0].sz = (SDWORD)INTERFACE_DEPTH; + pieVrts[0].vertexPos.z = (float)INTERFACE_DEPTH; - pieVrts[0].tu = (UWORD)0.0; - pieVrts[0].tv = (UWORD)0.0; + pieVrts[0].u = 0.0f; + pieVrts[0].v = 0.0f; pieVrts[0].light.argb = colour;//0x7fffffff; pieVrts[0].specular.argb = 0; @@ -92,14 +92,14 @@ memcpy(&pieVrts[3],&pieVrts[0],sizeof(PIEVERTEX)); memcpy(&pieVrts[4],&pieVrts[0],sizeof(PIEVERTEX)); - pieVrts[1].sx = v[0].x; - pieVrts[1].sy = v[0].y; + pieVrts[1].vertexPos.x = (float)v[0].x; + pieVrts[1].vertexPos.y = (float)v[0].y; - pieVrts[2].sx = v[2].x; - pieVrts[2].sy = v[2].y; + pieVrts[2].vertexPos.x = (float)v[2].x; + pieVrts[2].vertexPos.y = (float)v[2].y; - pieVrts[3].sx = v[3].x; - pieVrts[3].sy = v[3].y; + pieVrts[3].vertexPos.x = (float)v[3].x; + pieVrts[3].vertexPos.y = (float)v[3].y; pie_Set2DClip(x1,y1,x2-1,y2-1); clip = pie_ClipTextured(4, &pieVrts[0], &clippedVrts[0]); @@ -112,15 +112,15 @@ glBegin(GL_TRIANGLE_FAN); glColor4ub(c.byte.r, c.byte.g, c.byte.b, c.byte.a >> 1); for (i = 0; i < clip; i++) { - glVertex2f(clippedVrts[i].sx, clippedVrts[i].sy); + glVertex2f(clippedVrts[i].vertexPos.x, clippedVrts[i].vertexPos.y); } glEnd(); glBegin(GL_LINE_STRIP); glColor4ub(c.byte.r, c.byte.g, c.byte.b, c.byte.a); for (i = 0; i < clip; i++) { - glVertex2f(clippedVrts[i].sx, clippedVrts[i].sy); + glVertex2f(clippedVrts[i].vertexPos.x, clippedVrts[i].vertexPos.y); } - glVertex2f(clippedVrts[0].sx, clippedVrts[0].sy); + glVertex2f(clippedVrts[0].vertexPos.x, clippedVrts[0].vertexPos.y); glEnd(); } } @@ -128,7 +128,7 @@ /* ---------------------------------------------------------------------------------- */ void pie_TransColouredTriangle( PIEVERTEX *vrt, UDWORD rgb ) { - PIELIGHT c; + PIELIGHT c; UDWORD i; c.argb = rgb; @@ -136,13 +136,14 @@ pie_SetTexturePage(-1); pie_SetRendMode(REND_ALPHA_ITERATED); - glBegin(GL_TRIANGLE_FAN); - glColor4ub(c.byte.r, c.byte.g, c.byte.b, 128); - for (i = 0; i < 3; ++i) - { - glVertex3f(vrt[i].sx, vrt[i].sy, vrt[i].sz); + glBegin(GL_TRIANGLE_FAN); + glColor4ub(c.byte.r, c.byte.g, c.byte.b, 128); + for (i = 0; i < 3; ++i) + { + glVertex3f(vrt[i].vertexPos.x, vrt[i].vertexPos.y, vrt[i].vertexPos.z); } - glEnd();} + glEnd(); +} /* ---------------------------------------------------------------------------------- */ @@ -168,7 +169,7 @@ glDisable(GL_ALPHA_TEST); // Apply scale matrix - glScalef(scale,scale / 2.0,scale); + glScalef(scale, scale/2.0f, scale); glBegin(GL_QUAD_STRIP); // Front Index: lib/ivis_opengl/piedraw.c =================================================================== --- lib/ivis_opengl/piedraw.c (revision 1313) +++ lib/ivis_opengl/piedraw.c (working copy) @@ -196,6 +196,29 @@ lighting = FALSE; } + +Vector3i Vector3fToVector3i(Vector3f v) +{ + Vector3i result; + + result.x = (SDWORD)v.x; + result.y = (SDWORD)v.y; + result.z = (SDWORD)v.z; + return result; +} + + +Vector3f Vector3iToVector3f(Vector3i v) +{ + Vector3f result; + + result.x = (float)v.x; + result.y = (float)v.y; + result.z = (float)v.z; + return result; +} + + static inline void Vector3f_Set(Vector3f* v, float x, float y, float z) { v->x = x; @@ -250,14 +273,11 @@ } glBegin(GL_TRIANGLE_FAN); if (light) { - Vector3f p1, p2, p3, v1, v2, n; + Vector3f v1, v2, n; float l; - Vector3f_Set(&p1, pVrts[0].sx, pVrts[0].sy, pVrts[0].sz); - Vector3f_Set(&p2, pVrts[1].sx, pVrts[1].sy, pVrts[1].sz); - Vector3f_Set(&p3, pVrts[2].sx, pVrts[2].sy, pVrts[2].sz); - Vector3f_Sub(&v1, &p3, &p1); - Vector3f_Sub(&v2, &p2, &p1); + Vector3f_Sub(&v1, &pVrts[2].vertexPos, &pVrts[2].vertexPos); + Vector3f_Sub(&v2, &pVrts[1].vertexPos, &pVrts[0].vertexPos); Vector3f_CP(&n, &v1, &v2); l = 1.0; @@ -267,9 +287,9 @@ } for (i = 0; i < numVerts; i++) { glColor4ub(pVrts[i].light.byte.r, pVrts[i].light.byte.g, pVrts[i].light.byte.b, pVrts[i].light.byte.a); - glTexCoord2f(pVrts[i].tu, pVrts[i].tv+texture_offset); + glTexCoord2f(pVrts[i].u, pVrts[i].v + texture_offset); //d3dVrts[i].specular = pVrts[i].specular.argb; - glVertex3f(pVrts[i].sx, pVrts[i].sy, pVrts[i].sz); + glVertex3f(pVrts[i].vertexPos.x, pVrts[i].vertexPos.y, pVrts[i].vertexPos.z); } glEnd(); glDisable(GL_LIGHTING); @@ -310,9 +330,9 @@ static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELIGHT specular, int pieFlag, int pieFlagData) { - Sint32 tempY; + float tempY; int i, n; - Vector3i *pVertices; + Vector3f *pVertices; Vector3f *pPixels; iIMDPoly *pPolys; PIEPOLY piePoly; @@ -400,11 +420,9 @@ } for (n=0; n<pPolys->npnts; n++, index++) { - pieVrts[n].sx = MAKEINT(scrPoints[*index].x); - pieVrts[n].sy = MAKEINT(scrPoints[*index].y); - pieVrts[n].sz = MAKEINT(scrPoints[*index].z); - pieVrts[n].tu = pPolys->vrt[n].u; - pieVrts[n].tv = pPolys->vrt[n].v; + pieVrts[n].vertexPos = scrPoints[*index]; + pieVrts[n].u = pPolys->vrt[n].u; + pieVrts[n].v = pPolys->vrt[n].v; pieVrts[n].light.argb = colour.argb; pieVrts[n].specular.argb = specular.argb; } @@ -423,13 +441,13 @@ } /// returns true if both vectors are equal -static inline BOOL compare_point (Vector3i *A, Vector3i *B) +static inline BOOL compare_point (Vector3f *A, Vector3f *B) { return A->x == B->x && A->y == B->y && A->z == B->z; } /// returns true if the edges are adjacent -static int compare_edge (EDGE *A, EDGE *B, Vector3i *pVertices ) +static int compare_edge (EDGE *A, EDGE *B, Vector3f *pVertices ) { if(A->from == B->to) { @@ -454,7 +472,7 @@ /// Add an edge to an edgelist /// Makes sure only silhouette edges are present -static void addToEdgeList(int a, int b, EDGE *edgelist, int *edge_count, Vector3i *pVertices) +static void addToEdgeList(int a, int b, EDGE *edgelist, int *edge_count, Vector3f *pVertices) { EDGE newEdge; int i; @@ -502,7 +520,7 @@ static void pie_DrawShadow(iIMDShape *shape, int flag, int flag_data, Vector3f* light) { int i,j, n; - Vector3i *pVertices; + Vector3f *pVertices; iIMDPoly *pPolys; int edge_count = 0; static EDGE *edgelist = NULL; @@ -1021,8 +1039,8 @@ for (j=0; j<poly->nVrts; j++) { - poly->pVrts[j].tu += uFrame; - poly->pVrts[j].tv += vFrame; + poly->pVrts[j].u += uFrame; + poly->pVrts[j].v += vFrame; } } } @@ -1062,8 +1080,8 @@ for ( i = 0; i < 3; i++ ) { glColor4ub( aVrts[i].light.byte.r, aVrts[i].light.byte.g, aVrts[i].light.byte.b, aVrts[i].light.byte.a ); - glTexCoord2f( aVrts[i].tu, aVrts[i].tv + offset ); - glVertex3f( aVrts[i].sx, aVrts[i].sy, aVrts[i].sz ); + glTexCoord2f( aVrts[i].u, aVrts[i].v + offset ); + glVertex3f( aVrts[i].vertexPos.x, aVrts[i].vertexPos.y, aVrts[i].vertexPos.z ); } glEnd();
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev