Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Fix Camera

Status
Not open for further replies.
Junior Spellweaver
Joined
Feb 4, 2008
Messages
122
Reaction score
148
I got a 21:9 monitor and tried to play in a few servers to notice the game render badly. Thus I'm posting the proper way to fix gunz camera in wide & ultrawide monitors in the hope that major pservers will fix it.

Sample images:
BEFORE

AFTER


REFERENCE (4:3)



Fixing camera (FOV)


Find for "DEFAULT_FOV" (in entire solution), then add the following line below it
Code:
[COLOR=#008000]#define FIXED_FOV(x)    
(2. * atan(tan((2. * atan(tan((x) / 2.) / (4./3.))) / 2.) * (RGetScreenWidth()/(float)RGetScreenHeight())))[/COLOR]

Next find for all ocurrences of "RSetProjection" and replace all calls (A, B and C are figurative names)
Code:
[COLOR=#ff0000]RSetProjection(A, B, C);[/COLOR]

by

Code:
[COLOR=#008000]RSetProjection(FIXED_FOV(A), B, C);[/COLOR]

Congrats you're done fixing the camera! but we're not done yet, this change will mess the ZCombatInterface (the in-game interface) rendering.

Fixing ZCombatInterface

In MDrawContext.h
find
Code:
void FillRectangle(const MRECT& r);
add below it
Code:
[COLOR=#008000][SIZE=5][SIZE=2]virtual void DrawRelative(float x, float y, float w, float h) = 0;
virtual void DrawRelative(float x, float y, int w, int h) = 0;
virtual int TextRelative(float x, float y, const char* szText) = 0;
virtual void DrawRelative(float x, float y, float w, float h, int sx, int sy, int sw, int sh) = 0;
virtual void FillRectangleRelative(float x, float y, float cx, float cy) = 0;[/SIZE][/SIZE][/COLOR]

Go to Mint4R2.h and add below line
Code:
virtual void FillRectangleW(int x, int y, int cx, int cy);

the following
Code:
[COLOR=#008000]virtual void DrawRelative(float x, float y, float w, float h);
virtual void DrawRelative(float x, float y, int w, int h);
virtual int TextRelative(float x, float y, const char* szText);
virtual void DrawRelative(float x, float y, float w, float h, int sx, int sy, int sw, int sh);
virtual void FillRectangleRelative(float x, float y, float cx, float cy);[/COLOR]

Next go to Mint4R2.cpp and add the following lines in the end of the file
Code:
[COLOR=#008000]void MDrawContextR2::DrawRelative(float x, float y, float w, float h)
{
    int correct_w = MGetWorkspaceWidth() / RGetAspect() * (4. / 3.);
    int correct_h = MGetWorkspaceHeight();
    int start = (MGetWorkspaceWidth() - correct_w) / 2;
    float m = correct_w / 800.f;

    MDrawContext::Draw(x * correct_w + start, y * correct_h, w * m, h * m);
}
void MDrawContextR2::DrawRelative(float x, float y, int w, int h)
{
    int correct_w = MGetWorkspaceWidth() / (RGetScreenWidth()/(float)RGetScreenHeight()) * (4. / 3.);
    int correct_h = MGetWorkspaceHeight();
    int start = (MGetWorkspaceWidth() - correct_w) / 2;

    MDrawContext::Draw(x * correct_w + start, y * correct_h, w, h);
}
int MDrawContextR2::TextRelative(float x, float y, const char* szText)
{
    int correct_w = MGetWorkspaceWidth() / (RGetScreenWidth()/(float)RGetScreenHeight()) * (4. / 3.);
    int correct_h = MGetWorkspaceHeight();
    int start = (MGetWorkspaceWidth() - correct_w) / 2;

    return Text(x * correct_w + start, y * correct_h, szText);
}
void MDrawContextR2::DrawRelative(float x, float y, float w, float h, int sx, int sy, int sw, int sh)
{
    int correct_w = MGetWorkspaceWidth() / (RGetScreenWidth()/(float)RGetScreenHeight()) * (4. / 3.);
    int correct_h = MGetWorkspaceHeight();
    int start = (MGetWorkspaceWidth() - correct_w) / 2;
    float m = correct_w / 800.f;

    MDrawContext::Draw(x * correct_w + start, y * correct_h, w * m, h * m, sx, sy, sw, sh);
}
void MDrawContextR2::FillRectangleRelative(float x, float y, float cx, float cy)
{
    int correct_w = MGetWorkspaceWidth() / (RGetScreenWidth()/(float)RGetScreenHeight()) * (4. / 3.);
    int correct_h = MGetWorkspaceHeight();
    int start = (MGetWorkspaceWidth() - correct_w) / 2;

    FillRectangle(x * correct_w + start, y * correct_h, cx * correct_w, cy * correct_h);
}[/COLOR]


Then go to ZCombatInterface.cpp in function"void TextRelative"
find
Code:
[COLOR=#ff0000]int screenx = x*MGetWorkspaceWidth();[/COLOR]
replace by
Code:
[COLOR=#008000]int corrected_workspace_w = MGetWorkspaceWidth() / (RGetScreenWidth()/(float)RGetScreenHeight()) * (4. / 3.);
int start = (MGetWorkspaceWidth() - corrected_workspace_w) / 2;
int screenx = x * corrected_workspace_w + start;[/COLOR]

In function "void ZCombatInterface::OnDraw" find
Code:
[COLOR=#ff0000]int nIcon = 50.0f*fRx;
pDC->Draw( 8.0f*fRx, 153.0f*fRy, nIcon, nIcon);[/COLOR]
replace by
Code:
[COLOR=#008000]float nIcon = 50.0f;
pDC->DrawRelative(8.0f / 800.f, 153.0f / 600.f, nIcon, nIcon);[/COLOR]

find
Code:
[COLOR=#ff0000]int nIcon = 22.0f*fRx;
pDC->Draw( 60.0f*fRx, 175.0f*fRy, nIcon, nIcon);
pDC->Draw( 53.0f*fRx, 175.0f*fRy, nIcon, nIcon);[/COLOR]
replace by
Code:
[COLOR=#008000]float nIcon = 22.0f;
pDC->DrawRelative(60.0f / 800.f, 175.0f / 600.f, nIcon, nIcon);
pDC->DrawRelative(53.0f / 800.f, 175.0f / 600.f, nIcon, nIcon);[/COLOR]

find
Code:
[COLOR=#ff0000]int nPosY = 160.0f*fRy;
pDC->Text( 60.0f*fRx, nPosY, charName[ 0]);[/COLOR]
replace by
Code:
[COLOR=#008000]float nPosY = 160.0f / 600.f;
pDC->TextRelative(60.0f / 800.f, nPosY, charName[ 0]);[/COLOR]

find
Code:
[COLOR=#ff0000]nPosY += 20;
pDC->Text( 80.0f*fRx, nPosY, charName[ 1]);
nPosY += 15;[/COLOR]
replace by
Code:
[COLOR=#008000]nPosY += 20.f / MGetWorkspaceHeight();
pDC->Text(80.0f/ 800.f, nPosY, charName[ 1]);
nPosY += 15 / MGetWorkspaceHeight();[/COLOR]


In function "int ZCombatInterface::DrawVictory"
find
Code:
[COLOR=#ff0000]int nPosX = x * fRx;
int nPosY = y * fRy;
int nSize = 17.0f * fRx;[/COLOR]
replace by
Code:
[COLOR=#008000]float nPosX = x / 800.f;
float nPosY = y / 600.f;
float nSize = 17.0f;[/COLOR]

find
Code:
[COLOR=#ff0000]pDC->Draw( nPosX, nPosY, nSize, nSize, nImage, 0, 32, 32);
nPosX -= nSize * 0.63f;[/COLOR]
replace by
Code:
[COLOR=#008000]pDC->DrawRelative(nPosX, nPosY, nSize, nSize, nImage, 0, 32, 32);
nPosX -= nSize * 0.63f / 800.f;[/COLOR]

find
Code:
[COLOR=#ff0000]nSize = 19.0f * fRx;
nPosY = ( y - 2) * fRy;[/COLOR]
replace by
Code:
[COLOR=#008000]nSize = 19.0f;
nPosY = ( y - 2) / 600.f;[/COLOR]

find
Code:
[COLOR=#ff0000]nPosX -= nSize * 0.2f;
pDC->Draw( nPosX, nPosY, nSize, nSize, nImage, 64, 32, 32);
nPosX -= nSize * 1.1f;[/COLOR]
replace by
Code:
[COLOR=#008000]nPosX -= nSize * 0.2f / 800.f;
pDC->DrawRelative(nPosX, nPosY, nSize, nSize, nImage, 64, 32, 32);
nPosX -= nSize * 1.1f / 800.f;[/COLOR]

find
Code:
[COLOR=#ff0000]nSize = 22.0f * fRx;
nPosY = ( y - 5) * fRy;[/COLOR]
replace by
Code:
[COLOR=#008000]nSize = 22.0f;
+    nPosY = ( y - 5) / 600.f;[/COLOR]


In function "void ZCombatInterface::DrawScoreBoard"

find
Code:
[COLOR=#ff0000]const float fIconSize = .1f;
int nIconSize = fIconSize * MGetWorkspaceWidth();
int screenx=(clancenter-.5f*fIconSize)*MGetWorkspaceWidth();
int screeny=(clany)*MGetWorkspaceHeight();
pDC->Draw(screenx,screeny,nIconSize,nIconSize);[/COLOR]
replace by
Code:
[COLOR=#008000]const float fIconSize = .1f * 800.f;
pDC->DrawRelative(clancenter - 0.5f * fIconSize, clany, fIconSize, fIconSize);[/COLOR]

find
Code:
[COLOR=#ff0000]int y1 = itemy * MGetWorkspaceHeight();
int y2 = (y + linespace * nCount) * MGetWorkspaceHeight();[/COLOR]
replace by
Code:
[COLOR=#008000]float y1 = itemy;
float y2 = y + linespace * nCount;[/COLOR]

find
Code:
[COLOR=#ff0000]int x1 = bClanGame ? 0.43*MGetWorkspaceWidth() : 0.255*MGetWorkspaceWidth();
int x2 = (0.715+0.26)*MGetWorkspaceWidth();
pDC->SetColor(backgroundcolor);
pDC->FillRectangle(x1,y1,x2-x1,y2-y1);
pDC->FillRectangleRelative(x1,y1,x2-x1,y2-y1);[/COLOR]
replace by
Code:
[COLOR=#008000]float x1 = bClanGame ? 0.43 : 0.255;
float x2 = 0.715 + 0.26;
pDC->SetColor(backgroundcolor);
pDC->FillRectangleRelative(x1,y1,x2-x1,y2-y1);[/COLOR]

find
Code:
[COLOR=#ff0000]int screenx = ( ITEM_XPOS[0] - 0.024f) * MGetWorkspaceWidth();
int screeny = icony * MGetWorkspaceHeight();
pDC->Draw( screenx, screeny, nIconSize+4, nIconSize);[/COLOR]
replace by
Code:
[COLOR=#008000]float iconx = ITEM_XPOS[0] - 0.024f;
pDC->DrawRelative(iconx, icony, nIconSize+4, nIconSize);[/COLOR]

find
Code:
[COLOR=#ff0000]int screenx=x*MGetWorkspaceWidth();
int screeny=icony*MGetWorkspaceHeight();
pDC->Draw(screenx,screeny,nIconSize,nIconSize);[/COLOR]
replace by
Code:
[COLOR=#008000]pDC->DrawRelative(x, icony, nIconSize, nIconSize);[/COLOR]

find
Code:
[COLOR=#ff0000]float inv_h = 1.f / MGetWorkspaceHeight();
pDC->SetColor( MCOLOR( 0x40FF0000));
pDC->FillRectangle( (x*MGetWorkspaceWidth()), texty*MGetWorkspaceHeight()+1, 0.08*MGetWorkspaceWidth(), 7);
pQuestPlayerInfo->GetProperty()->fMaxHP;
                 pDC->SetColor( MCOLOR( 0x90FF0000));
pDC->FillRectangle( (x*MGetWorkspaceWidth()), texty*MGetWorkspaceHeight()+1, nValue*MGetWorkspaceWidth(), 7);
 
pDC->SetColor( MCOLOR( 0x4000FF00));
pDC->FillRectangle( (x*MGetWorkspaceWidth()), texty*MGetWorkspaceHeight()+9, 0.08*MGetWorkspaceWidth(), 3);
pQuestPlayerInfo->GetProperty()->fMaxAP;
pDC->SetColor( MCOLOR( 0x9000FF00));
pDC->FillRectangle( (x*MGetWorkspaceWidth()), texty*MGetWorkspaceHeight()+9, nValue*MGetWorkspaceWidth(), 3);[/COLOR]
replace by
Code:
[COLOR=#008000]float inv_h = 1.f / MGetWorkspaceHeight();
pDC->SetColor( MCOLOR( 0x40FF0000));
pDC->FillRectangleRelative(x, texty + inv_h, 0.08, 7.f * inv_h);
float nValue = 0.08 * pQuestPlayerInfo->GetHP() / pQuestPlayerInfo->GetProperty()->fMaxHP;
pDC->SetColor( MCOLOR( 0x90FF0000));
pDC->FillRectangle(x, texty + inv_h, nValue, 7.f * inv_h);
 
pDC->SetColor( MCOLOR( 0x4000FF00));
pDC->FillRectangle(x, texty + 9.f * inv_h, 0.08, 3.f * inv_h);
nValue = 0.08 * pQuestPlayerInfo->GetAP() / pQuestPlayerInfo->GetProperty()->fMaxAP;
pDC->SetColor( MCOLOR( 0x9000FF00));
pDC->FillRectangle(x, texty + 9.f * inv_h, nValue, 3.f * inv_h);[/COLOR]


In function "void ZCombatInterface::DrawResultBoard"

find
Code:
[COLOR=#ff0000]int y1,y2;[/COLOR]
replace by
Code:
[COLOR=#008000]float y1, y2;[/COLOR]

find
Code:
[COLOR=#ff0000]y1 = itemy * MGetWorkspaceHeight();
y2 = (y + linespace * nLeft) * MGetWorkspaceHeight();[/COLOR]
replace by
Code:
[COLOR=#008000]y1 = itemy;
y2 = (y + linespace * nLeft);[/COLOR]

find (no it is not wrongly repeated)
Code:
[COLOR=#ff0000]y1 = itemy * MGetWorkspaceHeight();
y2 = (y + linespace * nRight) * MGetWorkspaceHeight();[/COLOR]
replace by
Code:
[COLOR=#008000]y1 = itemy;
y2 = (y + linespace * nRight);[/COLOR]

find
Code:
[COLOR=#ff0000]pDC->FillRectangle(
               (x-.01f)*MGetWorkspaceWidth(),y1,
               .44f*MGetWorkspaceWidth(),y2-y1);[/COLOR]
replace by
Code:
[COLOR=#008000]pDC->FillRectangleRelative(x - 0.01f, y1, 0.44f, y2 - y1);[/COLOR]

find
Code:
[COLOR=#ff0000]int y1 = itemy * MGetWorkspaceHeight();
 int y2 = (y + linespace * nCount) * MGetWorkspaceHeight();

pDC->FillRectangle(
               0.022f*MGetWorkspaceWidth(),y1,
               0.960*MGetWorkspaceWidth(),y2-y1);[/COLOR]
replace by
Code:
[COLOR=#008000]int y1 = itemy * MGetWorkspaceHeight();
float y1 = itemy;
float y2 = (y + linespace * nCount);
 
pDC->FillRectangleRelative(0.022f, y1, 0.960, y2 - y1);[/COLOR]


In function "void ZCombatInterface::IconRelative"
find
Code:
[COLOR=#ff0000]pDC->SetBitmap(pbmp);
int screenx=x*MGetWorkspaceWidth();
int screeny=y*MGetWorkspaceHeight();
 
int nSize=pDC->GetFont()->GetHeight();
pDC->Draw(screenx,screeny,nSize,nSize);[/COLOR]
replace by
Code:
[COLOR=#008000]pDC->SetBitmap(pbmp);
int nSize=pDC->GetFont()->GetHeight();
pDC->DrawRelative(x, y, nSize, nSize);[/COLOR]



Go to file ZScreenEffectManager.cpp in function "void DrawGuage"
find
Code:
[COLOR=#ff0000]int x1,y1,x2,y2;
x1=x*(float)MGetWorkspaceWidth();
y1=y*(float)MGetWorkspaceHeight();
x2=(x+fWidth)*(float)MGetWorkspaceWidth();
y2=(y+fHeight)*(float)MGetWorkspaceHeight();[/COLOR]
replace by
Code:
[COLOR=#008000]int corrected_workspace_w = MGetWorkspaceWidth() / RGetAspect() * (4. / 3.);
int start = (MGetWorkspaceWidth() - corrected_workspace_w) / 2;

int x1,y1,x2,y2;
x1=x * corrected_workspace_w + start;
y1=y*(float)MGetWorkspaceHeight();
x2=(x+fWidth) * corrected_workspace_w + start;
y2=(y+fHeight)*(float)MGetWorkspaceHeight();[/COLOR]

Also in ZScreenEffectManager.cpp, your function "bool ZScreenEffect::DrawCustom" should look like
Code:
[COLOR=#008000]bool ZScreenEffect::DrawCustom(unsigned long int nTime, const rvector& vOffset, float fAngle)
{
    RGetDevice()->SetRenderState(D3DRS_ZENABLE, FALSE);
    RGetDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

    rmatrix World;
    GetIdentityMatrix(World);

    if (fAngle != 0.0f)
    {
        World = RGetRotZ(fAngle);
    }

    const rvector eye(0, 0, -650), at(0, 0, 0), up(0, 1, 0);
    auto View = ViewMatrix(eye, Normalized(at - eye), up);
    auto Offset = TranslationMatrix(vOffset);

    View = Offset * View;

    RSetTransform(D3DTS_VIEW, View);

    m_VMesh.SetWorldMatrix(World);
    m_VMesh.Render();

    if(m_VMesh.isOncePlayDone()) {
        return false;
    }

    return true;
}[/COLOR]
if it is different fron the above fix it!

Congrats! you fixed it!
 
Last edited:
Newbie Spellweaver
Joined
Dec 4, 2016
Messages
16
Reaction score
4
It would not be better a tutorial of how add more resolution of 1024 x 768 ??????( default max res.)
the hp bar is almost at the center of the screen ( it should not be )
AND I do not want to imagine how it will look "The Scoreboard" ( very small )

grandao - Fix Camera - RaGEZONE Forums
 
Junior Spellweaver
Joined
Feb 4, 2008
Messages
122
Reaction score
148
It would not be better a tutorial of how add more resolution of 1024 x 768 ??????( default max res.)
the hp bar is almost at the center of the screen ( it should not be )
AND I do not want to imagine how it will look "The Scoreboard" ( very small )
The hp bar isn't at the center it is in the same place as you would see it in 4:3 screen aspect. This change is intended. Notice that is a scaled down image from a 3440x1440 image. This is as is so you don't need to actually turn you head to see the hp bar in the monitor border, I think if anyone try it on any 21:9 they will notice how it feels better.
Also the scoreboard won't be small, it will be the same height as before but not stretched.

Anyway it is my personal opinion, others may not like it and I respect their opinion.
 
Newbie Spellweaver
Joined
Dec 4, 2016
Messages
16
Reaction score
4
The hp bar isn't at the center it is in the same place as you would see it in 4:3 screen aspect. This change is intended. Notice that is a scaled down image from a 3440x1440 image. This is as is so you don't need to actually turn you head to see the hp bar in the monitor border, I think if anyone try it on any 21:9 they will notice how it feels better.
Also the scoreboard won't be small, it will be the same height as before but not stretched.

Anyway it is my personal opinion, others may not like it and I respect their opinion.

one last question,only Automatically activates when you detect 21: 9 ????? Or also applies to standard monitors espectre 4:3 , 16:9
 
Junior Spellweaver
Joined
Feb 4, 2008
Messages
122
Reaction score
148
one last question,only Automatically activates when you detect 21: 9 ????? Or also applies to standard monitors espectre 4:3 , 16:9

It will be always "active" but you will notice the difference only in wide & ultrawide aspects.
 
Newbie Spellweaver
Joined
May 10, 2016
Messages
26
Reaction score
2
DEFAULT_FOV appears to me 4 as knowing what is the correct one???
 
Junior Spellweaver
Joined
Feb 4, 2008
Messages
122
Reaction score
148
DEFAULT_FOV appears to me 4 as knowing what is the correct one???
I don't undertand what you mean but, originally DEFAULT_FOV is 1.22173048, which corresponds to 70 degrees in radians.
If you used the above code the FOV will vary depending on resolution, but a value of 4 seems completely wrong.
 
Status
Not open for further replies.
Back
Top