How would I go about storing 3D object data into a database?
I`m having issues with converting our 2D database model to translate for our upcoming 3D model in UNity3D
His biggest question is this: What does a Unity 3D object look like and can I store that object in the db for retrieval to be rendered on-the-fly?
Here is the email from my database guy: (Can you please help to find a solution that works with Unity3D)
Parsing out the data into XML should be an easy matter, depending on how we enter raw data and how the 3D environment wants to handle it. At present, youll note that I have an XML field (not formatted as such, just a NVARCHAR container.) My assumption is that the XML data will attach to Articles. I have not defined yet what to do with this XML since that is TBD. Articles themselves may become XML data too; this is also TBD. There are a few ways we can handle this.
My biggest question is this: What does a Unity 3D object look like and can I store that object in the db for retrieval to be rendered on-the-fly? If our data is to be represented (at least on occasion) as 3D objects then we must be able to store those objects in the db, not in the 3D code. This makes it seem like we cant: REF. Note that to me it appears that Unity only connects to a game db server, as they call it, for stats and things, not 3D objects. Retrieving text and binaries (images, videos, documents, etc.) is one thing, but retrieving dynamic 3D objects is, as far as I understand, what this is all about.
Thanks and looking forward to ANY help you can give me.
Mostly agree with Brian Kehrer in that you need to use Assetbundles to load model data on the fly. However, a database could store an AssetBundle as a base64 encoded pile of bits instead of linking to it in a filesystem.
Another approach, depending on what your incoming data is, is to write an XML exporter for the model and an XML importer to read it out of the database. The importer would then need to build the mesh on the fly. This approach really only makes sense if your Unity app is creating new geometry that it needs to store somewhere. It is several levels more complex than using Assetbundles alone.
answered Jan 17 '10 at 03:14 AM
Hey! It's completely possible to store meshes in a database and then transport them into Unity, either through using native C# sockets or the WWW class (by getting a php page or something like that to echo the binary BLOB data). You would however need to produce your own way of storing mesh information in a binary file (or produce your own decoder for a standard mesh file format like OBJ). As a minimum, meshes need:
You'd probably want texture information too and an actual texture, but all that depends on what you actually mean by a '3D object' :).
I'm currently making an MMORPG in Unity3D and as you might have guessed that's alot of content; all of which is streamed into the client (which is only 300kb) (including code, images, meshes, animations, audio,text etc). Anything can be streamed in; you've just got to produce a suitable binary format to do it in :)
answered Jun 25 '11 at 06:02 PM
As Mike said, there are lots of ways to do this.
What you probably want are AssetBundles.
These allow you to store 3d objects, meshes, textures, materials and more externally, and load them at runtime.
The database would obviously just point to an AssetBundle URL.
Piece of cake.
answered Jan 15 '10 at 12:38 AM
I'm not entirely sure I understand your question. I believe that a good bit of it would benefit from a more clear description of what you are specifically trying to accomplish.
There isn't really anything magical about "3D Objects". You can model the data that represents the GameObject and store that data in a number of ways; but at the end of the day this is all very dependent on what you are trying to do. Say, for example, I have a collection of spheres. I may store a position vector and a radius for each sphere in a database; Unity can call Instantiate a bunch of times and create them for me in my visual space.
Unity can connect to a database and fetch whatever you want from it. You just have to define your data model appropriately so that you can supply Unity with the information it needs to represent the data you fetched.
answered Dec 17 '09 at 10:46 PM