Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

DrawPrimitives usage

Started by ruddermode Oct 30, 2004 at 6:40 AM 1 replies 1k views
Original Post
ruddermode
ruddermode
Does DrawPrimitives work in screen space or world space? I'm trying to draw a simple line from one place on the screen to another (though eventually it will be from one place in world space to another so the camera location is miles away from the origin)

verts(0).SetPosition(New Vector3(10, 0, 0.0F))
verts(0).Color = System.Drawing.Color.Black.ToArgb()
verts(1).SetPosition(New Vector3(100, 100, 0.0F))
verts(1).Color = System.Drawing.Color.Black.ToArgb()
vb.SetData(verts, 0, LockFlags.None)

device.DrawPrimitives(PrimitiveType.LineList, 0, 2)
It doesn't seem to consistently show the lines, however... (and lets not talk about getting them to show a colour either!)
BigBadBob
BigBadBob
you specify local coordinates to draw which are then transformed into world space by world transform, then into view space by the view transform. Then into 3d screen space by the projection transform. Then finally into 2d screen space on the monitor.

So if your camera is miles from the world space origin, yet your lines are at the world space origin. You may not see the lines.
ruddermode
ruddermode
Thanks for the reply.

How much of this transforming is automatically done?

By local coordinates do you mean screen coordinates? E.g. if a window is 1000 by a 1000 then the centre is approx 500,500 (the end of a line, say), but because the window is somewhere away from the origin in worldspace then the line may or may not appear.

Hmmm, sorry, that's not very clear, is it!

Should I be transforming the end-of-the-line point values to be in worldspace?

(The lines are appearing in the centre of the window, which doesn't seem to make sense of them being in either world or screen space IYSWIM. They are appearing approximately where I want them, but that just gets me more confused...)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.