Advertisement

Is it possible to export Unity scenes and load via ASSIMP?

Started by January 20, 2015 07:39 AM
7 comments, last by SparkyNZ 10 years ago

Hi. I am relatively new to Unity, OpenGL, ASSIMP and Blender. I have written basic OpenGL programs, and experimented quite a bit with Unity lately. I'm tempted to use my own game engine or an open source one instead of Unity - just to give me complete control over things and I cannot afford nor justify $1500 for a copy of Unity Pro for my non-profit hobby projects.

So.. I was wondering if there was a way in which I could mock scenes up within Unity and then export them somehow to a flexible format that I could manipulate myself.

I'm not talking about exporting scripts and other properties - just a bare-bones placement of any meshes/models/materials that I import etc.

Any ideas what I could use?

I guess my other option could be to use Blender and its own game engine etc - all I really want is the ability to mock-up/prototype environments and then pull them into my own code.

There is a script for exporting a Gameobject and all its children to OBJ in Unity which should work enough for your purpose. You would need to setup the scene in a certain way to get this to work (Have one object that all the geometry is a child of). Im not too familiar with unity so not sure how practical this is.

http://wiki.unity3d.com/index.php?title=ExportOBJ

However, is there a reason why you want to use Unity and not just Blender? If you use blender you can easily adjust the geometry however you see fit without having to reimport to unity, and then export again.

Likewise, why don't you just mock-up/prototype environments in your own code, this way you don't have to recreate logic in a completely separate framework (as it would be difficult to test environments with different movement logic etc.). Especially since you will be spending more time importing/exporting from unity.

Advertisement

There is a script for exporting a Gameobject and all its children to OBJ in Unity which should work enough for your purpose. You would need to setup the scene in a certain way to get this to work (Have one object that all the geometry is a child of). Im not too familiar with unity so not sure how practical this is.

http://wiki.unity3d.com/index.php?title=ExportOBJ

However, is there a reason why you want to use Unity and not just Blender? If you use blender you can easily adjust the geometry however you see fit without having to reimport to unity, and then export again.

Likewise, why don't you just mock-up/prototype environments in your own code, this way you don't have to recreate logic in a completely separate framework (as it would be difficult to test environments with different movement logic etc.). Especially since you will be spending more time importing/exporting from unity.

Thanks I'll have to have a look at this! I'm not really that familiar with Blender at the moment. I've been spending heaps of time playing around with Unity and its nice to be able quickly set up scripts etc and use the built-in editor for placing objects, making terrain etc. I'd be doing it by hand if I did it in my own code. Once I get used to Blender, it may be the way to go. Its all a learning curve and a journey.. :) I'll see if I can export and load an OBJ.

I guess the solution by theflamingskunk should work fine for you, as long as you leave the behaviourscripts out of the equation. For just placing geometry, and maybe convert a heightmap into a mesh, or run arbitrary scripts in the editor for procedural placement of 3D objects / creation of meshes.

On the other hand I second what theflamingskunk asked: why go through the hassle of setting up the project in one engine and importing everything, when you finally want to export everything again to import it to a different engine? Why not just setup your scene in any 3D Package (like Blender) that you will have to use besides the Unity editor anyway?

If its just about scripting capabilities for running in-editor scripts, you can do that in Blender too.

If you hope to can do more than just setup the 3D Objects in the scene in the Unity Editor, I would quickly forget about that. If you do not manage to read the format Unity creates for its projects editor representation for your own engine, and then "build the game" out of that yourself, all you will be able to export is an obj file containing the 3D scene. The scripts you write and test in Unity could still work for you, if your own engine also uses Mono, and you are able to replicate the Unity API somehow (not sure how hard that is).

But this all sound like a lot of work you could invest into either creating your own editor, or maybe integrate an opensource editor with your engine.

Anyway, my last VERY BIG question is: why are you convinced you need more control than using Unity would give you, or you need features only included in Unity Pro? How much expierience do you have with Unity, or with game development in general?

If you want to create your own engine for learning purposes, or you have very specific features in mind that you know Unity will be showstopper because of engine limitations, that is fine I guess. But don't scratch off an engine just because you THINK it might not work... chances are it will work just fine, with little work on your side.

I guess the solution by theflamingskunk should work fine for you, as long as you leave the behaviourscripts out of the equation. For just placing geometry, and maybe convert a heightmap into a mesh, or run arbitrary scripts in the editor for procedural placement of 3D objects / creation of meshes.

On the other hand I second what theflamingskunk asked: why go through the hassle of setting up the project in one engine and importing everything, when you finally want to export everything again to import it to a different engine? Why not just setup your scene in any 3D Package (like Blender) that you will have to use besides the Unity editor anyway?

If its just about scripting capabilities for running in-editor scripts, you can do that in Blender too.

If you hope to can do more than just setup the 3D Objects in the scene in the Unity Editor, I would quickly forget about that. If you do not manage to read the format Unity creates for its projects editor representation for your own engine, and then "build the game" out of that yourself, all you will be able to export is an obj file containing the 3D scene. The scripts you write and test in Unity could still work for you, if your own engine also uses Mono, and you are able to replicate the Unity API somehow (not sure how hard that is).

But this all sound like a lot of work you could invest into either creating your own editor, or maybe integrate an opensource editor with your engine.

Anyway, my last VERY BIG question is: why are you convinced you need more control than using Unity would give you, or you need features only included in Unity Pro? How much expierience do you have with Unity, or with game development in general?

If you want to create your own engine for learning purposes, or you have very specific features in mind that you know Unity will be showstopper because of engine limitations, that is fine I guess. But don't scratch off an engine just because you THINK it might not work... chances are it will work just fine, with little work on your side.

Hi. I hear what you're both saying and I am just experimenting at the moment. If I want to make use of a scene thats already been created for Unity within a tutorial then it would be nice to borrow one of those scenes while I fiddle with my own engine. My own 'engine' would be similar to a C++ construct that you'd find in any 3D game programming book.

The main reason I'm looking for alternatives to basic Unity is mainly around asset and scene streaming. I have a simple Unity project that consists of only 2 planets right now and I can walk around the planets or fly between the two, land and walk around etc. I've had a very quick look at http://www.pixelcrushers.com/scene-loader/ but I'm not sure if that will work for me since I'm not using flat scenes. I figured that once I start to get complex I may want to stream load assets when the player starts to approach planets - something I thought was only a feature of Unity Pro.

I have to admit that its also a learning/fun challenge I'm setting myself. I like the idea that I can make things happen with Unity in very little time but at the same time I'm keen to get under the hood and see how it all fits together. I'm sure people think I'm nuts but it is what it is.

For making scenes from scratch, it probably does make more sense to use Blender and then I could import the scenes into whatever engine I choose to use. For me, its just avoiding the need to learn new tool after tool. I started this journery with UDK, moved to Unity with the goal of learning how to use Blender to create simple models. I like Unity and don't really want to scratch it off so to speak. But do I really want to learn about the Blender engine and scripts just yet when I've only just started having fun with Unity?

As for experience, I have little experience in game development. I am very much a dabbler who's been dabbling in all aspects of programming for over 30 years - mainly C/C++.

I have used the thing theflamingskunk suggest and it did work fine. Was a while ago but i think i had some minor problems with the materials but it was easy to fix as .obj format is text. And assimp works well for .obj so should be no problem. I used it to test things in my own code with a test scene i made in unity. Budget level editor tongue.png .

@spinningcubes | Blog: Spinningcubes.com | Gamedev notes: GameDev Pensieve | Spinningcubes on Youtube

Advertisement

There is a script for exporting a Gameobject and all its children to OBJ in Unity which should work enough for your purpose. You would need to setup the scene in a certain way to get this to work (Have one object that all the geometry is a child of). Im not too familiar with unity so not sure how practical this is.

http://wiki.unity3d.com/index.php?title=ExportOBJ

Hey this worked really well! Thank you! Very easy indeed. I've managed to load an OBJ into Blender easily enough. I must admit I don't fully understand how materials and textures work so I don't know how I'm going to get those out of Unity as yet. I have located the folders to where the Materials/Textures are stored (.PNG and .META files) but how they would be combined with the OBJ model within Blender or within code via ASSIMP remains a mystery to me.

The main reason I'm looking for alternatives to basic Unity is mainly around asset and scene streaming. I have a simple Unity project that consists of only 2 planets right now and I can walk around the planets or fly between the two, land and walk around etc. I've had a very quick look at http://www.pixelcrushers.com/scene-loader/ but I'm not sure if that will work for me since I'm not using flat scenes. I figured that once I start to get complex I may want to stream load assets when the player starts to approach planets - something I thought was only a feature of Unity Pro.

If you just want to leave Unity behind because you think it will not work with the streaming you need, don't do that too quickly. There is an incredibly vast community out there around Unity and you can be sure somebody had the same problem before.

Have a good look at the asset store and the forums to make sure there isn't an existing solution out there. If there is (and there must be tons of terrain streaming assets for example in the asset store), and the dev asks for a price you cannot pay, you at least know now that somebody has solved the problem within Unity.

You could redevelop the functionality in Unity instead of starting to write from scratch. Might make SOME things more complicated, but at the other time you can concentrate on the one functionality you need to customize while not having to re-engineer the rest of the engine from scratch.

Just saying. I also scratched off Unity once during its 3.5 days, only to come to the realization while using a different engine that Unity indeed has so many good points for me that I can live with its limitations today. There are actually not many limitations you cannot work around somehow...

Just saying. I also scratched off Unity once during its 3.5 days, only to come to the realization while using a different engine that Unity indeed has so many good points for me that I can live with its limitations today. There are actually not many limitations you cannot work around somehow...

I don't honestly think I will abandon Unity. Well.. no way - I like it too much. Its good for me to learn more about whats available. I'll probably tick a few boxes of my own and then come back to it.. not that I will actually leave it. I'll check out the asset store and even look into the possibility of plugin/extension customisation myself perhaps.. but thats some time away. Unity has already proven my multiple world concept for me within a few days of effort (few days being following a couple of tutorials and experimenting on my own). That just spells "powerful" in my book. Blender is great fun too. I feel as though I've been missing out all these years. :)

This topic is closed to new replies.

Advertisement