Game Development Community

About the basics

by Akash · in Torque 3D Beginner · 03/16/2013 (7:17 pm) · 17 replies


The Rotation for Objects is -120 to 240 in T3D? When is rotation set to "1 0 0 0"(is it for rectangular /square objects)?

I haven't had time to go trhough the FPS "Tutorial" for quite sometime now, can i expect to learn the
fundamentals/basics (how things are done in Scripts, how things work in scripts, what i am supposed to do/script to make something happen,
etc etc) with the tutorial?

Thanks

#1
03/17/2013 (1:41 am)
Yeah it should cover all of that pretty well, the FPS tutorial should cover everything worth knowing to get started with Torque3D AFAIK. In case I haven't harassed you with it yet, I wrote a CoinCollection tutorial that you might find interesting aswell :)
Find it here

About rotation, it is an euler rotation (I believe it is "x y z theta")
So e.g. "1 0 0 180" will turn the object 180 degree around the x-axis. And
"0.5 0.5 0 180" will turn the object 90 degree around the x- and y-axis.
Not completely sure about it tho! Haven't spend too much time learning how the rotations works.
#2
03/17/2013 (4:41 am)
Thank you, also, TorqueScript does not support:
-> continue
-> break
-> do{}while();> loop

statements?

Thanks
#3
03/17/2013 (4:44 am)
Seems like: it does don't think I've used it tho lol.
#4
03/17/2013 (6:15 am)
Thank you, so it does support do while loop since it supports do while, i guess continue and break are supported too.

#5
03/17/2013 (8:54 am)
Yeah I believe so aswell.
Always happy to help!
And happy torque'ing! :)
#6
03/17/2013 (9:03 am)
Try reading the documentation. Particularly the Scripting > Overview section....

Yes, it supports while, break, continue, for, switch, etc... all in the docs....
#7
03/18/2013 (4:57 am)
Quote:
TorqueScript is not object oriented, you can treat it as such but it wasn't made with object oriented
programming in mind.
Wait, i read somewhere that TS is OO. AFAIK, the new keyword itself is a part of OOP reserved keywords used for creating new objects.

While this is your Personal life & Business, which i hope am not interfering with this now, but, .. you are just 19 years old? That's a quite an achievement at that age there, .. uhm .. i am 20 BTW, not much of "old" either. And thanks for the Tutorial ..

@Richard Ranft,
Thank you, i did actually, but i didn't actually find do{}while, now that you mention it, i guess i must have missed it. Thanks ..
#8
03/18/2013 (5:57 am)
@slowLorris, you don't have interfaces, abstract classes, public private keywords and a whole bunch of other stuff.. Yes it does have objects, but it is more correct to describe it as an event driven language.

And yes, I started at an early age ;) Bought TGE when I was ~15 years old I believe, started programming at 12 or 13 ;)
#9
03/18/2013 (9:46 am)
Updated post for clarity and correctness.

The real gotchas are:
prefix notation doesn't exist: ++%x;
postfix notation does exist: %x++; // but it does prefix operation, oops.

switch() cases don't require a break; to break out of a case before it falls to the next case cause the torque script virtual machine does it for you. So you cannot fall through cases in switch() statements.

Use $= to compare against strings and use == on non-strings. Object names aren't strings by the way, they're actually translated into unique unsigned integers internally. So compare them as non-strings:
%isRocket = (%obj.datablock == RocketProjectileData);

'This isn\'t the string you are looking for'. This is called a tagged string (in single quotation marks) that is used for cases when you are most likely to repeatedly send strings from server to client(s) in multiplayer games. The receiving end of the tagged string has to decode it via detag() and never use tagged strings for non-constant strings because it won't work.

Regular strings are in double quotation marks so "this string will work as you expect it to". Concatenating is easy as: %one = "two" + " three";

$global is a global variable exposed to all scripts as it is prefixed with a dollar sign($) and %local is a local variable to file or function scope when percent sign (%) is prefixed to the variable name. Usually it is common sense for most programmers, but variables and dynamic object fields do not exist until they are assigned a value to cause them to be created. Non-existent variables and object fields, ex. %obj.randomfieldNameHere, will result in an empty string ("") value.

More details can be found in the T3D documentation under User Guide tab: Scripting -> Overview -> Syntax Guide, and Reference Guide tab: Syntax Guide sections.
#10
03/18/2013 (10:26 am)
Really nice overview Nathan! :)
#11
03/18/2013 (10:16 pm)
Quote:
you don't have interfaces, abstract classes, public private keywords and a whole bunch of other stuff.. Yes it does have objects, but it is more correct to describe it as an event driven language.
Urgg, ... , anything from C, i'd give a big THUMBS UP, learned it myself, as i am not even a Computer Science Student, but anything from C++, those abstract classes, polymorphism, operator overloading, etc etc, they're designed to produce lunatics(C++ was meant to be a joke after all).
But my history with Programming is very weird, the first sourcecode that i ever read was that of a Keylogger written in C(it's comment was all that i understood at the time), i tried to get my hands dirty in everything, i tried all the things from Batch scripting, VBS, VB6, PAscal, C (i learned these) but i also tried to get involved in C++ (learned it a bit), JS(barebones), D(it's more weird than i can explain), ASM(learned it a bit), Objective-C(it's another weirdo lang' for me) and C#(never learned much though). But well C is the best for me, everything makes sense in C.

Quote:
switch() cases don't require a break; to break out of a case before it falls to the next case cause the torque script virtual machine does it for you. So you cannot fall through cases in switch() statements.
Oh yes, i had noticed that in the Documentation too .. Thanks for the infos..
#12
03/19/2013 (2:39 am)
If you think D's weird, wait till you try a functional language ;).
#13
03/19/2013 (4:38 am)
Ah, but that's because there is no do, just a while.

C++ is really not that bad. And it's C. The OOP features are very handy for following one of the basic rules; Data is King. Of course, you can use C to get some of the benefits of object oriented techniques - structs don't have a way to protect data, but you can certainly use function pointers as members and contain both data and methods using them. Actually, the worst thing about C++ (according to many aficionados) is the new operator itself - apparently it's terrible, though it works fine for me.

C# is very nice, to me it feels like a blend of C++ and Java. Fun for rapid prototyping.

After venturing into assembly I find it hard to believe that you find C++ difficult and weird. That is some brain-bending stuff.
#14
03/19/2013 (7:00 am)
Quote:If you think D's weird, wait till you try a functional language ;).
Well i couldn't actually pick it up, so it was sort of weird for me.

Quote:After venturing into assembly I find it hard to believe that you find C++ difficult and weird.
I tried ASM, i'm still interested in ASM, but well, after learning a bit, i always ended up questioning myself if the Assembler that i chose at the time was right for me.

I took HLA at first, i was too lazy to read the "Art of the Assembly Language" Book, i abandoned it although many keywords that it used were Pascal Keywords (repeat .. until is as far as i remember one of it's Keywords - that seems to be "borrowed" from Pascal for the sake of Simplicity).

Then I started MASM32 and started also few questions in their forum too, i learned many things that were, i have to admit, quite new to me, i ended up abandoning this one after i read that it was more sort of MACRO based and sort of un-ASM like to the REAL Assemblers.

Then i downloaded FASM, the documentation clearly pointed out that the Documentation was for those who were already comfortably familiar with other Assemblers. I abandoned this one too.

Then finally i chose NASM, i haven't learned it but i downloaded a Torrent VTC Course(Authored by: Arthur Griffith). I'm planning to watch this one when i get time to in future.

For C++, i have purchased a Book(purchased it a long time ago -- Book by: E Balagurusamy) for self study, haven't gone through comfortably with it(not enough to actually pick up with the Concepts clearly), i've downloaded many C++ Ebooks for self study too, but to tell the truth, i haven't studied a single one of those Ebooks.
So C++ is still a weirdo for me. Operator Overloading is one of those concepts that i find quite intimidating.

Well, looking at ASM, (though i admit i'm not an expert), it's not as difficult if enough time is dedicated. A member in MASM32 Forum said:
Quote:
Assembly is the easiest programming language in fact.
It's a personal taste, i believe.

To tell the truth, i actually downloaded ADA 2012 too, i never installed and/or used it. I got very excited and downloaded it after i read that it's used in Defense and similar purposes by the US Govt and also that it resembled the Pascal Programming Language.
But well, my excitement faded away with time as i never tried to learn it, i realized that the Setup file was only consuming my HDD space(it wasn't that heavy though, but it was of no use to me) so i deleted it.
#15
03/19/2013 (7:26 am)
Do you think i should learn C++? Of course again, the taste is not universal. But like you said:
Quote:
you can use C to get some of the benefits of object oriented techniques - structs don't have a way to protect data,
there are many tutorials out there that teach how to emulate OO features in C but, everywhere i look, it's C++, for eg. the T3D Engine SourceCode, fully C++ .. :( I'm familiar with C++ but not with many of it's OO side (which ultimately means i don't have C++ knowledge in reality because OO is what makes C++ the C++)..

Or should i instead go for Object Pascal(it has been a long time now that i haven't touched/read Pascal, i have been downloading the latest Stable release of FreePascal though) but my feeling is that i should concentrate in C++ because it's a superset of C..

Yes it's "choose whichever you want to or feel best" thing but, What would you suggest about C++??

Thanks
#16
03/19/2013 (7:40 am)
@slowLorris, I would recommend learning C++ for game development, most game engines are written in C++ these days.

Although C# is becoming more and more popular tbh, but I'd go with C++..
C++ is what you work with in T3D aswell and I believe Unreal Engine is using C++ aswell.
From C++ it is a small step to C#.
#17
03/19/2013 (3:44 pm)
The object model is very handy in many ways - it's easier to wrap your head around a truck if you can break it into smaller objects and define them clearly. Tire object has certain properties and manages them itself. Rim object has its own set of properties (including a tire, if all is well) and manages them. You can aggregate many objects into a final Truck object. Each piece can be built and tested independently, then assembled and tested. And it makes sense.

Overloading, polymorphism, abstract classes - these are all tools with specific purposes. Learning to use them takes time but is worth the effort.

For the record, MASM is an assembler. The "macro" comes from the "pseudo high-level emulation" and pre-processor features, not from some "hokey broken-ness" or other argument used by some NASM purist. MASM and NASM are functionally equivalent (and TASM) - I've used all three, and TASM shares similar high-level helpers to shorten tasks (those PASCAL-like keywords).

My recomendation is that you should learn what you want - and not let people chase you off of things that you want to learn. Most people here will tell you that C++ is a good place to focus because it will help you to understand, use and get the most out of T3D. If that's a good reason to you, then have at it! There are plenty of people on these forums willing to lend a hand.