Camera mocement code
by arteria3d · in Torque Game Engine · 12/22/2004 (7:17 am) · 67 replies
Which script actually contains the movement code for the camera - i.e. when keys are pressed it moves the camera. I want to know this as i wish to have a go at implementing some swim code, and i will need to use this camera move code to be able to do this. I have looked in camera.cs but i cannot see commands such as 'if w key pressed. then move camera..... etc.
Also how would i disable the editor functions in my finished game?? i.e. All the F functions?
Okay i may want the game to have an editor, but i want to know how i disable stuff like this
Cheers
Steve
Also how would i disable the editor functions in my finished game?? i.e. All the F functions?
Okay i may want the game to have an editor, but i want to know how i disable stuff like this
Cheers
Steve
About the author
Owner of uk based Ltd company ArteriaMediaLtd. with a trading name of Arteria3d Website;arteria3d.com
#42
shapeBase.cc
note: sWaterCoverage = mClampF(sWaterCoverage,0,1);
mWaterCoverage = sWaterCoverage;
which leads us to "sWaterCoverage"
which is set by
12/28/2004 (5:56 am)
More code on how it determines "mWaterCoverage"shapeBase.cc
void ShapeBase::updateContainer()
{
// Update container drag and buoyancy properties
mDrag = mDataBlock->drag;
mBuoyancy = 0;
sWaterCoverage = 0;
mGravityMod = 1.0;
mAppliedForce.set(0, 0, 0);
mContainer->findObjects(getWorldBox(), WaterObjectType|PhysicalZoneObjectType,findRouter,this);
sWaterCoverage = mClampF(sWaterCoverage,0,1);
mWaterCoverage = sWaterCoverage;
mLiquidType = sWaterType;
mLiquidHeight = sWaterHeight;
if (mWaterCoverage >= 0.1f) {
mDrag = mDataBlock->drag * sWaterViscosity * sWaterCoverage;
mBuoyancy = (sWaterDensity / mDataBlock->density) * sWaterCoverage;
}
}note: sWaterCoverage = mClampF(sWaterCoverage,0,1);
mWaterCoverage = sWaterCoverage;
which leads us to "sWaterCoverage"
which is set by
static void waterFind(SceneObject* obj,void * key)
{
ShapeBase* shape = reinterpret_cast<ShapeBase*>(key);
WaterBlock* wb = dynamic_cast<WaterBlock*>(obj);
AssertFatal(wb != NULL, "Error, not a water block!");
if (wb == NULL) {
sWaterCoverage = 0;
return;
}
const Box3F& wbox = obj->getWorldBox();
const Box3F& sbox = shape->getWorldBox();
sWaterType = 0;
if (wbox.isOverlapped(sbox)) {
sWaterType = wb->getLiquidType();
if (wbox.max.z < sbox.max.z)
sWaterCoverage = (wbox.max.z - sbox.min.z) / (sbox.max.z - sbox.min.z);
else
sWaterCoverage = 1;
sWaterViscosity = wb->getViscosity();
sWaterDensity = wb->getDensity();
sWaterHeight = wb->getSurfaceHeight();
}
}
#43
12/28/2004 (5:57 am)
Stephen - its not that i dont spend time looking - its just that as my fundamentals with C like languages are very limited, like Charlie mentioned - i dont know sometimes how to aparoach looking, hence the reason i list my question here!
#44
So what i now need to determine is a way of unlocking the avatar from locking to the terrain floor as in normal movement. Then this would allow freeform movement in the water. Perhaps if i use the command 'on enter water' then i can then set up some code to disable the standard movement and switch to freeflight in the water depth, until reaching the surface or the shore edge...
Cheers buddy for the help
12/28/2004 (6:00 am)
Thanks Charlie - thankyou indeed.So what i now need to determine is a way of unlocking the avatar from locking to the terrain floor as in normal movement. Then this would allow freeform movement in the water. Perhaps if i use the command 'on enter water' then i can then set up some code to disable the standard movement and switch to freeflight in the water depth, until reaching the surface or the shore edge...
Cheers buddy for the help
#45
You can do it I know, I can tell simply by what you are attempting that you have a strong grasp of game fundamentals, and what seems to be a good vision for your project, but since it appears that you are currently working alone, you need the background knowledge to accomplish what you want, and that will only come with time and effort!
12/28/2004 (6:02 am)
A bit of advice then: Many of the things you seem to be interested in either require knowledge of C++ (and the TGE source code), or are almost certainly better performed at that level. I think that your long term game development desires and plans would be most effectively met if you spend a month or so and build up the knowledge of C++, object oriented programming, and a wide variety of software development fundamentals.You can do it I know, I can tell simply by what you are attempting that you have a strong grasp of game fundamentals, and what seems to be a good vision for your project, but since it appears that you are currently working alone, you need the background knowledge to accomplish what you want, and that will only come with time and effort!
#46
After quickly reviewing the code snippets Mathhew posted, you'll note that the only movement vectors corrected/modified are .x and .y (left-right and "into screen/out of screen" in our 3-D cartesian coordinate world system), but no modifications are apparent for the .z movement axis.
This leads me to make a quick guestimate that the code is designed with the assumption that Z axis movement for player objects is clamped to the terrain level while under water (which is what you want to fix in the first place).
You'll want to search through player.cc, specifically updateMove() and see if there is any Z-axis modifications while the player is under water. This will in turn be the place where you want to modify the code for your free-form swimming.
You may be able to look at flying vehicles as well to see how they do Z-Axis movement, but this isn't an area I've worked much in at all. I seem to remember Z-Axis movement being an issue for flying vehicles as well, you may be able to find some help searching for various terms along those lines.
12/28/2004 (6:10 am)
Back to the question at hand:After quickly reviewing the code snippets Mathhew posted, you'll note that the only movement vectors corrected/modified are .x and .y (left-right and "into screen/out of screen" in our 3-D cartesian coordinate world system), but no modifications are apparent for the .z movement axis.
This leads me to make a quick guestimate that the code is designed with the assumption that Z axis movement for player objects is clamped to the terrain level while under water (which is what you want to fix in the first place).
You'll want to search through player.cc, specifically updateMove() and see if there is any Z-axis modifications while the player is under water. This will in turn be the place where you want to modify the code for your free-form swimming.
You may be able to look at flying vehicles as well to see how they do Z-Axis movement, but this isn't an area I've worked much in at all. I seem to remember Z-Axis movement being an issue for flying vehicles as well, you may be able to find some help searching for various terms along those lines.
#47
Actually i have just purchase a good 'Teach Yourself C' book, so i am going to have a good read. I suppose i do come across as a 'furstrated user' sometimes. Its because in Basic, and yes i do mentioned DB PRo a lot - i can program swimming, and all other game function easily now, so doing the same in C, although a lot of the command look similar are in fact quite differnt - so i just need to learn, learn ,learn!!!
12/28/2004 (6:10 am)
Thanks Stephen.. that means a lot, that u can see i am trying!!Actually i have just purchase a good 'Teach Yourself C' book, so i am going to have a good read. I suppose i do come across as a 'furstrated user' sometimes. Its because in Basic, and yes i do mentioned DB PRo a lot - i can program swimming, and all other game function easily now, so doing the same in C, although a lot of the command look similar are in fact quite differnt - so i just need to learn, learn ,learn!!!
#48
shapeBase.cc still
through wordpad haven't been able to find where "findRouter(" is called though, with a compiler this should be easy to find though :)
12/28/2004 (6:13 am)
Now searching for "waterFind(" to trace where it is called fromshapeBase.cc still
void findRouter(SceneObject* obj, void *key)
{
if (obj->getTypeMask() & WaterObjectType)
waterFind(obj, key);
else if (obj->getTypeMask() & PhysicalZoneObjectType)
physicalZoneFind(obj, key);
else {
AssertFatal(false, "Error, must be either water or physical zone here!");
}
}through wordpad haven't been able to find where "findRouter(" is called though, with a compiler this should be easy to find though :)
#49
Please note in db basic - Y is considered the height plane, as Z is, in Torque
So some psuedo code may be:
If (player_notswimming = 0) then
player = camera(1)
cz% = camera(z)
cx% = camera(x)
cy% = camera(y)
height% = get terrain ground height(player,cx%,cz%)
position player,cx%,height%,cz%
The above code would lock the player camera to the terrain height, so it rolls over the terrain like in TGE
If i wanted to go freeform and move the player in the place the camera was currently looking, i would simply take out the height% var and replace it with its counterpart variable cy% - so it doesnt lock anymore.
I am sure this is the similar way i would do it in TGE
12/28/2004 (6:16 am)
In basic, we had the command 'Get terrain height' i.e.Please note in db basic - Y is considered the height plane, as Z is, in Torque
So some psuedo code may be:
If (player_notswimming = 0) then
player = camera(1)
cz% = camera(z)
cx% = camera(x)
cy% = camera(y)
height% = get terrain ground height(player,cx%,cz%)
position player,cx%,height%,cz%
The above code would lock the player camera to the terrain height, so it rolls over the terrain like in TGE
If i wanted to go freeform and move the player in the place the camera was currently looking, i would simply take out the height% var and replace it with its counterpart variable cy% - so it doesnt lock anymore.
I am sure this is the similar way i would do it in TGE
#50
Take his advise and learn the language. Once you get the foundation you can read through code pretty well, even if you can't write it out the same way.
Personally, I don't get mad when people like him get ticked off. Everyone has a breaking point. It does bother me however, that some people seem to just run around and knock other people down.
Life would be better if we could just walk away from the things that tick us off. It really serves no good purpose to bring others down.
EDIT: Mathew, thanks for taking the time to walk through the code.
Stevie: I read just about every post that comes through here even if it doesn't seem like it related to what I'm going after. A lot of the time, I see things that I didn't even know I was looking for. Sort of like this post.
12/28/2004 (6:17 am)
Stephen is very good at getting down to the c stuff. Half the time I see a script post I see him come out with a source alternative.Take his advise and learn the language. Once you get the foundation you can read through code pretty well, even if you can't write it out the same way.
Personally, I don't get mad when people like him get ticked off. Everyone has a breaking point. It does bother me however, that some people seem to just run around and knock other people down.
Life would be better if we could just walk away from the things that tick us off. It really serves no good purpose to bring others down.
EDIT: Mathew, thanks for taking the time to walk through the code.
Stevie: I read just about every post that comes through here even if it doesn't seem like it related to what I'm going after. A lot of the time, I see things that I didn't even know I was looking for. Sort of like this post.
#51
agreed
true, not too far off at least
look at the snippets... inLiquid = true (or false);
similar value... I traced back where it was established for you, at least fairly far back
12/28/2004 (6:22 am)
Quote:Life would be better if we could just walk away from the things that tick us off. It really serves no good purpose to bring others down.
agreed
Quote:I am sure this is the similar way i would do it in TGE
true, not too far off at least
look at the snippets... inLiquid = true (or false);
similar value... I traced back where it was established for you, at least fairly far back
#52
12/28/2004 (6:22 am)
Thanks Mathew
#53
in the scripts under player.cs there is
though to implement what you want you'll probably have to reference some of the source code I posted, I'm interested in doing a similar thing so might test some things out...
as most things in code theres a couple ways to do this...
an interesting way might be to add another value that effects the player movement, so in script you can trigger this value in those case statements, allowing a triggering of new movement physics to swim ( can start small and build up )... might be a better way to do it though
12/28/2004 (6:27 am)
Np, learning a lot myself... I posted them in the order I traced them, so if you trace it back in the same order you should see it in order ( or reverse order depending on how you look at it lol :) )in the scripts under player.cs there is
function Armor::onEnterLiquid(%this, %obj, %coverage, %type)
{
switch(%type)
{
case 0: //Water
case 1: //Ocean Water
case 2: //River Water
case 3: //Stagnant Water
case 4: //Lava
%obj.setDamageDt(%this, $DamageLava, "Lava");
case 5: //Hot Lava
%obj.setDamageDt(%this, $DamageHotLava, "Lava");
case 6: //Crusty Lava
%obj.setDamageDt(%this, $DamageCrustyLava, "Lava");
case 7: //Quick Sand
}
}though to implement what you want you'll probably have to reference some of the source code I posted, I'm interested in doing a similar thing so might test some things out...
as most things in code theres a couple ways to do this...
an interesting way might be to add another value that effects the player movement, so in script you can trigger this value in those case statements, allowing a triggering of new movement physics to swim ( can start small and build up )... might be a better way to do it though
#54
Thanks, but you want to know how? "Search in Files" baby! I literally have spent hundreds and hundreds of hours digging through the source code by searching the entire set of code for various terms like "getTransform", "setHeight", "onEnterLiquid", simply to read, attempt to understand, and compare various uses of functionality within the code.
It's a slow way of learning, and can be difficult when you are simply trying to accomplish one small task, but as the knowledge builds up, things come a lot quicker in the long run.
An editor/IDE that allows you to "Search in Files" (UltraEdit is what I use), or an IDE that gives "Search in Project" capability is just critical in learning a project of the size and complexity TGE has.
12/28/2004 (6:29 am)
@Charlie:Quote:Stephen is very good at getting down to the c stuff. Half the time I see a script post I see him come out with a source alternative.
Thanks, but you want to know how? "Search in Files" baby! I literally have spent hundreds and hundreds of hours digging through the source code by searching the entire set of code for various terms like "getTransform", "setHeight", "onEnterLiquid", simply to read, attempt to understand, and compare various uses of functionality within the code.
It's a slow way of learning, and can be difficult when you are simply trying to accomplish one small task, but as the knowledge builds up, things come a lot quicker in the long run.
An editor/IDE that allows you to "Search in Files" (UltraEdit is what I use), or an IDE that gives "Search in Project" capability is just critical in learning a project of the size and complexity TGE has.
#55
12/28/2004 (6:31 am)
Lol I definately back up what Stephen says... have Visual Studios on my laptop... here on work pc using wordpad... *very* grueling way to do this
#56
There are not many people out here that can wear all the hats and teams are made for that reason. Some are artists, writerss, coders, scripters etc...
So maybe it would be good to get some kind of script private forum going. So people who want to learn just the scripting side can ask questions and get answers that relate to source code. Being that it's not allowed on the public forums.
It would also cut down on incidents like this. Maybe one for the SDk and One for the getting started..
I know a couple of good modders that really can't grasp C++. Just like I know some really high paid VB programmers that can't grasp OOP for the life of them.
It seems a more role centric forum set up would work out really well. Though the site is almost there
Edit:
Stephen, I do alot of the reading on the sdk docs at work. I work third shift so it's way past my bed time now.
I do not however have much time to poor through the code in VS or any editor. I just follow the code the long, long way.
IE writing down functions and following them out on paper .
When I'm home, my four year old has a habit of taking over the machine to play MarbleBlast.
or in her words "Suppa Speeed!"
How could I say no to that?
12/28/2004 (6:34 am)
You know, I was just thinking, GG should throw a forum up in the SDK for scripting questions.There are not many people out here that can wear all the hats and teams are made for that reason. Some are artists, writerss, coders, scripters etc...
So maybe it would be good to get some kind of script private forum going. So people who want to learn just the scripting side can ask questions and get answers that relate to source code. Being that it's not allowed on the public forums.
It would also cut down on incidents like this. Maybe one for the SDk and One for the getting started..
I know a couple of good modders that really can't grasp C++. Just like I know some really high paid VB programmers that can't grasp OOP for the life of them.
It seems a more role centric forum set up would work out really well. Though the site is almost there
Edit:
Stephen, I do alot of the reading on the sdk docs at work. I work third shift so it's way past my bed time now.
I do not however have much time to poor through the code in VS or any editor. I just follow the code the long, long way.
IE writing down functions and following them out on paper .
When I'm home, my four year old has a habit of taking over the machine to play MarbleBlast.
or in her words "Suppa Speeed!"
How could I say no to that?
#57
for all I know you could just throw a modifier when the movespeed is set for when you enterLiquid... then set the density of the water somwhere around 7 or 8... and throw in a swimming animation... course that might not work too lol
edit: @Charlie... I agree... the modding forum is fairly... "weak" you could say lol
12/28/2004 (6:36 am)
More code... shapeBase.h/// Returns the height of the liquid on this object
F32 getLiquidHeight() { return mLiquidHeight; }for all I know you could just throw a modifier when the movespeed is set for when you enterLiquid... then set the density of the water somwhere around 7 or 8... and throw in a swimming animation... course that might not work too lol
edit: @Charlie... I agree... the modding forum is fairly... "weak" you could say lol
#58
Let me adjust your facts a little. First off, I have been a member and TGE owner since January of 2003. You can click on my history and easily verify that I did not post my FIRST forum question untill February of 2004. Not because I couldn't find the forums, or because I wasn't messing with TGE, but because between the search function, and a little hard work, I found I could answer nearly any question I had for myself faster and easier than waiting for someone else to answer it for me. You on the other hand were whining and popping off questions from the day you got here. Now I'm not trying to say I'm better than you or that I'm some kind of coding god or something, I just prefer to learn on my own untill I'm so stumped that I really need help. IMO nearly every question you have asked you could have answered yourself had you tried. I know, because I was a newbie when I bought TGE also. I didn't start out with a manual in my head, I learned it as I went. All I had to go on when I got here was what skills I had, and nothing more. And trust me dude, I was just as lost and just as intimidated when I first jumped into the code. But I didn't waste my time or anyone else's with my newbism because I was more interested in learning it for myself. I personally have nothing against newbies or anyone else asking questions at all. But when it's obvious to me that they are spending more time asking questions than even trying to help themselves, then I stop helping them altogether. And my biggest problem with you is your total lack of appreciation for GG and their products. Saying "TGE has more features than DB" is not going to cut it with me when every other thing out of your mouth is "DB does this, DB does that, DB has this, DB has that, on DB I could, on TGE I can't, DB, DB, DB, DB, DB"
Oh really? Well I reckon you are WRONG. Speaking just for myself I know I put in well more than 10 hours a day on average and most likely spend about 16 or so, EVERY DAY. Most of that time is for paying contracts, some of it is for learning, some of it is for TEACHING or answering questions here at the forums, some of it is for the the pack I'm working on. Very little if ANY is ever spent asking for help, but I will ask when I need it. I also know for a fact that plenty of others spend more than 10 hours a day doing this as well, but I'll let them throw their names in the ring if they choose and stick to you and I for now.
You mean like the assumptions you made in the rest of the paragraph? Or the assumptions you made from the moment you got here? You have done pretty much nothing but criticize the community and the product since the moment you arrived, your history clearly shows that.
So what are you? 'Captain Newb', defender of newbies everywhere? Or are you just a newb that's afraid to admit his own status? And where in the hell do you get off attacking the answers I give? I've helped dozens upon dozens of newbies, experienced coders, and actual paying business' as well. Who in the hell have you helped? You have PLENTY to learn about educating yourself before your mouth makes you look like a total idiot. I even tried to help YOU against my better judgement only to have you want more help and then ultimately having you attack my character as if you were some kind of authority on my contributions here.
Huh? That doesn't even make sense. Are you trying to say it's not good that I know more than you? If so, why not?
12/28/2004 (6:57 am)
StevieLet me adjust your facts a little. First off, I have been a member and TGE owner since January of 2003. You can click on my history and easily verify that I did not post my FIRST forum question untill February of 2004. Not because I couldn't find the forums, or because I wasn't messing with TGE, but because between the search function, and a little hard work, I found I could answer nearly any question I had for myself faster and easier than waiting for someone else to answer it for me. You on the other hand were whining and popping off questions from the day you got here. Now I'm not trying to say I'm better than you or that I'm some kind of coding god or something, I just prefer to learn on my own untill I'm so stumped that I really need help. IMO nearly every question you have asked you could have answered yourself had you tried. I know, because I was a newbie when I bought TGE also. I didn't start out with a manual in my head, I learned it as I went. All I had to go on when I got here was what skills I had, and nothing more. And trust me dude, I was just as lost and just as intimidated when I first jumped into the code. But I didn't waste my time or anyone else's with my newbism because I was more interested in learning it for myself. I personally have nothing against newbies or anyone else asking questions at all. But when it's obvious to me that they are spending more time asking questions than even trying to help themselves, then I stop helping them altogether. And my biggest problem with you is your total lack of appreciation for GG and their products. Saying "TGE has more features than DB" is not going to cut it with me when every other thing out of your mouth is "DB does this, DB does that, DB has this, DB has that, on DB I could, on TGE I can't, DB, DB, DB, DB, DB"
Quote:Believe me, i reckon over the past month there is nobody who has spent the ammount of tiime and effort i have put into torque.
Oh really? Well I reckon you are WRONG. Speaking just for myself I know I put in well more than 10 hours a day on average and most likely spend about 16 or so, EVERY DAY. Most of that time is for paying contracts, some of it is for learning, some of it is for TEACHING or answering questions here at the forums, some of it is for the the pack I'm working on. Very little if ANY is ever spent asking for help, but I will ask when I need it. I also know for a fact that plenty of others spend more than 10 hours a day doing this as well, but I'll let them throw their names in the ring if they choose and stick to you and I for now.
Quote:People should never make assumptions.
You mean like the assumptions you made in the rest of the paragraph? Or the assumptions you made from the moment you got here? You have done pretty much nothing but criticize the community and the product since the moment you arrived, your history clearly shows that.
Quote:I will defend newbies against the crossfire from answers people like u give.
So what are you? 'Captain Newb', defender of newbies everywhere? Or are you just a newb that's afraid to admit his own status? And where in the hell do you get off attacking the answers I give? I've helped dozens upon dozens of newbies, experienced coders, and actual paying business' as well. Who in the hell have you helped? You have PLENTY to learn about educating yourself before your mouth makes you look like a total idiot. I even tried to help YOU against my better judgement only to have you want more help and then ultimately having you attack my character as if you were some kind of authority on my contributions here.
Quote:Its not good you know or clever to think you have an upper hand with newbies
Huh? That doesn't even make sense. Are you trying to say it's not good that I know more than you? If so, why not?
#59
I really could care less how I look to you. It's the last thing on my mind. I'll let my work and contributions speak for how good I am.
Well, I know better than you by a long shot, when you wise up, you might figure that out. And just so you know what exactly you will be missing by striking out at everyone that crosses your path, here is the only help you'll ever get from me untill I see your attitude change quite a bit....
www.garagegames.com/mg/forums/result.thread.php?qt=24126
(Notice how the first thing you said to me in that post after I answered your question was you needed more help because it's not DB? Ironic isn't it?)
12/28/2004 (6:58 am)
Quote:and it certainly doesnt make you look good either.
I really could care less how I look to you. It's the last thing on my mind. I'll let my work and contributions speak for how good I am.
Quote:But i suppose a clown knows best.....
Well, I know better than you by a long shot, when you wise up, you might figure that out. And just so you know what exactly you will be missing by striking out at everyone that crosses your path, here is the only help you'll ever get from me untill I see your attitude change quite a bit....
www.garagegames.com/mg/forums/result.thread.php?qt=24126
(Notice how the first thing you said to me in that post after I answered your question was you needed more help because it's not DB? Ironic isn't it?)
#60
12/28/2004 (7:02 am)
Well Gonzo - i am glad i finally made everyone see how rude you are.......nuff said
Torque 3D Owner Stephen Zepp
If you are willing to spend the time and trace various aggressive posts over the history of who was responded to, I think a high percentage of the time you will see the person that ultimately made an aggressive response has probably "spiraled up" to that aggressive response based on previous history. I know I have in this particular case, and I've seen it happen with other cases as well.
@Stevie:
I've never seen TGE promoted in that manner anywhere. Please point me to where that type of marketing is done (officially), and at the worst, I'll show you the caveats involved. In general, they consist of:
"If you don't want to change any underlying functionality whatsoever, you can modify gameplay, and in many cases accomplish good things using script only".
"Used properly with an understanding of the underlying engine functionality, Torque Script is extensible and extremely powerful, but cannot be used exclusively for all desired functionality, especially if the functionality is new and/or unique".