CMODFIX CMODTool bug?

Report bugs, bug fixes and workarounds here.
Avatar
Topic author
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years 2 months
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

CMODFIX CMODTool bug?

Post #1by cartrite » 30.11.2007, 11:29

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?
Image


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
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #2by chris » 30.11.2007, 14:09

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

BobHegwood
Posts: 1803
Joined: 12.10.2007
With us: 17 years 1 month

Post #3by BobHegwood » 30.11.2007, 14:12

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
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Re: CMODFIX CMODTool bug?

Post #4by ElChristou » 30.11.2007, 14:13

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?
Image

Avatar
Topic author
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years 2 months
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Re: CMODFIX CMODTool bug?

Post #5by cartrite » 30.11.2007, 14:56

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
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4

Avatar
Topic author
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years 2 months
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Post #6by cartrite » 30.11.2007, 23:18

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])

Image
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])

Image

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
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Post #7by ElChristou » 01.12.2007, 00:13

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...
Image

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #8by chris » 01.12.2007, 00:29

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

Avatar
Topic author
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years 2 months
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Post #9by cartrite » 01.12.2007, 00:39

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.
Image

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
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Post #10by ElChristou » 01.12.2007, 01:54

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))...
Image

Avatar
Topic author
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years 2 months
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Post #11by cartrite » 01.12.2007, 08:27

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
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Post #12by ElChristou » 01.12.2007, 10:11

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?
Image

Avatar
Topic author
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years 2 months
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Post #13by cartrite » 01.12.2007, 10:27

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
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Post #14by ElChristou » 01.12.2007, 18:29

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...
Image

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 7 months
Location: Thyrrenian sea

Post #15by Fenerit » 04.12.2007, 01:17

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.
Never at rest.
Massimo

Avatar
Topic author
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years 2 months
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Post #16by cartrite » 04.12.2007, 22:37

:? 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
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4


Return to “Bugs”