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!

My camera option

Joined
Jan 9, 2009
Messages
614
Reaction score
152
So I wanted to see if I could make my own camera option, turned out to be pretty easy, and since I don't see a lot of servers with it, I figured i'd release it (I'm sure it's not the cleanest code you guys have seen, it's probably downright crappy looking, but it gets the job done. Also, updatedist is a optional function for resetting the distance in game, i won't post it because it's simple to create. a function with one line of code in it)


Step 1:Open ZCOnfiguration.cpp.

search for this:
childElement.GetChildContents(&m_Etc.nCrossHair, ZTOK_ETC_CROSSHAIR);
Add this below it :
childElement.GetChildContents(&m_Etc.nCameraDistance, ZTOK_ETC_CAMERA);

Step 2:
search for this :
parentElement.AppendText("\n\t\t");
aElement = parentElement.CreateChildElement(ZTOK_ETC_CROSSHAIR);
sprintf(temp, "%d", m_Etc.nCrossHair);
aElement.SetContents(temp);
Under it, add this:
//Camera Distance
parentElement.AppendText("\n\t\t");
aElement = parentElement.CreateChildElement(ZTOK_ETC_CAMERA);
sprintf(temp, "%d", m_Etc.nCameraDistance);
aElement.SetContents(temp);

Step 3:
Search for this :
m_Etc.nCrossHair = 0;
Under it, add this: m_Etc.nCameraDistance = 290.f; // 290.f = default value

Step 4: Open ZConfiguration.h
Search for this int nCrossHair;
under it, add this:
int nCameraDistance;

step 5:
Search for this :
#define ZTOK_ETC_CROSSHAIR "CROSSHAIR"
under it, add this:
#define ZTOK_ETC_CAMERA "CAMERA"

Step 6:
search for this:
#define Z_ETC_CROSSHAIR (ZGetConfiguration()->GetEtc()->nCrossHair)
under it, add this:
#define Z_ETC_CAMERA (ZGetConfiguration()->GetEtc()->nCameraDistance)

Step 7:Open ZOptionInterface.cpp
At the top add this under #include "ZInterfaceListener.h":
#include "ZCamera.h"

Step 8:
Search for this:
ZCanvas* pCrossHairPreview = (ZCanvas*)pResource->FindWidget("CrossHairPreviewCanvas");
if (pCrossHairPreview)
{
pCrossHairPreview->SetOnDrawCallback(ZCrossHair::OnDrawOptionCrossHairPreview);
}
Under it, add this:
pComboBox = (MComboBox*)pResource->FindWidget("CameraDistance");
if (pComboBox)
{
pComboBox->SetSelIndex(Z_ETC_CAMERA);
ZGetCamera()->RSetCameraDistance(Z_ETC_CAMERA);
}

Step 9:
search for this:
MComboBox* pComboBox = (MComboBox*)pResource->FindWidget("CrossHairComboBox");
if (pComboBox)
{
Z_ETC_CROSSHAIR = pComboBox->GetSelIndex();
}

Under it, add this:

pComboBox = (MComboBox*)pResource->FindWidget("CameraDistance");
if (pComboBox)
{
Z_ETC_CAMERA = pComboBox->GetSelIndex ();
ZGetCamera()->RSetCameraDistance(Z_ETC_CAMERA);
ZGetCamera()->UpdateDist();
}

Step 10: Open ZCamera.h
under this:
void StopShock();
Add this:
void RSetCameraDistance(unsigned short nCameraDistance = 0.f);

Step 11:Open ZCamera.cpp
At the top, under CAMERA_WALL_TRACKSPEED, add this:
unsigned short g_nCameraDistance = 0.f;

Step 12:
Search for ZCamera::Init(), above it, add this:

void ZCamera::RSetCameraDistance(unsigned short nCameraDistance)
{
switch (nCameraDistance)
{
case 0: { g_nCameraDistance = 290.f; } break;
case 1: { g_nCameraDistance = 390.f; } break;
case 2: { g_nCameraDistance = 490.f; } break;
case 3: { g_nCameraDistance = 590.f; } break;
case 4: { g_nCameraDistance = 690.f; } break;
case 5: { g_nCameraDistance = 790.f; } break;
case 6: { g_nCameraDistance = 890.f; } break;
case 7: { g_nCameraDistance = 990.f; } break;
default:{ g_nCameraDistance = 290.f; } break;
}
}

Step 13:
Inside, ZCamera::Init(), near the top, replace m_fdist and m_fcurrantdist with this:

m_fDist = g_nCameraDistance;
m_fCurrentDist = g_nCameraDistance;

Step 14:

Add this to your option.xml(note, change the optiongroup to whatever you want):
<LABEL item="Label" parent="VideoOptionGroup2">
<FONT>FONTa9</FONT>
<TEXTCOLOR>
<R>205</R>
<G>205</G>
<B>205</B>
</TEXTCOLOR>
<BOUNDS>
<X>2</X>
<Y>240</Y>
<W>300</W>
<H>24</H>
</BOUNDS>
<TEXT>CameraDistance</TEXT> <!-- 1초당 프레임 제한 -->
</LABEL>
<COMBOBOX item="CameraDistance" parent="VideoOptionGroup">
<LISTBOXLOOK>CustomListBoxLook</LISTBOXLOOK>
<BUTTONLOOK>ListBoxButtonLook</BUTTONLOOK>
<FONT>FONTa9</FONT>
<TEXTCOLOR>
<R>205</R>
<G>205</G>
<B>205</B>
</TEXTCOLOR>
<TEXTALIGN>
<VALIGN>center</VALIGN>
<HALIGN>left</HALIGN>
</TEXTALIGN>
<BOUNDS>
<X>105</X>
<Y>240</Y>
<W>90</W>
<H>24</H>
</BOUNDS>
<ALIGN>
<HALIGN>right</HALIGN>
</ALIGN>
<LISTITEM selected="true">Default</LISTITEM>
<LISTITEM>390</LISTITEM>
<LISTITEM>490</LISTITEM>
<LISTITEM>590</LISTITEM>
<LISTITEM>690</LISTITEM>
<LISTITEM>790</LISTITEM>
<LISTITEM>890</LISTITEM>
<LISTITEM>990</LISTITEM>
<DROPSIZE>80</DROPSIZE>
<COMBOTYPE>1</COMBOTYPE>
</COMBOBOX>

If this was already release I apologize, I didnt see it though :) if you guys have any questionsor problems let me know.
 
Last edited:
Skilled Illusionist
Joined
Dec 24, 2011
Messages
356
Reaction score
35
i got this problem when i try to build for.
3 IntelliSense: class "ZCONFIG_ETC" has no member "nCameraDistance" d:\1-2-3\Source\Source\Gunz\ZOptionInterface.cpp 455 26 Gunz
7 IntelliSense: class "ZCamera" has no member "UpdateDist" d:\1-2-3\Source\Source\Gunz\ZOptionInterface.cpp 900 17 Gunz
Error 2 error C2039: 'UpdateDist' : is not a member of 'ZCamera' D:\1-2-3\Source\Source\Gunz\ZOptionInterface.cpp 900 1 Gunz
 
Joined
Jan 9, 2009
Messages
614
Reaction score
152
I said in the beginning paragraph that updatedist is optional code, you have to do that part yourself, just remove updatedist from that line. And the first error is because you didn't add int nCameraDistance in ZCONFIG_ETC.
 
Joined
Jan 9, 2009
Messages
614
Reaction score
152
fov and camera are 2 totally different things. your default fov is 70/180 * pi, your default camera distance is 290.f. when you change your camera you aren't changing the field of view, doing the field of view can make the game look like quake, doing the camera just lets you zoom in/out, doesn't affect FOV.

For example, look at franscescos fov add-on, and then compare it to this image:



The camera is zoomed out, but the field of view value remains the same, so you don't get that long view distance that you would if you toyed with the fov.

I've had a couple people ask me how i did the updatedist function, i guess i'll post it, it's very simple.

Step 1:

Open ZCamera.h, search for void setnextlookmode, add this under it:

void UpdateDist();

Step 2:, open ZCamera.cpp, at the bottom of the cpp, add this:

void ZCamera::UpdateDist()
{
m_fDist = g_nCameraDistance;
}

What this does is when you change the game option in game, it'll update the camera rather than requiring you to rejoin the room.
 
Last edited:
Joined
Jan 9, 2009
Messages
614
Reaction score
152
Actually you're totally wrong on that one, the fov can affect the distance at which you view your character, but it causes issues with the view distance looking distorted, this zooms the camera out and leaves the fov value alone. Search the source yourself, they're 2 different things.

Think of FOV being your ability to see left/right/up/down *like with your eyes, humans have a fov of around 135 degrees), camera distance is simply how close the camera is to your character, it doesn't affect the field of view in the slightest. *think of the camera as binoculars, they zoom in your view distance, and if you remove them, your view distance goes back to normal*
 
Last edited:
Joined
Jan 9, 2009
Messages
614
Reaction score
152
Help jetman82 this error appears.

jgmbauP - My camera option - RaGEZONE Forums

Reread my first post, you missed adding the functions in zcamera.h and zcamera.cpp
 

Attachments

You must be registered for see attachments list
Back
Top