.3ds normals

Started by
7 comments, last by Motorherp 19 years, 6 months ago
Hi. I've just started writing my own .3ds file parser for directX and I've just realised that the tri meshes in 3ds files contain no normals. Does anyone know the best way to get normals into my directX meshes. As far as I know directX doesn't have any built in functionality for this sort of thing but maybe there's some trick I'm missing that'll make my life easier. Also how can I tell when a vert normal should reflect the face normal to simulate flat surfaces or should be blends of adjacent face normals to simulate a smooth surface? Cheers.
[size="1"] [size="4"]:: SHMUP-DEV ::
Advertisement
Hi -

In the Advanced Topics section of the Max SDK, there is a section called 'Computing Face and Vertex Normals'. This should give you plenty of info to get started.

joe
image space
You could use D3DXComputeNorlams() ?
You can even pass smoothing group to it.
It works almost good.

The other way is you calculate face normals yourself and then compute vertex normals ( exact that does D3DXComputeNormals) for you.

But I have never seen any CORRECT SOURCE CODE for loading 3ds file with normals. There is one attempt with lib3ds (a library that loads 3ds files) but it is not 100%.
Scoob Droolins - are you talking about the help documentation. I'll check it out.

AP - Excellent, I didn't realise D3DXComputeNormals() existed. That'll make my life easier. What do you mean by smoothing groups?? I've noticed that .3ds files contain smooth lists which I assume is related. Any ideas??


PS: Scoob Droolins - I've just searched through the user reference and tutorials and couldn't find anything about computing normals. Which version of max do you have??

PPS: Ahhh found what you were on about, cheers:

'Computing Face and Vertex Normals'

[Edited by - Motorherp on September 28, 2004 11:34:30 AM]
[size="1"] [size="4"]:: SHMUP-DEV ::
That's the one. Post if you have any more questions, I'll try to help out.

joe
image space
There is a lot information about computing vertex normals in internet. This is how I do it:
- > Compute Face normal
- > Comput vertex normal (or smoothing groups, if used)

Remember that *.3ds file doesn't save smoothing group normals either, so you have to compute them too. I used to use *.3ds format, but it really isn't the best.

I would make an ASCII(these are easier to use) format converter and convert it to own binary format, just parse the data you need. Only thing I hate in binary formats is that if you read even one bit wrong it crashes! :)
Sincerely,Arto RuotsalainenDawn Bringer 3D - Tips & Tricks
That 'Computing Face and Vertex Normals' article explains it pretty well. The problem wasn't being able to calc the normals but knowing when they should blend or copy the face normal. That D3DXComputeNormals() looks like it could be a good helper but I've decided against it since I don't intend to use directX meshes anymore. Instead I'm trying to load in static scenes from max with materials, textures, bumpmaps, lights, and cameras. The vert and face info will be loaded into two big buffers which I then plan to optimise to maximise cache hits and reduce the number of render state changes. Dynamic meshes will then be handled seperately but I havn't planned that bit out yet. This is my first attempt at a large scale rendering project (I'm a physics programmer usually and just doing this out of curiosity and so I can create my own games) so if anyone has any tips they'd be greatly appreciated. Cheers for the help everyone.

PS: probably the wrong forum but does anyone know how to pre-compute shadow maps in max and export them with the scene.
[size="1"] [size="4"]:: SHMUP-DEV ::
Quote:Original post by Motorherp
That D3DXComputeNormals() looks like it could be a good helper but I've decided against it since I don't intend to use directX meshes anymore.


Also, if you're loading any significant amounts of mesh, you don't want to be computing normals during mesh loading. I wouldn't recommend using .3ds as loadable mesh source. Write a Max utility plugin to export directly from Max to your custom format.

joe
image space
Yeh the loading process is gonna be slow cause of the optimizing I'll be doing aswell. The 3ds parser is being written as an offline converter that'll output a file comaptible with my RenderScene class. I've decided to go back to directX meshes as well to take advantage of the directX helper functions and built in optimisers. My original concern was that I wanted all the static scenery to be held in the same place and 3ds files only support a limited amount of verts and faces per mesh. However I suppose there's nothing stopping me from dividing up my scenes in max, loading them in as seperate DX meshes, and then combining them all into one big mesh before optimising. I'll have to buid my own mesh class on top which inherits ID3DXMesh to take advantage of my added functionality like bump maps and the like. I wouldn't quote me on any off this though, I really don't have a clue what I'm doing and just coding by the seat of my pants. Chances are I'll have changed my mind again tomorrow. Any insights to keep me focused and moving in a straight line much appreciated :)
[size="1"] [size="4"]:: SHMUP-DEV ::

This topic is closed to new replies.

Advertisement