Jump to content

Custom Sky Renderer Using Quaternion to Rotate One Vector to Another


Floydman

Recommended Posts

This is a follow-up to a question I asked earlier on Discord but didn't get resolved: I am working on a custom sky renderer, and my goal is to be able to take 2 vectors, one representing the in-game y-axis and the other pointing toward the object I want to render, generate a quaternion that rotates the first to become the second, and give that quaternion to the MatrixStack to render the object in the correct place. When I brought it up before, I was a little unsure of my vector math, but I have now verified that when using my quaternion to rotate the first vector, it perfectly (or almost perfectly since I'm dealing in floats) rotates to become the second vector. (I've even put together a Mathematica workbook that shows all the vectors behaving like they should.) However, when giving this quaternion to the MatrixStack, I still get very odd behavior. (For example, even with no orbital or axial tilt, the sun renders a very odd path instead of it's normal vanilla circle.) So what I'm thinking is that I must be messing up the rendering code, even though I basically copied how Minecraft renders its sky objects.

Here are the two classes I am using (one for vector math and the other for rendering): https://gist.github.com/TheFloydman/3443e0b888dd04f2770a785080e8b76d

I am aware there are simpler ways to render a stationary sun around which the Minecraft planet is orbiting, but I'm using this as a simple situation to prepare for something more complex, like a planet or comet is is orbiting the sun. If I can describe an object's current position with a vector, I want to be able to render it correctly.

Edit: Adding an animation to demonstrate what should be happening. The black vector is the current rotation of the observer, red is the position of the observer, green is the position of another orbiting planet, and blue is the vector generated when I transform the black rotation vector with the quaternion I generate. This view is from overhear, but the orbital inclinations of each planet is 7 degrees, and the observer's planet is tilted 23 degrees. As you can see, no matter where the black observer rotation and green other planet vectors are pointed, the blue vector always points from the observer's planet to the other planet.

fyJEC.gif

Edited by Floydman
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Is there a way to copy effect for example Darkness or Nausea? Like an absolute copy
    • Tapi sebelum itu kalian sudah tahu belum kenapa kami menyarankan DUTA89 kepada kalian semua? Karena DUTA89 bisa dikatakan sebagai salah satu tempat atau wadah untuk menghasilkan uang dengan cepat dan mudah hanya dengan modal receh dan rebahan saja
    • It is painful to invest and lose, binary options are more of a gamble if you ask me, especially when your broker decides to invest on your behalf. That's how I lost all my funds thanks to my broker who claimed to have invested on my behalf and lost a sum of 115,000 USD. This made me realize that people should really be careful out there especially when funds are involved, this is not to say recovery is not possible even though there are several frauds out there who claim they can recover your funds. This will only depend if you have done your research on the recovery agent that you would want to use to help you. After what happened to me, I wouldn’t like the same situation to happen to me, losing money. I did a thorough check on CYBERSPACE HACK PRO after coming across numerous testimonies on him helping lots of people to recover their funds/BTC. It took me a whole week to decide if I would be doing the right thing by hiring him. I emailed on Cyberspacehackpro(@)rescueteam.com and he responded. Asked him various questions and he really did impress me; he really knew his way on recovery. After providing all the necessary details, he did his incredible work and in 4 days time, my funds were recovered. Whether someone outside there feels like whatever I did to recover my funds rather than report it to the police was through unethical means, I wouldn’t care because as far as I am concerned, I don’t care because I was able to retrieve my hard-earned funds taken from me and that’s all, a big thank you to CYBERSPACE HACK PRO Recovery. CONTACT: CYBERSPACE HACK PRO Email: Cyberspacehackpro(@)rescueteam.com
    • Im using exaroton hosting with mods. Im play normally with my friends, and in some point the server freezes, and eventually kicks us for ''time out'', and the server never unfreezes again. when i reload the server, the world doesn't suffer any damage, but the players seem to go back in time. Example: I'm in a cave mining diamonds and I collect them. The server freezes and times out. when I restart the server, the cave diamonds are gone, but they are not in my inventory either. as if the player has gone back in time, but the world has not. Its really annoying for me and my friends. If someone can help me ill be so grateful. It doesn't seem to be any error in the console nor log.
    • Logs: https://pastebin.com/LBZs2U25
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.