I have been trying to draw lines and i have managed to get it working but they don't draw using the colors they are ment to be using :(Unless i start the sunburn light editor and then all of a sudden they are fully colored...What is sunburn changeing to get my lines to draw right when we open the editor? Some render state or option but i can't figure it out please help..Here is the code i am using.
TotalLines = new VertexPositionColor[10];//Fill out some lineseffect.Begin();for (int i = 0; i < effect.CurrentTechnique.Passes.Count; i++){ EffectPass pass = effect.CurrentTechnique.Passes[i]; pass.Begin(); GraphicsDevice.DrawUserPrimitives<VertexPositionColor>PrimitiveType.LineList,TotalLines,0,LastLineAddIndex); pass.End();}effect.End();
Hi 2.0,
What type of effect are you using (BasicEffect, LightingEffect, custom)?
It's easiest to use BasicEffect, though there is a little bit of initial setup required after creating the effect (disable lighting, specular, and enable color vertex mode).
SunBurn has a built-in line rendering class (LineRenderHelper) that might help simplify your code. Although you still need to provide an effect, the helper class manages the vertex arrays, effect begin / end loop, and rendering code.
Follow me on Twitter – development and personal tweetsAwesome XNA Videos – Lighting, Rendering, and game videos
I wrote a small article on Sunburn's LineRenderHelper:
http://coreenginedev.blogspot.com/2009/12/how-to-render-grid.html
I hope this will get you started.
Contributor on the SunBurn sgMotion Animation Library open source project.
Yer we are using a basic effect but dont worry i fixed it.i was missing this :(
g_Camera3D.GET.Graphics.GraphicsDevice.VertexDeclaration = new VertexDeclaration(g_Camera3D.GET.Graphics.GraphicsDevice, VertexPositionColor.VertexElements);
its all good now.
Also however i was just wondering is there anyway to get my lines to have alpha? I assume there is but just setting "Graphics.GraphicsDevice.RenderState.AlphaBlendEnable" to true does not work... I see there is a Alpha for the whole basic effect but that seems to do nothing eather
You'll need to also set the blend mode, try this for alpha blending:
GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha;GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
The alpha amount can be controlled using either the vertex color alpha component or the BasicEffect.Alpha property (depending on if vertex colors are enabled in the BasicEffect).
Let me know if this helps!
Yep that worked.Thanks heaps.