• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=AaRoNg11;36967226]Starting a new job doing a lot of stuff with Microsoft Azure and Sharepoint next month. Can anybody recommend any books / websites?[/QUOTE] run
[cpp] public Matrix4f invert() { float det = a*f*k*p + a*g*l*n + a*h*j*o + b*e*l*o + b*g*i*p + b*h*k*m + c*e*j*p + c*f*l*m + c*h*i*n + d*e*k*n + d*f*i*o + d*g*j*m - a*f*l*o - a*g*j*p - a*h*k*n - b*e*k*p - b*g*l*m - b*h*i*o - c*e*l*n - c*f*i*p - c*h*j*m - d*e*j*o - d*f*k*m - d*g*i*n; if (det == 0) return null; float na = f*k*p + g*l*n + h*j*o - f*l*o - g*j*p - h*k*n; float nb = b*l*o + c*j*p + d*k*n - b*k*p - c*l*n - d*j*o; float nc = b*g*p + c*h*n + d*f*o - b*h*o - c*f*p - d*g*n; float nd = b*h*k + c*f*l + d*g*j - b*g*l - c*h*j - d*f*k; float ne = e*l*o + g*i*p + h*k*m - e*k*p - g*l*m - h*i*o; float nf = a*k*p + c*l*m + d*i*o - a*l*o - c*i*p - d*k*m; float ng = a*h*o + c*e*p + d*g*m - a*g*p - c*h*m - d*e*o; float nh = a*g*l + c*h*i + d*e*k - a*h*k - c*e*l - d*g*i; float ni = e*j*p + f*l*m + h*i*n - e*l*n - f*i*p - h*j*m; float nj = a*l*n + b*i*p + d*j*m - a*j*p - b*l*m - d*i*n; float nk = a*f*p + b*h*m + d*e*n - a*h*n - b*e*p - d*f*m; float nl = a*h*j + b*e*l + d*f*i - a*f*l - b*h*i - d*e*j; float nm = e*k*n + f*i*o + g*j*m - e*j*o - f*k*m - g*i*n; float nn = a*j*o + b*k*m + c*i*n - a*k*n - b*i*o - c*j*m; float no = a*g*n + b*e*o + c*f*m - a*f*o - b*g*m - c*e*n; float np = a*f*k + b*g*i + c*e*j - a*g*j - b*e*k - c*f*i; a = na; b = nb; c = nc; d = nd; e = ne; f = nf; g = ng; h = nh; i = ni; j = nj; k = nk; l = nl; m = nm; n = nn; o = no; p = np; mult(1f/det); return this; } [/cpp] Is Java gonna optimize this or do I have to do it myself?
should be right
[QUOTE=swift and shift;36971098]should be right[/QUOTE] You sure? The JIT's gonna detect all the redundant multiplications at compile time?
[QUOTE=Smashmaster;36971094][cpp] public Matrix4f invert() { float det = a*f*k*p + a*g*l*n + a*h*j*o + b*e*l*o + b*g*i*p + b*h*k*m + c*e*j*p + c*f*l*m + c*h*i*n + d*e*k*n + d*f*i*o + d*g*j*m - a*f*l*o - a*g*j*p - a*h*k*n - b*e*k*p - b*g*l*m - b*h*i*o - c*e*l*n - c*f*i*p - c*h*j*m - d*e*j*o - d*f*k*m - d*g*i*n; if (det == 0) return null; float na = f*k*p + g*l*n + h*j*o - f*l*o - g*j*p - h*k*n; float nb = b*l*o + c*j*p + d*k*n - b*k*p - c*l*n - d*j*o; float nc = b*g*p + c*h*n + d*f*o - b*h*o - c*f*p - d*g*n; float nd = b*h*k + c*f*l + d*g*j - b*g*l - c*h*j - d*f*k; float ne = e*l*o + g*i*p + h*k*m - e*k*p - g*l*m - h*i*o; float nf = a*k*p + c*l*m + d*i*o - a*l*o - c*i*p - d*k*m; float ng = a*h*o + c*e*p + d*g*m - a*g*p - c*h*m - d*e*o; float nh = a*g*l + c*h*i + d*e*k - a*h*k - c*e*l - d*g*i; float ni = e*j*p + f*l*m + h*i*n - e*l*n - f*i*p - h*j*m; float nj = a*l*n + b*i*p + d*j*m - a*j*p - b*l*m - d*i*n; float nk = a*f*p + b*h*m + d*e*n - a*h*n - b*e*p - d*f*m; float nl = a*h*j + b*e*l + d*f*i - a*f*l - b*h*i - d*e*j; float nm = e*k*n + f*i*o + g*j*m - e*j*o - f*k*m - g*i*n; float nn = a*j*o + b*k*m + c*i*n - a*k*n - b*i*o - c*j*m; float no = a*g*n + b*e*o + c*f*m - a*f*o - b*g*m - c*e*n; float np = a*f*k + b*g*i + c*e*j - a*g*j - b*e*k - c*f*i; a = na; b = nb; c = nc; d = nd; e = ne; f = nf; g = ng; h = nh; i = ni; j = nj; k = nk; l = nl; m = nm; n = nn; o = no; p = np; mult(1f/det); return this; } [/cpp] Is Java gonna optimize this or do I have to do it myself?[/QUOTE] Swap the order of operations - calculate the determinant like so after calculating the auxiliary values: [cpp]float na = ... float ne = ... float ni = ... float nm = ... float det = a * na + b * ne + c * ni + d * nm; if (det == 0) return null; float nb = ... float nc = ... ...[/cpp] Reduces the amount of code and you don't need to rely on the compiler to optimize it. [editline]28th July 2012[/editline] note: I didn't check that the determinant is calculated exactly like that, but it'll at least be something extremely similar
Yeah, that'll work. But this whole thing is making me wonder exactly how much the JIT optimizes.
I am having trouble understanding this articles ( [url]http://gafferongames.com/networking-for-game-programmers/reliability-and-flow-control/[/url] ) Reliability / Flow Control theories. I looked at the source, but it's in C++ and I don't know anything about C++. More specifically, the vector talk. How would I even begin to determine where to update the vector if I received a packet that came 500 milliseconds late. Or even if the sequence has wrapped around? Not to mention how to put the vector to use so I can determine what packets received and what were not. I've been reading this article over and over for about a month now and haven't come to grips with it.
Hey guys. Could somebody suggest what 3d model format should I use for a game? I only need it to support skeletal animations. Preferably easy to read. And hopefully one that doesn't get heavier than 10 mb for something like an animated low-poly character.
So, I'm making a text RPG. I'm trying to create a battle system. I have an Enemy class which has generic members for an enemy (Health,strength,agility etc..). Then I use inheritance for creating a class for an enemy type: [code] class Goblin : public Enemy { }; [/code] So, I have a class for every enemy type there is (Orcs, goblins, bandits). In my battle function I want to pass an enemy type object reference as a parameter. But since I have separate classes for different types of enemies I would have to do this: [code] void Battle(Orc &orc); or void Battle(Goblin &goblin) [/code] How can I make so that I could pass any enemy type that is inherited the Enemy class with one parameter Something like [code] void Battle(Enemy &enemy) [/code] So i would be able to pass any type of enemy
[QUOTE=demoTron;36976058]So, I'm making a text RPG. I'm trying to create a battle system. I have an Enemy class which has generic members for an enemy (Health,strength,agility etc..). Then I use inheritance for creating a class for an enemy type: [code] class Goblin : public Enemy { }; [/code] So, I have a class for every enemy type there is (Orcs, goblins, bandits). In my battle function I want to pass an enemy type object reference as a parameter. But since I have separate classes for different types of enemies I would have to do this: [code] void Battle(Orc &orc); or void Battle(Goblin &goblin) [/code] How can I make so that I could pass any enemy type that is inherited the Enemy class with one parameter Something like [code] void Battle(Enemy &enemy) [/code] So i would be able to pass any type of enemy[/QUOTE] That is already correct? You can point to any child of a base class with the base class pointer, and access any virtual methods on that base class pointer as if they were the ones of the child: [code] Goblin goblin; Enemy enemy Enemy *generic; generic = &goblin enemy.damage( 10 ); //This will call the method from the Enemy class generic->damage( 10 ); //If the damage method is declared virtual, this will call the damage method specific to the goblin if available //Of course, if the method is either not virtual or is not declared in the Goblin class the Enemy version will be called instead [/code] Correct me if I'm wrong, I just finished the C++ tutorial :v:
[QUOTE=demoTron;36976058]So, I'm making a text RPG. I'm trying to create a battle system. I have an Enemy class which has generic members for an enemy (Health,strength,agility etc..). Then I use inheritance for creating a class for an enemy type: [code] class Goblin : public Enemy { }; [/code] So, I have a class for every enemy type there is (Orcs, goblins, bandits). In my battle function I want to pass an enemy type object reference as a parameter. But since I have separate classes for different types of enemies I would have to do this: [code] void Battle(Orc &orc); or void Battle(Goblin &goblin) [/code] How can I make so that I could pass any enemy type that is inherited the Enemy class with one parameter Something like [code] void Battle(Enemy &enemy) [/code] So i would be able to pass any type of enemy[/QUOTE] void Battle(Enemy *enemy)
[QUOTE=Chris220;36976678]void Battle(Enemy *enemy)[/QUOTE] I've never quite understood the use of & in a parameter list. What is the difference between the address of an Enemy versus a pointer to an Enemy? [editline]28th July 2012[/editline] So the & means it is passed by reference, meaning you must pass the exact type, but the parameter variable will be already "pointing" to the same variable that is passed? So you could also do void foo(Bar *&bar) to pass a reference to a pointer to a Bar? [editline]28th July 2012[/editline] Not an exercise in pragmatism I suppose...
[QUOTE=Rayjingstorm;36976695]I've never quite understood the use of & in a parameter list. What is the difference between the address of an Enemy versus a pointer to an Enemy? [editline]28th July 2012[/editline] So the & means it is passed by reference, meaning you must pass the exact type, but the parameter variable will be already "pointing" to the same variable that is passed? So you could also do void foo(Bar *&bar) to pass a reference to a pointer to a Bar? [editline]28th July 2012[/editline] Not an exercise in pragmatism I suppose...[/QUOTE] Im pretty sure it boils down to the following (but I am not expert): * can NOT be changed or modified and are completely read-only & can be changed or modified and are both read/write
[QUOTE=T3hGamerDK;36977107]Im pretty sure it boils down to the following (but I am not expert): * can NOT be changed or modified and are completely read-only & can be changed or modified and are both read/write[/QUOTE] I thought a * could be changed unless declared const? You can change the thing it points to (value dereferenced) or even what it points to (the actual value of the pointer). Same thing with &, you can either pass it as normal( I may or may not change stuff ) or declare it const (I want a reference, but I promise not to mess with it)
Good reference/pointer for the differences: [url]http://yosefk.com/c++fqa/ref.html[/url]
[QUOTE=raBBish;36977474]Good reference/pointer for the differences: [url]http://yosefk.com/c++fqa/ref.html[/url][/QUOTE] So, the & implies you don't really care to have a pointer, but you still want a reference ( either you want to change stuff or you just don't want the overhead of passing a large structure by value ). It doesn't actually add any functionality, it just makes some things a little easier to write? You could just as well ask for a pointer and force the caller to add the & and force yourself to use ->? [editline]28th July 2012[/editline] Sorry if I'm still missing a lot of what you linked to, but much of it goes way over my head :v:
I need help understanding something very simple in assembly. I understand how local stack variables are stored. But how are the offsets from ebp changed into symbolic readable constants. I turned on the assembler output on Visual C++ and I got very odd looking code. [code] _nBase$ = -276 ; size = 4 _base$ = -264 ; size = 4 _depth$ = -252 ; size = 4 _outputName$ = -240 ; size = 4 _header$ = -228 ; size = 18 _newPixels$ = -200 ; size = 4 _pixels$ = -188 ; size = 4 _inputStr$ = -176 ; size = 32 _fileName$ = -136 ; size = 32 _le$ = -96 ; size = 4 _bytesRead$ = -84 ; size = 4 _cellWidth$ = -72 ; size = 4 _height$ = -60 ; size = 4 _width$ = -48 ; size = 4 _outputFile$ = -36 ; size = 4 _inputFile$ = -24 ; size = 4 [/code] Those are the names of the local variables in my function (with underscore and dollar sign added). But I don't recognize this strange syntax. Edit: I figured it out. = is a MASM directive that assigns a symbolic constant (basically a macro in this case) to constant that can be changed later in the program.
I'm not 100% sure why you have to use a pointer to make it 'accept' children of the class as valid arguments for the function, but I know the syntax works. :v: If anyone can explain it, I'd be interested to know as well...
[QUOTE=Rayjingstorm;36977517]So, the & implies you don't really care to have a pointer, but you still want a reference ( either you want to change stuff or you just don't want the overhead of passing a large structure by value ). It doesn't actually add any functionality, it just makes some things a little easier to write? You could just as well ask for a pointer and force the caller to add the & and force yourself to use ->?[/QUOTE] You could say reference is "simpler" or "safer" than a pointer. A reference can't be invalid (like a null pointer), so you can safely assume the given object exists. You can't do pointer arithmetics with references. A reference will always point to the same object. A good tip is to always use references, unless you need to pass a null pointer or do pointer arithmetics. [QUOTE=Chris220;36977821]I'm not 100% sure why you have to use a pointer to make it 'accept' children of the class as valid arguments for the function, but I know the syntax works. :v: If anyone can explain it, I'd be interested to know as well...[/QUOTE] You don't have to use a pointer, references work just as well. [url]http://codepad.org/9wqNQ28C[/url]
[QUOTE=Chris220;36977821]I'm not 100% sure why you have to use a pointer to make it 'accept' children of the class as valid arguments for the function, but I know the syntax works. :v: If anyone can explain it, I'd be interested to know as well...[/QUOTE] Actually, references 'accept' child classes too.
[QUOTE=Chris220;36977821]I'm not 100% sure why you have to use a pointer to make it 'accept' children of the class as valid arguments for the function, but I know the syntax works. :v: If anyone can explain it, I'd be interested to know as well...[/QUOTE] If references are truly automatic pointers (which I'm pretty sure they are). Then references should be acceptable. Since C++ uses polymorphism, classes and structures that inherit from a parent class have to put the variables in order to make the pointer compatable. Syntax example: [code] class a { char a; }; class b : public a { int var; }; [/code] Is the same as an 'a' struct followed by a 'b' struct in memory linearly. It cannot be the other way around even if an optimization could be made out of it. This means as long as you don't depend on the size of struct 'a' or struct 'b' you can utilize THE ADDRESS OF struct 'b' as THE ADDRESS OF struct 'a'. If you need more info, google polymorphism; cplusplus.com provides an excellent explanation of this.
[QUOTE=Nikita;36972679]Hey guys. Could somebody suggest what 3d model format should I use for a game? I only need it to support skeletal animations. Preferably easy to read. And hopefully one that doesn't get heavier than 10 mb for something like an animated low-poly character.[/QUOTE] FBX? Many says that you should make your own format but for me it do not make any sense to reinvent the wheel.
[QUOTE=AlienCat;36978038]FBX? Many says that you should make your own format but for me it do not make any sense to reinvent the wheel.[/QUOTE] FBX is slow to parse and is a proprietary format, requiring the Autodesk FBX SDK to load them.
[QUOTE=Nikita;36972679]Hey guys. Could somebody suggest what 3d model format should I use for a game? I only need it to support skeletal animations. Preferably easy to read. And hopefully one that doesn't get heavier than 10 mb for something like an animated low-poly character.[/QUOTE] IQM - [url]http://lee.fov120.com/iqm/[/url]
Wow, I never knew that you could use references there. I swear I tried once before and it didn't work, so I've used pointers ever since. :v: Well, thanks for telling me that.
[QUOTE=Rayjingstorm;36976653] [/QUOTE] Thank you
[QUOTE=demoTron;36979907]Thank you[/QUOTE] No problem. All of that talk about references/pointers and I'm not even sure it was a part of the question :v:
I was feeling pretty confident after a bit of reading up on OOP and C++, but now that I'm trying to translate my game from C to C++ I'm a wreck trying to decide what should go where. I have a game object, which is going to hold on to the map, players, and per-tick functions to keep the game going. I need to do really basic collision detection, and in C I just used a "collision mesh" over the top of the regular map which was either true ( this tile is colliding ) or false ( this tile is passable ). This is probably a pretty ridiculous method of checking, but the map was basically static, so I populated the mesh once with colliding tiles in the base map, and then kept track of player positions as they moved. In this new model, I'm not sure where this "mesh" should exist or if it needs to exist at all. Does anyone have a better solution? I would like to keep the whole system as modular as possible because I might want to add more attributes later, rather than just colliding or not. [editline]29th July 2012[/editline] Should everything, including the player nodes, just be derived from some generic Tile object or something? I would still keep a base map and a set of players ( all of their positions/directions etc ) but if they were all inherited from one class I could have one unified method for checking their common attributes.
How old is the "int (int, int)" portion of the syntax? I'm not familiar with it - it seems like an awfully application-specific way to pass in a parameter pack. [code] std::function<int (int, int)> func; [/code]
[QUOTE=HubmaN;36991592]How old is the "int (int, int)" portion of the syntax? I'm not familiar with it - it seems like an awfully application-specific way to pass in a parameter pack. [code] std::function<int (int, int)> func; [/code][/QUOTE] It's old. That's a function definition without a name. Takes two ints, returns one.
Sorry, you need to Log In to post a reply to this thread.