Advanced Camera not working
by Caleb Child · in Torque Game Engine · 11/14/2006 (1:35 am) · 9 replies
I've been trying to impliment the advanced camera code ( http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5471 ) but I am unsuccessful at actually getting it to run.
First of all, the first step of exposing the mCameraObject seems to have already been done, so I have not changed my GameConnection.cc from what I had to begin with. All the code that I was instructed to put into it was already there, the only differance being the two Console Method's were slightly differant, but seeing as the instructions indicate that they were previously not there at all, I figured that I just have a more recent version of Torque that already had the mCameraObject exposed.
By all means, correct me if I am wrong about that.
After that I have done everything that the instructions had told me to do (except for adding the stuff to control the orbit camera, which I will not be using.) The only thing I even wonder about is the second step in the script, with its vague description of "right after %this.camera is set up" so I wonder if the code is supposed to go right after the line "%this.camera = new Camera() { dataBlock = Observer; };" or after "MissionCleanup.add( %this.camera ); %this.camera.scopeToClient(%this);" though I have tried it both way with no change in result; I have left it in the latter form.
What I'm really statring to think is that I simply don't know the proper way to switch camera modes. I was assuming that the script API they list could be typed into the console, and that hasn't done anything. When I tried to use "setPlayerObject();" it squabbled at me because that function doesn't exist. I was never told to create such a function, so I don't know how to do that.
I also have no clue how to adjust the game to defaultly use a specific camera mode. If I could kill two birds with one stone, that would be cool, but otherwise I'll just deal with this one step at a time.
Thank you.
First of all, the first step of exposing the mCameraObject seems to have already been done, so I have not changed my GameConnection.cc from what I had to begin with. All the code that I was instructed to put into it was already there, the only differance being the two Console Method's were slightly differant, but seeing as the instructions indicate that they were previously not there at all, I figured that I just have a more recent version of Torque that already had the mCameraObject exposed.
By all means, correct me if I am wrong about that.
After that I have done everything that the instructions had told me to do (except for adding the stuff to control the orbit camera, which I will not be using.) The only thing I even wonder about is the second step in the script, with its vague description of "right after %this.camera is set up" so I wonder if the code is supposed to go right after the line "%this.camera = new Camera() { dataBlock = Observer; };" or after "MissionCleanup.add( %this.camera ); %this.camera.scopeToClient(%this);" though I have tried it both way with no change in result; I have left it in the latter form.
What I'm really statring to think is that I simply don't know the proper way to switch camera modes. I was assuming that the script API they list could be typed into the console, and that hasn't done anything. When I tried to use "setPlayerObject();" it squabbled at me because that function doesn't exist. I was never told to create such a function, so I don't know how to do that.
I also have no clue how to adjust the game to defaultly use a specific camera mode. If I could kill two birds with one stone, that would be cool, but otherwise I'll just deal with this one step at a time.
Thank you.
About the author
http://calebchild.boldlygoingnowhere.org/caleb/
#2
Even still I figure that there is a considerable differance between adding a function that was not there previously, and modifying one that is already there when the new code might have stuff I still need.
I mean, here's what it says I should add:
ConsoleMethod( GameConnection, setCameraObject, bool, 3, 3, "(ShapeBase object)")
{
ShapeBase *gb;
if(!Sim::findObject(argv[2], gb))
return false;
object->setCameraObject(gb);
return true;
}
ConsoleMethod( GameConnection, getCameraObject, S32, 2, 2, "")
{
argv;
SimObject* cp = object->getCameraObject();
return cp ? cp->getId(): 0;
}
And this is what I already have:
ConsoleMethod(GameConnection, setCameraObject, S32, 3, 3, "")
{
ShapeBase *obj;
if(!Sim::findObject(argv[2], obj))
return false;
object->setCameraObject(obj);
return true;
}
ConsoleMethod(GameConnection, getCameraObject, S32, 2, 2, "")
{
SimObject *obj = object->getCameraObject();
return obj ? obj->getId() : 0;
}
I mean, these are pretty similar. I don't understnad the code that well, so I don't know what the differance between obj and cp is. Even still, the slight changes has me supposing that now some other feature somewhere else in the code will be calling this console method. I don't want to change it and have it mess up something else.
So as it stands right now, I have done nothing more than dump the two new files into the engine\game folder and make the perscribed changes to the files in the FPS's scripts folder.
And currently, it doesn't work.
11/14/2006 (10:03 pm)
Hmm, I can't find anything stating what version I have. I know I picked it up in June, so it's pretty recent.Even still I figure that there is a considerable differance between adding a function that was not there previously, and modifying one that is already there when the new code might have stuff I still need.
I mean, here's what it says I should add:
ConsoleMethod( GameConnection, setCameraObject, bool, 3, 3, "(ShapeBase object)")
{
ShapeBase *gb;
if(!Sim::findObject(argv[2], gb))
return false;
object->setCameraObject(gb);
return true;
}
ConsoleMethod( GameConnection, getCameraObject, S32, 2, 2, "")
{
argv;
SimObject* cp = object->getCameraObject();
return cp ? cp->getId(): 0;
}
And this is what I already have:
ConsoleMethod(GameConnection, setCameraObject, S32, 3, 3, "")
{
ShapeBase *obj;
if(!Sim::findObject(argv[2], obj))
return false;
object->setCameraObject(obj);
return true;
}
ConsoleMethod(GameConnection, getCameraObject, S32, 2, 2, "")
{
SimObject *obj = object->getCameraObject();
return obj ? obj->getId() : 0;
}
I mean, these are pretty similar. I don't understnad the code that well, so I don't know what the differance between obj and cp is. Even still, the slight changes has me supposing that now some other feature somewhere else in the code will be calling this console method. I don't want to change it and have it mess up something else.
So as it stands right now, I have done nothing more than dump the two new files into the engine\game folder and make the perscribed changes to the files in the FPS's scripts folder.
And currently, it doesn't work.
#3
cp and obj are just names for the same thing
if you have done everything else i suppose the problem is in your script rather than in the engine
11/14/2006 (11:27 pm)
Those functions are exactly the samecp and obj are just names for the same thing
if you have done everything else i suppose the problem is in your script rather than in the engine
#4
Am I actually going about the right way of trying to switch camera modes? Maybe everything else is set up right, and I just screwed up my execution.
And at last, the only thing else I can think of is... it said at the end of exposing the mCameraObject that I had to recompile everything. Was I actually having to make a new exe or something? (*tries to run the game without the engine folder, discovers it still works without it*) Crap; I thought that everything I was dealing with were scripts. So how do I recompile with those two new files I had to add?
11/15/2006 (1:18 pm)
Hmm, but I just copied the text straight out of the tutorial. The only thing I had to do to it was re-insert linebreaks so it didn't think the whole thing was commented out.Am I actually going about the right way of trying to switch camera modes? Maybe everything else is set up right, and I just screwed up my execution.
And at last, the only thing else I can think of is... it said at the end of exposing the mCameraObject that I had to recompile everything. Was I actually having to make a new exe or something? (*tries to run the game without the engine folder, discovers it still works without it*) Crap; I thought that everything I was dealing with were scripts. So how do I recompile with those two new files I had to add?
#5
to run the game you dont need the engine folder because everything in there goes into the exe once you compile it.
so what you do is:
1. copy the two advanced camera files to the engine/game folder
2. open up visual studio (or what ever you use)
3. open the torque project
4. add the two files you added to the folder to the project
5. compile the engine
6. you copy the new exe from the outputfolder to your project
then you are ready to go
there is a resource somewhere on how to set up a torque project to compile a new exe i caint find it right now but if you have any problems just post and i will look it up when i get home from work
11/16/2006 (12:22 am)
Well...to run the game you dont need the engine folder because everything in there goes into the exe once you compile it.
so what you do is:
1. copy the two advanced camera files to the engine/game folder
2. open up visual studio (or what ever you use)
3. open the torque project
4. add the two files you added to the folder to the project
5. compile the engine
6. you copy the new exe from the outputfolder to your project
then you are ready to go
there is a resource somewhere on how to set up a torque project to compile a new exe i caint find it right now but if you have any problems just post and i will look it up when i get home from work
#6
Ha ha! and without any help! yes! I am the best!
I actually made a new .exe file!
I can tell that it actually has the advanced camera stuff in it now, because when I go to third person and look up or down the camera stays level.
Nonetheless, it appears that I still don't ACTUALLY know how to activate GodView or any of the other camera modes. What do I need to impliment into the script, or type into the console?
11/16/2006 (12:43 pm)
Holy crap! I did it!Ha ha! and without any help! yes! I am the best!
I actually made a new .exe file!
I can tell that it actually has the advanced camera stuff in it now, because when I go to third person and look up or down the camera stays level.
Nonetheless, it appears that I still don't ACTUALLY know how to activate GodView or any of the other camera modes. What do I need to impliment into the script, or type into the console?
#7
What's that about? I didn't change anything, I just added the advance camera and its header.
11/16/2006 (8:17 pm)
Hey wait a minute, the demoPlayer that runs around the map is invisible now.What's that about? I didn't change anything, I just added the advance camera and its header.
#8
11/16/2006 (9:17 pm)
I had this problem too. Maneol Neto posted a fix for it in the comments:Quote:Okay, found a nasty bug.
The advanced camera server position is always ZERO, so things like items and vehicles will disappear around you if you walk too far from the world origin.
I got a small hack to solve it, and better solutions are welcome.
Go to advancedCamera::advanceTime() and move everything past updateMovementValues(dt) to advancedCamera::interpolateTick(), after Parent::interpolateTick(dt), so now yout advanceTime looks like this:
void AdvancedCamera::advanceTime(F32 dt) {
Parent::advanceTime(dt);
updateMovementValues(dt);
}
Now go to AdvancedCamera::processTick and add these at the end:
if (isServerObject())
{
interpolateTick(0.032f);
}
(that magical number is how long a tick lasts - it wasn't needed really)
Compile, and now the scope problems are gone.
#9
I still don't know how to switch camera modes, though.
What Do I need to type into the console? What can I do to set the default camera?
11/19/2006 (2:01 pm)
Great! I can see Kork again!I still don't know how to switch camera modes, though.
What Do I need to type into the console? What can I do to set the default camera?
Associate David Montgomery-Blake
David MontgomeryBlake