VS2012 using 3D models dilemma - c++

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.

Related

What is a good UV mapping library writing in C++?

I am currently scripting Blender right now but it's excruciatingly slow for large models.
I usually use OpenGL and freeImage when building something from scratch. However, if you want to use an existing framework to save time, I recommend OGRE. There's also a converter written for Ogre to convert models from blender called blender2Ogre. However, it's kindof in the beta stages. You will also find tutorials on the Ogre wiki.

C++ library/file format for exporting 3D skeletal animations?

I'm writing an application for creating 3D skeletal animations. I'm currently using Blender for modeling/rigging, export, then load and render the model with OGRE. But I'm stuck when it comes to exporting.
I'd like to be able to export the finished animated model/scene to some known file format, so that it can be imported back into Blender for rendering. So what's the best way to get the animated skeleton/armature back into Blender?
I think COLLADA is the way to go when it comes to file formats. I'm unsure about the library. FCOLLADA is dead, I'm not sure how up-to-date it is. The latest version of Assimp had COLLADA export functionality added to it, but unfortunately not for animation yet. There's OpenCOLLADA, which doesn't seem to be well documented, but there's two plug-ins which are probably better examples than any tutorial. Lastly there's COLLADA DOM.
Have you heard about FBX? It is widely used as an exchange format for geometry and animation. It support bones/joints which should fit for your skeletal animation.
Wikipedia: http://en.wikipedia.org/wiki/FBX
Autodesk Page: http://usa.autodesk.com/fbx/

c/c++ application importing 3d models from modelling softwares at runtime

I am an openGL beginner. I need to build a c/c++ application which displays 3d models in augmented reality. For AR i'm using ARToolkit. In the app it must import 3d models built with modelling softwares like blender,sketchup etc.. the models might be .obj,.3ds,.collada(suggest me any others if any??).
ARToolkit mainly uses opengl to render(AFAIK), the 3d objects to camera input.
Is it possible to load 3d models/objects at runtime dynamically. what libraries are existing if any for this?
I want to have keyboard interaction with the models also where i can move specific parts of the model(eg: rrotate wheels of a car)
The models here maybe as simple as a simple house to character(man/woman).suggest me the resources i need for this and any technicalities i missed. I prefer if possible my code to work with opengl 1.4
You will need some import mechanism to import meshes in various formats into your runtime format. OpenGL (or DirectX) doesn't specify how your meshes must look on disk, and there is various stuff stored on disk that is not required for rendering. Basically, you need a way to get the vertex positions and attributes from the file, and optionally an index list (if you render using indexed triangle lists, which you probably should be doing.)
The easiest for sure is .obj, which is an ASCII format that you can easily parse and which is supported by many applications. Otherwise, look at libraries like Open Asset Import.
However, I would assume you are looking for an OpenGL based rendering system, which does the rendering for you as well as the mouse interaction. There are lot of existing engines you can use out there, for instance, Ogre3D or IrrLicht. IrrLicht is easy to use and provides support for a bunch of the formats you mentioned. It you must stick with ARToolkit for rendering, then you can probably easily convert the formats from either engine to whatever ARToolkit expects.
I'm very recomending you to try http://assimp.sourceforge.net/lib_html/
It supports a lot of open/not-very-open data formats, skelet-animation, affine transfer animation, etc.

Importing 3D objects and its animation to iphone openGL

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.

Using Blender/SketchUp Models in OpenGL

I'm making a renderer using OpenGL. I have textured models in Blender / Sketchup (I can exchange between the two easily), and I'd like to be able to export those files into my renderer. My initial idea was to simply export the raw faces and render those triangles, but I'd like to easily slice my texture files into texture coordinates as well.
By that, I mean that my model faces get carved into triangles. You can see in this image (reproduced below) that my curve becomes 24 triangles. I would like to know what texture coordinates to use for each triangle.
Would a DAE file be the easiest way to do that? I've been reading the specs for the format and it looks easy enough. I think I could parse the XML and faithfully recreate the models in OpenGL. I'm wondering if there is an easier way (i.e. one that doesn't reinvent the wheel).
If you're comfortable with parsing the .dae-format, sure use it. However, if you're only interested in exporting textured triangle meshes I would consider using the .obj format which is much more simple to parse. From what I can tell both Sketchup and Blender can export this format.
If binary formats don't scare you, I'd suggest writing a Blender & Sketchup plug-in and exporting the geometry pre-baked into packed vertex arrays.
The beautiful thing about this method is that there's no parsing or type conversion in your app. Everything is ready to be sent to the GPU in simple contiguous memory copies. Great for static geometry.
A stripped down blender exporter looks something like this:
#!BPY
import bpy, struct
from Blender import *
self.fh = open("MyFileName", "w")
m = bpy.data.meshes["MyMeshName"]
faces = m.faces
for face in faces:
for (vertex, uv) in zip(face.verts, face.uv):
self.fh.write(struct.pack('<fff', *vertex.co)) # coords
self.fh.write(struct.pack('<fff', *vertex.no)) # normals
self.fh.write(struct.pack('<ff', uv.x, uv.y)) # uvs
self.fh.close()
If you wish to parse .dae files, i would suggest to look into Collada parsers.
.dae is actually the extension for Collada files, the latest effort from the Khronos group (maintainers of OpenGL) to have a single unified file format for 3D data exchange.
As for the existing parsers, here is what I've come across:
collada-dom, the reference implementation. As the name suggests, it is just an abstraction of the XML tree.
FCollada, a nicer abstraction. However, this project has been dead for almost two years, and, from what I've gathered, it is unlikely that we'll see any update in the future.
OpenCollada, a recent new effort. Haven't tried it, but there is an active community behind it.
That being said, if your only goal is loading a simple piece of geometry with vertices, normals and texture coordinates, going with the .obj file format might be a quicker way.
Any decent file format used by modeling programs (such as Blender or Sketchup) will include all information necessary to recreate the geometry you see. This should include the geometry type (e.g. triangle strips, individual triangles, etc), the vertices and normals for the geometry, the material properties used, and also the textures used along with the appropriate texture coordinates. If anything is lacking from a potential file format, choose another one.
If you think that parsing XML is simple, then I hope you're planning on using existing libraries to do this, such as expat, Xerces, or some other language specific implementation.
When considering import/export, first try to find an open source library that can handle the import for you and make the data available to your program in a reasonable format. If that's not available, and you must write your own importer, then try to find a simple ASCII (not XML-based) or binary format that fits your needs. PLY might be suitable. Only as a a last resort, would I recommend trying to implement an importer for an XML-based format.
There's also:
Lib3DS - http://www.lib3ds.org/
LibOBJ (won't let me post link)
You should take a look at:
http://sketchup.google.com/community/developers.html
The sketchup team provides a C++ COM server for free. Using this, you can get access to lots of information about a .skp file.
You should be able to use this COM server to write a .skp importer for your application.
You should try to get the .tlb file if you can. This will give you access to smart pointers, which will simplify your importer (COM client)
I used the version 6 SDK (which included the tlb file). The current version of the SDK does not appear to include this file.
Someone posted a solution (for the missing tlb file) on the developer forums:
http://groups.google.com/group/su-sdk-fileshare/topics