just transform all matrix element.

for (int u=0; u<4; u++)

for (int v=0; v<4; v++)

DxMatrix[u,v] = glMatrix[v,u];

Please log in or register to post a reply.

just transform all matrix element.

for (int u=0; u<4; u++)

for (int v=0; v<4; v++)

DxMatrix[u,v] = glMatrix[v,u];

thats why im asking. Since im pretty new to DX though is there some
other function which i can use to do what you described?

Matrix4 transpose;

for (blah) tranpose[u,v] = matrix[v,u];

Device.Transform.World = transpose;

@Reedbeta

Matrix4 transpose;

for (blah) tranpose[u,v] = matrix[v,u];

Device.Transform.World = transpose;

That wont work, Device.Transform.World doesnt take my custom Matrix4 class as a parameter because it only works with DirectX matrices, which is called Matrix.

Also, Axel, i do not want to use any opengl api specific code because this function is inside a directx implementation of my renderer.

let me explain this a bit further..

The reason i dont use directx matrices all over my project is because i
want to work with 1 matrix class only independantly of which rendering
api i am using. I am making a generic renderer class which should
transparently cover the directx/ogl specific code within their
respective implementation.

The function should simply convert from my Matrix4 class into a directx
matrix. Since the matrix elements in a directx Matrix is read only i
cant set its elements directly (or can i?) so instead im calling the
translate, rotate etc functions of directx manually to set it up.

I don’t know about the C# access to directx, but a matrix class that can’t be written to sounds a bit useless to me.

If the matrix is the same as the c# Mobile d3d, then you can write to M11 M12, M13 and so on.

```
namespace Microsoft.DirectX
{
public struct Matrix
{
public float M11;
public float M12;
public float M13;
public float M14;
public float M21;
...
//
// Summary:
// Returns the matrix transpose of a matrix.
//
// Parameters:
// source:
public void Transpose( Matrix source );
}
}
```

Thus, you can access/modify the elements, just create an instance:

```
Matrix mx = new Matrix();
mx.M11 = ...;
...
device.Transform.World = mx;
```

@Dias

Also, Axel, i do not want to use any opengl api specific code because this function is inside a directx implementation of my renderer.

Sorry, I misunderstood your question.

- Upcoming Multiplatform Game Program...
- Network Emulation Tool
- Trouble with accessing GLSL array
- Game Programming Patterns: Bytecode
- Fiction
- Skeletal Animation Tutorial with GP...
- Interactive WebGL Water Demo
- Unreal Engine 4
- Microsoft xbox one selling poorly
- Using OpenGL Camera with Box2D in C++

Hey :)

Im doing some matrix coding and have run into a small problem.

I have a generic 4x4 matrix class which is the same type as OpenGL uses.

I also have a function in my program called setMatrix() which takes a matrix of this type and applies it to directx which from what i know, uses a mirrored/different style matrix.

So far ive added the translation of the matrix like shown below, but how do i apply the x, y, z axis rotations to it?

Any code samples would be appreciated :)

// C# code

public override void setMatrix(Matrix4 matrix)

{

// Apply the translation of the passed matrix

device.Transform.World = Matrix.Translation(matrix.m[0,3], matrix.m[1,3], matrix.m[2,3]);

}

/Cheers