pouët.net

Go to bottom

favourite way to load 3d models

category: general [glöplog]
 
hi,

being a starter in demo coding, what i found out so far:
most ppl code their demos in c++ using directx for the 3d.

but how do most ppl load their 3d models into the code?

i assume its exported from 3dsmax or maya. but what format?

thanks!
added on the 2004-04-08 01:31:10 by zatom zatom
Actually most people use OpenGL but especially cool sceners use DirectX :)
Yu can create your own format and code an exporter for your favourite modellnig tool or use a well documented format such as 3ds. It all depends on what you want to reach in the end...
added on the 2004-04-08 01:38:16 by Paralax Paralax
look in the data folders, .obj .3ds .lwo, they are all being used, depends on what modeller you like ;)

there is a lot of examples on the web for loading (and animating) models right from the app into your code

(That's why most people frown on static 3D flyby scenes, it's easy)
emzic: i'll let you share my Blender exporter and player, if i ever come to write one. :>
added on the 2004-04-08 01:45:02 by eye eye
hmm, does it really depend on the modeller you like? i think its more like you can choose your favourite format since most modeller are able to save/export in several formats (or are there compatibility problems... i never tried/checked this)
added on the 2004-04-08 01:49:16 by ttl ttl
thanks for all the replies so far.

most people use openGL? really? in demos?

most demos dont have any additional files. seems like they are in the exe already.

isn't there one format that stands above all other? what does farb-rausch use for example?
added on the 2004-04-08 01:57:45 by zatom zatom
Some especially kewl groups tend to use format like this:

float verts[][3] = {{ -1, -1, -1 }, { -1, 1, 1 }, { 1, -1, 1 }, { 1, 1, -1 }};
int faces[][3] = {{ 0, 2, 1 }, { 0, 3, 2 }, { 0, 1, 3 }, { 1, 2, 3 }};
added on the 2004-04-08 02:05:37 by 216 216
The key is to write your engine so it doesnt depend on one format, however, you will most likely be forced to depend on one kind of scenegraph thinking since you will wake up in a nightmare otherwise (tho It isnt impossible to support more than one, it just get.. euhm.. bitchy :).

.3ds is a very outdated format in generally and i wouldnt recommend it to anyone.

If you want to use 3dsmax or Maya, you will be forced to use a non-standard exporter, either you write your own or you take someone elses. A good alternative for 3dsmax is Flexporter i heard, however i dont remember if it has any default plugin wich acctually will give you an exporting result, or if you will have to write your own plugin (everyone i know who used it have done that.. so it seems likely).

Lightwaves .lws / .lwo is okayish so you can do with it.. However a real exporter plugin is always a good thing :)
added on the 2004-04-08 02:15:05 by Hatikvah Hatikvah
well, thanks again.

but i dont wanna know how to load in a format. i can do that pretty good with a couple of formats in OpenGL
.
i just wanna know what the majority of sceners does. or what the reel leet ones do. do they really code verts by hand?
added on the 2004-04-08 02:26:58 by zatom zatom
no, they have a converter. or ascii output and editor with good search/replace;)
added on the 2004-04-08 02:28:45 by 216 216
emzic, so if you store your 3d as the 1337 ones then you will be in the charts next pain or ? - well probably (just keep in mind to inform everybody at pouet about it).

No, seriously, what other people does is irrellevant, trust me, the majority of the demos out there has really bad engines. The best engines usually are used to create crap demos, this is a fact :)
added on the 2004-04-08 04:31:34 by Hatikvah Hatikvah
Well, since this is your first 3d loader, you might not want to jump in head in =)
Try to create an abstract base 3d model class with standard properties (norms, vertices, textures/materials, whatnot), and see if you can load simple formats with it (IE *.ase). Once you succeed in doing this, add keyframing support (through interpolation) and try to load more advanced formats into your base class, with animations and such... This should be easier then just looking up the .lwo/.3ds/etc format and trying to code a full fledged loader from scratch =)
added on the 2004-04-08 10:39:34 by Nezbie Nezbie
I agree with NeZBie and arneweisse :-).

Try to make a good engine for a good demo and you'll end up screwing your time for the engine and having zero motivation for the demo.

The best thing, especially for new coders, is to make stuff that appear to the screen as fast as possible. So first, try to make an abstract base 3d model class (as nezbie said) and make a cube with that class by defining the vertices by hand (it is not hard - just imagine the positions - or open a modeller, create a cube and get the coords from there). Then -after making it rotate around just to make you feel happy :-)- try to implement keyframe interpolation. What is this? Simply, make your 3d model class to be able to hold more than one mesh and all these meshes to have the same count of vertices and faces (or else you'll need to do morphing, not keyframing). Now in each timetick (for starters, this is usally the framerate - but you should set up a timer - while for real demos it is not a good idea, for testing purposes the Win32 setTimer function is good) just interpolate linearly from the first mesh to the second (i suppose that you know how to interpolate a value from one to another - if not check out www.gamedev.net or www.flipcode.net). Now define a second polyhedron (using either your mind, your favourite modeller or just a copy/paste), similar to the first one, but being a bit taller). Now set the first polyhedron as the first mesh, the second polyhedron as the second mesh, fireup your code and see your keyframe animated model roll your screen :-).

Now the next step is to load the polyhedrons from an extenral file, like .asc/.ase. Just make a simple model (f.e. a balloon) and define a 2-keyframe animation. Export the first keyframe as the first file and the next as the second file. Implement an .asc/.ase loader (most .asc loaders can be read with freadf()) and see your baloon animate in your screen. By extending this to infinite meshes (f.e. by having a dynamic array for the meshes) you'll have anything you need, engine-wise, for a keyframe-based model class.

The next -and probably the last for this topic- step is to implement a loader for your artist's favourite modeler (or force him to use a loader that exports your favourite file format :->).

Keep coding and have fun ;-).
added on the 2004-04-14 17:21:31 by BadSector BadSector
I never said he's a complete newbie and never stated he should do things quick'n'dirty. I said the most demos does.
added on the 2004-04-15 22:37:01 by Hatikvah Hatikvah
honestly, we're no 1337 group, but i guess our engine is not bad at all (see arneweisse's comment above ;)
what i've in there is a simply ase loader which in turn spits out a proprietary format since ase files are *huge*
the advantage of ase is, that there is _everything_ listed in it, you don't have to fiddle around with 3dsmax's ugly api, just export ase and you can actually read what's where in the file
the only pita is the string parsing stuff required to load ase files...
and personally i really hate 3ds format for its chunk shit. that really sucks! and it doesn't export all data i need
oh i forgot:
quick-hacking the first engine may be ok, since you'll end up rewriting your engine several times ;)
given enough time you'll end up with a pretty stable and powerful engine sometime.
do demos with it and you'll see what can be done, what can be improved, what is unnecessary. and you'll fix a lot of bugs
don't code a new engine for every demo!
ok
thanks a lot!

so ASE it is.

btw: is there support for texture mapping as well? seems so, but how can i get it to work?
added on the 2004-04-16 11:40:07 by zatom zatom
what you mean?
ase exports the texture coordinates for all vertices as well if you mean that!?
For I always used tpbLoadsingleObjectFrom3DS :)
(Talking about lame..)
added on the 2004-04-16 11:45:27 by superplek superplek

login

Go to top