[SOLVED] Missing vertex type of Vertex Position Normal Tangent Binormal ?

This are the only vertex type I can see available on MG 3.6 :

Where is VertexPositionNormalTangentBinormal ?

I’m automating the bounding box creation with vertex perfect base on model space, I have no problem if I will not use “CreateTangentFrames” from the Pipeline tools, most likely it will fall on the available vertex type listed from above and using VertexPosition on creating my Bounding box is correct as shown below:

When using “GenerateTangentFrames” on Pipeline tools, I have no option but to use VertexPositionNormalTexture and by using VertexPosition my bounding box is NOT correct as shown below :

Any tips clue to correct this , thanks ^_^y

A scene builder that looks pretty cool dexter.

I have no idea if this will be helpful but nkast showed me a little trick a ways back maybe you might be able to use it as a sort of hack.

If you declare namespace Microsoft.Xna.Framework as the namespace in a class file then add a made up struct then it should show up in your list.

like the below will pop up under the other vertex structures in my vs solution when i start typing vertex,.

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Microsoft.Xna.Framework
{

        // vertex structure data.  
        // i generate the binormal on the shader when i use custom vertexs
        // so maybe you could make it and match it up to that function.
        public struct VertexPositionNormalTextureTangent : IVertexType
        {
            public Vector3 Position;
            public Vector3 Normal;
            public Vector2 TextureCoordinate;
            public Vector3 Tangent;

            public static VertexDeclaration VertexDeclaration = new VertexDeclaration
            (
                  new VertexElement(VertexElementByteOffset.PositionStartOffset(), VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
                  new VertexElement(VertexElementByteOffset.OffsetVector3(), VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
                  new VertexElement(VertexElementByteOffset.OffsetVector2(), VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
                  new VertexElement(VertexElementByteOffset.OffsetVector3(), VertexElementFormat.Vector3, VertexElementUsage.Normal, 1)
            );
            VertexDeclaration IVertexType.VertexDeclaration { get { return VertexDeclaration; } }
        }
        /// <summary>
        /// This is a helper struct for tallying byte offsets
        /// </summary>
        public struct VertexElementByteOffset
        {
            public static int currentByteSize = 0;
            [STAThread]
            public static int PositionStartOffset() { currentByteSize = 0; var s = sizeof(float) * 3; currentByteSize += s; return currentByteSize - s; }
            public static int Offset(float n) { var s = sizeof(float); currentByteSize += s; return currentByteSize - s; }
            public static int Offset(Vector2 n) { var s = sizeof(float) * 2; currentByteSize += s; return currentByteSize - s; }
            public static int Offset(Color n) { var s = sizeof(int); currentByteSize += s; return currentByteSize - s; }
            public static int Offset(Vector3 n) { var s = sizeof(float) * 3; currentByteSize += s; return currentByteSize - s; }
            public static int Offset(Vector4 n) { var s = sizeof(float) * 4; currentByteSize += s; return currentByteSize - s; }

            public static int OffsetFloat() { var s = sizeof(float); currentByteSize += s; return currentByteSize - s; }
            public static int OffsetColor() { var s = sizeof(int); currentByteSize += s; return currentByteSize - s; }
            public static int OffsetVector2() { var s = sizeof(float) * 2; currentByteSize += s; return currentByteSize - s; }
            public static int OffsetVector3() { var s = sizeof(float) * 3; currentByteSize += s; return currentByteSize - s; }
            public static int OffsetVector4() { var s = sizeof(float) * 4; currentByteSize += s; return currentByteSize - s; }
        }
}

Dunno if that will actually help your situation i don’t know how get tangent frames works.
But you should be able to create a vertex structure of any kind you like with the above idea.

1 Like

Yo bro! thanks!

I didn’t know that creating your own VertexType will be compatible to MG internals, I’ll see what I can do, I do have my custom vertex PNNTB I will try to use and see how it goes…

Thanks man!

Aray bro! your hint, hit the G-SPOT ( Graphic Spot :smiley: )

Here’s the complete PNTTB Vertex type that is compatible with “CreateTangentFrames” even with your own namespace.
//

    /// <summary>
    /// ZGDK:Vertex structure: PNTTB : Position, Normal, TextureUV, Tangent, BiNormal.
    /// </summary>
    public struct VertexPNTTB
    {

        #region F I E L D S
        //!!
        //!

        /// <summary>
        /// Vertex position.
        /// </summary>
        public XF.Vector3 Position;     
        
        /// <summary>
        /// Vertex normal.
        /// </summary>
        public XF.Vector3 Normal; 
        
        /// <summary>
        /// Vertex to texture coordinates.
        /// </summary>
        public XF.Vector2 TextureUV;   
        
        /// <summary>
        /// Vertex tangent.
        /// </summary>
        public XF.Vector3 Tangent;  
        
        /// <summary>
        /// Vertex Binormal
        /// </summary>
        public XF.Vector3 BiNormal;

        //!
        //!!
        #endregion F I E L D S
     

        #region C O N S T R U C T O R
        //!!
        //!

        /// <summary>
        /// ZGDK:Vertex Type: Position, Normal, TextureUV, Tanget, BiNormal
        /// </summary>
        /// <param name="pos">Vertex position</param>
        /// <param name="normal">Vertex normal</param>
        /// <param name="textureUV">Texture UV</param>
        /// <param name="tangent">Vertex tangent</param>
        /// <param name="biNormal">Vetext BiNormal</param>
        public VertexPNTTB( XF.Vector3 pos, XF.Vector3 normal, XF.Vector2 textureUV, XF.Vector3 tangent, XF.Vector3 biNormal )
        {
            Position  = pos;
            Normal    = normal;
            TextureUV = textureUV;
            Tangent   = tangent;
            BiNormal  = biNormal;
        }

        //!
        //!!
        #endregion C O N S T R U C T O R


        #region S T A T I C  P R O P E R T I E S
        //!!
        //!

        /// <summary>
        /// Vertex declaration
        /// </summary>
        public static readonly XFG.VertexDeclaration VertexDeclaration = new XFG.VertexDeclaration
        (
            new XFG.VertexElement( 0, XFG.VertexElementFormat.Vector3, XFG.VertexElementUsage.Position, 0),
            new XFG.VertexElement(12, XFG.VertexElementFormat.Vector3, XFG.VertexElementUsage.Normal, 0),
            new XFG.VertexElement(24, XFG.VertexElementFormat.Vector2, XFG.VertexElementUsage.TextureCoordinate, 0),
            new XFG.VertexElement(32, XFG.VertexElementFormat.Vector3, XFG.VertexElementUsage.Tangent, 0),
            new XFG.VertexElement(44, XFG.VertexElementFormat.Vector3, XFG.VertexElementUsage.Binormal, 0)
        );

        /// <summary>
        /// Vertex elements
        /// </summary>
        public static XFG.VertexElement[] VertexElements = new XFG.VertexElement[5]
        {
            new XFG.VertexElement(  0, XFG.VertexElementFormat.Vector3, XFG.VertexElementUsage.Position,          0),
            new XFG.VertexElement( 12, XFG.VertexElementFormat.Vector3, XFG.VertexElementUsage.Normal,            0),
            new XFG.VertexElement( 24, XFG.VertexElementFormat.Vector2, XFG.VertexElementUsage.TextureCoordinate, 0),
            new XFG.VertexElement( 32, XFG.VertexElementFormat.Vector3, XFG.VertexElementUsage.Tangent,           0),
            new XFG.VertexElement( 44, XFG.VertexElementFormat.Vector3, XFG.VertexElementUsage.Binormal,          0)
        };

        /// <summary>
        /// Vertex type size
        /// </summary>
        public static readonly int Size = sizeof(float) * (3 + 3 + 2 + 3 + 3);

        //!
        //!!
        #endregion S T A T I C  P R O P E R T I E S


    }//EndStruct

Ah… now even every model group has a vetex perfect bounding box ^_^y

Thanks for the hint Will ^_^y

1 Like

Glad it worked.

Does that load the animations as well ?

I suck with the whole importing and manipulating models to be honest. It be interesting to see how you do all that. Will you end up making that open source ?

Does that load the animations as well ?

I’m in the process of learning how model animation works using the Pipeline tools for FBX model, but yes if using with my own model animation system.

I suck with the whole importing and manipulating models to be honest.

Likewise here man, but when error arises; rather than pointing my fingers to 3D Modeling(MS,Blender,Max,Maya,Etc) or the rendering Framework(XNA,MG,FNA,Etc) or the underlying loader/parser(Assimp) and digging their code what went wrong, I resort to creating my own loader/parser.

I’m using my own loader/parser and model animation system using MS3D mesh file format as shown below it’s fully animated but I’m not using content pipeline tool here.

Frankly man, this is the first time I’m using Pipeline tool to load Models, since I started using MG I wrote my own OBJ, MS3D, DMF loader/parser I only use this 3 mesh file format for my engine:

OBJ for static mesh.
MS3D for animated model
DMF for world model with lightmaps

But now I wanted to support FBX mesh file format and I think I will loose all of my hair creating my own loaders for FBX file format, that leads me to use Content Pipeline tools with it’s underlying mesh loader and parser Assimp.

About the Scene builder Editor :

I’m tired of manually placing entity hard coded it’s make the source code ugly and long doing all the loading and setting entities properties everything in code, the reason I’m making this tool, in a single line of code everything will be loaded along with the entities property and settings.

Will you end up making that open source

Scene builder editor will be release publicly if anyone think this is useful : - D the scene file is intended to be just a place holder just like Tiled for 2D scene, in this case it’s a 3D scene place holder and without any attachment to any particular engine including mine, scene file and entity nodes can me manipulated directly in plain MonoGame project, Scene manager loader and parser and entities and other relevant classes to load the scene and to manipulate entities will be Open source.

_SceneNodes = SceneMngr.Load( @“Content\Scene01” );

It’s up to the developer how to handle all the entities in their update and draw methods; but seriously this is just an early project : - D

Cheers Bru ^_^y