I need help
I need help
In the project attached I made a cube. I am trying to get the cube to spin but I am not sure what code should be used to get the cube to rotate. I used the drawline function to make the cube.
I added my other project were the cube moves but it does not rotate.
I added my other project were the cube moves but it does not rotate.
- Attachments
-
- CubeTest2.zip
- The cube moves but wont rotate
- (439.76 KiB) Downloaded 166 times
-
- CubeTest.zip
- (424.46 KiB) Downloaded 183 times
CraigSpaz
- Ozi_Juggalo
- Posts: 23
- Joined: October 2nd, 2012, 3:00 am
- Location: Australia
Re: I need help
Have u tried finding (or creating) a SpriteSheet?
maybe worth lookin into
though if you can get it to spin without sprites, than i take my hat off 2 you
maybe worth lookin into
though if you can get it to spin without sprites, than i take my hat off 2 you
☺☻☻☺!Whoop Whoop MCL!☺☻☻☺
Re: I need help
You can do it with drawline. You need math. Lots and lots of math. And you need more than just x and y. You need a z in that mofro.
Chili
Re: I need help
Chili, will you be covering that sort of trig in the tutorials? But I would assume that there are already functions for this in DirectX3D though, I just don't know how to use them.
Re: I need help
Yup, I will be covering all of that. And yup, the D3DX utility library contains a bunch of funcitons for setting up transformation matrices and other useful math stuff.
Chili
Re: I need help
I passed out reading that. After I'm done with the beginner tuts, I'm going to be taking a long break and will try to learn some math beyond junior-high level. If only the teachers taught math using video games...chili wrote:... transformation matrices and other useful math stuff.
Re: I need help
I don't think transforming matrices is that hard. After you get the idea of it, it's just series of multiplication and some simple geometry put together. But dunno what chili has in store for us.
ʕ •ᴥ•ʔ
Re: I need help
Well you said that you are trying to rotate the cube, so I kinda have a solution. In all, yes ALL, 3D game engines such as Unity there are things called matrices (Matrix pl.), and those hold things like transformation, rotation etc... but I was using a thing called XNA ( a framework for C# ) and I was trying to get a good 3D game going and had to use matrices. They are pretty easy to use with some simple playing around and getting used to them. But the real reason you use them is to make sure that your 3D image is going to be drawn to the screen in a 2.5D kind of way. There is no "true" 3D program because that would mean that you can actually see depth. The depth is just an optical illusion if you will. So when the image is drawn to the 2.5D (having 3D appearance), the matrices will then control things like rotation (what part of your 3D object is shown at the time) and make sure that it is drawn correctly. So I guess my point of telling you all that is that there is a function inside of C# that's called MathHelper, and it has all of these nice things in it that allow the computer to take care of most of the math. With that being said you may want to go to Micrsoft's website and check it out. Even though it is in C# if you have any basic knowledge of C++ than you can look at it and have a clue of what's going on. So just look at the MathHelper function and maybe you can imitate some of the math that is going on in there and you can maybe get a rotation going on. I can't help you with much of the math though, as I am only a freshman in Highschool and currently in Geometry, so I can't really recommend what knowledge of math you need to know either. But if I had to guess I would say at least some basic Trigonometry, and probably some basic algebra too.
Good luck bro
EDIT: I just realized that it would also be a good idea for you to understand a Vector2 and a Vector3. They are variables that hold an X and a Y (Vector2), and hold X,Y, and Z coordinates (Vector3). I would make sure that you try to rework the put pixel function to try to use those too because then you can imitate almost exactly what is going on in the MathHelper function. MathHelper and almost every single 3D object will make EXTENSIVE use of Vector3's, mostly because I guess they are more organised in a way. I don't know if the framework is optimized for a 3D image yet so I would also look into some of the ways to optimize DirectX9 to work with 3D objects... I also said that you need some knowledge of Trig too, well that is true. I said that because every shape in 3D space is drawn with Triangles, so having a good knowledge of trig is good when you are working with a game engine, or your own code, to get things to rotate or move when there aren't any functions to do it for you...So with all of these tips I would recommend starting with getting the framework going with 3D, and then maybe you can use some vector3's and matrices (along with the math from MathHelper) to start drawing some 3D images. Then you can work on the Rotation of the object.
Good luck bro
EDIT: I just realized that it would also be a good idea for you to understand a Vector2 and a Vector3. They are variables that hold an X and a Y (Vector2), and hold X,Y, and Z coordinates (Vector3). I would make sure that you try to rework the put pixel function to try to use those too because then you can imitate almost exactly what is going on in the MathHelper function. MathHelper and almost every single 3D object will make EXTENSIVE use of Vector3's, mostly because I guess they are more organised in a way. I don't know if the framework is optimized for a 3D image yet so I would also look into some of the ways to optimize DirectX9 to work with 3D objects... I also said that you need some knowledge of Trig too, well that is true. I said that because every shape in 3D space is drawn with Triangles, so having a good knowledge of trig is good when you are working with a game engine, or your own code, to get things to rotate or move when there aren't any functions to do it for you...So with all of these tips I would recommend starting with getting the framework going with 3D, and then maybe you can use some vector3's and matrices (along with the math from MathHelper) to start drawing some 3D images. Then you can work on the Rotation of the object.
MOOOOOO