Line drawing coming up black instead of colored. Unless sunburn editor is attached

rated by 0 users
This post has 6 Replies | 3 Followers

Top 25 Contributor
Posts 233
SunBurn_Community_Licensee
SunBurn_Pro_Licensee
2.0 Studios Posted: 01-17-2010 2:35 AM

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 lines

effect.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();

Top 10 Contributor
Posts 5,378
Employee
SunBurn_Studio_Licensee

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 tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 10 Contributor
Posts 708
SunBurn_Community_Licensee
SunBurn_Contributor

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.

Top 25 Contributor
Posts 233
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

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.

 

Top 25 Contributor
Posts 233
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

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

Top 10 Contributor
Posts 5,378
Employee
SunBurn_Studio_Licensee

Hi 2.0,

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!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 25 Contributor
Posts 233
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

Yep that worked.
Thanks heaps.

Page 1 of 1 (7 items) | RSS