For scaled sprite graphics, don't interpret Picture coordinates as scaled

Otherwise an object with a scale of 5 and a picture of 64x64 (such as the
Metal and the GoldBar objects) cannot properly set the picture rectangle.
rope
Armin Burgmeier 2012-02-25 17:35:24 +01:00
parent cebbacd3f4
commit 9d94b1da6e
39 changed files with 94 additions and 46 deletions

View File

@ -9,7 +9,7 @@ Vertices=3
VertexX=0,-3,3
VertexY=-3,2,2
VertexFriction=40,40,40
Picture=0,0,8,8
Picture=0,0,64,64
Value=25
Mass=2
Rotate=1

View File

@ -9,7 +9,7 @@ Vertices=3
VertexX=0,-3,3
VertexY=-3,2,2
VertexFriction=40,40,40
Picture=0,0,8,8
Picture=0,0,64,64
Value=25
Mass=2
Rotate=1

View File

@ -9,7 +9,7 @@ Vertices=3
VertexX=0,-3,3
VertexY=-3,2,2
VertexFriction=40,40,40
Picture=0,0,8,8
Picture=0,0,64,64
Value=25
Mass=2
Rotate=1

View File

@ -9,7 +9,7 @@ Vertices=3
VertexX=0,-3,3
VertexY=-3,2,2
VertexFriction=40,40,40
Picture=0,0,8,8
Picture=0,0,64,64
Value=25
Mass=2
Rotate=1

View File

@ -9,7 +9,7 @@ Vertices=3
VertexX=0,-3,3
VertexY=-3,2,2
VertexFriction=40,40,40
Picture=0,0,8,8
Picture=0,0,64,64
Value=25
Mass=2
Rotate=1

View File

@ -9,7 +9,7 @@ Vertices=3
VertexX=0,-3,3
VertexY=-3,2,2
VertexFriction=40,40,40
Picture=0,0,8,8
Picture=0,0,64,64
Value=25
Mass=2
Rotate=1

View File

@ -9,7 +9,7 @@ Vertices=3
VertexX=0,-3,3
VertexY=-3,2,2
VertexFriction=40,40,40
Picture=0,0,8,8
Picture=0,0,64,64
Value=25
Mass=2
Rotate=1

View File

@ -9,7 +9,7 @@ Vertices=3
VertexX=0,-3,3
VertexY=-3,2,2
VertexFriction=40,40,40
Picture=0,0,8,8
Picture=0,0,64,64
Value=25
Mass=2
Rotate=1

View File

@ -9,7 +9,7 @@ Vertices=3
VertexX=0,-3,3
VertexY=-3,2,2
VertexFriction=40,40,40
Picture=0,0,8,8
Picture=0,0,64,64
Value=25
Mass=2
Rotate=1

View File

@ -12,4 +12,4 @@ VertexFriction=50,100,100
Value=10
Mass=2
Components=Flour=1
Picture=8,0,16,16
Picture=32,0,64,64

View File

@ -5,7 +5,7 @@ Category=C4D_Object
Width=8
Height=8
Offset=-4,-4
Picture=0,0,8,8
Picture=0,0,64,64
Vertices=3
VertexX=0,2,-2
VertexY=1,-1,-1

View File

@ -12,6 +12,6 @@ VertexCNAT=1,2,16
VertexFriction=30,30,30
Value=25
Mass=16
Picture=0,4,13,13
Picture=0,20,64,64
Components=Nugget=3
Rotate=1

View File

@ -7,7 +7,7 @@ TimerCall=Check
Width=8
Height=8
Offset=-4,-4
Picture=0,0,8,8
Picture=0,0,64,64
Vertices=3
VertexX=0,2,-2
VertexY=1,-1,-1

View File

@ -5,7 +5,7 @@ Category=C4D_Object
Width=8
Height=8
Offset=-4,-4
Picture=0,0,8,8
Picture=0,0,64,64
Vertices=2
VertexX=0,0
VertexY=3,-3

View File

@ -14,4 +14,4 @@ Value=8
Mass=12
Components=Ore=1
Rotate=1
Picture=0,4,13,13
Picture=0,20,64,64

View File

@ -5,7 +5,7 @@ Category=C4D_Object
Width=8
Height=8
Offset=-4,-4
Picture=0,0,8,8
Picture=0,0,64,64
Vertices=3
VertexX=0,2,-2
VertexY=1,-1,-1

View File

@ -7,7 +7,7 @@ TimerCall=Check
Width=8
Height=8
Offset=-4,-4
Picture=0,0,8,8
Picture=0,0,64,64
Vertices=3
VertexX=0,2,-2
VertexY=1,-1,-1

View File

@ -5,7 +5,7 @@ Category=C4D_Object
Width=8
Height=8
Offset=-4,-4
Picture=0,0,8,8
Picture=0,0,64,64
Vertices=3
VertexX=0,2,-2
VertexY=1,-1,-1

View File

@ -5,7 +5,7 @@ Category=C4D_Object
Width=3
Height=10
Offset=-2,-5
Picture=4,0,16,16
Picture=16,0,64,64
Vertices=3
VertexX=-2,+2,0
VertexY=5,5,-5

View File

@ -9,7 +9,7 @@ Vertices=4
VertexX=-1,3,-1,-5
VertexY=-4,0,4,0
VertexFriction=50,50,50,50
Picture=0,1,9,9
Picture=0,0,64,64
Value=14
Mass=15
Components=Rock=6;Metal=1;

View File

@ -2,11 +2,11 @@
id=Ropebridge_Post
Version=5,2,0,1
Category=C4D_Structure
Picture=20,0,64,64
Picture=0,0,96,128
Width=12
Height=16
Offset=-6,-10
Vertices=2
VertexY=5,5
VertexX=-2,2
Rotate=0
Rotate=0

View File

@ -8,4 +8,4 @@ Offset=-3,-7
Vertices=2
VertexX=0,0
VertexY=-5,5
Picture=0,0,36,32
Picture=0,0,50,80

View File

@ -11,6 +11,6 @@ VertexFriction=120,120,120
Value=15
Mass=8
Components=Wood=3
Picture=4,0,21,21
Picture=12,0,64,64
Rotate=1
Float=1

View File

@ -11,6 +11,5 @@ VertexFriction=120,120,120
Value=15
Mass=15
Components=Wood=5
Picture=4,0,21,21
Rotate=1
Float=1

View File

@ -5,7 +5,7 @@ Category=C4D_Object
Width=6
Height=6
Offset=-3,-3
Picture=6,0,16,16
Picture=24,0,64,64
Vertices=3
VertexX=0,3,-3
VertexY=-2,2,2

View File

@ -9,7 +9,7 @@ Vertices=3
VertexX=0,-3,3
VertexY=0,1,1
VertexFriction=50
Picture=8,0,8,8
Picture=64,0,64,64
Value=10
Mass=5
Components=Metal=1;Blackpowder=1;

View File

@ -2,7 +2,7 @@
id=Icon_Producer_Acid
Version=5,2,0,1
Category=C4D_StaticBack
Picture=0,0,64,64
Picture=0,0,128,128
Width=64
Height=64
Offset=-32,-32

View File

@ -2,7 +2,7 @@
id=Icon_Producer_Fuel
Version=5,2,0,1
Category=C4D_StaticBack
Picture=0,0,64,64
Picture=0,0,128,128
Width=64
Height=64
Offset=-32,-32

View File

@ -2,7 +2,7 @@
id=Icon_Producer_Lava
Version=5,2,0,1
Category=C4D_StaticBack
Picture=0,0,64,64
Picture=0,0,128,128
Width=64
Height=64
Offset=-32,-32

View File

@ -2,7 +2,7 @@
id=Icon_Producer_Oil
Version=5,2,0,1
Category=C4D_StaticBack
Picture=0,0,64,64
Picture=0,0,128,128
Width=64
Height=64
Offset=-32,-32

View File

@ -2,7 +2,7 @@
id=Icon_Producer_Water
Version=5,2,0,1
Category=C4D_StaticBack
Picture=0,0,64,64
Picture=0,0,128,128
Width=64
Height=64
Offset=-32,-32

View File

@ -12,8 +12,8 @@ VertexFriction=50,100,100
Value=40
Mass=5
#Components=Metal=1
Picture=0,0,20,20
Picture=0,0,160,160
Exclusive=1
BlastIncinerate=50
Construction=1
Collection=-10,-10,20,20
Collection=-10,-10,20,20

View File

@ -7,7 +7,7 @@ Offset=-5,-5
Vertices=1
VertexY=0
VertexFriction=100
Picture=0,0,10,10
Picture=0,0,60,60
Value=8
Mass=1
Rotate=1

View File

@ -5,7 +5,7 @@ Category=C4D_Object
Width=8
Height=8
Offset=-4,-4
Picture=0,0,8,8
Picture=0,0,64,64
Vertices=3
VertexX=0,2,-2
VertexY=1,-1,-1
@ -18,4 +18,4 @@ ContactIncinerate=1
BlastIncinerate=1
Rotate=1
Float=1
Collectible=1
Collectible=1

View File

@ -117,10 +117,6 @@ bool C4Def::LoadDefCore(C4Group &hGroup)
hGroup.Rename(C4CFN_DefCore, C4CFN_DefCore ".old");
Save(hGroup);*/
// Adjust picture rect
if ((PictureRect.Wdt==0) || (PictureRect.Hgt==0))
PictureRect.Set(0,0,Shape.Wdt,Shape.Hgt);
// Check category
if (!GetPlane() && Category & (C4D_SortLimit | C4D_BackgroundOrForeground))
{
@ -510,6 +506,10 @@ bool C4Def::Load(C4Group &hGroup,
MainFace.Set(NULL,0,0,Shape.Wdt,Shape.Hgt);
}
// Adjust picture rect
if ((PictureRect.Wdt==0) || (PictureRect.Hgt==0))
PictureRect.Set(0,0,Shape.Wdt*Graphics.Bmp.Bitmap->Scale, Shape.Hgt*Graphics.Bmp.Bitmap->Scale);
// validate TopFace
if (TopFace.x<0 || TopFace.y<0 || TopFace.x+TopFace.Wdt>Graphics.Bmp.Bitmap->Wdt || TopFace.y+TopFace.Hgt>Graphics.Bmp.Bitmap->Hgt)
{
@ -521,6 +521,7 @@ bool C4Def::Load(C4Group &hGroup,
else
{
TopFace.Default();
PictureRect.Default();
SolidMask.Default();
}
@ -552,7 +553,7 @@ void C4Def::Draw(C4Facet &cgo, bool fSelected, DWORD iColor, C4Object *pObj, int
{
case C4DefGraphics::TYPE_Bitmap:
fctPicture.Set(graphics->GetBitmap(iColor),fctPicRect.x,fctPicRect.y,fctPicRect.Wdt,fctPicRect.Hgt);
fctPicture.DrawT(cgo,true,iPhaseX,iPhaseY,trans);
fctPicture.DrawTUnscaled(cgo,true,iPhaseX,iPhaseY,trans);
break;
case C4DefGraphics::TYPE_Mesh:
// TODO: Allow rendering of a mesh directly, without instance (to render pose; no animation)

View File

@ -117,6 +117,45 @@ void C4Facet::DrawT(C4Facet &cgo, bool fAspect, int32_t iPhaseX, int32_t iPhaseY
true,pTransform);
}
void C4Facet::DrawTUnscaled(C4Surface * sfcTarget, float iX, float iY, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform)
{
if (!pDraw || !Surface || !sfcTarget || !Wdt || !Hgt) return;
pDraw->BlitUnscaled(Surface,
float(X+Wdt*iPhaseX),float(Y+Hgt*iPhaseY),float(Wdt),float(Hgt),
sfcTarget,
iX,iY,Wdt,Hgt,true,pTransform);
}
void C4Facet::DrawTUnscaled(C4Facet &cgo, bool fAspect, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform)
{
if (!pDraw || !Surface || !cgo.Surface || !Wdt || !Hgt) return;
// Drawing area
C4Facet ccgo = cgo;
// Adjust for fixed aspect ratio
if (fAspect)
{
// By height
if (100*cgo.Wdt/Wdt<100*cgo.Hgt/Hgt)
{
ccgo.Hgt=Hgt*cgo.Wdt/Wdt;
ccgo.Y+=(cgo.Hgt-ccgo.Hgt)/2;
}
// By width
else if (100*cgo.Hgt/Hgt<100*cgo.Wdt/Wdt)
{
ccgo.Wdt=Wdt*cgo.Hgt/Hgt;
ccgo.X+=(cgo.Wdt-ccgo.Wdt)/2;
}
}
pDraw->BlitUnscaled(Surface,
float(X+Wdt*iPhaseX),float(Y+Hgt*iPhaseY),float(Wdt),float(Hgt),
ccgo.Surface,ccgo.X,ccgo.Y,ccgo.Wdt,ccgo.Hgt,
true,pTransform);
}
void C4Facet::Draw(C4Facet &cgo, bool fAspect, int32_t iPhaseX, int32_t iPhaseY, bool fTransparent)
{
// Valid parameter check

View File

@ -142,6 +142,8 @@ public:
void DrawFullScreen(C4Facet &cgo);
void DrawT(C4Surface * sfcTarget, float iX, float iY, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform); // draw with transformation (if pTransform is assigned)
void DrawT(C4Facet &cgo, bool fAspect, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform);
void DrawTUnscaled(C4Surface * sfcTarget, float iX, float iY, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform); // interpret source coordinates as unscaled
void DrawTUnscaled(C4Facet &cgo, bool fAspect, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform);
void DrawXT(C4Surface * sfcTarget, float iX, float iY, int32_t iWdt, int32_t iHgt, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform);
void DrawClr(C4Facet &cgo, bool fAspect=true, DWORD dwClr=0); // set surface color and draw
void DrawXClr(C4Surface * sfcTarget, int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, DWORD dwClr); // set surface color and draw

View File

@ -503,6 +503,14 @@ void C4Draw::Blit8Fast(CSurface8 * sfcSource, int fx, int fy,
bool C4Draw::Blit(C4Surface * sfcSource, float fx, float fy, float fwdt, float fhgt,
C4Surface * sfcTarget, float tx, float ty, float twdt, float thgt,
bool fSrcColKey, const C4BltTransform *pTransform)
{
return BlitUnscaled(sfcSource, fx * sfcSource->Scale, fy * sfcSource->Scale, fwdt * sfcSource->Scale, fhgt * sfcSource->Scale,
sfcTarget, tx, ty, twdt, thgt, fSrcColKey, pTransform);
}
bool C4Draw::BlitUnscaled(C4Surface * sfcSource, float fx, float fy, float fwdt, float fhgt,
C4Surface * sfcTarget, float tx, float ty, float twdt, float thgt,
bool fSrcColKey, const C4BltTransform *pTransform)
{
// safety
if (!sfcSource || !sfcTarget || !twdt || !thgt || !fwdt || !fhgt) return false;
@ -524,10 +532,6 @@ bool C4Draw::Blit(C4Surface * sfcSource, float fx, float fy, float fwdt, float f
twdt *= Zoom;
thgt *= Zoom;
}
fx *= sfcSource->Scale;
fy *= sfcSource->Scale;
fwdt *= sfcSource->Scale;
fhgt *= sfcSource->Scale;
// emulated blit?
if (!sfcTarget->IsRenderTarget())
return Blit8(sfcSource, int(fx), int(fy), int(fwdt), int(fhgt), sfcTarget, int(tx), int(ty), int(twdt), int(thgt), fSrcColKey, pTransform);

View File

@ -243,6 +243,9 @@ public:
bool Blit(C4Surface * sfcSource, float fx, float fy, float fwdt, float fhgt,
C4Surface * sfcTarget, float tx, float ty, float twdt, float thgt,
bool fSrcColKey=false, const C4BltTransform *pTransform=NULL);
bool BlitUnscaled(C4Surface * sfcSource, float fx, float fy, float fwdt, float fhgt,
C4Surface * sfcTarget, float tx, float ty, float twdt, float thgt,
bool fSrcColKey=false, const C4BltTransform *pTransform=NULL);
bool RenderMesh(StdMeshInstance &instance, C4Surface * sfcTarget, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform* pTransform); // Call PrepareMaterial with Mesh's material before
virtual void PerformBlt(C4BltData &rBltData, C4TexRef *pTex, DWORD dwModClr, bool fMod2, bool fExact) = 0;
virtual void PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform* pTransform) = 0;