   view matrix or vector problem or angles problem or whateva
  helloI'm new to directx and c# (and I'm developing a little program under .net and managed directx). I would be very very gratefull If someone explained few things to me.I'm using Left Handed (LH) system.question 1) I want to create a view TPP and FPP. Could anyone tell me how to do that? Well I thought about it and tried to find the answer in the internet (in gamedev.net also).Let's just assume I have position in which I want to have the camera. It is a structure of 6 floating number points. 3 floats for position, 3 floats for every angle along each of the three axis.Simpliest way to set the device.Trainsform.View for the scene FPP (for the camera) is by calling:device.Transform.View = Matrix.LookAtLH(cam.cameraPosition, cam.cameraTarget, cam.cameraUpVector);cameraUpVector - is set as [0 1 0].cameraPosition - that's where camera iscameraTarget - with that I've got a problem. Where's the target? Probably the easiest way is to solve FPP view mystery is to create a point translated from camera position and rotate it (multiply by a rotation matrix) with the angle. Is it a good solution, or could someone mention better one?Similar would be TPP view with translating&rotating the source point, setting the camera position with the calculated point, translating&rotating source point again and setting the target point (now I would have the world of warcraft view).In addition I want to point out that I cannot implement vector/matrix multiplication, as if it could not be in the directx (maybe it is but I cannot find it?). Whenever I'm trying to inherit vector3 class and implement my own operator* compiler shows me the finger and says that the vector class is sealed class.I read that the view can be done with quaternion.question 2) What is quaternion? I mean - I read about it. It sounds as if they were  nice. It's a point described in polar coordinate system.The big question "do I need it?". Can't I just stay with simple Vector3 and matrixes? When should I use it.Thanks for any constructive responses.   
Quote:cameraTarget - with that I've got a problem. Where's the target? Probably the easiest way is to solve FPP view mystery is to create a point translated from camera position and rotate it (multiply by a rotation matrix) with the angle. Is it a good solution, or could someone mention better one?An easy way to compute a reasonable 'target' vector for use with a 'look at' function is simply to add the camera forward vector to the camera position, e.g.:vector3 target = camera.position + camera.forward;Note that the 'look at' function is just a convenience function; it's not the only way to build a view matrix. If you already have the world transform for your camera object available, the easiest way to get the view matrix is to invert the world matrix (bypassing the 'look at' function entirely).Quote:In addition I want to point out that I cannot implement vector/matrix multiplication, as if it could not be in the directx (maybe it is but I cannot find it?). Whenever I'm trying to inherit vector3 class and implement my own operator* compiler shows me the finger and says that the vector class is sealed class.Not sure I followed that - are you saying you want to implement your own vector/matrix multiplication functions? Or that the DirectX multiplication functions aren't working for you?Quote:question 2) What is quaternion? I mean - I read about it. It sounds as if they were  nice. It's a point described in polar coordinate system.The big question "do I need it?". Can't I just stay with simple Vector3 and matrixes?Yes, you can stay with vectors and matrices. Quaternions have some nice properties and are very useful in some situations, but I'd recommend sticking with matrices until you have a pretty thorough grasp of the topic of rotations and how they can be represented and manipulated (at which point you'll know when and why quaternions can be useful).   ;  Thank you very much! This info explained me a lot!issue 1) I think inverse matrix of world matrix of camera positon is great solution. I found my own solution also, to use inverse order of multiplication with negative values of position and angles. These multiplications (I think) are creating inverse matrix of camera position.//The view matrixfloat[] pos=new float[6];Matrix.Translation(new Vector3(-pos[0],-pos[1],-pos[2])) *Matrix.RotationZ(-pos[5] * Matrix.RotationY(-pos[4])* Matrix.RotationX(-pos[3])//world matrix of cameraMatrix.RotationX(pos[3])*Matrix.RotationY(pos[4])*Matrix.RotationZ(pos[5])*Matrix.Translation(new Vector3(pos[0], pos[1], pos[2]));The answer was so obvious. Why should anybody multiply the view (which for this case is inverse matrix of world matrix) with the world matrix? To get Identity matrix! The object stays with camera. If camera goes somewhere, the object stays where camera is.However I don't know which solution is better for the computer side (which is faster?). I think that better would be calculating inverse matrix than doing many multiplications (however iverting matrix is not fast).issue 2) I have a problem with multiplication like this:Vector3 vec = new Vector3(0, 0, 0);vec = vec * Matrix.RotationX(2);Why do I want to use vector/matrix multiplication? To get a point coordinates in other coordinate systems.;Quote:I think inverse matrix of world matrix of camera positon is great solution. I found my own solution also, to use inverse order of multiplication with negative values of position and angles. These multiplications (I think) are creating inverse matrix of camera position.Yes, you can get the inverse that way as well.Quote:However I don't know which solution is better for the computer side (which is faster?). I think that better would be calculating inverse matrix than doing many multiplications (however iverting matrix is not fast).For something that will only be done once or a few times per frame, it shouldn't matter - personally, I'd just invert the matrix. For what it's worth though, if a transform is a rigid body transform (i.e. rotation and translation only), you can invert it more efficiently by treating it as a special case.Quote:I have a problem with multiplication like this:Vector3 vec = new Vector3(0, 0, 0);vec = vec * Matrix.RotationX(2);Assuming DirectX conventions, I would expect it to be:vec = Matrix.RotationX(2) * vec;You still haven't mentioned what the problem is though, so I can't really offer much more than that.   ;  using Microsoft.DirectX;using Microsoft.DirectX.Direct3D;....Vector3 vec = new Vector3(0, 0, 0);vec = Matrix.RotationX(2) * vec;compiler outputerror CS0019: Operator '*' cannot be applied to operands of type 'Microsoft.DirectX.Matrix' and 'Microsoft.DirectX.Vector3'   ;Quote:Original post by renegatusing Microsoft.DirectX;using Microsoft.DirectX.Direct3D;....Vector3 vec = new Vector3(0, 0, 0);vec = Matrix.RotationX(2) * vec;compiler outputerror CS0019: Operator '*' cannot be applied to operands of type 'Microsoft.DirectX.Matrix' and 'Microsoft.DirectX.Vector3'Hm. I haven't used DirectX in this particular context - I'm afraid I can't tell you why that doesn't work. Maybe someone with more DirectX and/or C# experience can help out with this.   