Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


Member Since 13 Mar 2005
Offline Last Active Jul 26 2012 05:15 AM

Topics I've Started

[C++] std::map fills in extra key values?

29 July 2011 - 04:51 PM

Hello everyone,

I'm having this unusual problem when using std::map. I've been using maps for a while and have never seen this before.

Observe the following:

std::map<unsigned int, unsigned int> netObjectList;
std::map<unsigned int, unsigned int>::iterator itr;

netObjectList[2] = 12;

for(itr = netObjectList.begine(); itr != netObjectList.end(); itr++)
cout << itr->first << " = " << itr->second << endl;

Now I was excepting this output:

2 = 12

but for some reason I'm getting this output:

0 = 0
1 = 0
2 = 12

For some reason the map is filling in keys. Even if I had this:

netObjectList[13] = 2;

The output will be 14 lines with zero as value for all the keys that I didn't fill.

I can't seem to figure this out. Any ideas why this would happen?

Cheers :)

Rotating wiht Quaternion

24 November 2008 - 11:15 PM

So I have this small problem that I don't understand. I have an object that I want to rotate around it's Y-axis (regardless of the direction it's looking at) every frame. With me limited knowledg of quaternion I thought that this idea would work. 1- Get the quaternion for the object (objQuat) 2- Create a quaternion that rotates around the Y-axis with a certain degree/second (rotatQuat). Where x = 0, y = 1, z = 0, angleSpeed = how fast I want the object to rotate, and deltaTime = time diffrence between this frame and the last frame. So rotateQuat = Quaternion(x, y, z, angleSpeed * deltaTime). 3- I multiply both quaternion to get the direction I want (resutlQuat = objQuat * rotateQuat) I tested and it sort of worked. The object only rotates for like 180 degrees. It stops half way. I can rotate it back but it stops at it's first position. Can someone exmplin why is this happing? And how to solve it? Cheers :)

Problem with a class

14 September 2008 - 11:06 PM

Hi everyone. I’m having trouble with something. In my SubSystemManager.h file I have a class and a function that uses that class as an argument: class SubSystemManager { … … … void someFunction(void); }; unsigned int GetEntity(SubSystemManager *ssMgr); Now in my SubSystemManager.cpp I call the GetEntity function from inside one of the class functions like so: void SubSystemManager::someFunction(void) { GetEntity(this); } unsigned int GetEntity(SubSystemManager *ssMgr) { // some code Return 0; } OK, now, the above compiles without any errors, but when I run the program it crashes when the class function calls the GetEntity function. It doesn’t matter if the GetEntity function is empty (only return 0, I tried it) the program crashes. GetEntity works fine when I call it anywhere outside the SubSystemManager.cpp file. Any idea why this happens? Cheers

C++ calls the wrong virtual function

17 August 2008 - 11:19 AM

First, I would like to say sorry for not using a spell check, it's not working for some reason. Also, sorry for not giving a lot of detials, it's pretty stright forward. I have a base class with a vritual function: class BaseClass { public: virtual void update(void) = 0; }; now, I have 3 classes derived from BaseClass, and all with their own update() functions: class Class1 : public BaseClass { public: void update(void); } and the same for Class2 and Class3 Now when I do this: BaseClass *testClass = new Class3(); and I call update: testClass->update(); C++ should call the update() function that belonges to Class3. I know this and done it many times in many projects. The crazy thing is, C++ keeps calling the update() function that belonges to Class1 :/ The code is simple and straight forward. Does anyone know why something like this would happen?? Thanks.

So how many polys again?

16 June 2008 - 11:29 PM

This is getting frustrating. The ploy count limit for machines are increasing quickly I can’t catch up. Is there an equation out there that can tell me what would be the poly limit that can be displayed on a screen? If by displaying one 3D face (a triangle) would cause the game to reach a frame rate of (lets say) 300 fps, can you tell what the poly count limit for the machine not to not go under 60 fps? Would this be a good way to find the poly limit? And assuming that you have a game (adventure for example) how would you distribute the poly count on your game entities (PCs, NPCs, terrain, etc)? I re-read the post I can tell it’s not very clear. Sorry about that, it’s the best I can do. Thanks.