I'm building an WP8 app with Direct3D 11, and need to load 3dModel.
I know how to load it in XNA, but XNA is not valid for WP8 :|
I need an example of how to load a 3d model in Direct3D 11.
Wavefront OBJ is a very simple and widely supported format for static 3D models. Writing a cusom importer is not difficult.
I have written a Wavefront Importer for C#. It covers the most basic features of OBJ files (sub meshes; vertex positions, normals and texture coordinates). I do not guarantee that any of this works, it should just serve as an example on how to implement a custom mesh importer. I am using SlimDX's Vector types. You can replace them with vectors from your framework of choice.
Visual Studio 2012 is able to load FBX and OBJ files itself and compiles them to CMO format.
For reading CMO format and every other things you can use the sample below.
http://code.msdn.microsoft.com/windowsapps/Visual-Studio-3D-Starter-455a15f1
Related
I have searched SO and have not found one relating to the very basics, explaining step by step. We are in need of this.
Assuming that I am using only the DirectX SDK supplied by microsoft.
Also assuming that I have .fbx and .3ds models already made and in the working directory which are generic, monochrome, shapes (cube, sphere, pyramid, etc.).
Please also condense the rendering process into a function that uses the directX functions (As in, can be compiled), as an example:
//the following is a suggestion, not a guideline for those who
//want to get into 3D programming.
vector<DX3DModel>modelsToBeRendered;
void bufferFrame(vector<DX3DModel>models){
while(1){
/* something something vertexes, lets say DX3DModel only contains vertexes
and a string as a file link
(Rendering code would make it very
messy in the question, but please include it in the answer.) */
//render models.end(); here
models.pop_back();
}
}
Using a method similar to what I have above, how would I (safely) render all other actors in a single "area" while still being able to manipulate vertexes at will?
(Area is a (AxBx1) model which we will call field.fbx. This is a boundary for all actors to exist on)
The Direct3D 11 API, much like the OpenGL API, is a low-level rendering API that works in terms of resources and drawing operations on constructs containing points, lines, and triangles. It's not a high-level API that can directly load or render an model file from a 3D editor, nor does it inherently have a material/effects system.
If you are new to DirectX 11, you should consider using the DirectX Tool Kit as a good starting-point. You can't directly render from a 3DS or FBX model, but you can use either the built-in Visual Studio content pipeline for converting to a CMO or use the Samples Content Exporter to convert to SDKMESH, both of which can be loaded by DirectX Tool Kit.
Using the DirectX Tool Kit, you'd be able to use the Model class and get something basically like what you propose. See the DirectX Tool Kit tutorial, particularly the lesson Rendering a model.
For Direct3D 11 development, you should strongly consider not using the legacy DirectX SDK as it's deprecated. If you are using VS 2012 or later, you don't need it. See Where is the DirectX SDK (2015 Edition)? and The Zombie DirectX SDK.
I want to make a 3D model in Blender and load it in OpenGL. Can someone give a step-by-step approach on how to do so. I tried to google but did not get any proper results.
Programming language: C++,
Tools: GLFW + GLAD + GLM
Its a 3 step process, using external libraries.
Model in blender. Export from Blender to .obj format (also containing .mtl file with reference to textures used).
Refer to
https://blender.stackexchange.com/questions/121/how-do-i-export-a-model-to-obj-format
Use a library like Assimp to produce vertices and attributes.
Use the vertices and attributes in your OpenGL application, using a method like described in,
https://nickthecoder.wordpress.com/2013/01/20/mesh-loading-with-assimp/
I'm having problems understanding the the usage of VS2012's 3D features in a project. I'm current building a 3D project using DirectX (Direct3D) and want display a simple 3D object (teapot) for starters. I understand the usage of the shadergraph which is of great help, but when it comes to loading an FBX model, is there an alternative to using the Autodesk FBX SDK built in or am I just stuck with it (FBXSDK)?
Generally, is there anything in VS2012 for C++ similar in nature to how XNA uses it's content pipeline to simplify loading and working with models?
You will definitely need to manage the translation from the format of your model files to the typical D3D mesh/meshpart arrangement. You can get sometimes find models in the old .x format, which corresponds to a Direct3D model. This page has some good reference for loading .x files and also links to exporters for maya and max.
OTOH If your source data is in fbx, use the fbx sdk; it's just simpler than any alternative way to get fbx data. You'll need some library for importing 3d models and although they're all limited in different ways FBX has the advantage of being supported by the widest variety of DCC apps. There are text and binary versions of the FBX format, so if you're interested in manual debugging you can use the text based version to make it easier to crosscheck your results. This sample discusses using the FBX SDK with DirectX 11 - although it is in the context of vs 2010, there may be issues moving to VS 2012.
If you go with another intermediate format you should look for one supported by the 3d tool you'll be using or the model vendor you are buying from. Collada is the most widely available interchange format, and it's based on XML so you could probably implement your own loader -- however it's also notorious for complexity and inconsistent standards so I'd avoid it unless you have a compelling reason or a big trove f Collada format files.
If your needs are very simple and don't include animation, the OBJ format is widely available and easy to implement on your own -- however it does not support animation.
is there anything in VS2012 for C++ similar in nature to how XNA uses
it's content pipeline
As far as I know, there is no such thing. You will need your own solution, as always in native C++ world =). Probably, you can make use some of the modern rendering engines: Unity, OGRE, Irrlicht, Torque, etc.
when it comes to loading an FBX model, is there an alternative to
using the Autodesk FBX SDK built in or am I just stuck with it
(FBXSDK)
As far as I know, FBX is a closed proprietary format, so you stick with FBX SDK.
Another ways (from gamedev view)
FBX format is a terribly complicated and multifunctional. Typically, you don't need FBX to draw teapot. You don't even need FBX to create a good game.
to just draw teapot you, probably, better take another simple (or not so simple) format, such as .obj, .dae or .3ds. You can load it using 3rd party library, such as assimp (which is just few lines of code) or roll out your own loader (which is not so hard either).
to draw some meaningful interactive "teapots world" you will also need to wrap them into some kind of scene: scenegraph is a common solution.
mid-size game labels typically crate their own format, converter and loader for it:
artists create models in their favorite 3D editor
then they convert it using converter: convert to custom binary .mesh format. This can be done via plugin for 3D editor or in small standalone app
in C++ app, programmers just load .mesh, deserialize to structs and classes and use it.
serious game labels develop their own content pipelines: it can include multiple custom formats (static mesh, animated mesh, etc.), loaders (to load and stream content into app), 3ds max/Maya/Blender plugins, visual scene/level editors (to make artists happy). All content is created and managed by artists, so programmers don't need any integration of content to their IDEs.
Visual studio 2012 actually has it's own model processor now.
You can add different meshes to your project(I think that it natively supports .dae, .fbx, and .obj) and it'll spit out a ".cmo" model that's simple to parse.
The directX Toolkit also has pretty good support for loading the format, so if you're already using the DXTK, then I recommend seeing if the model loader meets your requirements.
Currently I have a 3D Cube that I drew by writing coordinates, that can rotate and move on a black screen.
Now I have a Model that I created in "3Ds Max"(It's a little backyard with high stonewalls, so I'm trying to use it as my world object.) and I want to load this model into my DirectX9/C++ project.
As far as I see in DirectX SDK examples this code is for loading .X model (which needs a plugin for "3Ds Max" to export that kind of extension. I'm not sure of this.)
Code for loading .X files into DX9/C++:
D3DXLoadMeshFromX( "Tiger.x", D3DXMESH_SYSTEMMEM,
g_pd3dDevice, NULL, &pD3DXMtrlBuffer, NULL,
&g_dwNumMaterials, &g_pMesh )
Is there a function like "D3DXLoadMeshFromOBJ(.....)" to load an Object? How do I load and render .OBJ files? 8(
Another question of mine is what is the difference between an .X file and an .OBJ file and which of them should I use?
AFAIK, DirectX does not support wavefront object files out of the box. You will need an external mesh loader for that purpose.
I can remember, that in the DX 10 SDK is a sample of how to load an .obj file, I think the sample is called MeshFromOBJ10. I don't know if it is of any use in DirectX 9.
As far as I know, the standard .x just supports basic meshes with no enhancements such as animation. If you want to try out graphical programming it is not bad, but if you are aiming for higher concepts you can later switch. I guess you can look up the advantages of the .obj files here.
It is always a good idea to create an abstraction for the input data you are using. For example, you could create a class AbstractMesh and an implementation XMesh deriving from it. Later on, you can than add other implementations like OBJMesh or anything similar.
I hope I could help you a bit :) Happy Coding!
Animation is full supported in x file format, and furthermore, it support fx files when you want to use shaders. A exporter plugin and samples you can download from this page:
http://www.cgdev.net/download.php
I am trying to develop a 3D game in openGL and i need to create many 3D objects.. I am a begginner in openGL.. I have tried with many 3D softwares like Blender , MODO, Unity 3D and Cheetah.
I am easily able to create my objects with these and exporting as Wavefront .OBJ, and converting it to a header file using a perl script. This header file is added to my openGL project..
The 3D objects are seen, but its not perfect. The script i used is to convert the .OBJ to .h using TRIANGLES.. And the object is seen with triangles. Its not full.. No way when i used TRIANGLE STRIP,FAN..? Problems with the vertices..
Is the problem with my Script or is it the wrong way i have gone..?? Or is there any other best ways to directly import 3D objects to openGL..??
The below link is the best one which you can get for 3D objects to openGL.. i got the scripts from these..
http://www.heikobehrens.net/2009/08/27/obj2opengl/
please help..
You don't want to go that way. Direct drawing mode (using TRIANGLE and friends) is extremely slow in OpenGL.
Instead, you should pick a decent format and write a loader for it (or use one found on the web). Good formats would be 3ds, obj if gzipped, collada.
Here's an example tutorial on loading from Milkshape files.
Once you load your objects programatically, you can use Vertex Arrays, or even better VBO's to display them. This is waaay faster.
Google for a mesh loader for your favorite format, or write one yourself.
I have written a reader/renderer for AC3D files that works fine on the iPhone (OpenGL ES)
Feel free to have a look at it here.
There is also an obj loader by Jeff Lamarche at google code.
AC3D can reduce the triangle count pretty good and as an alternative I ported QVis to the mac. My reader/renderer also tries to build tri-strips.
About VBO's. I have not seen any gained performance when using them in the iPhone. I'm not the only one.