Remove automatic scaling to bounding box (#321)

stable-5.1
Nicolas Hake 2010-07-10 21:49:31 +02:00
parent a08795f28d
commit b5e1ae2a65
10 changed files with 15 additions and 15 deletions

View File

@ -698,7 +698,7 @@ void C4Def::Draw(C4Facet &cgo, bool fSelected, DWORD iColor, C4Object *pObj, int
lpDDraw->SetMeshTransform(&matrix);
lpDDraw->SetPerspective(true);
lpDDraw->RenderMesh(*instance, cgo.Surface, cgo.X,cgo.Y, cgo.Wdt, cgo.Hgt, pObj ? pObj->Color : iColor, trans);
lpDDraw->RenderMesh(*instance, cgo.Surface, cgo.X,cgo.Y, cgo.Wdt, cgo.Hgt, 1.0f, pObj ? pObj->Color : iColor, trans);
lpDDraw->SetPerspective(false);
lpDDraw->SetMeshTransform(NULL);

View File

@ -1089,7 +1089,7 @@ void C4GraphicsOverlay::Draw(C4TargetFacet &cgo, C4Object *pForObj, int32_t iByP
if (C4ValueToMatrix(value, &matrix))
lpDDraw->SetMeshTransform(&matrix);
lpDDraw->RenderMesh(*pMeshInstance, cgo.Surface, iTx - pDef->Shape.Wdt/2.0, iTy - pDef->Shape.Hgt/2.0, pDef->Shape.Wdt, pDef->Shape.Hgt, pForObj->Color, &trf);
lpDDraw->RenderMesh(*pMeshInstance, cgo.Surface, iTx - pDef->Shape.Wdt/2.0, iTy - pDef->Shape.Hgt/2.0, pDef->Shape.Wdt, pDef->Shape.Hgt, 1.0f, pForObj->Color, &trf);
lpDDraw->SetMeshTransform(NULL);
}
else
@ -1116,7 +1116,7 @@ void C4GraphicsOverlay::Draw(C4TargetFacet &cgo, C4Object *pForObj, int32_t iByP
C4DrawTransform trf(Transform, float(iTx), float(iTy));
lpDDraw->SetPerspective(true);
lpDDraw->RenderMesh(*pMeshInstance, cgo.Surface, iTx - twdt/2, iTy - thgt/2, twdt, thgt, pForObj->Color, &trf);
lpDDraw->RenderMesh(*pMeshInstance, cgo.Surface, iTx - twdt/2, iTy - thgt/2, twdt, thgt, 1.0f, pForObj->Color, &trf);
lpDDraw->SetPerspective(false);
lpDDraw->SetMeshTransform(NULL);
}
@ -1199,7 +1199,7 @@ void C4GraphicsOverlay::DrawPicture(C4Facet &cgo, C4Object *pForObj, C4DrawTrans
if(trans) trf *= *trans;
lpDDraw->SetPerspective(true);
lpDDraw->RenderMesh(*pMeshInstance, cgo.Surface, cgo.X, cgo.Y, pForObj->Shape.Wdt, pForObj->Shape.Hgt, pForObj->Color, &trf);
lpDDraw->RenderMesh(*pMeshInstance, cgo.Surface, cgo.X, cgo.Y, pForObj->Shape.Wdt, pForObj->Shape.Hgt, 1.0f, pForObj->Color, &trf);
lpDDraw->SetPerspective(false);
lpDDraw->SetMeshTransform(NULL);
}

View File

@ -554,7 +554,7 @@ void C4Object::DrawFaceImpl(C4TargetFacet &cgo, bool action, float fx, float fy,
if (C4ValueToMatrix(value, &matrix))
lpDDraw->SetMeshTransform(&matrix);
lpDDraw->RenderMesh(*pMeshInstance, cgo.Surface, tx, ty, twdt, thgt, Color, transform);
lpDDraw->RenderMesh(*pMeshInstance, cgo.Surface, tx, ty, twdt, thgt, twdt/fwdt, Color, transform);
lpDDraw->SetMeshTransform(NULL);
break;
}

View File

@ -270,7 +270,7 @@ void CStdD3D::PerformBlt(CBltData &rBltData, CTexRef *pTex, DWORD dwModClr, bool
}
}
void CStdD3D::PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, CBltTransform *pTransform)
void CStdD3D::PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, float scale, DWORD dwPlayerColor, CBltTransform *pTransform)
{
// TODO: Implement this
for (int x = 0; x < twdt; x += 10)

View File

@ -130,7 +130,7 @@ public:
// Surface
bool PrepareRendering(SURFACE sfcToSurface); // check if/make rendering possible to given surface
// Blit
virtual void PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, CBltTransform* pTransform);
virtual void PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, float scale, DWORD dwPlayerColor, CBltTransform* pTransform);
void PerformBlt(CBltData &rBltData, CTexRef *pTex, DWORD dwModClr, bool fMod2, bool fExact);
bool BlitTex2Window(CTexRef *pTexRef, HDC hdcTarget, RECT &rtFrom, RECT &rtTo);
bool BlitSurface2Window(SURFACE sfcSource, int fX, int fY, int fWdt, int fHgt, HWND hWnd, int tX, int tY, int tWdt, int tHgt);

View File

@ -677,7 +677,7 @@ bool CStdDDraw::Blit(SURFACE sfcSource, float fx, float fy, float fwdt, float fh
return true;
}
bool CStdDDraw::RenderMesh(StdMeshInstance &instance, SURFACE sfcTarget, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, CBltTransform* pTransform)
bool CStdDDraw::RenderMesh(StdMeshInstance &instance, SURFACE sfcTarget, float tx, float ty, float twdt, float thgt, float scale, DWORD dwPlayerColor, CBltTransform* pTransform)
{
// TODO: Emulate rendering
if (!sfcTarget->IsRenderTarget()) return false;
@ -693,7 +693,7 @@ bool CStdDDraw::RenderMesh(StdMeshInstance &instance, SURFACE sfcTarget, float t
if(MeshTransform) mat = *MeshTransform * mat;
instance.ReorderFaces(&mat);
// Render mesh
PerformMesh(instance, tx, ty, twdt, thgt, dwPlayerColor, pTransform);
PerformMesh(instance, tx, ty, twdt, thgt, scale, dwPlayerColor, pTransform);
// success
return true;
}

View File

@ -259,9 +259,9 @@ public:
bool Blit(SURFACE sfcSource, float fx, float fy, float fwdt, float fhgt,
SURFACE sfcTarget, float tx, float ty, float twdt, float thgt,
bool fSrcColKey=false, CBltTransform *pTransform=NULL);
bool RenderMesh(StdMeshInstance &instance, SURFACE sfcTarget, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, CBltTransform* pTransform); // Call PrepareMaterial with Mesh's material before
bool RenderMesh(StdMeshInstance &instance, SURFACE sfcTarget, float tx, float ty, float twdt, float thgt, float scale, DWORD dwPlayerColor, CBltTransform* pTransform); // Call PrepareMaterial with Mesh's material before
virtual void PerformBlt(CBltData &rBltData, CTexRef *pTex, DWORD dwModClr, bool fMod2, bool fExact) = 0;
virtual void PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, CBltTransform* pTransform) = 0;
virtual void PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, float scale, DWORD dwPlayerColor, CBltTransform* pTransform) = 0;
bool Blit8(SURFACE sfcSource, int fx, int fy, int fwdt, int fhgt, // force 8bit-blit (inline)
SURFACE sfcTarget, int tx, int ty, int twdt, int thgt,
bool fSrcColKey=false, CBltTransform *pTransform=NULL);

View File

@ -1096,7 +1096,7 @@ namespace
}
}
void CStdGL::PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, CBltTransform* pTransform)
void CStdGL::PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, float scale, DWORD dwPlayerColor, CBltTransform* pTransform)
{
// Field of View for perspective projection, in degrees
static const float FOV = 60.0f;
@ -1162,7 +1162,6 @@ void CStdGL::PerformMesh(StdMeshInstance &instance, float tx, float ty, float tw
const float ry = -std::min(v1.y,v2.y) / fabs(v2.y - v1.y);
const float dx = tx + rx*twdt;
const float dy = ty + ry*thgt;
const float scale = std::min(twdt/fabs(v2.x - v1.x), thgt/fabs(v2.y - v1.y));
// Scale so that Z coordinate is between -1 and 1, otherwise parts of
// the mesh could be clipped away by the near or far clipping plane.
@ -1220,6 +1219,7 @@ void CStdGL::PerformMesh(StdMeshInstance &instance, float tx, float ty, float tw
glTranslatef(ttx, tty, 0.0f);
glScalef(((float)ttwdt)/iWdt, ((float)tthgt)/iHgt, 1.0f);
glScalef(scale, scale, 1.0f);
// Return to Clonk coordinate frame
glScalef(iWdt/2.0, -iHgt/2.0, 1.0f);

View File

@ -111,7 +111,7 @@ public:
// Blit
void SetupTextureEnv(bool fMod2, bool landscape);
virtual void PerformBlt(CBltData &rBltData, CTexRef *pTex, DWORD dwModClr, bool fMod2, bool fExact);
virtual void PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, CBltTransform* pTransform);
virtual void PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, float scale, DWORD dwPlayerColor, CBltTransform* pTransform);
virtual void BlitLandscape(SURFACE sfcSource, float fx, float fy,
SURFACE sfcTarget, float tx, float ty, float wdt, float hgt, const SURFACE textures[]);
void FillBG(DWORD dwClr=0);

View File

@ -40,7 +40,7 @@ public:
virtual bool PrepareRendering(SURFACE) { return true; }
virtual void FillBG(DWORD dwClr=0) { }
virtual void PerformBlt(CBltData &, CTexRef *, DWORD, bool, bool) { }
virtual void PerformMesh(StdMeshInstance &, float, float, float, float, DWORD, CBltTransform* pTransform) { }
virtual void PerformMesh(StdMeshInstance &, float, float, float, float, float, DWORD, CBltTransform* pTransform) { }
virtual void PerformLine(SURFACE, float, float, float, float, DWORD) { }
virtual void DrawQuadDw(SURFACE, float *, DWORD, DWORD, DWORD, DWORD) { }
virtual void PerformPix(SURFACE, float, float, DWORD) { }