QUOTE(pythonBoy @ 01/14/08, 09:47 PM) [snapback]279654[/snapback]
1. Scripting language for games? What does that mean?
mel is a scripting language for 3D graphics. Unlike C++, it doesn't need to be re-compiled, can be tested and debugged easily, and can be easily modified to fit the needs. It's syntax is simpler than C++, and it tends to be a lot more artist friendly. Code written in C++ cannot be modified when running the application - in a sense it is hard coded. If you were writing a game engine, you might want bits of custom code to allow you to handle custom scenarios and puzzles, eg
This sort of code really should be written by the games designer rather than the engine programmer. Considering that compile times for a game these days may be approaching an hour in some extreme examples, writing and testing code without having to re-compile becomes rather useful!
Lua is basically to games, what mel is to Maya. It's just a simple lightweight scripting language.
2. Why should i learn Lua in my case,where my goal is to write a simple 3d application with basic modeling operations?
The way Maya works (and infact our software at NaturalMotion) is to write code in C++ that exposes functionality to the scripting language (Maya uses mel, we use lua). Having done that, you basically have a way of issuing run time scripts to the system, eg
for i=0,10 do
s = createSphere();
which also means, if you have a scripted GUI as well, you can start issuing callbacks from button clicks which call some scripted func. wxLua is available as a scripted version of wx for GUI stuff if you want to go that route.
There are a number of benefits.
- It's trivial to then write unit tests for your apps functionality in the scripting language.
- With a lack of rotate/translate/scale tools (which you've not written yet), you can still move, rotate and scale objects via scripts....
- Ensuring that all GUI commands go through script is a very easy way to ensure you can run your app without a GUI. useful to say, render!
3. You said c# for scripting language.You mean when i write my application then i should use c# to write a scripting language for it? Like mel is for maya?
If you work with .NET (i.e. C#, managed C++, VB etc) then you basically get an extremely good scripting language for free (which is ANY dot net language, i.e. VB, C# etc). It requires about 20 lines of code, and that's it. The nice thing about it is that you also get a plug-in API for free as well with an additional 10 lines of code. For any other scripting language you work with, you'll have to write bindings to expose the C/C++ code to the scripting language. For lua, that would look a bit like this:
float add2nums(float a,float b)
int add2numsBinding(lua_State* lua)
float a = lua_tonumber(lua, -1);
float b = lua_tonumber(lua, -2);
float result = add2nums(a,b);
lua_pushnumber( luaVM, result );
You might notice straight away that the amount of code you need to write to bind the function is more than the function itself - and this example includes no error checking! There are some libs around (i.e. luaBind) that can take some of the dogwork out of binding classes and funcs, but even so it's work that you simply do not have to do with C#.
Things like representing OOP languages and objects starts to get a bit tricky, and frequently messy. It's extremely rare that you'll be able to completely represent an object in script as it appears in C++. These difficulties is why mel script looks very different to the underlying C++ API. (i.e. mel has no concept of objects whatsoever).
Contrast that to .NET, with a bit of organisation at the beginning of a project, and <30 lines of code, you'll never need to write a single binding function. The amount of time that saves you is phenominal (considering that you also get the windows.forms namespace for scripted GUI's as well). I posted here with a rough explanation and code example:
The final advantage of C# is the PropertyGrid control, which basically gives you an attribute editor for free. (trust me, writing any sort of attribute editor in C++ is a PITA). Combine that with a simple TreeView control and you suddenly have your outliner as well. So, with C# you'll get the following for (close to) free:
To get the same level of functionality in C++ may take an experianced programmer a month, an in-experianced one upto a year.
4. The site you gave me,http://lib3ds.sourceforge.net/.Why is that ? 3DS is the format of 3dstudio max files right? Please explain more why this site is useful for me?
3ds, rtg, obj, dxf, ase, bvh, fbx, collada, dotXsi etc are all fairly standard file formats. It makes sense to support one or more of them, preferably by re-using an existing library. Doesn't matter which ones, it'd just be nice to be able to import objects modelled in your app into Maya/Max etc.
5. Can you talk more about collada please? From what i read,I can't understand what it is ?why do i need collada in my case?
It's just a file format. Some people love it, i'm a bit meh with it (i just use my own importers/exporters for the various 3d apps into my own format. Not a strategy i'd recommend though - the file format i wrote pre-dates collada and is more robust due to 8 years or so of development. Doing the same without an existing code base may take you, well, 8 years in my case ).