Zoom Console Function - Not working
by Jared Schnelle · in Torque Game Engine · 10/26/2002 (8:38 pm) · 6 replies
I'm getting pretty close to a 3rd person zoom which will work. I will post my code, then at the end, post the problems I am having with it:
ShapeBase.h
ShapeBase.cc
commands.cs
When I press 'Home' to zoom in, I get:
Unknown Command setZoomValue (endline)
Object LocalClientConnection(1377) GameConnection -> NetConnection -> SimGroup -> SimSet -> SimObject (endline)
Ok, now that it's all on the table, here is what I think my problem is:
I think the function chokes because of the way I have the zoom function set up. I dont have setZoomValue(S32 value) set up in the Camera class, but rather the ShapeBase. I did this ONLY because the line I needed to change:
is actually in the ShapeBase.cc file. Seeing as Camera is derived from ShapeBase, there would be no way for the last code snippet to ever see the changed value(if I had placed all the functions in camera.cc).
I'm very open for suggestions, thanks.
-Jared
ShapeBase.h
in [i]Class ShapeBase : public GameBase[/i] S32 cameraZoomValue; // Public zoom value virtual void setZoomValue(S32);
ShapeBase.cc
in [i]ShapeBase::ShapeBase[/i]
cameraZoomValue = 0; // Init Zoom to 0
......
in [i]ShapeBase::getCameraTransform[/i]
vp.y = -(max + cameraZoomValue - min) * *pos;
//Actual implementation of this whole thing
......
in [i]New Code[/i]
static void cSetZoomValue(SimObject *ptr, S32, const char **argv)
{
//Console turned our S32 into a string,
//we need to turn it back int an S32
ShapeBase* obj = static_cast<ShapeBase*>(ptr);
obj->setZoomValue(dAtof(argv[2]));
//Debugging purposes
Con::printf("Increment Zoom in cSetZoomValue");
}
......
in [i]New Code[/i]
void ShapeBase::setZoomValue(S32 increment)
{
//Called once we have S32 numbers again
cameraZoomValue += increment; // Public Data
Con::printf("Increment Zoom"); //Debug purposes
}
......
in [i]ShapeBase::consoleInit[/i]
Con::addCommand("ShapeBase", "setZoomValue", cSetZoomValue, "obj.setZoomValue(value)", 3, 3);commands.cs
function serverCmdZoomInCamera(%client)
{
%client.setZoomValue(-1);
}
// Example of my script command to call it.When I press 'Home' to zoom in, I get:
Unknown Command setZoomValue (endline)
Object LocalClientConnection(1377) GameConnection -> NetConnection -> SimGroup -> SimSet -> SimObject (endline)
Ok, now that it's all on the table, here is what I think my problem is:
I think the function chokes because of the way I have the zoom function set up. I dont have setZoomValue(S32 value) set up in the Camera class, but rather the ShapeBase. I did this ONLY because the line I needed to change:
vp.y = -(max + cameraZoomValue - min) * *pos;
is actually in the ShapeBase.cc file. Seeing as Camera is derived from ShapeBase, there would be no way for the last code snippet to ever see the changed value(if I had placed all the functions in camera.cc).
I'm very open for suggestions, thanks.
-Jared
About the author
#2
Script commands do inherit in most cases.
10/26/2002 (11:24 pm)
Check and make sure you're propagating the zoom value over the network if you're setting it on the server, and also, make sure that you're actually refencing a shapebase... I think that the controlled object is a subitem of %client.Script commands do inherit in most cases.
#3
Newbies should read it! I learned a lot doing this.
Tutorial is here.
10/27/2002 (4:34 pm)
I have everything working, and I've posted it as a tutorial.Newbies should read it! I learned a lot doing this.
Tutorial is here.
#4
Did you ever have a chance to look into the 1st person question that Stefan asked on your resource page for zoom in/out?
Just curious before I dig into it myself and waste time rehashing something you've already figured out.
11/22/2002 (2:43 am)
Jared:Did you ever have a chance to look into the 1st person question that Stefan asked on your resource page for zoom in/out?
Just curious before I dig into it myself and waste time rehashing something you've already figured out.
#5
$Pref::player::CurrentFOV = 105;
Also, if you'll notice what happens when you press "e" in the unmodified build, you'll see how they make you zoom in.
11/22/2002 (1:21 pm)
Yes it's very easy. You just need to adjust the FOV value. Take a look in prefs.cs, specifically at:$Pref::player::CurrentFOV = 105;
Also, if you'll notice what happens when you press "e" in the unmodified build, you'll see how they make you zoom in.
#6
Ben, you wrote:
>>Check and make sure you're propagating the zoom value over the network if you're setting it on the
>>server, and also, make sure that you're actually refencing a shapebase... I think that the controlled
>>object is a subitem of %client.
This is exactly my problem, the code is not working when using a dedicated server, which is relating to your conceirns/advise.
Jared, Ben:
How to change the code that this zoom is working with a dedicated server/client model?
12/26/2006 (2:00 pm)
Sorry to dig out this old topic.Ben, you wrote:
>>Check and make sure you're propagating the zoom value over the network if you're setting it on the
>>server, and also, make sure that you're actually refencing a shapebase... I think that the controlled
>>object is a subitem of %client.
This is exactly my problem, the code is not working when using a dedicated server, which is relating to your conceirns/advise.
Jared, Ben:
How to change the code that this zoom is working with a dedicated server/client model?
Torque Owner Jared Schnelle
Point being, that works, I just need to figure out how to get that number changed.
Thanks,
Jared