RealBreezer Posted October 3, 2004 Posted October 3, 2004 Hello everyone. I started picking up c# to learn directx9.0 Everything goes fine and I'm doing some tutorials... though I run into problems at a certain moment where they want to set the position of a vertex. They use the "SetPosition" method... though if I try I get the bug saying that this method doesn't exist. CustomVertex.PositionNormalColored[] verts = new Microsoft.DirectX.Direct3D.CustomVertex.PositionNormalColored[3]; //vert 0 verts[0].X=0.0f; verts[0].Y=1.0f; verts[0].Z=1.0f; verts[0].SetNormal(new Vector3(0.0f,0.0f,-1.0f)); verts[0].Color = System.Drawing.Color.Aqua.ToArgb(); as you can tell from the code, I found a workaround for this. But now I'm at the point where they start talking 'bout normals... and SetNormal doesn't exist either. My question then... has these methods been removed? Or is it likely that I downloaded the wrong SDK. (I've the summer one-->dxsdk_sum2004.exe). Thx in advance. Quote
RealBreezer Posted October 3, 2004 Author Posted October 3, 2004 (edited) I found out that both methods SetPosition and SetNormal have been replaced by Position and Normal in the latest dx-release. However... when I adjust this code from verts[0].SetNormal(new Vector3(0.0f,0.0f,-1.0f)); to verts[0].Normal(new Vector3(0.0f,0.0f,-1.0f)); it results in the following error: "'Microsoft.DirectX.Direct3D.CustomVertex.PositionNormalColored.Normal' denotes a 'property' where a 'method' was expected" So... to my understanding... there's no way to set the normal since we're not talking 'bout a method. Whilst this is stated in the object window: public Microsoft.DirectX.Vector3 Normal [ get, set ] Member of Microsoft.DirectX.Direct3D.CustomVertex.PositionNormalColored Summary: Retrieves or sets the vertex normal data. Would this be another bug? [edit] Nope it isn't... I found out what the problem was, and it resided in my wrong believe. here's the proper code to set a normal in the latest dxSDK.... I hope someone will get this problem aswell sometime... just to make me feel less noob :p verts[0].Normal = new Vector3(0.0f, 0.0f, -1.0f); PS: Same DOES NOT apply to setposition. verts[0].position = new Vector3(0.0f, 0.0f, -1.0f); will give you nothing... it won't error... but with that everything is said. pretty weird... does someone has a clue what's going on with this? [/edit] Edited October 3, 2004 by RealBreezer Quote
ThePentiumGuy Posted October 3, 2004 Posted October 3, 2004 Hmm.. This is strange - I always thought that it was rhw instead of Normal. Maybe in the latest release it isn't. I'm not even sure what the normal DOES :-P. I usually set it to 1f: verts[0].Rhw=1f; Maybe you could try something like this? verts[0].Rhw = (Convert.ToSingle(new Vector3(0,0,1))); or possibly verts[0].Rhw = new Vector3(0,0,1).Normalize -The Pentium Guy Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Aragorn7 Posted October 3, 2004 Posted October 3, 2004 I'm not even sure what the normal DOES :-P. I usually set it to 1f: This is usually how DirectX or any API for that matter works. You learn bits and pieces at a time, but never learn it all. Quote
RealBreezer Posted October 3, 2004 Author Posted October 3, 2004 Lighting calculations can only be done if each face in your geometry has a normal. A normal is a perpendicular vector pointing away from the front side of a face. If it's correct, this is what a normal is used for. The rwh mentioned, is the 4th coordinate to set the creation into screenspace, rather than into worldspace. (Vector 4)... it's also called the w-coördinate. Apart from this, I got the normal thing working as I mentioned before. The only thing that's bugging me at this moment is the "setposition" member. It isn't there and should have been replaced by "position". Though it doesn't work for me like this (it doesn't error...but it doesn't create the vector): verts[0].Position = new Vector3(0.0f, 1.0f, 1.0f); However, I found a rather tedious workaround where I hardcode each coördinate seperatly. (verts[0].X = 0.0f; etcetc...) It's not a really big problem... though it's just weird that this isn't working the way it should.... and since I'm just learning dx9, I wonder whether it has to do with my code...(then again, it works this way for the normal). But hey :D then this quote kicks in: This is usually how DirectX or any API for that matter works. You learn bits and pieces at a time, but never learn it all. I second that :) Quote
ThePentiumGuy Posted October 3, 2004 Posted October 3, 2004 Heh - I just realized another solution for your "problem" :-P, vertx[0] = new CustomVertex.PositionNormalColored(x,y,z, rhw or normal, clr) Points away from the front side of the face eh? Hmm I'll mess around with that.. Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
RealBreezer Posted October 3, 2004 Author Posted October 3, 2004 Heh - I just realized another solution for your "problem" :-P, vertx[0] = new CustomVertex.PositionNormalColored(x,y,z, rhw or normal, clr) Points away from the front side of the face eh? Hmm I'll mess around with that.. Works like a charm! Thx! And... whilst testing this method... I realized there was a coördinate with a typo in it... :eek: 1.0f instead of -1.0f which resulted into the triangle-won't-draw syndrome... So the fault is all mine... verts[0].Position = new Vector3(0.0f, 1.0f, 1.0f); ---> It DOES work :rolleyes:.... but I like your method better :cool: Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.