Jump to content


  • Posts

  • Joined

  • Last visited

Vamidi's Achievements


Newbie (1/14)



  1. @lucid I don't know if I should start a new topic, but what do you need to keep in mind when these variables are set to false --> bool EditorSettings::reverseYOnLoad = false; bool EditorSettings::reversePivotYOnLoad = false; bool EditorSettings::reverseAngleOnLoad = false; because in mine opengl app I have it reversed. Also I am not that great in math, so I dont see what I need to add or decrease to rotate the objects right. I tried to set the variable to false as well in the spriterplusplus example and that is the exact result that I get in mine opengl application. If you wonder about the matrix is it the same as my previous post. https://gyazo.com/3f3e855fdb7ab9b6b68281986d5deb48 EDIT: I fixed it in a way. I had wrong devices coordinates setup in OpenGL. I see that SFML had it different so I watched a tutorial about positions and uv coords --> after that I saw that my matrix was different again when setting all the reverseYonload etc back to true again. when the matrix was the same everything came together. The only problem is that my animation goes faster everytime (running more than 60fps).
  2. Alright I finally understand what is happening in Spriter sfml version. So basically you have bone_refs and sprite objects. the bones control the images. in order to make it relative to each other you need to calculate all the bones first. When those are caculated you add those values to the sprite object. this will get a sprite position, scale, rotation basically and those values needs to be calculated again to get the right matrix. --> So basically get the rotation in radians, then rotate and scale it (that is what sfml also does). Multiply the calculated sprite position with the rotation matrix to get the right position. Once that is done make a translation matrix and a scale matrix (scale matrix needed in my case because I am dealing with normalized positions, texcoords in OpenGL). Then multiply in this order to get the model matrix and send that to the gpu. auto rot = glm::rotate(Matrix4(1.0f), angle, Vector3(0.0f, 0.0f, 1.0f)); rot = glm::scale(rot, Vector3(m_scale, 1.0f)); auto pos = rot * Vector4(-m_origin.x, -m_origin.y, 0.0f, 1.0f); pos += Vector4(m_position, 0.0f, 1.0f); auto trans = glm::translate(Matrix4(1.0f), { pos.x, pos.y, pos.z }); auto scale = glm::scale(Matrix4(1.0f), glm::vec3(dimensions, 1.0f)); model = trans * rot * scale; result https://gyazo.com/02580b6038c30ec31e47c7a0daa37cc2
  3. So if you would only have the loading part implemented which only contains spriterefs, entityrefs and boneref will this still apply? (I removed everything else because of the amount of classes and having my own transformation class) so would you have the same indices for the parent, so for example we take your example and take each bone ref with the parent id. then when I build the matrix I should grab the parentid (and search) and apply those transformations to get it on the right place? Do I understand it correctly?
  4. Hi everyone I am tryng to render Spriter images with Opengl. I am using glm as a library to place the object on screen. However if I just take the first zorder and render it with glm by doing it with this code // Prepare transformations Matrix4 model = glm::mat4(1.0f); // Translate to center model = glm::translate(model, Vector3(parentPos, 0.0f)); float deg = pObjectInfo->GetAngleInfo().fAngle; deg *= (pObjectInfo->GetAngleInfo().iSpinDirection) ? -1.0f : 1.0f; // convert to degrees and rotate model model = glm::rotate(model, static_cast<float>(glm::degrees(deg)), glm::vec3(0.0f, 0.0f, 1.0f)); // take spriter location and translate based from center of the screen model = glm::translate(model, Vector3(position, 0.0f)); // translate with negative pivot * scale model = glm::translate(model, Vector3(-anchor, 0.0f)); // Scale the model with the dimensions of the image model = glm::scale(model, glm::vec3(Vector2{ dest_scale_w, dest_scale_h }, 1.0f)); I hope someone can give clearity on how the positions, pivot and rotations work in a spriter file. or giving me glm feedback how to solve this. https://gyazo.com/69327225f9f94b4919e7d7944b1f4124
  • Create New...