Click here to Skip to main content
15,923,789 members
Home / Discussions / C#
   

C#

 
GeneralChange image property of a picturebox object at run time Pin
Einar Kvandahl12-Jan-05 15:45
Einar Kvandahl12-Jan-05 15:45 
GeneralRe: Change image property of a picturebox object at run time Pin
Adam Goossens13-Jan-05 1:01
Adam Goossens13-Jan-05 1:01 
GeneralClass / Database design document Pin
econner12-Jan-05 15:17
econner12-Jan-05 15:17 
GeneralRe: Class / Database design document Pin
Adam Goossens13-Jan-05 1:05
Adam Goossens13-Jan-05 1:05 
GeneralWindows ContextMenu... Pin
new_phoenix12-Jan-05 13:45
new_phoenix12-Jan-05 13:45 
GeneralRe: Windows ContextMenu... Pin
Guinness4Strength12-Jan-05 13:52
Guinness4Strength12-Jan-05 13:52 
GeneralRe: Windows ContextMenu... Pin
new_phoenix13-Jan-05 9:24
new_phoenix13-Jan-05 9:24 
GeneralDirectX 9 & c# problem Pin
dratcha12-Jan-05 12:28
dratcha12-Jan-05 12:28 
I didn't see a DirectX board so I thought I'd post here since I am writing in C#.

I am having an issue with setting some vectors on a CustomVertex. Here is my code:

<br />
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)<br />
{<br />
   device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI/4, this.Width/this.Height, 1f, 50f);<br />
   device.Transform.View = Matrix.LookAtLH(new Vector3(0,0,30), new Vector3(0,0,0), new Vector3(0,1,0));<br />
   device.RenderState.Lighting = false;<br />
   device.RenderState.CullMode = Cull.None;<br />
<br />
   CustomVertex.PositionColored[] vertices = new CustomVertex.PositionColored[3];<br />
   vertices[0].SetPosition(new Vector3(0f, 0f, 0f));<br />
   vertices[0].Color = Color.Red.ToArgb();<br />
   vertices[1].SetPosition(new Vector3(10f, 0f, 0f));<br />
   vertices[1].Color = Color.Green.ToArgb();<br />
   vertices[2].SetPosition(new Vector3(5f, 100f, 0f));<br />
   vertices[2].Color = Color.Yellow.ToArgb();<br />
<br />
   device.Clear(ClearFlags.Target, Color.DarkSlateBlue, 1.0f, 0);<br />
<br />
   device.BeginScene();<br />
   device.VertexFormat = CustomVertex.PositionColored.Format;<br />
   device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertices);<br />
   device.EndScene();<br />
<br />
   device.Present();<br />
<br />
   this.Invalidate();			<br />
}<br />


The problem is with the vertices[x].SetPosition(new Vector3(0f, 0f, 0f));
When I try to compile, I get the error message: Microsoft.DirectX.Direct3D.CustomVertex.PositionColored does not contain a definition for SetPosition.

I have also tried: vertices[x].Position.Add(new Vector3(0f, 0f, 0f));
This doesn't give me an error, but it also doesn't render anything on the screen.

Also, I can render the triangle if I use CustomVertex.TransformedColored so I know that is working, but I need to use CustomVertex.PositionColored

In most of the examples I have seen, this is how it is done. If you know DirectX, then you also know it is very hard to find any sort of good documentation on it too. I don't know if most examples I am following are 8.0 and earlier. Is there another way to do this? Am I doing it right but missing something?
GeneralSimple ListBox Event Pin
Snowjim12-Jan-05 12:27
Snowjim12-Jan-05 12:27 
GeneralRe: Simple ListBox Event Pin
Stefan Troschuetz12-Jan-05 21:41
Stefan Troschuetz12-Jan-05 21:41 
GeneralRe: Simple ListBox Event Pin
Snowjim12-Jan-05 23:21
Snowjim12-Jan-05 23:21 
GeneralRe: Simple ListBox Event Pin
Stefan Troschuetz12-Jan-05 23:30
Stefan Troschuetz12-Jan-05 23:30 
GeneralVS.NET Add-In Problem Pin
Guinness4Strength12-Jan-05 12:13
Guinness4Strength12-Jan-05 12:13 
GeneralARRAY LIST Pin
suthagar12-Jan-05 10:29
suthagar12-Jan-05 10:29 
GeneralRe: ARRAY LIST Pin
Christian Graus12-Jan-05 10:53
protectorChristian Graus12-Jan-05 10:53 
Generalnot post back Pin
Ahmed Galal12-Jan-05 7:40
Ahmed Galal12-Jan-05 7:40 
GeneralRe: not post back Pin
Christian Graus12-Jan-05 8:56
protectorChristian Graus12-Jan-05 8:56 
GeneralRe: not post back Pin
Ahmed Galal12-Jan-05 10:12
Ahmed Galal12-Jan-05 10:12 
GeneralRe: not post back Pin
Esmo200012-Jan-05 9:54
Esmo200012-Jan-05 9:54 
GeneralList Tables Pin
Dirso12-Jan-05 7:38
Dirso12-Jan-05 7:38 
GeneralNeed assistance with System.Diagnostics.process.startinfo.createnowindow ... Pin
new_phoenix12-Jan-05 7:08
new_phoenix12-Jan-05 7:08 
GeneralByte array to struct Pin
Arjan Schouten12-Jan-05 6:39
Arjan Schouten12-Jan-05 6:39 
GeneralRe: difference between .NET remoting and shared/private assembly? Pin
liyang yu12-Jan-05 5:58
liyang yu12-Jan-05 5:58 
Generalproblem with SQL Pin
ronin177012-Jan-05 5:40
ronin177012-Jan-05 5:40 
GeneralRe: problem with SQL Pin
Steve Maier12-Jan-05 5:45
professionalSteve Maier12-Jan-05 5:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.