|
|||||||
| Forum Home | Register | Members List | Mark Forums Read |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | ||||||||
|
Member
Location: N. America |
I am trying to learn 3D game programming now (in XNA). Though, its really a math question..
(XNA follows the right hand coordinate system: From MSDN: " The XNA Framework uses a right-handed coordinate system, with the positive z-axis pointing toward the observer when the positive x-axis is pointing to the right, and the positive y-axis is pointing up. " Ok, now in this tutorial at msdn, its about basic movement and displaying stuff. Before that, here are some positions: Camera: AvatarHeadOffset = new Vector3(0, 7, -15); TargetOffset = new Vector3(0, 5, 0); Objects located at: Cube.Position = new Vector3(10, 0, 10); Pyramid.Position = new Vector3(20, 0, 10); My Position = Origin As per these, in my opinion, the cube should be displayed on the right and the pyramid afterwards at x = 10 and x = 20. But, when I run the tutorial, it displays: the cube first on the left followed by pyramid (feels as if, cube is at x = -10 and pyramid at x = -20). I dont understand why this is happening ? Given the coordinate system and where I currently am, should they not be seen on the right ? The next question follows this one: Its about movement along the x axis again. on right arrow, if i decrease my current position, i strafe right. Can somebody please explain me as to what am I doing wrong here ? The tutorial can be found over here. Also, I have attached a copy of the code. Its XNA 3.0 (& it uses WASD for strafing, Q/E for rotation). Thanks |
||||||||
|
|
|
|
|
#2 | ||||||||
|
Junior Member
Location: Nashville, TN |
I think you have the coordinate system a bit backward from my look at it. From the starting point of view of your "fuelcarrier" the x axis has a positive direction to the left and negative to the right, the y axis is positive up and negative down, and the z-axis is positive in the way your camera is looking (so out away from you) and negative from behind you. I hope that helps somewhat, I'm not sure if that's the answer but playing around with a few of your vector3's that's what it's looking like.
|
||||||||
|
|
|
|
|
#3 | ||||||||
|
Member
Location: N. America |
Exactly!
But the definition of coordinate system from msdn says, that +X should be on the right. Thus, the models should appear on right and not on left ![]() I dint write this code, its from a tutorial at msdn. Personally, I think I am getting messed up between the frame of reference from where the right hand coordinate is considered..but, coordinate system is one place, where I want to be absolutely sure before I actually get into some serious XNA 3d programming..otherwise, it will be a pain all along the way, and I would never be confident about what code I write.. But yeah, thanks for your suggestion. If I find an answer, I will definitely post it and log it in my FAQ ![]() |
||||||||
|
|
|
|
|
#4 | ||||||||
|
Senior Member
Location: London |
I've not really looked at this in depth, but it seems a very simple problem. Your head offset is the -15 along the Z axis from the camera position. and the Target offset (which the camera is looking at) is 0 on the Z axis. If you remember that you are looking into the negative direction along the Z axis, that means that your camera is essentially looking backwards. Thus reversing the way things look.
|
||||||||
|
|
|
|
|
#5 | ||||||||
|
Administrator
Location: London, UK |
The right hand rule for coordinates:
![]()
__________________
Michael 'Adrir' Scott :: Games, Virtual Worlds, Education Networking | Research | Teaching |
||||||||
|
|
|
|
|
#6 | |||||||||
|
Junior Member
Location: Nashville, TN |
Quote:
|
|||||||||
|
|
|
|
|
#7 | ||||||||
|
Moderator
Location: Philadelphia, PA |
Win! This is the best way to remember the rule.
__________________
Grant Shonkwiler() "I would love to fix the world if someone would just give me the source code" Website Industry blog LinkedIn |
||||||||
|
|
|
|
|
#8 | ||||||||
|
Administrator
Location: London, UK |
Yeah, that sounds about right.
__________________
Michael 'Adrir' Scott :: Games, Virtual Worlds, Education Networking | Research | Teaching |
||||||||
|
|
|
|
|
#9 | ||||||||
|
Member
Location: N. America |
Ah, I finally understand how this works. Also, I put my understanding to test in my code and it works, yaaay !!
Thanks a lot, for clarifying this. I drew a grid on paper and marked everything, then I was able to see how things got inverted. Also, I made these following changes: Camera: AvatarHeadOffset = new Vector3(0, 7, 15); TargetOffset = new Vector3(0, 5, 0); voila, and it behaves the way i want it to. Also, for strafing, I say something like this> If W: velocity.z = -1; else if S: velocity.z = 1; if A: velocity.x = -1; else if D: velocity.x = 1; (I do this, keeping in mind the right hand coordinate system) and it works fine. I wonder why did the tutorial at msdn; place the camera at z = -15 ? Is this an industry convention or what? Also, they had the velocity increments inverted (as to what I have written here). Personally, I found that to complicate things. Anyways, I would like to know, if that is some sort of industry convention or is there something like that that I need to keep in mind when I code for 3D. As of now, I can roam around in this 3d world, strafe and rotate..woohoo ![]() Thanks guys! (I will post my code here and on my blog FAQ..just in case, if some1 lands into the same trouble and needs to see it..) |
||||||||
|
|
|
|
|
#10 | |||||||||
|
Senior Member
Location: London |
Quote:
|
|||||||||
|
|
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
All times are GMT -8. The time now is 01:06 PM.





























Linear Mode

