Jump to content

JackStone

Members
  • Posts

    67
  • Joined

  • Last visited

JackStone's Achievements

  1. Hello, thank you for your reply. I had a good look at that link, and I do think it helped a lot. It is possible that I am closer than I thought. I actually have code that rotates a point (using Rodrigues' rotation formula). However, this seems to rotate about the wrong origin point. I think if I could translate the nodes back to the origin, rotate them, then translate them again by the same distance, I could accomplish the rotation. The angle to rotate by seems to be given by the code you posted. Wikipedia says about Rodrigues formula: "By extension, this can be used to transform all three basis vectors to compute a rotation matrix in SO(3), the group of all rotation matrices, from an axis–angle representation" So, this should work... I will give it a go as soon as I can, and post an update either way, thanks again!
  2. Sorry, I only just noticed this. I have looked at those tutorials in detail, thanks Daniel, they are hugely useful.
  3. Hi, Thanks for your reply, I think you're right, translating probably won't do it. Ah, and there is matrix math again :P I'm still not great with that stuff, it's probably why I haven't figured this out yet. From what I am told, I don't need to actually convert too a spherical coordinate system, is this correct? I can use the translation algorithm on the cartesian coordinates? I will have to look into matrix math then, and see if I can figure this out. Thanks!
  4. I have the 3D gravity completely done, that was fairly easy. That just pulls the player towards the center of the world though, it doesn't seem to help with moving/offsetting the terrain. The player is already moving in a spherical path, really, since the terrain itself is actually working an paging properly. The only thing I need to do is reset the positions of the terrain and the player when the player has walked a certain distance. This sketch illustrates what is essentially happening: The player is standing at the origin, with the nodes close by rendering (The red x is the origin, and the nodes with the red lines are rendering). They then walk towards the blue X, which is a distance of 10,000 meters. They have now moved in a curve, around the terrain. I am now rendering the nodes with the blue lines under them. This works fine. What I now need to do is move the player back to the red x, which is simple, AND move the BLUE nodes back to the origin as well, such that the player doesn't notice a transition. Moving the nodes is easy, but they are always offset in some way.
  5. Of course, you are absolutely right! I realised this myself a day or so ago, and your post put the final little piece into place. The problem wasn't with the *planet*, it was with the *player*. I thought I was making this easier by moving the player along one axis only, but of course that is essentially what caused the problem. What I need to do is move the *player* in a circular path. That is going to take a little time to figure out, with my current implementation, but with all the work i've done on spherical rotation so far, it shouldn't be too difficult! Thanks for your help, that was the last little piece of the puzzle that I needed!
  6. Yeah, I am basically just doing this: nn1 += moveoffsetvec; Where the moveoffsetvec is a simple vector. I was just doing: nn1.x -= 10000, which was even simpler. However, if you look at this image: http://phoenixgamedevelopment.com/blog/wp-content/uploads/2016/09/PhoenixGameDevelopment-04_09_2016-01_43_54-AM.jpg If I move point 4 by the offset distance, it will be beneath p3, since it is offset on Z. So, I am assuming that this is due to the curvature of the planet, and I need to move the new nodes along that curvature, but I may be totally wrong about that...
  7. Hi, I have run into something of a brick wall with my spherical terrain implementation (again!). I may have gotten myself into a situation that can't actually be resolved here, I'm still trying to figure out what the problem is exactly, and I'm hoping someone here can shed at least a little light on what's going on. Basically, I have got a very large planet rendering in T3D by dividing it up using a quad tree, and rendering only nodes close to the player. For the purposes of this argument, the player is close to the surface of the planet, and has moved 10,000 meters into the next "zone", and so I want to render the next set of nodes. This is what gnuplot shows: http://phoenixgamedevelopment.com/blog/wp-content/uploads/2016/08/PhoenixGameDevelopment-28_08_2016-08_06_07-AM.jpg This is correct. P1 (pink) are the original nodes, at the players starting position, these are now no longer needed, as the player has moved on to P2(green) which is now rendering. So far so good. The problem is that I need to implement a floating origin system, I can't have the player walking all around the planet, since there will be all kinds of precision issues. So, I reset the player back to the origin, and I now need to move the P2 nodes back along the same vector that I moved the player back (let's assume it's 10,000 units along the x axis for now). Now, the player should be at the origin, and the p2 nodes should be rendering as if they were in their original position, but they have been moved back 10,000 units. The X axis is indeed correct, but for some reason, the nodes are in the wrong positions in the Y and Z axes. Each time I increase the distance by 10,000 units, this error increases, causing the nodes position to be completely incorrect. This is the best image I have of what's happening. This is after just one movement by 10,000 units: http://phoenixgamedevelopment.com/blog/wp-content/uploads/2016/08/PhoenixGameDevelopment-28_08_2016-08_19_15-AM.jpg These two groups of nodes should be in exactly the same place, but as can be seen, the second set of green nodes is offset along the z axis. I have tried all manner of solutions, from changing the positions in the spherical terrain code, changing them in preprenderimage, scaling and rotating, using rodrigues rotation formula, and adding an offset to the z axes to try to compensate for the shift. Nothing seems to work. I have confirmed that when I move the nodes by 10,000 units, then move them back by 10,000 units, they are *exactly* the same, which means that what ever is happening is not some random occurrence, for some reason there is an offset being added to the y and z axes of these nodes when I change their x values. I suspect that the fact that the nodes are on a curve (being part of a spherical terrain surface) must be the issue. It could also be to do with the local coordinates of the nodes, they are between -1 and +1, could this be an issue? Another thing that I just thought of is some kind of an issue caused by the scale of the actual world object, in the mission editor. Does anyone have any advice on where I could continue looking?
  8. I actually got this working, it turned out to be so simple. I just needed to change: runAcc.z = 0; to runAcc.z = runAcc.z * mDataBlock->airControl; Inside: else if (!mSwimming && mDataBlock->airControl > 0.0f) That enables full 3D rotation and movement. This is pretty cool, I can walk all around any object in 3 dimensions now.
  9. Alright, the camera issue is fixed. I now just have one issue left, and that is that the players movement direction changes when their orientation changes. IE, pressing the forward key when the player is oriented with Z-Up moves them forward, but when Y is up the forward key moves them in a different direction. Do I need to somehow rotate the move vector by the mOrient quaternion?
  10. Hi, Thanks again for your help. I am using standard move, and the code you posted *almost* fixed the issue. The camera is stable, but now, for some reason, the players head moves by itself to face a particular direction, and every time I move the camera, it return to that same spot. So there must be something causing the player to move their head? It's not the doQuatOrientation code, I checked that. I'm also having issues combining the move vector (the actual player movement) with the gravity vector. The two vectors seem to cancel out at certain points. making the player unable to move. I am currently combining them simply by adding them and normalising: Point3F m = Point3F(move->x, move->y, move->z); gravvec += m; gravvec.normalize(); VectorF acc(gravvec); This, again, *almost* works, but the direction of the players movement along X and Y changes as their orientation changes. I just saw your edit about the pack/unpack, I will have a look at that tomorrow. I am slowly making progress with this, thanks again!
  11. Irei1as, you sir are a genius! Thank you very much for that! Your code works great! I have the orientation working perfectly now. However, I have run into issues with the camera, as you said. I am using a plane at the moment, but even so, as the player rotates the camera, it seems to interfere with the new code that I added to orient the player. I assume I have to combine the "look" quaternion with the new quaternion that I added, do you have any ideas how I would go about doing this? My current code is: if (!contactNormal.isZero()) { Con::printf("CONTACTNORMAL %f %f %f", contactNormal.x, contactNormal.y, contactNormal.z); doQuatOrientation(contactNormal); } else { Con::printf("NO CONTACT NORMAL"); Point3F cogvec = Point3F(0, 0, 0) - getPosition(); cogvec.normalize(); cogvec *= -1; doQuatOrientation(cogvec); }
  12. Ok, so I think I have reduced this to a simple test case. When the player is standing on top of a cube, the contact normal is 0,0,1, and the quaternion should be QuatF(Point3F(0,0,0)) for the to be correctly rotated. When the stand on the side of the cube, facing the negative x axis, the contact normal is (-1,0,0), which it should be. The quaternion here, for correct facing, should be: QuatF(Point3F(0,1.57,0)). Which is basically a 90 degree rotation along y. The question is, how do I mathematically derive that quaternion from the contact normal and the player position, etc, alone?
  13. Thank, you this seems to have helped me a little. I had seen that code before, but hadn't used it, since I was working on a system using a vector from the players position to the terrain center. I have replaced my spherical terrain with a simple cube for testing, and I can obtain a contact normal, of the form: "1,0,1" with the player standing on one of the faces. However, I now need to convert this VectorF into a QuatF. I tried just setting the quatf to the contactnormal, which compiled, but doesn't work. There is obviously a trick to this that I am not getting.
  14. This would be ideal, but I'm not sure how to grab that normal? The other thing, is that I'm not sure how to align the player to face a particular normal. I am doing this at the moment: Point3F gravityvec = teraincenterpos - getPosition(); gravityvec.normalize(); QuatF q = QuatF(gravityvec); mOrient = q; It seems to be close to working, but it doesn't work on all cases.
  15. I have made some progress with this. If I add this to updatemove(): QuatF q = QuatF(0, 0, 1, 0); mOrient = q; I can change the orientation of the player. I just need to know what to set mOrient to in order to face the center of the terrain.
×
×
  • Create New...