Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

163 Neutral


  • Rank
  1. ITGER

    Quick verification on AST's

    Quote:Original post by ToohrVyk You're confusing precedence and order of evaluation. With only precedence rules applying, the code above could very well print "five", "three" then "four" or any other permutation of these. Oh right, now that I think about it, the C standard doesn't specify a particular order in which subexpressions are evaluated.
  2. ITGER

    Quick verification on AST's

    SoftwareGuy256 is right - the OP's first AST is in fact correct. I just ran that expression through my Java subset compiler and looked at the AST printout, and it matches what he has. The divide being above the multiply does NOT mean that division has a higher or lower precedence than multiplication; it just means that the 3*4 is being done before the divide by 5. This implies that binary operations are left associative, which is the case in C-like languages. If you don't believe me, try running the following program and tell me what you get: (you should get a result of 2, with "three", "four", then "five" being printed out.) int three() { printf("three\n"); return 3; } int four() { printf("four\n"); return 4; } int five() { printf("five\n"); return 5; } int main() { int x = three()*four()/five(); printf("%d\n", x); return 0; In general, if you have a sequence of binary operations with the same precedence level and you want to capture left associativity, you place the rightmost operator as the root, which is what the OP has done.
  3. ITGER

    Help with Dynamic Arrays

    If this is C, then you want sizeof(struct info), not sizeof(info).
  4. If the pointer is not in the vector, then you're passing the end() iterator to the erase method. This will raise an assert in debug mode, so make sure you handle that case.
  5. ITGER

    c# networking engine

    YYYYYYYYYYYYYYYYYIIIIIIIIIIIIIII Diego!!!!!!!111111 What happened to Greg's code?
  6. Ah, good point. It seems that C# separates the storage of the data (stream classes) from the reading/writing of data (readers/writers) from/to the storage. I'll look into that.
  7. Does C# have a class that's similar to Java's ByteBuffer class? More specifically, I'd like a class that has put and get methods for bytes, floats, ints, etc. If not, then should I just write my own that is implemented using a BufferedStream or some other stream class?
  8. It might be a color depth issue. Try setting your desktop color depth to 32-bit if you haven't done so already.
  9. Is it possible to export a model in Lightwave 7.0 to a .X file with animation set data? It seems that if I want to animate multiple instances of a character in my game, I need to give each one an AnimationController, bind each one to a current animation set, and call the controller's updateTime() function for each instance. This seems pretty hard to do unless I actually have the animation set data. My other idea was to just have all of the animations that the character uses in one single animation set, and just split it up into start/end intervals. However, I don't know if it's possible to control an animation just by specifying begin/end times, much less by specifying exact frames in the animation cycle to use. So, I'd rather not do this. As a last resort, I could just create a separate .X file for each animation sequence, but that's pretty awful. What cun I deww? (Btw, I am using the DStorm exporter; should I use a different one?)
  10. This probably isn't that your problem is, but I recall MSVC 7.1 barfing on me when I used the keyboard 'class' rather than 'struct' to forward declare some types used in the SDL library. For example, I used 'class SDL_Event' in a header file, and the compiler did not like that very much, probably because SDL_Event is declared as a struct.
  11. Quote:If the index buffer is set up for triangle lists, which is the default... Is there a way for me to check if triangle lists are being used? Can I convert the mesh format to use triangle lists? Quote:I would suggest not copying this data into some sort of vector of triangles, since you already have a linear ordering of triangles in the index buffer. Just use the index and vertex buffers directly as inputs to the kd-tree builder. Like the poster above me, I'm not how I would construct the kd-tree given just the index and vertex buffers. It seems that I would need to figure out where all of the triangles are, and then once they're placed into the leaf nodes, I would reconstruct index and vertex buffers from them. I don't see how you would reconstruct vertex and index buffers from the original index and vertex buffer. Then again, I'm not sure if either option is possible. Does anyone know?
  12. I'm trying to build a kd-tree for rendering and collision detection. I would like to construct the tree given a .X file for the level geometry. However, I'm having some DirectX related difficulties in extracting the triangle data. My original plan was to create a vector of Triangle structs, each of which consists of three Vertex structs. Each Vertex has three floats, xyz. I would then lock the index and vertex buffers, somehow iterate through that data, and build up Triangles and put those into my vector. Once I had a flat vector of Triangles, I would then just build the kd-tree, which would result in each leaf node having 0 or more Triangles. Finally, at each leaf, I would reconstruct a vertex and an index buffer, and then maybe reconstruct a mesh from those. However, I'm not sure if this is actually feasible. I suppose I'll start with the more general question. Is this even a good idea? Should I represent the level mesh file some other way, thus saving myself the need to get down into the triangle level? It seems like this would cause building the kd-tree to be a huge pain in the ass. More specifically, how can I iterate through either the vertex or index buffers in an order such that I can easily construct these Triangle structs? It would really nice if the vertices were ordered such that every consecutive, non-overlapping group of three vertices would define one triangle in the mesh, but I don't think that I can assume this ordering.
  13. Quote:The base class and all derived classes need to have their desturctors virtual, not just your base class. I'm pretty sure that's not true, i.e. that once a function is declared virtual, it stays virtual from that point down the class hierarchy. It's worth a try though.
  14. ITGER

    Merge sort problem in c++

    I sure hope that you're doing this for some sort (pun definitely intended) of learning benefit, and not because you're actually going to use this in a project... Why do you need extra storage? Mergesort inherently works by sorting in place, unlike quicksort. But like iMalc said, there's really no reason to avoid the recursion. Just use the STL for the win!
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!