Having spent some hours trying to learn more on Perl (BTW, very powerful language!) and analyzing phobos_cmod.pl I figured out a way to convert point clouds from .OBJ format to CMOD. When I render in .OBJ a set of data points I obtain (at least in my 3d modeller) a file so structured (here is shortening):
Code:
# File created by Luuv tsx 1.1.4
# Created on: Ott 02 14:31:18 2009
# Vertices: 26
v -43.4009 1.77351 -12.4959
v 9.63625 1.39427 16.1281
v -15.8813 15.4539 -32.2675
v -1.40235 -16.6047 -2.31708
v -0.807881 -12.1676 -2.18712
v -1.33854 1.64537 -15.2684
v -57.4847 4.01311 25.9169
v -1.72484 -15.9285 -2.09209
v -0.200683 -15.6711 -0.19031
v 0.13409 -14.9585 -2.46175
v 2.59238 13.124 9.64037
v 7.32817 6.11586 -14.5365
v 27.977 15.7262 22.3328
v -0.849096 -14.5154 -1.08298
v -0.211933 -13.5063 -0.949419
v -1.49628 -15.284 -0.183421
v -1.49917 -8.2716 -0.919193
v -0.353005 -10.311 -2.52
v -35.5242 8.8571 -14.1308
v 3.40951 -4.4969 1.38028
v 50.4466 11.9673 -8.6956
v -0.740291 -9.791 -0.768139
v -0.823455 -15.4874 -1.82547
v -0.8397 -14.8641 -0.255595
v -0.204464 -8.38986 -2.60387
v 0.750323 -15.3491 -1.51054
# End of file
in which there are some comments about modeler or plugin. Now, when I apply this script:
Code:
#
# Author Fenerit <fenerit@interfree.it>
# Version 1.0, 02.10.2009
# Note: this Perl script is strongly based upon the phobos_cmod.pl
# script by Dr. Fridger Schrempp <www.celestialmatters.org>
# A prototype for converting .OBJ cloud points into
# proprietary Celestia CMOD format.
# Limitations: is required manual erasing of all that in the .OBJ file
# is not vertex related (headers, indent, comments).
#
open(CMOD, " > points2cmod.cmod") || die "Can not create points2cmod.cmod\n";
$l = 0;
while (<>) {
($vlett,$x,$y,$z) = split (" ",$_);
$vlett[$1] = $vlett; # index for .OBJ's letter text "v"
$x[$l] = $x;
$y[$l] = $y;
$z[$l] = $z;
$l++;
}
print CMOD "#celmodel__ascii\n";
print CMOD "\n";
print CMOD "material\n";
print CMOD "#texture0 \"your_texture.*\"\n";
print CMOD "#blend add\n";
print CMOD "#blend premultiplied\n";
print CMOD "diffuse 1 1 1\n";
print CMOD "#emissive 1 1 1\n";
print CMOD "end_material\n";
print CMOD "\n";
print CMOD "mesh\n";
print CMOD "vertexdesc\n";
print CMOD "position f3\n";
#print CMOD "texcoord0 f2\n";
print CMOD "end_vertexdesc\n";
$vertexcount = $l;
print CMOD "\nvertices $vertexcount\n";
for ($index=0; $index < $vertexcount; $index++)
{printf CMOD "%8.5f %8.5f %8.5f\n", $x[$index],$y[$index],$z[$index];}
print CMOD "\npoints 0 $vertexcount\n";
for ($index=0; $index < $vertexcount; $index++) # count n° points
{printf CMOD "%6d\n", $i++;} # write n° points
print CMOD "\nend_mesh\n";
the output is so:
Code:
#celmodel__ascii
material
#texture0 "your_texture.*"
#blend add
#blend premultiplied
diffuse 1 1 1
#emissive 1 1 1
end_material
mesh
vertexdesc
position f3
#texcoord0 f2
end_vertexdesc
vertices 33
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 26.00000 0.00000
0.00000 0.00000 0.00000
-43.40090 1.77351 -12.49590
9.63625 1.39427 16.12810
-15.88130 15.45390 -32.26750
-1.40235 -16.60470 -2.31708
-0.80788 -12.16760 -2.18712
-1.33854 1.64537 -15.26840
-57.48470 4.01311 25.91690
-1.72484 -15.92850 -2.09209
-0.20068 -15.67110 -0.19031
0.13409 -14.95850 -2.46175
2.59238 13.12400 9.64037
7.32817 6.11586 -14.53650
27.97700 15.72620 22.33280
-0.84910 -14.51540 -1.08298
-0.21193 -13.50630 -0.94942
-1.49628 -15.28400 -0.18342
-1.49917 -8.27160 -0.91919
-0.35301 -10.31100 -2.52000
-35.52420 8.85710 -14.13080
3.40951 -4.49690 1.38028
50.44660 11.96730 -8.69560
-0.74029 -9.79100 -0.76814
-0.82346 -15.48740 -1.82547
-0.83970 -14.86410 -0.25560
-0.20446 -8.38986 -2.60387
0.75032 -15.34910 -1.51054
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
points 0 33
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
end_mesh
Practically are computed also the comment line. Due to my ignorance in programming, I unable to erase and trim the redundant text both at init and at EOF!

I say this because whether I manually erase them to obtain a structure likewise that:
Code:
v -43.4009 1.77351 -12.4959
v 9.63625 1.39427 16.1281
v -15.8813 15.4539 -32.2675
v -1.40235 -16.6047 -2.31708
v -0.807881 -12.1676 -2.18712
v -1.33854 1.64537 -15.2684
v -57.4847 4.01311 25.9169
v -1.72484 -15.9285 -2.09209
v -0.200683 -15.6711 -0.19031
v 0.13409 -14.9585 -2.46175
v 2.59238 13.124 9.64037
v 7.32817 6.11586 -14.5365
v 27.977 15.7262 22.3328
v -0.849096 -14.5154 -1.08298
v -0.211933 -13.5063 -0.949419
v -1.49628 -15.284 -0.183421
v -1.49917 -8.2716 -0.919193
v -0.353005 -10.311 -2.52
v -35.5242 8.8571 -14.1308
v 3.40951 -4.4969 1.38028
v 50.4466 11.9673 -8.6956
v -0.740291 -9.791 -0.768139
v -0.823455 -15.4874 -1.82547
v -0.8397 -14.8641 -0.255595
v -0.204464 -8.38986 -2.60387
v 0.750323 -15.3491 -1.51054
without spaces at init and at EOF, the result is so:
Code:
#celmodel__ascii
material
#texture0 "your_texture.*"
#blend add
#blend premultiplied
diffuse 1 1 1
#emissive 1 1 1
end_material
mesh
vertexdesc
position f3
#texcoord0 f2
end_vertexdesc
vertices 26
-43.40090 1.77351 -12.49590
9.63625 1.39427 16.12810
-15.88130 15.45390 -32.26750
-1.40235 -16.60470 -2.31708
-0.80788 -12.16760 -2.18712
-1.33854 1.64537 -15.26840
-57.48470 4.01311 25.91690
-1.72484 -15.92850 -2.09209
-0.20068 -15.67110 -0.19031
0.13409 -14.95850 -2.46175
2.59238 13.12400 9.64037
7.32817 6.11586 -14.53650
27.97700 15.72620 22.33280
-0.84910 -14.51540 -1.08298
-0.21193 -13.50630 -0.94942
-1.49628 -15.28400 -0.18342
-1.49917 -8.27160 -0.91919
-0.35301 -10.31100 -2.52000
-35.52420 8.85710 -14.13080
3.40951 -4.49690 1.38028
50.44660 11.96730 -8.69560
-0.74029 -9.79100 -0.76814
-0.82346 -15.48740 -1.82547
-0.83970 -14.86410 -0.25560
-0.20446 -8.38986 -2.60387
0.75032 -15.34910 -1.51054
points 0 26
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
end_mesh
which is what we need for put points in Celestia. Hope this thread might interesting someone.
EDIT LATER:
texcoord0 f2 may be commented (#texcoord0 f2).