• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Vexal

Getting model from 3DS Max to my game engine

14 posts in this topic

For a 3D game engine I wrote,

I currently get models loaded into the engine by parsing files exported from 3DS Max using the ASCII export function.  However, I cannot get this to work usefully for anything other than the geometry.

Specifically, animations and particle systems.

I have tried to export from 3DS Max in most of the formats in the list of export options, but I can't see any useful information in the resulting exported files about the animations and particle systems.

For my engine, I need the actual key frame information for animations.  The engine is designed to just take the keyframe information and then do the interpolation and calculations in real-time.  But I can't seem to figure out how to get 3DS Max to export the animations like that.  Instead, they appear to be exported by just listing the transform at each various sampled frames, instead of listing the keyframes.

This is what I see when I try to export a model in the ASCII format with an animation that just translates a cube.


*TM_ANIMATION {
*NODE_NAME "Box001"
*CONTROL_POS_TRACK {
*CONTROL_POS_SAMPLE 0 48.7667 2.7128 0.0000
*CONTROL_POS_SAMPLE 800 37.3693 6.5535 0.0000
*CONTROL_POS_SAMPLE 1600 10.9041 15.4717 0.0000
*CONTROL_POS_SAMPLE 2400 -19.0383 25.5616 0.0000
*CONTROL_POS_SAMPLE 3200 -40.8672 32.9175 0.0000
*CONTROL_POS_SAMPLE 4000 -45.2485 34.3939 0.0000
}
}
 

Also, when I try to export a particle system, I see nothing useful in the resulting file.  My engine is designed to take a bunch of parameters for the system, and then instantiate a particle system with those parameters.  I would like to be able to take the exact parameters of the system in 3DS Max and load them into my engine.

This is all I see when exporting a scene with a particle system:
 

*NODE_NAME "Spray001"
*NODE_TM {
*NODE_NAME "Spray001"
*INHERIT_POS 0 0 0
*INHERIT_ROT 0 0 0
*INHERIT_SCL 0 0 0
*TM_ROW0 1.0000 0.0000 0.0000
*TM_ROW1 0.0000 1.0000 0.0000
*TM_ROW2 0.0000 0.0000 1.0000
*TM_ROW3 17.6095 19.0154 0.0000
*TM_POS 17.6095 19.0154 0.0000
*TM_ROTAXIS 0.0000 0.0000 0.0000
*TM_ROTANGLE 0.0000
*TM_SCALE 1.0000 1.0000 1.0000
*TM_SCALEAXIS 0.0000 0.0000 0.0000
*TM_SCALEAXISANG 0.0000
}
*PROP_MOTIONBLUR 0
*PROP_CASTSHADOW 1
*PROP_RECVSHADOW 1
*WIREFRAME_COLOR 0.5490 0.3451 0.8824
*MESH_ANIMATION {
}


I tried looking for guides on how to do this but have found nothing useful yet.
0

Share this post


Link to post
Share on other sites
Export to something like Collada, parse the Collada file (it's xml and well defined) and save the resulting data to your own binary format and load into your engine - you could also consider FBX/Assimp but I haven't used either of those.

There are several threads on gamedev about exporting/importing from DCC tools and converting to one of these formats - it looks daunting but it really isn't when you get into it.

This will tell you most of what you need to know about parsing Collada files and is brilliantly written I think:
<a href='http://thecansin.com/Files/COLLADA.pdf'>http://thecansin.com/Files/COLLADA.pdf</a>
0

Share this post


Link to post
Share on other sites

I tried exporting a particle system as Collada, but all it gave me was this: (for reference, the particle system in the scene was just a default Spray system with a few parameters changed).  Am I doing something wrong?



<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
  <asset>
    <contributor>
      <author></author>
      <authoring_tool>FBX COLLADA exporter</authoring_tool>
      <comments></comments>
    </contributor>
    <created>2013-01-16T20:13:55Z</created>
    <keywords></keywords>
    <modified>2013-01-16T20:13:55Z</modified>
    <revision></revision>
    <subject></subject>
    <title></title>
    <unit meter="0.025400" name="centimeter"></unit>
    <up_axis>Y_UP</up_axis>
  </asset>
  <library_visual_scenes>
    <visual_scene id="" name="">
      <node name="Spray001" id="Spray001" sid="Spray001">
        <matrix sid="matrix">1.000000 0.000000 0.000000 17.609482 0.000000 0.000000 1.000000 0.000000 0.000000 -1.000000 0.000000 -19.015411 0.000000 0.000000 0.000000 1.000000</matrix>
        <extra>
          <technique profile="FCOLLADA">
            <visibility>1.000000</visibility>
          </technique>
        </extra>
      </node>
      <extra>
        <technique profile="MAX3D">
          <frame_rate>30.000000</frame_rate>
        </technique>
        <technique profile="FCOLLADA">
          <start_time>0.000000</start_time>
          <end_time>3.333333</end_time>
        </technique>
      </extra>
    </visual_scene>
  </library_visual_scenes>
  <scene>
    <instance_visual_scene url="#"></instance_visual_scene>
  </scene>
</COLLADA>
 
0

Share this post


Link to post
Share on other sites

Your best bet is with Autodesk® FBX® (.FBX extension).  They export emitters and animations (just the key-frames) and the SDK makes it easy to load and work with all of this information.

Don’t try to parse model files manually unless there is no other way.

 

 

L. Spiro

0

Share this post


Link to post
Share on other sites

I'm doing everything from scratch for this, so FBX is not an option (wikipedia says the format is not revealed and you have to use Autodesk's importer code).

 

I'll try the Collada exporter that you linked, thanks.

1

Share this post


Link to post
Share on other sites

My engine is from-scratch too.  I don’t see how that is related to the Autodesk® FBX® SDK.

You are aware that it is wrong to import directly into your engine from .DAE, .MAX, .3DS, .FBX, etc., right?

You are supposed to make converters from these to your own custom format and then load that by your engine.

 

 

L. Spiro

Edited by L. Spiro
1

Share this post


Link to post
Share on other sites

Yes I am aware that I should not directly import the intermediate formats to my engine, but it is a necessary step at the moment so I can learn how it works.  I need to be able to parse these intermediate formats if I wish to convert the format to what my engine eventually uses.

 

I currently parse the ASCII model files directly to my engine.  It is slow, but it is a necessary step for the engine at the moment because I know very little about how files like this are stored in the real world, and how graphics theory translates to practical use. I don't know what the best way to make my own format for use directly with the engine will be.  

 

It is a better option for me to first load the models directly from human-readable formats so I can understand everything about them.  Once I know exactly what's practical to have in a final format and what needs to be stored, or what's better to calculate in real-time instead, I will settle on a format.

 

.FBX is useless to me for this because I can't open the file and look at it.

 

Also, Collada is not working very well either.  I can't figure out how to export a cube the way it should be exported.

 

With the ASCII format, 3DS Max would not generate duplicate vertices for non-smoothed faces.  So my engine generates additional vertices for faces that are meant to be not smooth based on the smoothing groups.

 

Collada does not seem to support smoothing groups.  Instead it just duplicates every vertex no matter what -- even if I set the entire object to all be in the same smoothing group.  If I turn off the duplication, then the triangle list in the exported file still tries to use indices of vertices that weren't output by the exporter.

 

For example:  this is the output of the collada exporter for a model with a cube with all faces set to the same smoothing group:

 

 

<triangles count="12"><input semantic="VERTEX" offset="0" source="#Box001-VERTEX"/><input semantic="NORMAL" offset="1" source="#Box001-Normal0"/><input semantic="TEXCOORD" offset="2" set="0" source="#Box001-UV0"/><p> 1 0 1 0 1 0 3 2 3 0 3 0 2 4 2 3 5 3 7 6 7 6 7 6 4 8 4 7 9 7 4 10 4 5 11 5 5 12 11 4 13 10 0 14 8 5 15 11 0 16 8 1 17 9 7 18 15 5 19 14 1 20 12 7 21 15 1 22 12 3 23 13 6 24 19 7 25 18 3 26 16 6 27 19 3 28 16 2 29 17 4 30 23 6 31 22 2 32 20 4 33 23 2 34 20 0 35 21</p></triangles>
 
The exporter still thinks there are 6 vertices per side of the cube (36 total) even though the output of the vertex list is just 8 vertices total.  This is completely broken.
 
How do I get around this?
 
EDIT:  I think I interpreted those lines wrong -- I think the offset tag means the that for each triangle three of those integers are part of a single vertex description, so every 3rd integer in that list is a vertex index, and the indices in that list that go higher than the number of vertices must refer to the normals.
 
But I still don't understand why there are more normals than vertices.  If they are all smoothed together, why isn't it just exporting a single normal per vertex?  Is it possible to correctly reconstruct the model if I use Collada? How can I know whether or not each triangle needs to have its own three distinct vertices whose normals aren't averaged with those of the surrounding faces?
Edited by Vexal
1

Share this post


Link to post
Share on other sites
I think it depends on the texture coordinates. If you create an organic shape in 3ds max and uv wrap it correctly, vertices should be shared.

For the cube example, it may be that 3ds max creates it with texture coordinates different on each face, meaning that you'll need duplicated vertices (unless you're using an atlas) and that's what it'll export.

The offset thing, yes that just means that for each consecutive group of 3 indices in the p element, the first is the vertex lookup, the second is the normal lookup and the third is the texture coordinate lookup.

That link I sent explains all this very well.
1

Share this post


Link to post
Share on other sites

So is there no way to just have 3DS Max export a list of the exact vertices the triangles should use?  Meaning, if I export a cube with each face in a different smoothing group, it will export three vertices per triangle (totaling 2 triangles per face * 6 faces * 3 vertices = 36 vertices), while at the same time any edges in the same smoothing group will not have their vertices duplicated?  I've tried every option I could, and it seems that I can either just export a list of non-duplicated vertices and completely rely on smoothing groups for knowing whether my engine should duplicate them, or I can export a list with every single vertex duplicated for each triangle, and then the engine doesn't have to duplicate anything to render the model correctly, but it wastes a lot of memory.

 

Also, apparently you can export FBX in ASCII.  However, the C++ SDK for FBX doesn't work with VS2012 (my main IDE).  There's a link for a beta version, but they have to manually add you to it when you email them (they haven't gotten back to me yet).  VS2012 lets you edit FBX, Collada, and OBJ models inside the IDE.  It's pretty cool.

Edited by Vexal
1

Share this post


Link to post
Share on other sites
I need to be able to parse these intermediate formats if I wish to convert the format to what my engine eventually uses.

 

Or, you can use Assimp to load the files for you. You will then get a general purpose data representation of the animation. The data will be organized into something like this:

 

Assimp.png

It takes some effort to understand why a structure like this is needed. Possibly, depending on your requirements, you can simplify your layout. Some of the data can be intermediate.

 

Eventually, as was stated earlier in the discussion thread, you will want to use your own data format to load.

0

Share this post


Link to post
Share on other sites

I already explained exactly the reason I am doing things the way I am, and that I am aware of the downsides of directly using an intermediate format, but why it still makes sense for me to use it anyway.

 

I do not want to use a third-party tool.  It's a waste to me because I have no development goal other than I'm bored.  If I eventually do pick a direction I want to take this project, any third-party tool I've decided to use will probably be obsolete.

 

A prime example of this is the fact that I can't even use the FBX SDK with my engine because I'm using Visual Studio 2012.

0

Share this post


Link to post
Share on other sites

I contacted them and they gave me the link to download the beta for the FBX SDK that supports VS 2012, so I have decided to use that because I discovered that parsing the file myself makes me hate life.

 

Thanks for the suggestions.

0

Share this post


Link to post
Share on other sites

[quote name='Vexal' timestamp='1358591840' post='5023145']
A prime example of this is the fact that I can't even use the FBX SDK with my engine because I'm using Visual Studio 2012.
[/quote]

 

Have you looked at 2013 beta version. It does support VS2012.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0