Use VertexPositionColor and VertexPositionTexture at the same time?

Started by
-1 comments, last by john13to 12 years, 11 months ago
I have a glass prism object and a gridplane that are built up by VertexPositionColors and they
were displayed in wireframes. Since I am now trying to apply a texture, represented by the attached
image 'gridsquare.png', on every gridcell, I changed from VertexPositionColor to VertexPositionTexture
on the gridplane. At the same tame I inserted the texture coordinates on every vertex without any larger
problems. But when I try to draw both of the object on the screen, it won´t show the objects correctly.


The first result, which can be seen in the attached image 'vpcolor.png', appears when I write the following
code in the draw function:

////////////////////////////////////CODE/////////////////////////////////////////////////////

[color="#0000ff"][color="#0000ff"]foreach

([color="#2b91af"][color="#2b91af"]EffectPass pass [color="#0000ff"][color="#0000ff"]in basicEffect.CurrentTechnique.Passes)

{

pass.Begin();

GraphicsDevice.RenderState.FillMode =

[color="#2b91af"][color="#2b91af"]FillMode.WireFrame;

basicEffect.VertexColorEnabled =

[color="#0000ff"][color="#0000ff"]true;

GraphicsDevice.VertexDeclaration = vDColor;

basicEffect.TextureEnabled =

[color="#0000ff"][color="#0000ff"]false;

DrawTriPrismData();

GraphicsDevice.RenderState.FillMode =

[color="#2b91af"][color="#2b91af"]FillMode.Solid;

basicEffect.TextureEnabled =

[color="#0000ff"][color="#0000ff"]true;

GraphicsDevice.VertexDeclaration = vDTexture;

basicEffect.VertexColorEnabled =

[color="#0000ff"][color="#0000ff"]false;

DrawGridData();

basicEffect.VertexColorEnabled =

[color="#0000ff"][color="#0000ff"]true;

GraphicsDevice.VertexDeclaration = vDColor;

basicEffect.TextureEnabled =

[color="#0000ff"][color="#0000ff"]false;



DrawTriPrismNormals();

graphics.GraphicsDevice.RenderState.CullMode =

[color="#2b91af"][color="#2b91af"]CullMode.None;

pass.End();

}

basicEffect.End();

//////////////////////////////////END CODE////////////////////////////////////////////////////////
But when I remove these two lines where they are written as:

basicEffect.VertexColorEnabled =

[color="#0000ff"][color="#0000ff"]true;

and

basicEffect.TextureEnabled =

[color="#0000ff"][color="#0000ff"]false;

[color="#008000"]
that comes after DrawGridData() I get the following result, that is shown on the image 'vpcolorandtexture.png',
you finally see the textured grid but where the glass prisms and the normal edge colors have the same color as
the texture color. Neither is the gridtexture drawn correctly but rather it has been drawn along a diagonal direction
and show rectangle patterns instead. How do you display VertexPositionColor objects and VertexPositionTexture object
at the same time and how do you make sure that the texture is drawn correctly?

This topic is closed to new replies.

Advertisement