If you noticed the dates from the post it was 15 years ago.
I still remember some of it but the thing is, more recently, I used a script written by Fridger and all the discussions were posted on CelestialMatters which apparently no longer exists. I could have sworn that it was part of the tools in Celestia. I also look though F-Tex tools also written by Fridger.
With Blender you should be able to accomplish what you want. I still have the cmod exporter written for Blender. The version of Blender you used is quite old. The latest version now is 2.8. Anyhow what I remember from those days is I subdivided the plane many more times. The reason you probably got the divide by zero error is because the plane was not displaced. And I'm not sure why that happened. I'm back at work for the rest of the week so I will look into updating the zfold script and the cmod exporter for Blender 2.8 this weekend.My work week started today and ends on Saturday evening.
Added after 3 hours 23 minutes:OK, My memory is starting to return. I found this thread.
https://celestia.space/forum/viewtopic.php?f=5&t=16195 I was looking though the files of my computer and found the perl script Fridger wrote. Unfortunately I now remember it was written for Phobos. Here is a link to the file he wrote it for. It's called m1phobos.tab.
https://sbn.psi.edu/pds/resource/oshape.html You can open this in a text editor like notepad. You can see that the file lists lat and long coordinates with a height value. What I can remember doing now is writing a similar script that doesn't need the lat long coords. I calculated them based on which
'pixel' was being read. This was from pixel resolution in the map. This way I was able to use an ascii file with only numbers in the form of mars's radius in height values. Which is what I created last night. I don't have this script on my current computer I'm using. That computer is a PC and it's in storage miles away from where I currently live. But I should be able to write it again. Possibly this weekend.
Added after 3 minutes 15 seconds:Here is the script that creates a Phobos model
Code: Select all
#!/usr/bin/perl
#
# Author Dr. Fridger Schrempp
# Version 1.0, 23.9.2009
#
open(CMOD, " > phobos_ascii.cmod") || die "Can not create phobos_ascii.cmod\n";
$pi = 3.14159265359;
$m = 90;
$mm = 2 * $m + 1;
#
# Read-in the generalized Phobos elevation map (m1phobos.tab),
# [lat, long, radius(lat,long)] , lat=-90 + 2*$i, long = 2*$j,
# $i = 0..90, $j = 0..180. South pole<=> $i=0, North pole <=> $i=90,
# 2 degree mesh
#
$l = 0;
while (<>) {
($lat,$long,$radius) = split (" ",$_);
# Polar angle $theta in radian
$theta = $pi/180.0 * ($lat - 90);
# Azimuthal angle $phi in radian
$phi = $pi/180.0 * $long;
# Convert to Carthesian coordinates ([km])
# Note: Celestia involves z <=> y exchange convention!
$x[$l] = $radius * cos($phi) * sin($theta);
$z[$l] = $radius * sin($phi) * sin($theta);
$y[$l] = $radius * cos($theta);
# 2D Texture coordinates ($s,$t):
$s[$l] = 0.5 * (1 - $phi/$pi);
$t[$l] = 1 - $theta/$pi;
$l++;
}
print CMOD "#celmodel__ascii\n";
print CMOD "\n";
print CMOD "material\n";
print CMOD "texture0 \"phobos.jpg\"\n";
print CMOD "diffuse 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; # = $mm *($m + 1) = 16471
print CMOD "\nvertices $vertexcount\n";
#
# Print out vertices
#
for ($index=0; $index < $vertexcount; $index++){
printf CMOD "%8.5f %8.5f %8.5f %8.5f %8.5f\n", $x[$index],$y[$index],$z[$index],$s[$index],$t[$index];
}
#
# Next, generate triangular faces
#
# First, calculate $facecount: Count in (i,j) cylindrical map with
# (2*$m + 1)*($m + 1) = 16471 vertices: it contains 2*$m * ($m-2)
# non-degenerate quadrilinear faces = 4*$m*($m-2) non-degenerate
# triangular faces and in addition 2*$m non-degenerate triangles from
# $i=0 row (South pole) and 2*$m such triangles from the $i=$m row
# (North pole). Altogether gives $facecount = 4 * $m * ($m -1) = 32040
#
# The 2*$m /degenerate/ triangles both in the $i=0 and $i=$m rows are
# left out!
#
$facecount = 4 * $m * ($m - 1);
$trival = 3 * $facecount;
print CMOD "\ntrilist 0 $trival\n";
for ($i = 0; $i < $m; $i++){
for ($j = 0; $j < 2 * $m; $j++){
$l1 = $mm * $i + $j;
$l2 = $l1 + 1;
$l4 = $l1 + $mm;
$l3 = $l4 + 1;
if ($i == 0) {printf CMOD "%6d %6d %6d\n",$l1,$l4,$l3;}
elsif ($i == $m-1){printf CMOD "%6d %6d %6d\n",$l1,$l3,$l2;}
else{printf CMOD "%6d %6d %6d\n%6d %6d %6d\n",$l1,$l3,$l2,$l1,$l4,$l3;}
}
}
print CMOD "\nend_mesh\n";
Added after 20 minutes 19 seconds:I just ran it and produced a model of Phobos. I used this command on linux.
Here is the beginning of the file
Code: Select all
#celmodel__ascii
material
texture0 "phobos.jpg"
diffuse 1 1 1
end_material
mesh
vertexdesc
position f3
texcoord0 f2
end_vertexdesc
vertices 16471
0.00000 -8.37260 0.00000 0.50000 2.00000
.....................
16287 16469 16288
16288 16470 16289
end_mesh
When I get this done, you'll need to repeat that header 4 times for each cropped model tile and assign the texture of your choice. This is a single mesh model. You'll need to repeat the section above starting with material and all the numbers until end_mesh.
Added after 1 minute 17 seconds:Then you'll have a single model with 4 meshes and 4 textures.
Added after 31 minutes 40 seconds:Actually that was a bad example. This would be a better one. An ascii version of one of my mars models.
Code: Select all
#celmodel__ascii
material
diffuse 0.878431 0.878431 0.878431
specular 0.498039 0.498039 0.498039
texture0 "mars.*"
normalmap "mars-norm.*"
specularmap "spec.*"
end_material
material
diffuse 0.878431 0.878431 0.878431
specular 0.498039 0.498039 0.498039
texture0 "mons.*"
normalmap "mons-norm.*"
specularmap "tex-spec.*"
end_material
material
diffuse 0.878431 0.878431 0.878431
specular 0.498039 0.498039 0.498039
texture0 "valles.*"
normalmap "valless-norm.*"
specularmap "tex-spec.*"
end_material
mesh
vertexdesc
position f3
normal f3
texcoord0 f2
tangent f3
end_vertexdesc
vertices 33398
-0.276371 -0.314521 0.911074 -0.283303 -0.307809 0.908291 0.703125 0.601563 0.954877 -0.00238351 0.296991
Notice that I have 3 meshes. My material list are at the beginning of the file. You'll need to do something similar. But for 4 materials. Then My first mesh. Followed by end_mesh Then the next mesh and so on.
Added after 5 minutes 48 seconds:Also each mesh should have it's trilist
Code: Select all
trilist 0 190464
14443 26153 16588 16589 16591 14442 26153 18560 16305 16303 16589 26152
Added after 32 minutes 49 seconds:I created this video about 13 years ago of one of my mars models.
https://www.youtube.com/watch?v=zmrJYZxJmtY