Jump to content

  • Log In with Google      Sign In   
  • Create Account


Brother Bob

Member Since 26 Nov 2001
Offline Last Active Today, 05:19 PM
*****

#4993714 Assimp number of vertices

Posted by Brother Bob on 25 October 2012 - 02:15 AM

A model with 100k vertices MAY have, not will have, 300k after loading. For obvious reasons, you cannot share two vertices that have different values with the same index, and a cube simply has no shared vertices. Your average model with smooth surfaces is going to have plenty of shared vertices. The problem is sharp corners; at those points you have discontinuities in some attribute, typically the normal, and those are the cases where you cannot have shared vertices anymore. A cube consists entirely of sharp corners.


#4993517 Quaternion Questions

Posted by Brother Bob on 24 October 2012 - 01:35 PM

I have encountered 0 problems with this implementation so far. However, I am starting to implement classes for objects in my 3D world and quickly realized the order of operations would definitely matter, i.e. (X * Y * Z) != (Z * Y * X) for rotations.

It seems the standard solution to this issue and others (Gimbal lock, interpolation, etc.) is to employ quaternions to represent the same information in a different form. I have read several tutorials on quaternions from around the net, and I have a few questions:

Before you dive into quaternions for these reasons, you should know what quaternions are just as sensitive to gimbal lock and order of operations as matrices.

Gimbal lock is an effect of using Euler angles, and using Euler angles as a basis for your quaternions is no better that using Euler angles as a basis for your matrices. The correct solution is to prevent gimbal lock is not to switch to quaternions, but to stop using Euler angles. You can run into the gimbal lock problem with quaternions also if youäre still composing your rotations from Euler angles.

Order of operations is an effect of how rotations work. If you're having problems with order of operations with matrices, you're going to have it with quaternions as well.

It sounds very much like you're just misinformed about what quaternions can do for you. They are no different than matrices when it comes to representing a rotation. Both are just tools to represent a rotation. Problems come from how you use your tools, and both tools are order-dependent and prone to gimbal lock when used with Euler angles. You don't change to quaternions for the reasons you mention, because you're going to keep running in to the same problems.


#4993368 How to test if OpenGL support textures of non power of 2?

Posted by Brother Bob on 24 October 2012 - 03:30 AM

Just because you're using textures doesn't mean you have to draw the whole texture. Another option is to use a texture the size of the next larger power of two and then stick your image in a part of the larger texture. You can even pack multiple images in in the same texture if you want.


#4993272 Finding Index of Class Array

Posted by Brother Bob on 23 October 2012 - 05:33 PM

How you choose to name your functions, if you make them members of a physics object, if want the physics code to have direct access to the characters position of if the physics code moves it with a move function in the character class, or any other details was not the point of my reply. I just commented on that the character should not be responsible for moving itself and checking for collisions, but that the you physics code is responsible for the physics if your game.

If you want to do character.move(), then go ahead and do so. But it is the physics code that should be responsible for deciding how to move an object (the distance and direction to move the character, not how to actually access and alter the characters X and Y coordinates) and if there are any collision. For example, the physics code will call move() on the character only if there are no collisions. If the physics code tells the character to move 5 units forward, then the character should do just that, and it is up to the physics code to ensure that the character can move 5 units forward.


#4993258 Finding Index of Class Array

Posted by Brother Bob on 23 October 2012 - 05:06 PM

Your physics code is responsible for moving objects around and handling collisions. So yes, that would be handled in code outside the character.


#4993252 How to test if OpenGL support textures of non power of 2?

Posted by Brother Bob on 23 October 2012 - 04:45 PM

OpenGL 2.0 or later alone is enough, you don't need to check the extension if the version is OK. If the version is pre-2.0, then you need to check the extension. But note that 2.0 does not mean that the extension will be listed so you cannot rely on the extension alone. You have to check both if you want to cover for earlier versions, but passing one of the tests is enough.


#4993216 How to test if OpenGL support textures of non power of 2?

Posted by Brother Bob on 23 October 2012 - 03:37 PM

Check the extension string for ARB_texture_non_power_of_two. For OpenGL 2.0 and later you don't have to check anything since its in the core already.


#4993100 Struct vs Classes?

Posted by Brother Bob on 23 October 2012 - 08:38 AM

The first one will print an undefined value since the integer allocated by new int is not initialized. The second one will print zero, because the integer allocated by new int() is default initialized to zero. The parentheses syntax default initializes primitive types to zero. The same goes for members; if you explicitly default initialize a primitive member of a structure or a class in the initializer list it is initialized to zero; if you omit it from the initializer list it is left with an undefined value.


#4993067 Struct vs Classes?

Posted by Brother Bob on 23 October 2012 - 06:07 AM

Once Serapth had thought to ask which language the OP was asking about, sure....

To be clear, the specific language was given from the very beginning of the thread. Not in the most obvious place though; the thread is tagged as "C++".


#4992900 Struct vs Classes?

Posted by Brother Bob on 22 October 2012 - 03:08 PM

It is entirely a personal preference which one you chose. A common way is to use struct for pure data containers and class for objects which has some way of interacting with them. For example, a header for a file format could be a struct since its only purpose is to represent and group the data in a file, but your linked list could be a class since you interact with it by adding data to it. Whatever you decide to do though, consistency is important in any design decision.


#4992880 Wrapping numerical types in classes?

Posted by Brother Bob on 22 October 2012 - 01:56 PM

Having separate specialized classes is a good thing, not a bad thing. Your solution requires a huge class responsible for everything you want to know, and you cannot easily extend the class. By using small separate functions and classes, you can extend your type information as much as you like with whatever information you like, anywhere you like.


#4992851 Wrapping numerical types in classes?

Posted by Brother Bob on 22 October 2012 - 12:48 PM

Template programming can handle things like that rather easily.
template<unsigned int bits> struct bitcount {
    static unsigned int const value = bitcount<(bits>>1)>::value + 1;
};
template<> struct bitcount<0> {
    static unsigned int const value = 0;
};
Now you can get the number of bits of a value by int foo=bitcount<42>::value.


#4992846 Struct vs Classes?

Posted by Brother Bob on 22 October 2012 - 12:40 PM

The only difference is default member and inheritance access. Structs default to public members and inheritance while classes default to private.


#4992805 Wrapping numerical types in classes?

Posted by Brother Bob on 22 October 2012 - 10:19 AM

The standard library already has a class for that: std::numeric_limits.


#4992245 Is it acceptable to call a destructor?

Posted by Brother Bob on 20 October 2012 - 01:54 PM

You could make your own Delete() method, and that would set a boolean flag in the object (IsNull, for example) to true and delete any memory you may have allocated. Then, you could have a get() function (Or integrate this into the class with the boolean flag) to make sure you never tried to access members of the class that weren't there anymore.

That is entirely the wrong approach. If you delete an object and access it later, then the object shouldn't have been deleted in the first place because it was still in use. You have a lifetime management issue in that case and the proper way to handle that is to ensure that objects that are in use are never deleted, not to delete them arbitrarily and add a safety net just in case.




PARTNERS