• Content count

  • Joined

  • Last visited

Community Reputation

449 Neutral

About Danicco

  • Rank
  1. Another example, probably better explained:   The 3DS Max vertex data is upside down in my engine, and I'm guessing it's because the XYZ values in 3DS Max are left handed, and OpenGL is right handed right? That's manageable, but the UV data is messed around too, and I noticed that the way I was even going on about mirroring textures is wrong because I was assuming a texture that covers the entire image, not just part of it.   I'm meaning that, in the example above, if I only put some texture color in the Purple area, and I mirror it horizontally with my current code, I'm just picking the UV values that correspond to the Red area in the texture, and that's wrong... I made this assuming 2D images and square textures and now that I'm loading directly from the FBX, it's not working for 3D models.   Using "1.0f - uv" values work for 2D planes, but not for 3D models...
  2. I'm reading the FBX file format and getting the UVs from the models, but I'm having weird issues with the UV Mapping from the textures.   Also, I'm using the sbti_image loader to load a PNG file, not sure if it's relevant (I think it reverses the pixels but I think that's common for all image types).   So, when I load a 2D Image, using a texture I have the image mirrored both in horizontal and vertical. That was fine if I just reversed the positions and mirror the texture, but that only works when the texture is full. I didn't want to keep that as a "fix" so I tried to get the correct orientation from the FBX and apply it properly.   The 2nd image is how it is in the 3DS Max, in the first image is how my engine is displaying it.     I'm reversing the V component so the texture is at least correct vertically: for(int i = 0; i < totaUVs; i++) { float u = UVs[uIndex]; float v = UVs[uIndex + 1]; UVs[uIndex] = u; UVs[uIndex + 1] = 1.0f - v; } If I don't do this, the image is also mirrored upside down. The "1.0f - v" part is correcting the V part, but the U is still incorrectly mapped. I can't do "1.0f - u" because then the U part would be reversed in the image, so in an image of 200 pixels width, a U part of 10 would be 190, meaning it works if the image is full (100% width and 100% height) but not when I'm using a mapped texture like this.   How can I solve this? I'm thinking in reversing the pixels in my image data but if possible I'd like to find a "smarter" solution, any help with this?
  3. Skeletal Animation System

    Okay, hopefully, my last post in this topic!   Finally got it to work perfectly! I had some trouble with bone's origin of rotation since I was using quaternions and had to adjust a few things...   In the end, I did: class Skeleton { public: //bunch of controls private: float _bonePositions[MAX_BONES * 3]; //Bone Local Position float _boneTranslations[MAX_BONES * 3]; //Bone Translate float _boneRotations[MAX_BONES * 4]; //Bone Rotation in Quat } The local position mostly never changes, but I had to use it to figure the point of each bone to center the rotation around it... and the shader: #version 330 core layout(location = 0) in vec3 vertexPosition; layout(location = 1) in vec2 vertexUV; layout(location = 2) in vec3 vertexNormal; layout(location = 3) in vec4 boneIndexes; layout(location = 4) in vec4 boneWeights; out vec2 UV; uniform mat4 transformationMatrix; uniform vec3 bonePosition[64]; uniform vec3 boneTranslation[64]; uniform vec4 boneRotation[64]; void skinVertex(in vec3 vertexPosition, in vec3 bonePosition, in vec3 boneTranslation, in vec4 boneRotation, in float boneWeight, out vec3 updatedVertexPosition) { vec3 rotationOrigin = vertexPosition - bonePosition; vec3 cross; cross.x = (boneRotation.y * rotationOrigin.z - rotationOrigin.y * boneRotation.z) * 2; cross.y = (boneRotation.z * rotationOrigin.x - rotationOrigin.z * boneRotation.x) * 2; cross.z = (boneRotation.x * rotationOrigin.y - rotationOrigin.x * boneRotation.y) * 2; vec3 crossQuat; crossQuat.x = boneRotation.y * cross.z - cross.y * boneRotation.z; crossQuat.y = boneRotation.z * cross.x - cross.z * boneRotation.x; crossQuat.z = boneRotation.x * cross.y - cross.x * boneRotation.y; cross.x = cross.x * boneRotation.w; cross.y = cross.y * boneRotation.w; cross.z = cross.z * boneRotation.w; updatedVertexPosition = vertexPosition + ((cross + crossQuat + boneTranslation) * boneWeight); } void main() { vec3 skinnedVertex = vertexPosition; skinVertex(skinnedVertex, bonePosition[int(boneIndexes.x)], boneTranslation[int(boneIndexes.x)], boneRotation[int(boneIndexes.x)], boneWeights.x, skinnedVertex); skinVertex(skinnedVertex, bonePosition[int(boneIndexes.y)], boneTranslation[int(boneIndexes.y)], boneRotation[int(boneIndexes.y)], boneWeights.y, skinnedVertex); skinVertex(skinnedVertex, bonePosition[int(boneIndexes.z)], boneTranslation[int(boneIndexes.z)], boneRotation[int(boneIndexes.z)], boneWeights.z, skinnedVertex); skinVertex(skinnedVertex, bonePosition[int(boneIndexes.w)], boneTranslation[int(boneIndexes.w)], boneRotation[int(boneIndexes.w)], boneWeights.w, skinnedVertex); gl_Position = transformationMatrix * vec4(skinnedVertex, 1); UV = vertexUV; } And it's working!   Many many many thanks to everyone, that's been a huge help!
  4. Skeletal Animation System

    I'm not using the FBX SDK, but it's just because I had already made a FBX Loader when I found out about the SDK... I'm reading the ASCII FBX file, but my 3DS Max is quite old (2010) so the format might've changed a bit, or because it's not the SDK there's some differences on what you've said, but it's nothing troublesome to adapt (like having zeros in all translates/rotates channels, on each keyframe that there is another value change anywhere, even if my animation didn't use that channel).   After I found out about the SDK, since I don't plan on using the FBX files (I'll read the data and save in a format of my game files), I didn't implemented it and kept using the old loader I had.         That's a great concept, I didn't even had "names" in my scene (I was just going with everything by IDs, names were purely conventional and not necessary), and with this I think it'll become easier to have an animation of "Human Skeleton" and apply it to different humanoid skeletons as long as they have some/most bones names.   I've implemented everything and it looks great so far, but I just realized I'm back to a problem I was having when I posted this, which is the Update function, and I was trying to come up with a structure/system that didn't look as bad as this (current): class PlayTrack { public: Track* track; float* valueReference; }; class PlayState { public: void PlaySequence(wstring sequenceName); void Update(double updateTime); private: Animation* _animation; vector<PlayTrack*> _tracks; //track instances, with the value refs assigned vector<Sequence*> _sequences; //an animation sequence defined by the code vector<double> _sequenceTimes; //the time of each sequence, I didn't make another class so I don't call "new" during the update loop }; //In my game's main code, it looks like this: void MyGame::Start() { //Loading stuff Animation* animation = FBXLoader.GetAnimation("HUMAN"); //Creating a new sequence of animation from frames 5 to 10 and naming it WALK //I'm using frames as time value, from the FBX I'm getting it's always set at 30 FPS but I'll convert it here depending on my update timer animation->AddSequence(L"WALK", 5, 10); Model* model = Resources.Load_Model(L"MyModel", L"MyAnimationName"); //and some other params //Here I'm linking this model's animation instance (PlayState) to the object it's supposed to animate //in this case, the model's skeleton Scene.Add(model); //It'll start playing an animation model->PlaySequence(L"WALK"); //will pass this to it's PlayState } void PlayState::PlaySequence(wstring& sequenceName) { //Getting the sequence from the original animation, so all models share the same sequences Sequence* sequence = _animation->GetSequence(sequenceName); if(sequence != 0) { _sequences.push_back(sequence); _sequenceTimes.push_back( (double) sequence->frameStart ); } //So I'll have for now a "WALK" only animation running, starting at frame 5, going till 10 } //Everything's set up already, now the engine call the scene to update the animations with a double updateTime //from the fixed time step impl., where I convert the frames to whatever my fixed time step update rate is void PlayState::Update(double updateTime) { //This is where I'm not happy with how it is //Updating all times for the playing sequences, this is a must for(unsigned int i = 0; i < _sequenceTimes.size(); i++) { _sequenceTimes[i] += updateTime; } //Now for each sequence playing... for(unsigned int i = 0; i < _sequences.size(); i++) { //Check all tracks for(unsigned int j = 0; j < _tracks.size(); j++) { double currentTime = _sequenceTimes[i];             KeyFrame* prevFrame = 0;             KeyFrame* nextFrame = _tracks[j]->track->keyFrames[0];           //Check all it's keyframes                        for(unsigned int k = 1; k < _tracks[j]->track->keyFrames.size(); k++)             {                 prevFrame = nextFrame;                 nextFrame = _tracks[j]->track->keyFrames[k];                 if(currentTime >= prevFrame->keyFrame && currentTime <= nextFrame->keyFrame)                 { //Here I got the keyFrame pair I'm looking for                  break;                 }             } } } } I can't really save the current time and a pair of keyframes per "PlayTrack" (trackInstance) because there might be more than one sequence playing, so I'm having to loop through so many vectors... isn't there a more elegant (ie. smarter) solution than this?   I'm thinking in maybe moving the sequences elsewhere, and making each "PlayState" able to play a single sequence, but that wouldn't change much since all I'd be doing is moving the sequence loop to another place and copying the PlayState multiple times because of it.   Edit: More Code Maybe I'm worried for nothing and this might not be a big issue but I can't help but worry "am I doing this right?" and if this is the only way it would be reassuring to listen so I don't think too much over it.
  5. Skeletal Animation System

      I was going on using KeyFrame with 3 values because I'm using 3DS Max to get my models data, and from what I could get from the files is that if I translate anything on the X-axis, it would create a translate channel (track) for X, Y and Z (with zeros on the unused values). But animating anything on screen is really great, I hadn't thought about it, thanks!   One question though, I'm supposed to have then an Animation class with a vector of tracks, and these tracks point to a value that they change, and each track has a vector of KeyFrames, the values at which time changes... I'm loading from a FBX file and pairing it with the base Skeleton I get from the file, so the reference values for each track are those bones (like Track #1 is translate X for Bone 1), but then I copy the skeleton to a "skeletonInstance" for the animated model, and the references would still be pointing to the original "pose skeleton".   How can I get to correctly assign the references without making the KeyFrame / Track classes specifically for the Bone/Skeleton structures?   For now I'm having each KeyFrame (changing to track in your structure) assigned to a bone index (int value, not ref), so I know which is which. And this also means I have to change my loader... ugh!
  6. Skeletal Animation System

      Oh that's what I was thinking in, but I wasn't really getting the idea behind it and I was mixing what Animation and PlayState is, thanks for clarifying that for me.     In the example I forgot about interpolation, but I didn't meant I wouldn't do it, I'm using a double as "frameTimer" and I'd multiply the value by that value (which should be between 0~1). Each update increases the "frameTimer" by a value depending on my "updates per second" timer.     Now it seems much more clearer how I can implement this, I wasn't really sure about the "PlayState" class and was trying to fit the Animation (dealing with it as if it wasn't a resource) with it and the code was getting just messy and confusing.   I'm only unsure if I should make the skeleton / bones as a scene object as well, or if I should leave them as only a reference to all "human models" in the scene for example. I think it might not be so bad calculating and updating all bones' matrices even if I'm not really using them in the scene, and I think I might be able to use them for physics/collisions easier if they're all in the scene (I haven't even started physics so I'm not sure, I'm only trying to plan ahead how I'd do it). Then implementing a "special case" when a game requires a bone to hold a children in the scene is looking bad since if I'm going to use them for anything else, it wouldn't be the "special" case anymore.   Again, many thanks for all the replies, I got a much clear vision of how I should deal with animations now.
  7. Skeletal Animation System

      I'm trying to avoid inheritance and virtuals so I did this on composition, but I don't know if this will be a problem in the future, so far, it's been manageable: class SceneObject { public: Orientation currentOrientation; Orientation previousOrientation SceneObject* parentObject; //SceneGraph void UpdateMatrix(float& interpolation); Matrix4x4& GetMatrix(); //etc, various functions required to "work" the calculations required for the scene positioning }; class Scene { public: private: vector<Model*> _models; vector<Image*> _images; //separated by type, I found it easier to sort and apply commands before drawing vector<SceneObject*> _objects; //but before drawing, I update all objects' matrices }; class Model { public: //etc void Draw(Camera* camera); private: SceneObject _sceneObject; }; class Image { public: private: SceneObject _sceneObject; }; And I'm kinda obsessed about performance, so I'm really trying to make the engine do only the minimum required work, so I'm trying to figure if I really really need to have the skeleton in the "scene". All objects in the scene have their matrices calculated, interpolated, checked for hierarchy (I have some trouble with this too, will describe below) etc   If a skeleton is used only to move a model's vertex data, I don't think I need to keep track of each bone's position in the scene. So I'm trying to figure if it'll be worth it or not. I'd implement a Bone object that can be held in the Scene, but I just wouldn't put ALL skeleton bones and update all of them for all skeletons. I'd leave it up to the game to know if the "HandBone" is required as an object, then he gets a new instance from the skeleton, attach it to a model, link to the Bone, and it joins the Scene and is an object able to hold children/parents.   ,placement>   I'm thinking in something a bit different, to avoid calculating the track's next keyframe and interpolate, since I'm using "Frames" as time unit for the animations, I'm thinking in doing something like a "Motion" class. When the skeleton/animation is loaded, I'd check all bones, all keyframes, and I'd create a Motion class with a value begin/end, like: class Motion { public: int frameStart, frameEnd; Vector3 position; Vector3 rotation; int boneIndex; Motion* nextMotion; } Then when my animation has a track playing, I wouldn't deal with figuring keyframes and such, I'd pick the current Motion, sum the values to the Bone's position if the "frame" time is between the motion. I'd probably be able to do something like this: //for each track, loop through the motions for(unsigned int i = 0; i < motion.size(); i++) { Bone* bone = skeleton->GetBone(motion->boneIndex); //Getting the bone ref bone->position += motion->position; bone->rotation += motion->rotation; } (By the way, this only if each model HAS it's own skeleton, I know it conflicts with my idea up above of keeping only one instance, but it's just that I'm trying a bunch of things)   This also provides blending since I can create new motions based on two keyframes, it's just that I don't have to calculate each one during play, except for blends.   There's so many possibilities and I don't know which one to follow...   (I know about premature optimization, but that's how I'd like to do this... I'm not in a hurry to code a game, and I'm using this engine to learn a lot about programming, so I'm doing step-by-step, slowly, understanding the concepts and implementing whatever I figure it's best)   And thanks for the replies, found so many things I've overlooked and so much more to think about and implement!
  8. Skeletal Animation System

      I've done GPU skinning already, but it was kinda hard to find resources (I think I only found 2 or 3 explaining the whole process) so it's nice to see more resources about it coming up. And your tutorial made me notice something I completely forgot about until now, I don't have any Bone "presence" in the scene. My bones don't have anything, actually, so they can't be used as elements to be parents or childs. The transformations I have stored are local only because I thought "since it's index/weight are already defined, I only need that".   This changes a bunch of things for me since I was trying to have a single Skeleton instance for multiple models and that was restraining some options... I was trying to have this Skeleton class, with bones only having their keyFrames values, and I would calculate it's position/rotations according to each model's animation tracks, then upload the data, since the GPU is doing the skinning and all the indexes/weights are already defined, that was the only thing I needed to do (change the bones, upload).   Really, thanks! I'd be really frustrated if I only realized this AFTER I finished this hahaha
  9. Skeletal Animation System

      Oh but that's been done already, it's that I want to use interpolation for the movements of the bones as well, that's why I put the update inside the Draw() function. The currentFrame will be changed during the update, and I want to get the previousFrame > currentFrame interpolation during the draw. But I still haven't done the regular updates so I left the deltaTime/interpolation out and forgot to mention it, I'm sorry about that.     If I understood correctly, then I'm supposed to bind all affected bones to a track, then I can iterate only over the affected ones of the current tracks. That seems better than searching the whole skeleton again, I'll do that, thanks!   But still, there's the issue of figuring out where the model is at a time. I was thinking in "saving" the current time on each bone, for example, so for example I have an animation called "WALK" that are frames 5 to 10, and I'm currently at 6, I'll have references to both the keyFrame 5 values and keyFrame 10 values so I don't have to look up it again all the time. But this idea crumbled when I realized that I can't "save" these references on the bones because of the situation when multiple models share the same skeleton and have different times. Then I went to the idea of having a reference of all bones and keyframes per model, but that didn't seemed right since I'm having to allocate a new bone/keyFrame structure per Track set on the model...   I'm trying to figure if there's some really clever way to deal with all of these either with some algorithm to handle the figuring out of the current keyframe and interpolation values, or using a new/changing structure to better handle all this.   And thanks for the link on blending, I'll definitely want to implement something like that and that'll be a good read.
  10. Hi, I'm coding my skeletal animation system for my engine and I'm not really sure what and how I'm supposed to do what I need to do... I have a vague idea, but I can't really put it into the code in a way that I like. I'm having trouble with both the concept and technical parts of it.   I have this structure: class KeyFrame { public: unsigned int keyFrame; Vector3 keyValues; }; class Bone { public: //Other stuff to deal with hierarchy vector<KeyFrame*> keyTranslates; vector<KeyFrame*> keyRotates; }; class Track { public: wstring trackName; bool trackLoop; unsigned int frameStart; unsigned int frameEnd; }; class Skeleton { public: vector<Track*> tracks; vector<Bone*> bones; //skeleton data here float boneTranslations[MAX_BONES * 3]; //vec3 trans float boneRotations[MAX_BONES * 4]; //quat rots }; I'm already loading the data I want, so I have something like "Bone01: keyFrame 5 > TranslateX 0.5, keyFrame 10 > TranslateX -0.5" etc Each model has a pointer to a skeleton, who has a collection of bones, and I define tracks: class Model { public: Skeleton* skeleton; Track* currentTrack; //current playing track }; //Game Start Model* myModel = Resources.Load("myModelName"); myModel->skeleton = Resources.Load("mySkeletonName"); //Skeleton::AddTrack(wstring trackName, uint frameStart, uint frameEnd, bool trackLoop); myModel->skeleton->AddTrack(L"WALK", 5, 10, true); //Setting this model's current track as WALK myModel->SetTrack(L"WALK"); So, first I think I need to change the "current track" to support multiple tracks to compose animations (such as WALK + ATTACK) right?   Then the problem I'm having most is figuring my "Update Skeleton" function: void Model::Draw(Camera* camera, float& interpolation) { Shader* shader = material->GetShader(); skeleton->UpdateSkeleton(currentFrame); //this meshSkin->Activate(shader); mesh->Render(shader); meshSkin->Deactivate(shader); } void Skeleton::Update(uint currentFrame) { for(uint i = 0; i < bones.size(); i++) { //checking ALL translates for that bone for(uint j = 0; j < bones[i]->keyTranslates.size(); j++) { //what should I do here? //check if this keyFrame value is higher or equal than currentFrame, then loop again //to search for the previousKeyFrame (if it has one), then interpolate between the two, //then interpolate again to find the middle (currentFrame)? //And where/how does deltaTime fits into this? Maybe having a previousFrame as well? //Actually, scratch this, this seems bad to do at every render call, //I'd like to avoid doing this if I can and "remember" the animation motion I'm currently at //for that model so I can skip this operation. //...or a clever way to handle this } //Now check for rotations as well... for(uint j = 0; j < bones[i]->keyRotates.size(); j++) {} } } I'm trying to save these operations by remembering the motion I was, but then I'd need to save in the model, for each bone, the previous keyFrame and the next keyFrame for all of them. And I would only need to figure the next motion when I reach the "nextKeyFrame". But this means basically having a copy of the skeleton's bones in the model... not sure if I should go this way.   I've been thinking since yesterday but I can't figure how should I proceed from here... any help?
  11. Unity Spritesheet Algorithms

      No, I think your problem isn't really a problem for your engine to do... you can first implement a simpler option to cut the spritesheet in equal rectangles, and that might work for simpler games, so you'll only have a single rectangle for that object and you just change the UVs of the texture. As for irregular rectangle sizes, instead of trying to automatize (ie. figuring what the user wants) you can let the user TELL you what he wants. If you have an GUI you can put a list that he can add the sprites' areas manually via typing, and maybe then even evolve to a graphical tool that the user selects an area and you insert a new sprite area to the list.   I'm coding an engine and this is what I do to deal with spritesheets: //This will load "MyImage.png" a 500x500 image, and cut it in pieces of 50 Sprite* myCharacter = Resources.Load("MyImage.png", 50, 50); myCharacter->currentFrame = 10; //This will load "MyImage.png" a 500x500 image, and cut it in pieces of 50 Sprite* anotherCharacter = Resources.Load("MyImage.png", 50, 50); //And now I'm changing frame 0's width and height to something else anotherCharacter->Frame[0]->SetSize(75, 75); //But I want to be lazy to type in code so I got a .txt file like this: //frame=0 x=0 y=0 w=75 h=50 //frame=1 x=50 y=0 w=50 h=50 //frame=2 x100 y=0 w=25 h=50 //And a method to auto load it: Sprite* lastCharacter = Resources.Load("MyImage.png"); lastCharacter->LoadSpritesheet("MySpritesheetInfo.txt"); This will let the user (game coder) decides how he deals with it, either by using pre-defined rects for everything, or manually typing, or loading from another file (maybe even generated from a map editor of their game).
  12. Porting C++ to Android

    Wow, thanks alot!   I'm new to Java and Eclipse so I don't know my way around and I didn't even knew how to look for errors... after learning where the log is I found it was an UnstatisfiedLink - Native Method not found, and a simple google taught me that JNI doesn't work with C++ naming, so I have to use extern "C" before the functions and now it's not crashing anymore!   Really, thank you!
  13. I am coding a game engine and I'm trying to port it to Android to check for errors and tests. But I still haven't even been able to get a simple function working...   I'm following a few tutorials and I think I know what I am supposed to do:   - Put my C sources in my android project's JNI folder. - Build it with the Android NDK, after setting everything up. - Link the lib on my Activity class, call a method, crash.   My C source looks like this: #include <jni.h> jint Java_my_engine_test_MainActivity_MyFunctionName(JNIEnv* env, jobject obj) { return 0; } My Android.mk is: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := EngineTest LOCAL_SRC_FILES := EngineTest.c include $(BUILD_SHARED_LIBRARY) And my Java file is: package my.engine.test; import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //If I uncomment this line, the app crashes, else it's ok //int a = MyFunctionName(); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } private native int MyFunctionName(); static { System.loadLibrary("EngineTest"); } } So I've made certain that the function name is according to the specification (Java, package name, class name, then function name) and that I'm using JNI types, and it's a really really really simple function.   Also, for some reason, none of the examples that came with the NDK build for me when using the Eclipse NDK support. I get syntax errors (syntax!). So I'm guessing they must've changed it somewhere along the way...   I'm at a loss, I've been looking all over for what could be causing this and how I can get a simple C function to work in the Android Emulator, but found nothing so far. I'm still checking other tutorials and following them but they're all the same thing and have the same errors, so I'm guessing it must be something else.   I've also set up the NDK folder in Eclipse and now it's auto-building my C sources every time, and it builds, but the app simply crashes when I try to access a function from the lib.   Does anyone know what could be causing this?   Also, a question, the engine's nearly finished for a first project and I made it with certain rules that I'd like to ask about when porting to Android. I've made it a single class containing everything to run a game, and a few classes available to the game code such as Image, Models, Animations, etc. There's only one rule that the game code must abide to and that is to inherit the "GameState" class (abstract) so it forces implementations of the methods required for the engine to run (Start, Pause, Resume, Update, Exit functions).   I was thinking in having the engine and making the game elsewhere, like Java (when I get the engine working) for faster coding, but then there's the problems of the C++ classes (Image, Models etc) that probably won't be available on Java (although this I can fix with a wrapper), and the GameState class that a state must inherit to set it to the engine. I don't think I can wrap this last one and I'm don't know how to proceed with this.   If there's no way, I'll probably try coding the entire game in C++ and trying to port it all at once... if only I can get this NDK to work...   Thank you in advance.
  14. The difference between them (obvious example inc!): class MyClassCons { public: MyClassCons() { Pointer* p = new Pointer(); } }; class MyClassInit { public: MyClassInit(); void Init() { Pointer* p = new Pointer(); } }; int main() { MyClassConsc aClass; //p* already exists! MyClassInit bClass; //p* doesn't exist yet! }; The problem with this is that sometimes p* could be a variable that depends on something ELSE to work. Using a really bad example, say you put some OpenGL commands in your class' default constructor. Just by definining the class somewhere you'll get a runtime error because when the variable was created, right at the start of your program, the OpenGL context which is required before issuing glCommands wasn't active/didn't exist.   But you do could use Init(); since it would ONLY be called when you explicitly say so: int main() { MyClassInit aClass; //it's okay InitOpenGL(); aClass.Init(); //okay, no runtime error } But you couldn't do the otherway around: int main() { InitOpenGL(); MyClassCons aClass; //Still runtime error } Other than this situation (which I found to be sorta common), I think everything else is due preference...
  15.   The vector is also supposed to keep the "history" of relevant inputs, so the game code could call: if(input.IsMatch("MOVE_DOWN", "MOVE_DOWN_LEFT", "MOVE_LEFT")) { //Do something knowing this sequence has been pressed, such as a special move for fighting games } So I check if it's time to remove the input from the history or not, and process the ones for the next update (because my code might've lagged out, so I'm only queueing the ones in between a certain time frame).   And well, regarding the names, it's still a queue... it's just not the std::queue. When I think queue, I think "ah, something that will be dealt with later on" (and when the order is important). And also I never knew about the std::queue before this topic ahahaha Though it wouldn't fit in this example since the vector is doing more than just a queue.