Page 1 of 1
CMODFIX CMODTool bug?
Posted: 30.11.2007, 11:29
by cartrite
I was viewing a thread in the addons forum ......... Instead of posting this there I decided to start a separate thread.
http://www.celestiaproject.net/forum/viewtopic ... 6210#96210
Cham wrote:ElChristou wrote:Today I can load the page; indeed it's a much better model! Have you send an email as those guys asked? (else I'll send it)
I'll publish a 3ds version only (no CMOD version), since there's some problems with smoothing with the CMODTool utility (we need to solve this, by the way !).
Is this the smoothing problem your referring to?
All my models go through the cmodfix tool. I noticed that when I export models with only quads that these ugly squares
do not appear. This model was created by converting a height map to a dem and then converting the dem to a waveobject. This conversion to waveobject creates triangles. When I export this to cmod I get the ugly squares even after running through cmodfix.
I'm not sure why the squares disappear when I export quad models to cmod. The exporter I wrote creates the triangles during export with this code.
Code: Select all
for face in mesh.faces:
out.write( '%f %f %f %f %f %f' % (face.v[2].co.x, face.v[2].co.y, face.v[2].co.z, face.v[2].no.x, face.v[2].no.z, face.v[2].no.y,))
out.write( ' %f %f\n' % face.uv[2])
out.write( '%f %f %f %f %f %f' % (face.v[3].co.x, face.v[3].co.y, face.v[3].co.z, face.v[3].no.x, face.v[3].no.z, face.v[3].no.y,))
out.write( ' %f %f\n' % face.uv[3])
out.write( '%f %f %f %f %f %f' % (face.v[0].co.x, face.v[0].co.y, face.v[0].co.z, face.v[0].no.x, face.v[0].no.z, face.v[0].no.y,))
out.write( ' %f %f\n' % face.uv[0])
out.write( '%f %f %f %f %f %f' % (face.v[0].co.x, face.v[0].co.y, face.v[0].co.z, face.v[0].no.x, face.v[0].no.z, face.v[0].no.y,))
out.write( ' %f %f\n' % face.uv[0])
out.write( '%f %f %f %f %f %f' % (face.v[1].co.x, face.v[1].co.y, face.v[1].co.z, face.v[1].no.x, face.v[1].no.z, face.v[1].no.y,))
out.write( ' %f %f\n' % face.uv[1])
out.write( '%f %f %f %f %f %f' % (face.v[2].co.x, face.v[2].co.y, face.v[2].co.z, face.v[2].no.x, face.v[2].no.z, face.v[2].no.y,))
out.write( ' %f %f\n' % face.uv[2])
Models that have triangles already are exported with this code.
Code: Select all
for face in mesh.faces:
d = 0
for vert in face.v:
out.write( '%f %f %f %f %f %f' % (face.v[d].co.x, face.v[d].co.y, face.v[d].co.z, face.v[d].no.x, face.v[d].no.z, face.v[0].no.y,))
out.write( ' %f %f\n' % face.uv[d])
When I view the models with wiremode in Celestia, they all have similar looking triangles but when exported with the second code block they have ugly squares that I can't get rid of..Models exported to cmod with the first code block look smooth with no ugly squares.
Cham, if you see this, maybe you could post what these smoothing problems your having look like?
cartrite
Posted: 30.11.2007, 14:09
by chris
I'd like to hear more about this. I looked at cmodfix a while ago and didn't find any problems in the normal generation code. Experiments bore this out--in several test cases, generated normals looked exactly as expected, with no creases (or no unexpected creases--I generally use a smoothing angle of less than 90 degrees so that smoothing isn't applied inappropriately, such as between the faces of a cube.)
--Chris
Posted: 30.11.2007, 14:12
by BobHegwood
Just FYI...
I also have had NO troubles with the 3dstocmod program. Again,
though, I never use anything greater than 90 degrees for the
smoothing angle.
Thanks, Brain-Dead
Re: CMODFIX CMODTool bug?
Posted: 30.11.2007, 14:13
by ElChristou
cartrite wrote:Is this the smoothing problem your referring to?
Cartrite, this looks to me as the tiles (2 poly) are not merged (4 points each tiles)... Are you sure the weld vertices fix don't eliminate these squares?
Re: CMODFIX CMODTool bug?
Posted: 30.11.2007, 14:56
by cartrite
ElChristou wrote:cartrite wrote:Is this the smoothing problem your referring to?
Cartrite, this looks to me as the tiles (2 poly) are not merged (4 points each tiles)... Are you sure the weld vertices fix don't eliminate these squares?
I tried everything to eliminate the squares from the above model and nothing worked.
I converted the high resolution part of the model to quads but never put it together and exported it to cmod yet. I'm going to try it and see if this eliminates the squares. Later this weekend I should know if this works or not.
I know that some of the models I export have squares and some don't no matter what the resolution is. I never did find out why but I think it has something to do with which exporter I use? I'll try to track down what is really going on this weekend.
cartrite
Posted: 30.11.2007, 23:18
by cartrite
Here is the original model that had triangles and was exported with
Code: Select all
for face in mesh.faces:
d = 0
for vert in face.v:
out.write( '%f %f %f %f %f %f' % (face.v[d].co.x, face.v[d].co.y, face.v[d].co.z, face.v[d].no.x, face.v[d].no.z, face.v[0].no.y,))
out.write( ' %f %f\n' % face.uv[d])
Here is the model I converted to quads and exported with this
Code: Select all
for face in mesh.faces:
out.write( '%f %f %f %f %f %f' % (face.v[2].co.x, face.v[2].co.y, face.v[2].co.z, face.v[2].no.x, face.v[2].no.z, face.v[2].no.y,))
out.write( ' %f %f\n' % face.uv[2])
out.write( '%f %f %f %f %f %f' % (face.v[3].co.x, face.v[3].co.y, face.v[3].co.z, face.v[3].no.x, face.v[3].no.z, face.v[3].no.y,))
out.write( ' %f %f\n' % face.uv[3])
out.write( '%f %f %f %f %f %f' % (face.v[0].co.x, face.v[0].co.y, face.v[0].co.z, face.v[0].no.x, face.v[0].no.z, face.v[0].no.y,))
out.write( ' %f %f\n' % face.uv[0])
out.write( '%f %f %f %f %f %f' % (face.v[0].co.x, face.v[0].co.y, face.v[0].co.z, face.v[0].no.x, face.v[0].no.z, face.v[0].no.y,))
out.write( ' %f %f\n' % face.uv[0])
out.write( '%f %f %f %f %f %f' % (face.v[1].co.x, face.v[1].co.y, face.v[1].co.z, face.v[1].no.x, face.v[1].no.z, face.v[1].no.y,))
out.write( ' %f %f\n' % face.uv[1])
out.write( '%f %f %f %f %f %f' % (face.v[2].co.x, face.v[2].co.y, face.v[2].co.z, face.v[2].no.x, face.v[2].no.z, face.v[2].no.y,))
out.write( ' %f %f\n' % face.uv[2])
See the difference. Both versions did cmodfix -u -n -s 180 -b .
Is this what others are considering a smoothing problem?
I don't know if cmodfix has any effect on the squares or if it is even supposed to. This is how I always worked around the problem since I wrote the exporters.
Could it also be the order that the verticies are listed?
The code that creates triangles are doing so in a specific order. I'm not sure but I think the other code writes out in assending order.
cartrite
Posted: 01.12.2007, 00:13
by ElChristou
cartrite wrote:...Is this what others are considering a smoothing problem?
Not sure it's related; actually there is two known problems with the cmodtool
ON OSX; a problem of seam on cylindrical meshes once textured (can be fix with generate normals but then lost of any different smooth settings in the 3D soft) and a problem of wireframe with possible lost of FPS if (if I recall correctly) optimize is used.
Now concerning your export method, as I'm not used to such export scripts (I use those integrated to my soft then convert via cmodtool) I have no idea of what's going on. If you could do a small piece (in both versions) then export it to 3DS, perhaps I could load it in Amapi to look what's the problem...
Posted: 01.12.2007, 00:29
by chris
cartrite wrote:Here is the original model that had triangles and was exported with [code]for face in mesh.faces:
...
See the difference. Both versions did cmodfix -u -n -s 180 -b .
Is this what others are considering a smoothing problem?
I don't know if cmodfix has any effect on the squares or if it is even supposed to. This is how I always worked around the problem since I wrote the exporters.
I think the only problem is that--as Christophe pointed out--you aren't welding vertices with cmodfix. Just add a -w to the cmodfix command line. Without this option, cmodfix may not know that identical vertices actually belong to the same face if the mesh generated by your export script doesn't use shared vertices. Best not to worry about it and just use -w; it may take slightly longer to process the mesh, but smoothing should work.
--Chris
Posted: 01.12.2007, 00:39
by cartrite
ElChristou wrote:If you could do a small piece (in both versions) then export it to 3DS, perhaps I could load it in Amapi to look what's the problem...
That could be a problem. That model has 4285764 vertices. 3ds can only handle 65000?
A shot with some stats.
Anyhow I thought this may have been related to what Cham was saying. If it isn't, I'm fine with exporting quads. Can't go wrong that way. Another thing. This will be one of the last times I do planets this way. I'm going to start using custom code to create the models right from dems. Not quite there yet but.......
chris wrote:I think the only problem is that--as Christophe pointed out--you aren't welding vertices with cmodfix. Just add a -w to the cmodfix command line. Without this option, cmodfix may not know that identical vertices actually belong to the same face if the mesh generated by your export script doesn't use shared vertices. Best not to worry about it and just use -w; it may take slightly longer to process the mesh, but smoothing should work.
I also tried that. -w that is. It didn't do anything though. I tried the exact order that you have in the readme.
Code: Select all
cmodfix -u -w -n -s 45 in.cmod out.cmod
Anyhow, as long as I export quads and use the order that I use, everything is fine.
cartrite
Posted: 01.12.2007, 01:54
by ElChristou
cartrite wrote:ElChristou wrote:If you could do a small piece (in both versions) then export it to 3DS, perhaps I could load it in Amapi to look what's the problem...
That could be a problem. That model has 4285764 vertices. 3ds can only handle 65000?
No, just a little part, a few poly extracted from your model (before and after smoothing (both versions))...
Posted: 01.12.2007, 08:27
by cartrite
ElChristou wrote:cartrite wrote:ElChristou wrote:If you could do a small piece (in both versions) then export it to 3DS, perhaps I could load it in Amapi to look what's the problem...
That could be a problem. That model has 4285764 vertices. 3ds can only handle 65000?
No, just a little part, a few poly extracted from your model (before and after smoothing (both versions))...
Is there a tool or program that converts cmod to 3ds? If I export to cmod with the 2 different scripts, how to I convert them to 3ds?
I could export a small part to 3ds with Blender but that will not do anything. This problem with squares only becomes visible AFTER exporting from Blender. I NEVER see them in Blender.
There are 2 models. One with quads and one with triangles. The reason I have 2 different export scripts is that quad faces have 4 vertices and triangles have 3. The quad script writes the 4 vertices in the order 2,3,0,0,1,2. That doesn't work with triangles. I get an index error.
If I export the order 0,1,2,2,3,0 I also got squares. I think? I wrote these scripts a couple of years ago and I remember I had to play around with the order to get the models to look right in Celestia. I can't remember all the details though. Only that the 2,3,0,0,1,2 order worked.
cartrite
Posted: 01.12.2007, 10:11
by ElChristou
Cartrite, I'm not sure about this, but do you export directly your model in cmod? The scripts you talk about here are to export in cmod? And you have two different scripts, one outputting triangles, one outputting quads? is that right?
Posted: 01.12.2007, 10:27
by cartrite
ElChristou wrote:Cartrite, I'm not sure about this, but do you export directly your model in cmod? The scripts you talk about here are to export in cmod?
I export the .blend files to cmod directly. Only a part of the script is posted though. The part that formats and writes the lines.
ElChristou wrote:And you have two different scripts, one outputting triangles, one outputting quads? is that right?
No. They both output triangles. One uses quads as input and the other one uses triangles as input.
cartrite
Posted: 01.12.2007, 18:29
by ElChristou
cartrite wrote:ElChristou wrote:And you have two different scripts, one outputting triangles, one outputting quads? is that right?
No. They both output triangles. One uses quads as input and the other one uses triangles as input.
cartrite
Right, so could you cut a small piece with triangles and the same with quads then export to 3DS both versions? I'm curious to see if the quad version is welded or not...
Posted: 04.12.2007, 01:17
by Fenerit
This matter seem to me controversial, since I've found the squares and the seams on the .cmod models as well as in the 3ds models when I test the latters in Celestia time after time during the develop before the conversion with the tool, and the formers once converted after these operations. That is, in doing a reboot of the computer and loaded in the first place both the 3d formats once again in Celestia, the seams and the squares desappears. This behaviour does happen even (not ever, though) with my modeller setted in DirectX mode. It seem as the graphic card after a long switch amongst modeller and simulator does need to re-inizialize again.
EDIT LATER:
I bet that once a .cmod model be converted in 3ds format (if such progam exist) it doesn't shows the quads.
Posted: 04.12.2007, 22:37
by cartrite
I don't know why the squares happen. All I know is that welding with cmodfix doesn't get rid of them. I get rid of the squares by using the right export script. The model that I showed in the pics and video was exported with the right script.
http://www.celestiaproject.net/forum/viewtopic ... 6252#96252 The images and video are from a model that was not welded with cmodfix.
I have since welded the model with cmodfix and it did produce a smaller more efficient file but welding does not fix the squares if the model was exported with the wrong script. The one that just writes out the vertex coordinates for each face in "ascending or descending order?" As long as I export a model with quads and write out triangles in the order 2,3,0,0,1,2 the squares are gone.
cartrite