Trouble changing movement speed and camera height.

Get technical support about the C++ source code and about Lua scripts for maps, entities, GUIs, the console, materials, etc. Also covered are the Cafu libraries and APIs, as well as compiling, linking, and the build system.
Post Reply
Tatwi
Posts: 10
Joined: 2012-08-16, 23:13

Trouble changing movement speed and camera height.

Post by Tatwi » 2012-09-08, 08:39

This is probably really simple, but with my inexperience with the code base and a healthy amount of code comments in German, I am at loss lol...

For the sake of building a map at the appropriate scale, I need to recompile the following changes:

1. Increase movement speed by 200% to 400%.
2. Move the camera height down to 1m from the floor.

I've compiled the R611 suite and have gotten the tools and game functioning. I have even made minor changes to HumanPlayer.cpp in the Deathmatch/Code folder and successfully recompiled it, but when I play the game the changes do not appear to be applied. What I changed,

Code: Select all

const double        VelX    =12000.0*LookupTables::Angle16ToSin[m_Heading];     // 6000 == Client.MoveSpeed
                const double        VelY    =12000.0*LookupTables::Angle16ToCos[m_Heading];     // 6000 == Client.MoveSpeed
I figured that should double the movement speed, but no difference.

For the camera height, I was looking at the following code and I just couldn't make sense of the comment; I don't know what it's trying to tell me, so I don't understand what the values mean, so I can't change the camera height.

Code: Select all

BoundingBox3dT(Vector3dT( 400.0,  400.0,   100.0),    // Roughly 32*32*72 inches, eye height at 68 inches.
                                 Vector3dT(-400.0, -400.0, -1728.8)),   // 68*25.4 == 1727.2
I am probably in over my head here, but these two changes are really the most important first step to building the game, so I need to figure them out. :)

For a bit of background: the game is about whooshing around really quickly, not as a person, but as a little energy being that takes on different tank-like shapes. Ultimately, I would like the camera position to be slightly third person, locked directly over the "vehicle". Having a low camera height increases the illusion of speed and everyone loves to go fast, right?! :)
Thank you for making Cafu!
- Rob from Canada.
www.tpot.ca
User avatar
Carsten
Site Admin
Posts: 2160
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: Trouble changing movement speed and camera height.

Post by Carsten » 2012-09-09, 11:20

Hi Tatwi,
Tatwi wrote:I've compiled the R611 suite and have gotten the tools and game functioning.
What system do you use? Windows? Linux?
Would you mind upgrading to r625 that I've recently uploaded? (Especially if you're using Linux.)
I have even made minor changes to HumanPlayer.cpp in the Deathmatch/Code folder and successfully recompiled it, but when I play the game the changes do not appear to be applied. What I changed,

Code: Select all

const double        VelX    =12000.0*LookupTables::Angle16ToSin[m_Heading];     // 6000 == Client.MoveSpeed
const double        VelY    =12000.0*LookupTables::Angle16ToCos[m_Heading];     // 6000 == Client.MoveSpeed
I figured that should double the movement speed, but no difference.
This looks right, and I just tried the exact same change (lines 450 and 451), and it worked exactly as intended: reckless speed for the human player :cheesy:

Did it properly, without errors etc., recompile and link?
For the camera height, I was looking at the following code and I just couldn't make sense of the comment; I don't know what it's trying to tell me, so I don't understand what the values mean, so I can't change the camera height.

Code: Select all

BoundingBox3dT(Vector3dT( 400.0,  400.0,   100.0),    // Roughly 32*32*72 inches, eye height at 68 inches.
               Vector3dT(-400.0, -400.0, -1728.8)),   // 68*25.4 == 1727.2
The first two numbers in the two vectors define the lateral dimensions of the bounding-box when looking at the player from bird's eye view. The players eye/camera is at 0, so that the bounding box extends 100.0 units above the eye (to account for the parts of the head that are above eye level), and 1728.8 units below (the height of the body below eye level).

Unfortunately, this code is not very well written, and if you change the 1728.8, you have to do this in three or four places in HumanPlayer.cpp. Just search for them and replace them all with the new number (better yet, create a global static variable, and replace the 1728.8 with the new variable).
I am probably in over my head here, but these two changes are really the most important first step to building the game, so I need to figure them out. :)

For a bit of background: the game is about whooshing around really quickly, not as a person, but as a little energy being that takes on different tank-like shapes. Ultimately, I would like the camera position to be slightly third person, locked directly over the "vehicle". Having a low camera height increases the illusion of speed and everyone loves to go fast, right?! :)
:up:
Best regards,
Carsten
Tatwi
Posts: 10
Joined: 2012-08-16, 23:13

Re: Trouble changing movement speed and camera height.

Post by Tatwi » 2012-09-09, 23:59

Carsten wrote:Hi Tatwi,

What system do you use? Windows? Linux?
Would you mind upgrading to r625 that I've recently uploaded? (Especially if you're using Linux.)


Windows 7 64bit, MS Visual C++ Express 2010, Python 2.7.3, Scons 2.2.0, and just upgraded to Cafu r625.

Once I make the following change in CompilerSetup.py

envCommon=Environment(TARGET_ARCH="x86");

the source package compiles completely OK just by typing scons at the windows command line. When I move the EXE files to root Cafu dir and change the path in CaWe to the r625 dir, everything runs/works great. However, when I make changes to HumanPlayer.cpp and recompile with scons, all I end up with is object code in

F:\Cafu-src-r625\Games\DeathMatch\Code\build\win32\vc10\x86\release

DeathMatch.lib rather than DeathMatch.dll

Time stamps show that the DeathMatch.lib is updated, yet when running Cafu (from CaWe or directly), the speed changes are not applied. Obviously I am missing the linking stage to make the DLL and I am not sure why, but it looks like the game can run using the .lib too?

Sorry, I'm clearly a bit lost on the simple things. That first year college C++ experience I had more than a decade ago is showing lol... I tried reading up on scons, because I have never used it before, what I could find was more advanced than what I understand.
Carsten wrote: This looks right, and I just tried the exact same change (lines 450 and 451), and it worked exactly as intended: reckless speed for the human player :cheesy:

Did it properly, without errors etc., recompile and link?
No errors when using scons. The "IDE" seems to function.
Carsten wrote:

Code: Select all

BoundingBox3dT(Vector3dT( 400.0,  400.0,   100.0),    // Roughly 32*32*72 inches, eye height at 68 inches.
               Vector3dT(-400.0, -400.0, -1728.8)),   // 68*25.4 == 1727.2
The first two numbers in the two vectors define the lateral dimensions of the bounding-box when looking at the player from bird's eye view. The players eye/camera is at 0, so that the bounding box extends 100.0 units above the eye (to account for the parts of the head that are above eye level), and 1728.8 units below (the height of the body below eye level).

Unfortunately, this code is not very well written, and if you change the 1728.8, you have to do this in three or four places in HumanPlayer.cpp. Just search for them and replace them all with the new number (better yet, create a global static variable, and replace the 1728.8 with the new variable).
Thank you! Now the numbers make sense! lol... I sat there for a long time looking at that code wondering what it was describing and how I should interpret it. I'm going to add your comment here as a code comment. :) Good idea about making global static variable for it. I may do the same for the movement speed as well.

Speaking of movement speed, am I the only person to notice that holding WA or WD causes the character to run at a 45 degree angle roughly twice as quickly as normal? I haven't looked too closely at this, but it would seem that doing this adds the forward and sideways movement values together and then does not divide them by 2. Not really a problem, just something I noticed. :)

Thank you for all of your help. I am sure you have loads of other things to do!
Last edited by Tatwi on 2012-09-10, 05:47, edited 1 time in total.
Thank you for making Cafu!
- Rob from Canada.
www.tpot.ca
Tatwi
Posts: 10
Joined: 2012-08-16, 23:13

Re: Trouble changing movement speed and camera height.

Post by Tatwi » 2012-09-10, 05:36

lol... I am so dumb.

After I compiled the changes, I *assumed* the changes would be made in the deathmatch.dll, but in actual fact the changes are made right in Cafu.exe itself. So... of course I wouldn't see the changes if I didn't replace the Cafu.exe in the root Cafu dir!

Talk about a "face palm" moment, eh? Yeah...

UPDATE!

This is awesome! I having SO MUCH FUN with this, Carsten! And it was really easy too, once I figured out that my changes were being applied to Cafu.exe. I decided to post a little video of what the art style will look like.

The game takes place on a geometric shape somewhere out in "space". Each side will be a map and will feature a different line colour, but otherwise the whole world will look like this. Imagine all the tubes and platforms of water slide park mixed with a city scape - something fantastically fun to zoom around in. Anyhow, now that I have tested it at the proper speed, I think the art style works as I had envisioned it.
Thank you for making Cafu!
- Rob from Canada.
www.tpot.ca
User avatar
Carsten
Site Admin
Posts: 2160
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: Trouble changing movement speed and camera height.

Post by Carsten » 2012-09-11, 00:27

Tatwi wrote:After I compiled the changes, I *assumed* the changes would be made in the deathmatch.dll, but in actual fact the changes are made right in Cafu.exe itself. So... of course I wouldn't see the changes if I didn't replace the Cafu.exe in the root Cafu dir!

Talk about a "face palm" moment, eh? Yeah...
:cheesy:
Btw., why don't you use option "3." described at http://www.cafu.de/wiki/cppdev:gettings ... w_programs?
This way this hadn't happened at all. ;-)
UPDATE!

This is awesome! I having SO MUCH FUN with this, Carsten!
Wow, a big thanks, it's really nice to hear this! :wohow:
And it was really easy too, once I figured out that my changes were being applied to Cafu.exe. I decided to post a little video of what the art style will look like.
[Youtube video]
The game takes place on a geometric shape somewhere out in "space". Each side will be a map and will feature a different line colour, but otherwise the whole world will look like this. Imagine all the tubes and platforms of water slide park mixed with a city scape - something fantastically fun to zoom around in. Anyhow, now that I have tested it at the proper speed, I think the art style works as I had envisioned it.
Wow, this looks very promising!! :kewl:
I'm looking forward to see what you turn this into!
Speaking of movement speed, am I the only person to notice that holding WA or WD causes the character to run at a 45 degree angle roughly twice as quickly as normal? I haven't looked too closely at this, but it would seem that doing this adds the forward and sideways movement values together and then does not divide them by 2. Not really a problem, just something I noticed. :)
Hehehe... well observed. It's vector addition though, so we'd not need factor 2, but sqrt(2). Or even better, the vector should be normalized to length 1, then scaled back to the actual speed (e.g. *12000) to fix this.
Best regards,
Carsten
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests