Math for Game Developers - Prop Positioning (TRS Matrices)

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 16

  • @igz
    @igz 11 років тому +2

    Writing code after theory is always super helpful, thanks for these.

  • @WidmerNoel
    @WidmerNoel 10 років тому +1

    Oh, this us really awesome. I always thought that each object had its own coordinate system. Thank youu!

  • @julianaskuratovsky8701
    @julianaskuratovsky8701 3 місяці тому

    Extras cool! My thanks!❤

  • @JorgeVinoRodriguez
    @JorgeVinoRodriguez  11 років тому

    Generally as you implement your game engine you keep track of an object's position, rotation, and scaling independently so that you can re-create the TRS matrix when you need it. But if you don't have the original data then you can either do what you're describing, or else deconstruct the matrix to get at the original TRS data. I may cover how to get the TRS data back out of the matrix in a future video.

  • @lucianoinso
    @lucianoinso 11 років тому

    Eres el mejor jorge! You are the best, thanks for your videos, they are very helpful, keep 'em coming!

  • @TheNo1WarLord
    @TheNo1WarLord 11 років тому

    What if you wanted to rotate an object that's already been placed. Lets say want to rotate by 10 degrees every shoot. Would you have to translate it back, rotate then move back to previous position?

  • @JorgeVinoRodriguez
    @JorgeVinoRodriguez  11 років тому

    Ha, sorry, maybe I'll see if I can do a fade from now on.

  • @bemdav
    @bemdav 7 років тому

    How is this for CPU performance? Is it not too many calculations for the computer? I mean, if you're going to be using a lot of objects and you're using 4x4 matrices, that you first multiply by one another 3 times (T * R * S) then apply that to a vector. That is a bunchload of multiplication and addition for a single vector transformation. Is this what actual optimized games are using? Or is this just a concept to understand but is not normally used this way?

    • @JorgeVinoRodriguez
      @JorgeVinoRodriguez  7 років тому

      For a small game doing T*R*S is probably no big deal. If you're building a game engine from scratch I would say don't worry about it until it becomes a problem. For a larger game the typical approach is to do a lot of precomputation and then upload the result in a smaller format (vector/quat) to the GPU which can parallelize it away.

    • @bemdav
      @bemdav 7 років тому +1

      I'm still amazed that you are still active and keep replying to these years old videos. Thanks for the quick reply! Also, I assume by quat you mean quaternions? I didn't get to the part of the playlist where you talk about them yet, but I researched them earlier.

    • @JorgeVinoRodriguez
      @JorgeVinoRodriguez  7 років тому

      Yep. For a better development of quaternions, see the most recent video in my channel.

  • @yiandev4368
    @yiandev4368 6 років тому

    Im having issues with my matrix, when i scale i get the object rotating on Y axis instead of scale on X axis what?

    • @JorgeVinoRodriguez
      @JorgeVinoRodriguez  6 років тому

      I'm not sure I understand what your problem is, a better explanation would be useful. It sounds like you may have constructed your matrix wrong. Try watching some of the earlier videos about how transform matrices are constructed.

    • @yiandev4368
      @yiandev4368 6 років тому

      I did something wrong in the calulation hehe its working now.
      The one problem im left with and i cant find the answer to is how do i combine the local to world transformations.
      Asuming column major matrices for opengl.
      Do i store translation/scale etc in pos/localPos, scale/localScale as vector3 and then add the vectors togheter and create respective matrices like this:
      T = translation_matrix_from_vec3(pos+localPos)
      S = scale_matrix_from_vec3(scale+localScale)...
      TRS = T* R * S...
      Or do i create a matrix for each transform local/world:
      m4Pos = translation_matrix_from_vec3(pos)
      m4Local= translation_matrix_from_vec3(localPos)... etc
      m4Scale = scale_matrix_from_vec3(scale)
      m4localScale= scale_matrix_from_vec3(localScale)...
      ....
      T = m4Pos * m4Local
      S = m4Scale * m4ScaleLocal
      ...
      TRS = T* R * S;
      Do you have any video covering this subject i couldnt find one exactly, i know that transforming from one coordinate space to another you multiply matrices togheter but my second example seems very processor intensive to do it for each and every scene object.

    • @JorgeVinoRodriguez
      @JorgeVinoRodriguez  6 років тому

      I got videos up the wazaa for this. Go on my channel and look for a playlist called 'advanced matrices' or something like that. There's a video about coordinate transforms that I think you may find especially useful.
      I wouldn't worry about processor intensive for now. Unless you're trying to ship a game, just worry about learning how the things work at a basic level and writing correct code. Correct is more important than fast.

  • @snp27182
    @snp27182 4 роки тому

    Maybe a bit of a large segment dedicated to matrix composition. Still very interesting, haha.