stupid c# d3d9

Started by
11 comments, last by IStrikerI 20 years, 7 months ago
what type of variable is this Device.Transform.View ? for example this doesnt work: dev.Transform.View.M11 = 1; // not a variable ? what else ? this doesnt work: dev.Transform.View = new Matrix(); dev.Transform.View.M11 = 1; and what the hell does this function Matrix.PerspectiveFovLH()? does it return a new instance ? this cannot be, i already did it and it doesnt work. it also isnt a fu***** static variable. sorry, but im very angry about the fact that the prog-languages get slower and more complicated than c++
Advertisement
PerspectiveFovLH builds a left-handed perspective projection matrix based on a field of view and expects 5 parameters. Maybe thats why it doesn''t work?

Matrix.PerspectiveFovLH()...
- n/a -
PerspectiveFovLH Method
C#

public static Matrix PerspectiveFovLH(
float fieldOfViewY,
float aspectRatio,
float znearPlane,
float zfarPlane
);

Return Value

Microsoft.DirectX.Matrix

i know what mathematical stuff the function does, but i dont know how the function returns the matrix and what type of variable Device.Transform.View is.

this works, but how ?
Device.Transform.View = PerspectiveFovLH(0, 0, 0, 0);


is Device.Transform.View already referencing to an instance or not or is it static ?
If I''m not mistaken, Device.Transform.View is a read-only property, so you can''t alter it, but you can get the value. Its type is Matrix.

Bear in mind that C# has "properties", which C++ doesn''t have.
Device.Transform.View cannot be readonly because this works:
Device.Transform.View = PerspectiveFovLH(0, 0, 0, 0);
this is also an example from msdn

okok Device.Transform.Projection = PerspectiveFovLH(0, 0, 0, 0);
would be better ;-)

[edited by - IStrikerI on September 3, 2003 10:39:32 AM]
LOL... C#. Good luck dude.
In C# something is either a value-type (basically a struct from C/C++) or a reference type (a pointer to an instance of a class).

Matrix is a value type (it inherits from System.ValueType). Because you don''t get references to value types, a property that returns a value type will return a copy of it, not the value type itself.

So, Device.Transform.View returns a COPY of the View matrix. If Matrix was a reference type, the Device.Transform.View would return the actual view matrix (well, the reference to the actual view matrix).

So, if you want to muck with the view matrix (or some other matrix), you ususally need to do something like:

Matrix m = Device.Transform.View;
m.M11 = 1.0f;
Device.Transform.View = m; // (or Device.SetTransform(TransformType.View, m)

I had the same problem with the Viewport until I realized my error.

Cheers,
nerdboy80
Does any one know if you need C# for DX 9?
Uhm, how about:

device.Transform.View = Matrix.PerspectiveFovLH(90, 4f/3f, 1, 1000);         


Matrix.PerspectiveFovLH is a static member function. That means that you don't call it from a Matrix object, you just call it like so. It creates and returns a Matrix object that you can use for whatever you want.

How does it work?

public class Matrix{  public static Matrix PerspectiveFovLH(...)  {     Matrix m = new Matrix();     // fills the matrix     return m;  }}        


Device.TransForm.View is of type Matrix, and has both getter and setter.

And yes, properties that are of a value-type cannot be modified without using a temporary (value-types returned by a getter are treated as temporary constants by the compiler)



You don't need C# for DX9. DX9 provides both COM+ and .NET interfaces, so you can use it in C++, Managed C++, C#, VB.Net and any other languages that support either COM or .NET interop.

[edited by - Nypyren on September 3, 2003 8:39:41 PM]

This topic is closed to new replies.

Advertisement