Jump to content
  • Advertisement
Sign in to follow this  
john13to

Use VertexPositionColor and VertexPositionTexture at the same time?

This topic is 2600 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!