mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

@Tesu, note that he does augment the matrix with the RHS vector, see method solve_x() where he allocated C as N x N+1 and fills it up with values properly.

Also @Tesu, try not to post ready-made code. If the OP wanted to just pick a Gaussian elimination algorithm to copy-paste in his own code, he would have done so instead of posting a thread here, it's not hard to find simple algorithms with a simple Google search, but it takes the fun and learning out of doing it yourself. For instance, someone can download the source code for CLARAty and get all matrix numerical methods you can imagine, and much much more, in one shot, or I could give him my own extensive matrix numerical methods libraries.. But that's no fun.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Line 56 should take an array of answers, like this:

int answers(string* userAnswers, const int SENTINEL) //notice the * again.

Line 96 should call the answers() function like this:

score = answers(userAnswers, SENTINEL); //notice the removal of [SENTINEL]
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

First, INFINITY comes up because of a divide-by-zero, so check that you don't have a 0 divisor before dividing. NOTE: your random function is really unnecessarily complicated.

Line 59 should read: "b = b + (A[j] * s[j]);" notice the index "j" for the vector s.

Line 94 should read: "for(int m = 0; m <= N; ++m)" notice the <= instead of < because you need to pivot the solution vector as well.

Other then that, I think it's ok. Now you just have the actual elimination to do, which is not harder than what you did already. :)


BTW: just a little tip, to do a pivot, you don't actually need to swap the two rows, you can just add the proper one (the one with max diagonal) to the improper one (the one with smaller diagonal value), but keep it like that, it's fine.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

At line 63 you use getline() to write to an array of strings. You need to call this function for every string in the array:

string* grade = new string[SENTINEL];
  for(int i=0;i<SENTINEL;++i)
    getline(inAnswers, grade[i]);
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well just to settle that little argument about passing a double by value or const-ref, let me use the words of two of the gods of C++, Andrei Alexandrescu and Herb Sutter:

Prefer to follow these guidelines for choosing how to take parameters. For input-only parameters:
- Always const-qualify all pointers or references to input-only parameters.
- Prefer taking inputs of primitive types (e.g., char, float) and value objects that are cheap to copy (e.g., Point, complex<float>) by value.
- Prefer taking inputs of other user-defined types by reference to const.
- Consider pass-by-value instead of reference if the function requires a copy of its argument. This is conceptually identical to taking a reference to const plus doing a copy, and it can help compiler to better optimize away temporaries.

The second and last points here were the two points I was making in my previous post.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I don't think avoiding an extra useless copy of a double would be useless!!!

Well, I thought you originally made a _joke_ code correction altogether, because you have been posting questions on micro-optimization. It led me to believe you knew the inline keyword was useless there and the "const double&" is not way better than just "double", because swapping a _theoretical_ copy of a double by a _theoretical_ reference to a double (which is implemented as a pointer) is the same in theory. In practice, most compilers, even without optimization options, will not create a useless copy of the double or a useless pointer (ref), so it doesn't make a difference. Furthermore, while doing floating-point operations, it's more efficient to a stick to floats (or doubles) by value and avoid pointers or too many integers, it's a matter of avoiding mixing too much floating-point registers and integer registers.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I have an eagle eye for code, but not that sharp. "const double&" is OK, kind of useless, but OK.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

You didn't need to say it was line 59, I spotted the mistake in a second, line 59 should be:

string* grade = new string[SENTINEL]; //Notice the * sign

And just for good programming practices, you should have a "delete[] grade;" statement before returning from the answers() function.

EDIT: you beat me at it Agni.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

@stevee: you shouldn't post complete code like that, he can just grab it and hand it in as the assignment solution. Especially since there is one mistake:

Line 11 in the above should be:

if ((m[x][0] > m[y][0]) || ((m[x][0] == m[y][0]) && (m[x][1] > m[y][1]))) {

That is for primary sort by row ([0] values) and secondary sort by column ([1] values).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

>> compiler should still be able to accept initializer list cause it knows that order.
I guess vijayan was able to answer that, so I guess the new standard will allow that without problems.

I think it all revolves around the problem for compilers to achieve multiple inheritance (especially virtual inheritance) where the vtable pointer and data have to be mixed to some degree, and so the compiler has to have some freedom in choosing how to order private, protected and public data members. But I would really be going beyond my expertise if I said anything more. You should browse around the web on issues related to "Binary Compatibility in C++" to get a good understanding of this. I did that a while ago and it was very helpful, but it is also quite a bit complex and I don't remember enough of it to explain this more myself. Sorry.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Please wrap code in tags next time..

Why do you need to get the numbers a string first? Just use an array of int for "names" and get them from cin directly as integers, just like you do with "input".

so change the type of "names" to "int names[5];" and it will work.

Also, the size of your array is 5 not 500 (the value to send to search).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

>> Unfortunately the program that will read this information will not accept a binary input currently

yeah I thought so too, it seems like scientific code to me, and third-party software to load and analyse the data rarely accepts binary. It annoying to have to wait sometimes hours for the data to load in a software before it can be analysed.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

>> sizeof(char) is guaraneed to be 1, so that statement is like saying 1024*1, which makes little sense.

It may be so for char but never assume a type "in general" has a particular size in bytes, most types do not have a cross-all-platforms guarantee of that. (program on micro-controllers for a while and you will start to put sizeof() everywhere as an instinctive reflex.. you know sometimes, in some obscure platforms or hardware, there are weird things, like char of size 7 bits and such)

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Are you sure that your sort algorithm is doing what you want? or what is asked?

In my understanding, you have to take each pair (x,y) and sort them from lowest row-index (which is x) to highest and if x's are the same then put the pair with the lowest column-index (y) first. That is what I understand by "primarily sort by row" and "secondarily by column".

Now what your algorithm does is sort all row-indices (x) and then sort all column-indices (y). That will scramble all the pairs (x,y) so it doesn't make sense to me.

Imagine the problem as if you have a bunch of points on a graph, each point has a position (x,y). If you want to draw a line from one point to another, you would have to sort them from left to right (from lowest x to highest x) and points that coincide in x should be sorted from bottom to top (lowest y to highest y). But you shouldn't break up the pairs.

Well, that is just how I understand it, I could very well be wrong.

@firstPerson: why do you even suggest using a built-in sort function? You know this is for a course exercise, what kind of dumb professor would allow you to use a built-in sort function when the point of the exercise is to learn how to write this basic algorithm. If he didn't say that you cannot use it, it's because it's _implied_ …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

They are both correct.

Both just make sure that you use the sizeof() function to determine the size of you buffer, like:
char buffer[1024];
size_t bufferSize = 1024*sizeof(char); //NOT just 1024.


From www.cplusplus.com:

void * memset ( void * ptr, int value, size_t num );

Fill block of memory:
Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Look at this.

When you are about to write the value of No_atoms (which I guess is a dummy value at first), call tellp() before writing the dummy value and save the location value it returns. Afterwards, when you have a real value of No_atoms, use seekp() to get back to that position in the file and write No_atoms again. One thing to check for is that the length is the same, because it will overwrite characters of the original dummy value, so format the ofstream such that both the dummy value and the actual final value take up the same amount of characters (writing it in binary form would be also easier for that, but then you have to write the whole file in binary, which might not be a bad idea if the file is as long as you say it is).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Read this through and you will understand it all.

emps commented: Very good link! +1
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I remember, as I was looking into making an ABI for my projects, that there is very loose standards about how a compiler is allowed to lay out the variables of different scopes. From what I recall, public data members are required to be ordered in memory as they are declared in the class definition, but private members are not, the compiler can choose to arrange them differently. That is in fact one of the major reasons why the Pimpl or Cheeshire-Cat Idiom is often called a "compiler firewall", because it makes the private section have only one data member, i.e. the pimpl pointer, and thus, all compilers will produce the same binary foot-print for an object of that class (given that other conditions are satisfied too!).

So it appears that in the new up-coming standard they may have added some guidelines to make it possible to have all-private data members in a POD. But still not to break code that has mixed public-private data whose binary foot-print is compiler-specific (and even compiling options specific), it has to remain non-POD.

I'm not sure this all makes sense, or is really true, but this is my impression of it.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well as the compiler says, and he is always right, call to move() is ambiguous.

if(a==1)
  obj.move(); //What is the difference between this.
else if(a==0)
  obj.move(); //And that.

You need a final override method when you have a dreaded-diamond. move() needs to be implemented in the watercar class, which ever way you want to implement it for your purpose, it needs an implementation because the compiler cannot choose for you which of the car::move() or boat::move() methods you want to call.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Ok, relax. First of all, you may think that the "_db* db" pointer that is initialized in main.cpp is the same as the "static _db* db;" declared in main.h. IT IS NOT! How scoping works is that the compiler tries to find the first variable named "db" in the inner-most scope first, so it will find a pointer "db" declared in the main() function and initialize that one, not the global one in "main.h". So when you get to readConfig() function, you are addressing a garbage point "db" that has not been initialized.

Simple solution: replace "_db *db = new _db;" with "db = new _db;" and it should work fine.

Another issue, make sure both cpp are compiled in the same translation unit. Otherwise you will have two different global "db" variables... and things will get messy. Remember one of my earlier posts where I suggest a static variable wrapped in a global function implemented in a unique cpp file. I said that was very robust and that I use it for many reasons.. you are starting to experience those reasons, by not following my suggested solution.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Man.. you have some twisted questions..
I'm not sure of the rules. What I understand is, you mean what constructors will allow the compiler to build some constant values as literals. As in:

One some_variable(1,2); //would act like:
  int some_int(1);        //in the sense that the constructor is not called but the memory is initialized as part the initial stack frame of the function.

I would suspect, at least for the coming C++0x, that POD classes can be as such (look up POD classes (Plain Old Data)). Generally, anything that couldn't be a C struct is not a POD class. And in the case you have above non of them are POD because there are private data members. But I suspect, nevertheless, that compilers are clever enough to do a lot at compile time, even for complex classes.

But remember, this is a matter of micro-optimization, or even nano-optimization, which should never take precedence over code clarity and design. Don't let this issue determine how you program your application, because I can tell you that a constructor call is typically not within any CPU-bound looping algorithm, and thus, its speed is really not much of an issue.

Another thing, a function stack frame will be initialized as it is being cached, and the caching operation is usually much more expensive than any few class initialization you might have at the start of a function call.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Did you check the token string you get that should contain the balance? I would suspect it turns out to be "0" instead of "80" or errorneous. 3.35323e-307 is a really weird number, but it is a number very close to 0, so it might actually read 0 and not 80. This might help understand the problem.

BTW: you could use substr() function instead of loops to extract the characters of the returned token one by one, it is less error-prone to use built-in functions.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well look at Boost::Preprocessor, if there isn't a way to do this with that library, there is no way to do it period. There is BOOST_PP_STRINGIFY which takes a non-literal string like just abc and turns it into a literal string "abc". There might be other things of that flavour and that would somehow achieve what you desire.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Umm, adding the "inline" keyword there has absolutely no effect. Read about inline functions. Any method whose implementation is put in the class declaration is by default _suggested_ to be inlined, and adding the inline keyword simply does nothing, so don't waste your finger muscles on adding inline keywords everywhere. Only global or namespace scope free-functions or methods (static or not) whose implementation is later in the header file can be _suggested_ to the compiler to be inlined via the inline keyword.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

"If a class has only a private constructor, that constructor cannot be access and thus cannot be instantiated."

"If a non-POD class has no constructor, that class cannot be instantiated."

I though that was pretty clear from my explanation and examples.
Look up, "private constructors" and "non-POD classes" and you should find plenty of explanations on those concepts.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Ok.. well I won't do the global identifiers idea, that's just like your code but you take the enums out of the class declaration. But to attach the unit to the type is not obvious at first, but quite straight-forward:

struct CentimeterValue; //forward declaration.

struct MeterValue {
  double value;
  explicit MeterValue(double aValue) : value(aValue) { }; //"explicit" is crucial here.
  MeterValue(const CentimeterValue& aValue) : value(aValue.value / 100.0) { }; //this would actually need to be defined later, but just for example.
};

struct CentimeterValue {
  double value;
  explicit CentimeterValue(double aValue) : value(aValue) { };
  CentimeterValue(const MeterValue& aValue) : value(aValue.value * 100.0) { };
};

But again, the tutorial I mentioned in the previous thread is the most robust way to accomplish this, read it to know why. One main reason is that if you have many different unit you will have to program A LOT of pseudo-copy-constructors and unit transformations.

Also, operator overloading can make these structs act like primitive type.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Optimization by the compiler is always a nebulous matter because it is really up to the compiler to do the optimizations it deems necessary or not.

One solution is to use scopes within your functions (I mean "{ ..code.. }" just like that). This way the compiler can more easily determine at what point things become useless and can better piece together the smaller stack frames within the function. There is a general guideline in C++ (and in newer revisions of C), which says that you should try and reduce the scope (or life-time) of your variables to the bare minimum, as much as possible without making the code to messy. So, of course, the old C-style way of putting all variable declarations at the start of the function should be avoided altogether.

As far as how intelligent the compiler is at doing this DU-chain optimization.. it depends on the compiler (very highly as a matter fact). This compiler-intelligence is a reason why the intel compiler, for example, can sometimes produce executable code that is 2 or 3 times faster than any other compiler.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I see nothing wrong with that. Maybe if you are going to use this trick a lot, either you may want to have global (or namespaced) identifiers (enums) for your units or you may want to attach the unit to the type of the parameters, this way you don't have to implement a constructor for every different unit by using implicit type casts that convert a centimeter to a meter value or whatever.

If you are concerned with dimensions (or units) and you are comfortable with template meta-programming, you may want to look at this tutorial or this library.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well, at least with the current draft of C++0x, as implemented by the newest linux g++ compiler (with flag "-std=c++0x"), all of the following work, but not the _exact_ syntax you have up there.

Temp t = {'a','b'};
Final obj(t);
Final obj2({'a','b'});
Final obj3(Temp({'a','b'}));
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well.. it looks like you are looking for a quick answer for an assignment "short-answer" question and that you are not actually interested in understanding what makes a class not instantiatable (that's not a word but whatever).

So that's where I will stop helping you...

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Simple Google search gives this.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I think in code it makes more sense, here are all the cases I can think of:
Notice cases B, C, E and F, they are all valid classes that cannot be instantiated.

#include <iostream>

class simplePOD {
  public:
    int valueInt;
    double valueDouble;
};

class notPOD {
  public:
    simplePOD& someRef;
};

class privCtorClass {
  private:
    int someValue;

    privCtorClass() : someValue(42) { };

};

class privCtorClassWithStatic {
  private:
    int someValue;

    privCtorClassWithStatic() : someValue(42) { };
  public:
    static privCtorClassWithStatic* Create() { 
      return new privCtorClassWithStatic(); 
    };
};

class abstractBase {
  public:
    virtual void somePureVirtualMethod() = 0;
};

class abstractDerived : public abstractBase {
  public:
    virtual void anotherMethod() { 
      std::cout << "Hello!" << std::endl; 
    };
};

/* This will not compile with error class 'useForwardDeclared' is incomplete because of member 'someObject' or incomplete type 'forwardDeclared'
class forwardDeclared;

class useForwardDeclared {
  public:
    forwardDeclared someObject;
};

//No real declaration of forwardDeclared.
*/

int main() {
  simplePOD* A = new simplePOD(); //This works fine.

  notPOD* B = new notPOD(); //This does NOT work.
  
  privCtorClass* C = new privCtorClass(); //This does NOT work.

  privCtorClassWithStatic* D = privCtorClassWithStatic::Create(); //This works fine.

  abstractBase* E = new abstractBase(); //This does NOT work.

  abstractDerived* F = new abstractDerived(); //This does NOT work.
};
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Doesn't Borland have newer products like CodeGear RAD Studio and C++ Builder 2010, now from "embarcadero" at www.embarcadero.com. I think those allow you to take old VCL/CLX applications and port them to the newest library versions. Of course, these have a big price tag too! Visual C++ Express and Code::Blocks are free of course.

I used to love working with Borland products, far better than Microsoft solutions. I used to love being able to compile 40 kLOC projects in a less than 5 seconds with the Borland compiler instead of waiting half-an-hour for the Microsoft compiler to do the same job. Not to mention VCL and great code completion and other programming aids that are very productive in the Borland IDEs. So I understand that you want to stick with that, but don't try and compile stuff on IDE/compilers that are too outdated, it's not a good idea (there's a good reason why they crash or do weird things when you try).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

@thelamb nothing else, you're right.. but "complete abstract class" is not a term that people use (at least not in C++), so I was merely remarking the fact that using imprecise terminology is not an effective way to communicate in this field. And also the OP wants "other" classes beside abstract classes that cannot be instantiated, so that didn't really answer the question.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I'm not sure there is syntaxically correct way provided by C++ (or C legacy stuff), but here is one slightly dirty way to get it done:

memmove(variable + 6, "YouMary", 7 * sizeof(char));
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

@thelamb, any class that has at least one pure virtual method in its declaration or in any of its ancestors (base classes) that has not be overriden (provided an implementation for) is by definition an "Abstract Class". So I don't know what you mean by "complete abstract class" (I guess you mean what Java people call an interface class, which has no data members, no implemented methods, but only pure virtual methods).

One other example of a class that cannot be instantiated is an incomplete class which holds a data member of a type (by value) that was forward-declared but whose actual declaration is never found later. But I don't believe any compiler will actually compile this, but neither will it compile an instantiation of an abstract class either.

Another example is a class that is not POD (Plain Old Data) and that does not have any constructor declared for it (because the compiler will not be able to provide a default constructor is the data in the class it not simple plain old data).

Or a class that has a private default constructor and neither a public constructor nor a public static method to call the private constructor. (that trick btw can be quite useful sometimes)

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

lol.. @Agni, you mean like a job interview? I don't do job interviews... I get job offers. hehe.. just kidding.. my last job interview was on writing artificial intelligence algorithms to optimize fuel-consumption in interplanetary missions, so they didn't really bother asking me a string reversal problem.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Yeah, it's relevant! Dev-C++ is outdated and produces erroneous code on windows version Vista and newer. Use code::blocks instead.

I copied your code and compiled it on linux and I never got errors even with all the original issues that I though _might_ cause the error. So.. yeah it's relevant that you used Dev-C++!

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

All your seed() functions are just calling setSeed() from the base class. Just call setSeed() directly in your main function or replace setSeed in the base class by a virtual seed function. With that, no you don't need to cast.

MAKE YOUR BASE CLASS DESTRUCTOR VIRTUAL!! That's paramount before anything else.

Also, you already have a constructor that seeds the random number generator, the constructor of aRandomNumberGenerator.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Yeah, that's essentially what it's about for the size of string, because, I imagine (or know), that the string class must hold a pointer to the characters and that pointer is like an int in terms of rules about its length, it can be 4 or 8 (or even 2 or 1 on micro-controllers, well 1 is pretty improbable). But also, it can hold other stuff too, maybe an int for the length of the string such that it doesn't need to traverse the string up to the null-character every time you ask for its length.

No there is no limit to the length of a string, not that I know of, at least not for all practical purposes. Of course the ultimate max size of the amount of memory you have on the computer, but that goes without saying. I have, for example, in my earlier days read some huge files (megabytes long or more) into a single string without reaching the end. If you think you might reach the end, I believe you can do a "try-catch" clause on your string to catch the unavailable_resource exception, but I wouldn't bother with that.

Yes, the string will keep on resizing itself every time you change it. Of course, that is not specified in the standard, so a particular implementation of class "string" might have some other more efficient scheme like allocating more memory than it needs in anticipation of having to grow in size later (like a …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I'm not sure if this is the source of the crash, but you should have a virtual seed() function in the base class and the destructor in the base class needs to be virtual as well. the data member "seed" in the base class should be in the "protected" scope not in "private" scope. Try that and see if it helps.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

You should always test, after you use dynamic_cast, whether the returned pointer is NULL. In this case it shouldn't though, so back to square one.

This is not polymorphism (at least not what it usually refers to), you're not supposed to have to perform a dynamic_cast just to call a few virtual functions. Are your functions "seed" and "generate" virtual? Can you show the class declarations of all three classes?

Otherwise, I don't see anything wrong with the code.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I'm not sure I understand what you want to accomplish exactly, but consider first using a shell file (.sh in Unix/Linux or .bat in win console). I'm not sure how you should write it because I don't understand the goal, but I'm pretty sure that will be enough. If you want to write a command from a program, call "system(command_string);" that's all (at least for Linux/Unix).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

You didn't post the main function but I can already say that this error translates to the fact that the compiler cannot figure out what the type of point1 and point2 are. I guess you forgot to include the header for your Point class, or it's two typos.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Ok.. one very important thing that is missing from your understanding and I'm sure this will be a problem-solving revelation:

You implement the constructor to initialize the data members (including board).

Line 8 is just the declaration of the constructor, it does not do anything, YOU have to provide an implementation for it.
That is the error you are getting with compiling it. The compiler tells you that it cannot find the constructor. And all the questions you are asking are exactly about that. So you need to add:

TicTacToe::TicTacToe(char player_, char board_[]) {
  //put whatever initializing function you want there. like setting all the values of "board".
};

Also, I repeat make "box" an integer (int) and take this line "char X, O;" (line 11) out of there. And you forgot to change a few occurrences of X and O to 'X' and 'O'.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Which is better for development?

IDEs:
I have to say windows just because either Borland or Microsoft IDEs are really full-featured, but also expensive. If money is an issue, then Linux has great tools too, KDevelop is now a pretty descent rival to Visual Studio or RAD Studio.

General Programming support and tools:
Linux is the winner by far! All the packages, tools, free libraries, open-source community, etc. To me, doing "serious" programming on windows doesn't make much sense and is really time-consuming and frustrating. (by "serious" I mean not game programming ..please don't take this as offensive or anything)

Third-Party Tools for game development:
Windows wins by far, as pointed out by a few earlier posts. For 3D artists and shader programmers it beats Linux for sure.

Conclusion: I would develop the game cross-platform, spending most of the time programming it in Linux with KDevelop or other, then switching to windows for testing shaders or making models (although Blender in Linux is pretty good too!).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well first, you say (wrist, elbow, shoulder, etc.) so I guess what you have to start with is not the actual position and orientation of each part of the body, but the position of each joint of the body. Since parts are between joints, you need to transform those joint positions to part position and orientation (called just "pose"). Essentially, to do that, look up "3D pose from 3 points" or something like that, it's a classic math problem, and not very hard. Assuming you have enough points to start with, you can use that method with, for example, the points on the wrist and those on the elbow to find the pose of the forearm.

Then, once all the poses of the parts are known, you need to apply it to the model. First the model needs to be split in all the different body parts that you have, or at least, that you can get from the previous step. Then, render each piece with the proper transformation (its pose). To do that, well in openGL it would be with glRotatef() and glTranslatef() for the rotation and translation, respectively. For DX I have no idea, but it's most probably very similar.

That's the general procedure. The math of all this can pretty much be found anywhere on the internet, start with wikipedia, then mathworld, etc.

I hope I answer the question and that I didn't understand it wrong..

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

The purpose of a game engine is to facilitate development of one game, then another, then another, etc. (typically a real game is made of 80-90% game-engine code and the rest is the actual game logic, then you have the artistic part, all the 3D models and animations and everything). So really what it does is give "services" that are useful to develop a game, "any" game ("any" is a relative word, of course). So the first thing to do, is sit down, take a piece of paper and pencil, and make a list of services or features you want your game engine to provide. Start from simple tasks to more rendering-related and user-interface-related tasks. For example:
Basic stuff:
- Save and load a game.
- Load and Use texture files.
- Load and Play sound files.
- Load and Use 2D model files (if any, since an image usually is good enough in 2D).
- Communicate on network for multi-player.
- etc.
Game-related features:
- Display 2D objects (background, characters, etc.)
- Do some AI and control non-human characters.
- Take key-stroke inputs and mouse-clicks
- Display some user-interface (and what do you want on it?)
- etc.

I'm not saying you should take all of the above or any of the above and it's certainly not a complete list either, but do this for yourself. Then, you need to think hard about how they …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I'm not sure how glutBitmapCharacter works, and these results are very weird indeed. Somehow it must treat each letter as an unclippable entity, which is weird.

I used to render text to the screen the old-school way and it works without problem. That is, create 256 display lists, each rendering a unit-size rectangle with the corresponding letter bitmap in the font-file, except for carriage return, space, tab, newline, etc. for which you do some model-view matrix operation instead (for example: for carriage-return you pop the matrix, for new-line you translate down by 1 unit, for space you move left by 1 unit, so on). Once the display lists are done, all you have to do in to render a string is apply the proper translation, rotation, projection, scaling and do "glCallLists(strlen(your_string),GL_UNSIGNED_BYTE,your_string);", et voilà! No clipping problem or whatever else. And it's pretty fast since it's a display list.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well there is a very simple example (in C++):

//create an interface class for a visible objects.
class VisibleObject {
  public:
    virtual void render() = 0; //pure virtual function that renders the object.
};

class Box : public VisibleObject {
  private:
    ..
  public:
    void render(); //implement this such that it renders a box.
};

class Cylinder : public VisibleObject { .... };

class Model3D : public VisibleObject { .... };

//etc..

//later on:
class Scene {
  private:
    vector<VisibleObject*> visible_object_list;
  public:
    void render() {
      for(int i=0; i<visible_object_list.size(); ++i)
        visible_object_list[i]->render(); //polymorphic call to render whichever type of visible object this is.
    }; //the implementation should be in the cpp file.. but inlined for sake of example.
};