MDX9 c# SetPosition problem?

Started by
5 comments, last by acid2 19 years, 5 months ago
Trying to run through the code included in the Managed DirectX 9 KickStart book (which by the way is superb!)... ...but I've fallen at the first hurdle. I'm using the C# Express 2005 beta, and have copied the code in from the book (and indeed loaded it from the cd as well), but I get errors when compiling... Three errors specifically - all about the same problem... 'Microsoft.DirectX.Direct3D.CustomVertex.TransformedColored' does not contain a definition for SetPosition I've looked on the web, but every MDX9 tutorial I find uses this method to set up three vertexes for the triangle it then displays. The code in question is: (Line 1) CustomVertex.TransformedColored[] verts = new CustomVertex.TransformedColored[3]; (Line 2) verts[0].SetPosition(new Vector4(this.Width / 2.0f, 50.0f, 0.5f, 1.0f)); I've included all my references, and this is the only part that displays an error... any ideas please?
Advertisement
That's unusual, according to the TransformedColored and SetPosition documentation, there is. Which version of the runtime assemblies do you have installed?
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Running Visual C# 2005 Express Edition Beta 1

.Net Framework v2.0.40607

Microsoft DirectX v1.0.2902.0 runtime v1.1.4322 from C:\...\Managed DirectX\v9.02.3900\Microsoft.DirectX.DLL
My lack of knowledge leads me to following workaround (as shipped with in the tutorial code) - I'm not sure whether or not this has the same effect, but it works...

verts[0].SetPosition(new Vector4(this.Width / 2.0f, 50.0f, 0.5f, 1.0f));

becomes

verts[0].X = (this.Width / 2.0f)
verts[0].Y = 50.0f
verts[0].Z = 0.5f
verts[0].W = 1.0f;
There is no SetPosition on the latest bits. There is a Position property, so you could do

verts[0].Position = new Vector4(...);
Excellent! Thankyou very much indeed - now I suppose I ought to post a note to the publishers so they can update the errata!

To clarify (post testing...)

verts[0].SetPosition(new Vector4(this.Width / 2.0f, 50.0f, 0.5f, 1.0f));


becomes

verts[0].Position = new Vector4(this.Width / 2.0f, 50.0f, 0.5f, 1.0f);


Yea, they changed it fromt he version of MDX in the book, to what you have. You no longer need to use GetPosition and SetPosition to use Vector3's you can now use the one property. Why they didnt do this in the first place I guess we'll never know...
Ollie"It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]

This topic is closed to new replies.

Advertisement