Lexdysic

Members
  • Content count

    89
  • Joined

  • Last visited

Community Reputation

197 Neutral

About Lexdysic

  • Rank
    Member
  1. I think this might help explain things for you: Cpp FAQ
  2. It looks like a function pointer named Base which takes an std::ios_base& as its only parameter and returns an std::ios_base& and its default value is the function std::dec. Not sure that that clears it up, but it is just ugly code.
  3. pi calculator

    Simple answer: pi = 4 * arctan(1) Most computation of Pi use an iterative approach by adding terms of a series until the desired accuracy is reached. Some of these can be found Here and Here. There are many representations, some are better for computer computation than others. If what you are looking to do is compute as many digits of Pi as desired, you may have to look into some form a big-number representation, as the built in types in most languages do not support more enough resolution to describe lengthy amounts of digits.
  4. It has been quite some time since I have used 3D Studio Max. I do believe, however, that there is an option in the texturing menu which scales UV coordinates on top of the UV unwrapped coordinates. Edit: Aha! I did find this image here which shows the tiling options I was recalling.
  5. Planes - What for?

    Infinite planes are very useful in physics. For instance, in a ray-triangle intersection test, it is generally faster to first check the intersection of the ray with the infinite plane that the triangle lays in. Only then would you check if the intersection point lays within the triangle. You can use a plane as a half-space, as well. Using the intersection of half-spaces is very useful for containment tests. This would be useful in convex polyhedrals. The usually does not mean that a triangle for instance should inherit from a plane. It does mean you can use the plane object in computations involving triangles. On top of all of that. Planes are a very simple primitive. As such, the amount of computations involved with them is very little. If you are able to approximate a physical situation as a plane, rather than something more complex, you can lower the amount of work the computer has to do.
  6. The STL in itself is very fast, in fact is is very hard to write your own versions which will be faster. Many game studios cook up their own versions of containers for many different reasons. One big reason is knowing how that container will act. Meaning, knowing when and how basic functions access the data structure. Or knowing, for instance, how large, or when a vector will resize. By making your own container, you know for certain how each container will behave under different conditions. For console developers there are a few good reasons not to use the STL. Biggest is memory issues; the console only has a fixed amount of memory. STL containers could easily grow in size or fragment memory. As mentioned before, it is not always wise to resize a vector by doubling the size or something similar. Instead, it is a better use of memory to only add enough space for eight or 16 new items at a time. Another important thing for consoles to watch for is cache coherency. Node based data structures (list, map, etc. ) can easily have to load in new data every step. Instead you can cook up a version of these containers which hold everything in contiguous memory, but acts like a node based structure, this way there is a better chance of the node already being loaded into memory. Lastly, there may be feature that you wish to add or remove from the STL. For instance, it is usually undesirable for a map to create a new element when one does not exist using operator[]. Or you may wish for push_back() to return a reference to the newly inserted element. These are small things that can prevent bugs and make development go much faster.
  7. C++ XML parsers

    I have used TinyXml with good success. It seems to do the job pretty solidly.
  8. String hash code efficiency

    Using string hash in this way is entirely feasible in the scope of a game. That is of course, as long as the hashing function is very strong. Even in a large commercial game, you may have upwards of 50,000 unique strings that may be used in this manner. If you have a strong hash function this should be good enough to avoid most collisions. Of course there is no guarantee that collisions won't occur, in which case you will want to do as other have suggested and check for inequality of the hash. In my implementation, I have it so debug builds will check for collisions whenever a compare finds two matching hashes. This will then compile away in release builds and leave just the simple hash compare. I have run experiments using close to 40,000 different strings using a very strong hash and found no collision. This site was a great resource on different hashing functions. I used the one at the top in my implementation, which seems to do a great job.
  9. c++ making a union inside a class

    Quote:Original post by Driv3MeFar You could always use references to your array elements: *** Source Snippet Removed *** You have to be careful when using reference in this way. The references themselves take up space. So the sizeof(V) would be 24 and not 12 like you might think.
  10. Wireframe & Z-Buffer

    The z-buffer algorithm only works on what is drawn. Meaning that it will write to the z-buffer only where it it is drawing the lines, not the inside of the triangles. The inside of those triangles is completely skipped when it is rendering, so there is no way for it be able to write depth values to the buffer.
  11. static_cast is not working

    This should explain in more depth
  12. Quote:well i know that, what im asking is if i can do "return somefunc();" to break after somefunc executes Yes, you can do this. It will first execute the code in someFunc() then use the return value of someFunc() as the return value of function the switch is in.
  13. Yup, that will work just fine. As well as a continue statement, I believe.
  14. DC not erasing text (win32)

    If I remember right, the InvalidateRect function essentially just queues up another WM_PAINT message. It doesn't really have anything to do with clearing the DC. If you want to clear the screen you will have to fill the DC with a solid color. Unfortunetly I dont remember it at the moment.
  15. std::vector use [0] or front()

    You can also get a reference to the ball. That way the way in which you access the element matters even less. Ball& thisBall = listOfBalls.front(); OR Ball& thisBall = listOfBalls[0];