Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

XNA doesn't sometimes draw 3D models properly

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 ReyLith   Members   

105
Like
0Likes
Like

Posted 22 March 2013 - 11:52 AM

Hi,
 
I am developing an 3D platformer game with XNA framework and I am experimenting some errors in drawing. Here is some images of the errors, that appears in 3D models and in planes:
R4ro3.png    VOfHO.png
 
In the first image, all the plane should be with the gray texture. In the second image shouldn't appear the errors. The code that I am using to load the vertices and textures is the next:
 

    // CODE INCLUDED IN LOAD() METHOD
    Vector3 left = Vector3.Cross(_normal, _up);
    Vector3 lowerLeft, upperLeft, lowerRight, upperRight;
    for (int i = 0; i < _rows; i++)
    {
       for (int j = 0; j < _cols; j++)
       {
           if (information[i + 5, j] != "Null")
           {
               string[] aux = information[i + 5, j].Split('_');

               lowerLeft = _origin + (_up * i);
               lowerLeft += -left * j;
               lowerLeft += -left * ToInt(aux[1][0]);
               upperLeft = lowerLeft + (_up * ToInt(aux[1][1]));
               lowerRight = lowerLeft + (left * ToInt(aux[1][0]));
               upperRight = lowerRight + (_up * ToInt(aux[1][1]));

               _vertices.Add(new VertexPositionNormalTexture(
                   lowerRight, _normal, new Vector2((1.0f / _numberOfTiles) * (Convert.ToInt32(aux[0]) - 1), 1)));
               _vertices.Add(new VertexPositionNormalTexture(
                   upperRight, _normal, new Vector2((1.0f / _numberOfTiles) * (Convert.ToInt32(aux[0]) - 1), 0)));
               _vertices.Add(new VertexPositionNormalTexture(
                   lowerLeft, _normal, new Vector2((1.0f / _numberOfTiles) * Convert.ToInt32(aux[0]), 1)));

               _vertices.Add(new VertexPositionNormalTexture(
                   upperRight, _normal, new Vector2((1.0f / _numberOfTiles) * (Convert.ToInt32(aux[0]) - 1), 0)));
               _vertices.Add(new VertexPositionNormalTexture(
                   upperLeft, _normal, new Vector2((1.0f / _numberOfTiles) * Convert.ToInt32(aux[0]), 0)));
               _vertices.Add(new VertexPositionNormalTexture(
                   lowerLeft, _normal, new Vector2((1.0f / _numberOfTiles) * Convert.ToInt32(aux[0]), 1)));
           }
       }
    }

    _tileVertexBuffer = new DynamicVertexBuffer(EngineManager.GameGraphicsDevice,
        VertexPositionNormalTexture.VertexDeclaration,
        _rows * _cols * 6, BufferUsage.WriteOnly);

 

The code used to draw the vertices is the next:
 

    // CODE INCLUDED IN DRAW() METHOD
    _tileVertexBuffer.SetData<VertexPositionNormalTexture>(_vertices.ToArray());

    _effect.View = CameraManager.ActiveCamera.View;
    _effect.Projection = CameraManager.ActiveCamera.Projection;
    _effect.Texture = TextureManager.GetTexture(_textureName).BaseTexture;
    _effect.DiffuseColor = Color.LightBlue.ToVector3();
                
    foreach (EffectPass pass in _effect.CurrentTechnique.Passes)
    {
        pass.Apply();

        EngineManager.GameGraphicsDevice.SetVertexBuffer(_tileVertexBuffer);
        EngineManager.GameGraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, _tileVertexBuffer.VertexCount / 3);
    }

    EngineManager.GameGraphicsDevice.SetVertexBuffer(null);

 

I am not using an index buffer to draw the plane and I don't know if this is the problem. I have spent a long time surfing on Internet but I can't find a similar problem. Thanks in advance.
 
PD: Sorry for my english level.


#2 ReyLith   Members   

105
Like
0Likes
Like

Posted 23 March 2013 - 04:05 AM

I have moved the post to the DirectX and XNA section. Sorry.

http://www.gamedev.net/topic/640722-xna-doesnt-sometimes-draw-properly-moved/






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.