Jump to content
  • Advertisement
Sign in to follow this  
Stefan Fischlschweiger

DX11 [SharpDX] Storing model data in custom class

This topic is 1336 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

As of now I've been using the Model class from SharpDX.Toolkit.Graphics together with precompiled tkb models and the Toolkit Content Manager to load my 3D models into the game. As I've run into problems with this format, notably lacking features that I need, I decided to create a custom Model class and use a seperate loader to parse and load .obj files.

 

Now, this .obj loader (Didn't code it myself, just modified it a bit) outputs the model data this way:

using System.Collections.Generic;
using ModelHandler.ObjLoader.Data;
using ModelHandler.ObjLoader.Data.Elements;
using ModelHandler.ObjLoader.Data.VertexData;

namespace ModelHandler.ObjLoader.Loaders
{
    public class LoadResult  
    {
        public IList<Vertex> Vertices { get; set; }
        public IList<Texture> Textures { get; set; }
        public IList<Normal> Normals { get; set; }
        public IList<Group> Groups { get; set; }
        public IList<Material> Materials { get; set; }
        public IList<ModelHardpoint> Hardpoints { get; set; } 
    }
}

(I added the hardpoint part)

 

Now to my problem:

 

I just can't figure out how I can stuff the Vertex and Index data into buffers in my model. I tried to look at the Toolkits source code, at DX11 tutorials, SharpDX tutorials, but none of those work for me, mostly because SharpDX's Buffer creation methods have changed since these tut were written and the DX11 classes and methods are not fully mapped 1 : 1 in SharpDX

 

So if someone could point out to me where I can find an up-to-date example in SharpDX or some DX11 code that I can translate to it that would be cool.

Share this post


Link to post
Share on other sites
Advertisement

Without Toolkit:

using Buffer = SharpDX.Direct3D11.Buffer;
Vertex[] vertices = ...
int[] indices = ...
var vertexBuffer = Buffer.Create<Vertex>(device, BindFlags.VertexBuffer, vertices);
var indexBuffer = Buffer.Create<int>(device, BindFlags.IndexBuffer, indices);

With Toolkit:

using Buffer = SharpDX.Toolkit.Graphics.Buffer;
Vertex[] vertices = ...
int[] indices = ...
var vertexBuffer = Buffer.Vertex.New<Vertex>(graphicsDevice, vertices);
var indexBuffer = Buffer.Index.New<int>(graphicsDevice, indices);
Edited by lwm

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!