Jump to content
  • Advertisement

AcidInjury

Member
  • Content Count

    83
  • Joined

  • Last visited

Community Reputation

122 Neutral

About AcidInjury

  • Rank
    Member
  1. I've been working on this problem for a while now and its driving me crazy. When I insert multiple <key, val> pairs into the hash map I only ever get a map size of 1, the keys (structures) have different data (random in this case). I am trying to use a structure as the key type. The code below is what i've come up with after reading SGI's page on hash_maps and trying to decipher the msdn resources. #include <iostream> #include <hash_map> using namespace std; using namespace stdext; inline float randfloat() { return rand()/(float(RAND_MAX)+1); } struct StructTest { float x, y, z; float u, v; }; void setRandValue(StructTest &s) { s.x = randfloat(); s.y = randfloat(); s.z = randfloat(); s.u = randfloat(); s.v = randfloat(); } struct eqvert // comparitor for hash map { enum { bucket_size = 20, min_buckets = 16 }; bool operator()(const StructTest& v1, const StructTest& v2) const // Test for equality. { bool retval = true; // optimistic // positions retval &= (v1.x == v2.x) ? true : false; retval &= (v1.y == v2.y) ? true : false; retval &= (v1.z == v2.z) ? true : false; // UV's retval &= (v1.u == v2.u) ? true : false; retval &= (v1.v == v2.v) ? true : false; return retval; } size_t operator()(const StructTest& v1) const { size_t retVal = 0; retVal += *((unsigned int*)&v1.x) << 2; retVal += *((unsigned int*)&v1.y) << 2; retVal += *((unsigned int*)&v1.z); return retVal; } }; hash_map<StructTest, unsigned int, eqvert> gHashMap; hash_map<StructTest, unsigned int, eqvert>::iterator gHashItr; typedef pair<StructTest, unsigned int> vertPair; void main(void) { unsigned int idx = 0; for(int i = 0; i < 20; ++i) { StructTest v1, v2, v3; setRandValue(v1); setRandValue(v2); setRandValue(v3); gHashItr = gHashMap.find(v1); if(gHashItr == gHashMap.end()) gHashMap.insert(vertPair(v1, idx++)); else cout << "Key Val Pair exists?" << endl; gHashItr = gHashMap.find(v2); if(gHashItr == gHashMap.end()) gHashMap.insert(vertPair(v2, idx++)); else cout << "Key Val Pair exists?" << endl; gHashItr = gHashMap.find(v3); if(gHashItr == gHashMap.end()) gHashMap.insert(vertPair(v3, idx++)); else cout << "Key Val Pair exists?" << endl; cout << endl; } size_t mapSize = gHashMap.size(); cout << "Size of hash map is " << (unsigned int)mapSize << endl; } Any STL masters out there that can help?
  2. AcidInjury

    Quick & Clean Animation System?

    When I worked on my last 2D game I used a config or 'script' file that detailed animations. If I remember correctly I stored the frame dimensions/location and times between frames (on a per frame basis). All animations for any sprite were expected to be in the same file, the dimensions I talked about storing earlier were simple x,y locations of the top left and bottom right corners (min and max). The class on the engine side parsed the file and allowed me to query for an animations loop. Essentially it stored the animations as linked lists inside an array. When using the class I simply asked for the min and max expents of the next frame. The class internally kept track of time and returned the updated frame when necessary. It's really nice to have a non compiled script running your animations, so when you get down to tweaking timing you dont have to wait on compiles all the time. Good luck
  3. Here is on way, not necessairly the best, but it works nicely. If you reset your view matrix to identity, and set your world matrix to properly orient the gun you can render the gun without worrying about moving it to world space. Actually what your doing is putting the camera and weapon model in the same space. You might also want to disable Z testing when drawing the gun, or you will have a situation where the gun might stick into walls. This does require an extra Z buffer clear every frame though.
  4. AcidInjury

    Using Models in a 2d game

    Maybe I wouldnt have hated it if I hadnt been eaten by that dang dog every time =P and yes I mean the dog thing on level 1.
  5. AcidInjury

    Time shift graphics?

    It was most likely a performance optimization, and they hoped the other effects would offset the lack of geometric detail.
  6. I havent honestly implemented per bone collision detection, but your proposed method of bounding heirarchys is a good approach. I would suggest you calculate the min/max of the AABB for every bone at every bone key frame, and use a simple lerp between them. A separate class for the bounding information could be used, and just store a pointer to this data in the respective model/mesh/Actor, whatever. I would certainly keep my bounding data away from my vertex and index buffers, as they really dont have anything in common.
  7. I've heard about some compatability issues with Cg and ATI cards. Maybe this is an older problem, but it could still be a concern.
  8. AcidInjury

    Unity After High School....

    The quality of learning at any institution is more about the students own efforts than the ammount of money or time spent on the degree. A degree is only a piece of paper, what you can activly show is what will get you into the games industry. Also, your ROP work experience is going to be more or less useless on your resume anyway. Unless your job is programming or game related I wouldn't even bother putting it on the resume.
  9. AcidInjury

    Using Models in a 2d game

    OMG Out of this World!! Haha.. Thats perhaps the worst game i've seen. Except for Custers Revenge i guess. Do you have an API in mind for your game? That might make a difference (i.e. writing a software rasterizer much more work than orthoprojecting in D3D) I guess my question is, why not use sprites on a quad?
  10. AcidInjury

    Bitmap class

    Is it just loading the images that makes the program run slow, or are you rendering via the Win32 API? Windows blitting functions are terribly slow, since they are built for maximum stability. I suggest writing your own 2d blitter, its good practice. Ask if ya have any questions.
  11. Sounds interesting to me. Reminds me of Xenogears. I imagine if you lock the height of your camera, 360 rotation won't be a problem. Don't forget to depth sort your billboards, or you might get some crazy blending. Also, art creation in 2d (for a certain quality level) is arguably slower than modeling. I know some artists who hate to work with sprites, but others i'm sure are quite fond of it. Just know where your talent base stands.
  12. AcidInjury

    floatingPoint comparison

    acutally that proposed method is terrible. <, >, <=, >= all work great with floats. If you want to test equivalence I suggest. inline bool Equivalent(float a, float b, float err) { return ((a > b - err) && (a < b + err)); };
  13. AcidInjury

    State Sorting - The way forward?

    I think its generally accepted that sorting by shader, then subsorting by texture is a good start. Of course Alpha geometry throws a kink into things. I'm not currently doing any sorting of meshes and have yet to run into a performance issue. I don't know how much you should expect to gain from sorting until you have a lot of different shaders, or textures being used. I was working on a radix sort for this (and other) purposes for my engine, and would be interested to know the type of perf wins/loses people get from the presort. Also keep in mind that some effects require rendering in a specific order or rendering the scene from a different perspective.
  14. AcidInjury

    need to print my window

    The 4th parameter of CreateDIBSection is an output pointer parameter to the pixel data for the DIB.
  15. AcidInjury

    Index problem with heightmap

    From what I can tell from your shippet shouldn't the line cColor = g_xHeightData[(nScrollX + I) + ((nScrollY + J) * 17)]; be cColor = g_xHeightData[(nScrollX + I) + ((nScrollY + J) * 512)]; I would also advise not to hard code sizes in this way, const int is your friend.
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!