SetNormal,SetPosition not there :/

RealBreezer

Member
Joined
Dec 3, 2003
Messages
8
Location
Belgium
Hello everyone.

I started picking up c# to learn directx9.0
Everything goes fine and Im 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 doesnt exist.

Code:
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 Im at the point where they start talking bout normals... and SetNormal doesnt exist either.

My question then... has these methods been removed? Or is it likely that I downloaded the wrong SDK. (Ive the summer one-->dxsdk_sum2004.exe).

Thx in advance.
 
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
Code:
verts[0].SetNormal(new Vector3(0.0f,0.0f,-1.0f));

to

Code:
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... theres no way to set the normal since were 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 isnt... I found out what the problem was, and it resided in my wrong believe.

heres 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

Code:
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 wont error... but with that everything is said. pretty weird... does someone has a clue whats going on with this?
[/edit]
 
Last edited by a moderator:
Hmm.. This is strange - I always thought that it was rhw instead of Normal. Maybe in the latest release it isnt.

Im 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
 
ThePentiumGuy said:
Im 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.
 
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 its 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)... its also called the w-co
 
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 Ill mess around with that..
 
ThePentiumGuy said:
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 Ill mess around with that..

Works like a charm! Thx!

And... whilst testing this method... I realized there was a co
 
Back
Top