good news
i edited the php script from the cod forum and now is working.
now the textures look like they should, the only thing that isn't working is the rotation property, but is not a big deal, can be easily fixed using radiant
what I think will have to be done manually is to add the terrain patches, I could not find any tool to export them to a .map format
this is the script if you find something that can be improved (sorry if it doesn't look too clean)
PHP Code:
<?php
function convertVMF2map($name)
{
$content = file_get_contents($name);
if ($content != false) {
$brushes = explode("solid", $content);
//echo "brushes: " . count($brushes) . "\n";
$realBrushes = array();
for ($i=1; $i<count($brushes); $i++) {
$planes = explode("side", $brushes[$i]);
if (count($planes) < 2)
continue;
$realBrush = array();
$realBrush["planes"] = array();
$realBrush["isTrigger"] = false;
for ($ii = 1; $ii < count($planes); $ii++) {
$vars = explode("\n", $planes[$ii]);
$realPlane = array();
for ($iii = 1; $iii < count($vars); $iii++) {
$parts = explode("\"", $vars[$iii]);
if (count($parts) < 2)
continue;
//echo "brush $i planes $ii vars $iii: ";
$key = $parts[1];
$value = "";
if(count($parts) >= 4)
$value = $parts[3];
//echo "$key->$value\n";
if ($key == "plane" || $key == "material" || $key == "uaxis" || $key == "vaxis" || $key == "rotation") {
$realPlane[$key] = $value;
if ($value == "TOOLS/TOOLSTRIGGER")
$realBrush["isTrigger"] = true;
}
}
if (count(array_keys($realPlane)) >= 2) // only add if "plane" and "material" is set at least
$realBrush["planes"][] = $realPlane;
}
$realBrushes[] = $realBrush;
}
$map = "";
// PRINT NORMAL BRUSHES
$map .= "{\n";
$map .= "\"classname\" \"worldspawn\"\n";
foreach ($realBrushes as $brush) {
if ($brush["isTrigger"])
continue;
if (count($brush["planes"]) > 0) {
$map .= "{\n";
foreach ($brush["planes"] as $planes) {
$vector0 = array("(", ")");
$vector1 = array("( ", " )");
$planes["plane"] = str_replace($vector0, $vector1, $planes["plane"]);
$brackets = array("[", "]");
$planes["uaxis"] = str_replace($brackets, "", $planes["uaxis"]);
$horizontal = explode(" ", $planes["uaxis"]);
$horizontal_shift = $horizontal[3];
$horizontal_scale = $horizontal[4];
$planes["vaxis"] = str_replace($brackets, "", $planes["vaxis"]);
$vertical = explode(" ", $planes["vaxis"]);
$vertical_shift = $vertical[3];
$vertical_scale = $vertical[4];
// ( 0 0 0 ) ( 0 0 0 ) ( 0 0 0 ) <material> <horizontal_shift> <vertical_shift> <rotation> <horizontal_scale> <vertical_cale> <content_flags> <surface_flags> <intensity>
$map .= $planes["plane"]. " " .getNewMaterial($planes["material"]). " " .$horizontal_shift. " " .$vertical_shift. " ".$planes["rotation"]. " " .$horizontal_scale. " " .$vertical_scale. " 0 0 0 \n";
}
$map .= "}\n";
}
}
$map .= "}\n";
// PRINT ONLY TRIGGERS AS ENTITY
foreach ($realBrushes as $brush) {
if ($brush["isTrigger"] == false)
continue;
$map .= "{\n";
$map .= "\"classname\" \"trigger_multiple\"\n";
if (count($brush["planes"]) > 0) {
$map .= "{\n";
foreach ($brush["planes"] as $planes) {
$map .= $planes["plane"] . " " .getNewMaterial($planes["material"]). " 60 0 0.00 1 1 0 160 0 \n";
}
$map .= "}\n";
}
$map .= "}\n";
}
return $map;
}
else
echo "Could not read ".$name;
return false;
}
$missingTextures = array();
function getNewMaterial($materialname)
{
global $missingTextures;
// missing textures will be notexture for easy recognition in MohRadiant
$material = "notexture";
$materialname = strtoupper($materialname);
switch($materialname)
{
// Editor Shaders
case "TOOLS/TOOLSAREAPORTAL": $material = "common/areaportal"; break;
case "TOOLS/TOOLSBLOCKLIGHT": $material = "common/sunblock"; break;
case "TOOLS/TOOLSCLIP": $material = "common/clip"; break;
case "TOOLS/TOOLSHINT": $material = "common/hint"; break;
case "TOOLS/TOOLSINVISIBLE": $material = "common/vis"; break;
case "TOOLS/TOOLSNODRAW": $material = "common/nodraw"; break;
case "TOOLS/TOOLSPLAYERCLIP": $material = "common/playerclip"; break;
case "TOOLS/TOOLSSKIP": $material = "common/skip"; break;
case "TOOLS/TOOLSSKYBOX": $material = "common/caulksky"; break;
case "TOOLS/TOOLSTRIGGER": $material = "common/trigger"; break;
// Maps Shaders to convert
// de_dust2
// case "CS_HAVANA/WHITE": $material = "notexture"; break;
// case "CS_ITALY/MARKETWALL04": $material = "notexture"; break;
// case "CS_ITALY/MARKETWALL04A": $material = "notexture"; break;
// case "CS_ITALY/MARKETWALL04B": $material = "notexture"; break;
case "DE_DUST/DOOR011": $material = "css/de_dust/door011"; break;
case "DE_DUST/DOOR02": $material = "css/de_dust/door02"; break;
case "DE_DUST/DOOR04": $material = "css/de_dust/door04"; break;
case "DE_DUST/DOOR05": $material = "css/de_dust/door05"; break;
case "DE_DUST/DOOR07": $material = "css/de_dust/door07"; break;
case "DE_DUST/DOOR10": $material = "css/de_dust/door10"; break;
case "DE_DUST/DUCRTLRGSD": $material = "css/de_dust/ducrtlrgsd"; break;
case "DE_DUST/DUCRTLRGTP": $material = "css/de_dust/ducrtlrgtp"; break;
case "DE_DUST/DUMLTRYCRSD2": $material = "css/de_dust/dumltrycrsd2"; break;
case "DE_DUST/DUMLTRYCRTP": $material = "css/de_dust/dumltrycrtp"; break;
case "DE_DUST/DUSANDCRETE": $material = "css/de_dust/dusandcrete"; break;
case "DE_DUST/DUTILE1": $material = "css/de_dust/dutile1"; break;
case "DE_DUST/GROUNDSAND03": $material = "css/de_dust/groundsand03"; break;
case "DE_DUST/GROUNDSAND_BLEND": $material = "css/de_dust/groundsand_blend"; break;
case "DE_DUST/MARKETWALL02": $material = "css/de_dust/marketwall02"; break;
case "DE_DUST/MARKETWALL02B": $material = "css/de_dust/marketwall02b"; break;
case "DE_DUST/MARKETWALL03": $material = "css/de_dust/marketwall03"; break;
case "DE_DUST/PI_RUST": $material = "css/de_dust/pi_rust"; break;
case "DE_DUST/PICRATE1": $material = "css/de_dust/picrate1"; break;
case "DE_DUST/PICRATE2": $material = "css/de_dust/picrate2"; break;
case "DE_DUST/PWTRIM1": $material = "css/de_dust/pwtrim1"; break;
case "DE_DUST/RESIDBWALL01": $material = "css/de_dust/residbwall01"; break;
case "DE_DUST/RESIDBWALL01B": $material = "css/de_dust/residbwall01b"; break;
case "DE_DUST/RESIDBWALL02": $material = "css/de_dust/residbwall02"; break;
case "DE_DUST/RESIDBWALL02A": $material = "css/de_dust/residbwall02a"; break;
case "DE_DUST/RESIDBWALL02B": $material = "css/de_dust/residbwall02b"; break;
case "DE_DUST/RESIDBWALL03": $material = "css/de_dust/residbwall03"; break;
case "DE_DUST/RESIDBWALL03A": $material = "css/de_dust/residbwall03a"; break;
case "DE_DUST/RESIDBWALL03B": $material = "css/de_dust/residbwall03b"; break;
case "DE_DUST/RESIDBWALL04": $material = "css/de_dust/residbwall04"; break;
case "DE_DUST/RESIDBWALL04A": $material = "css/de_dust/residbwall04a"; break;
case "DE_DUST/RESIDBWALL04B": $material = "css/de_dust/residbwall04b"; break;
case "DE_DUST/RESIDWALL01": $material = "css/de_dust/residwall01"; break;
case "DE_DUST/RESIDWALL01A": $material = "css/de_dust/residwall01a"; break;
case "DE_DUST/RESIDWALL01B": $material = "css/de_dust/residwall01b"; break;
case "DE_DUST/RESIDWALL02": $material = "css/de_dust/residwall02"; break;
case "DE_DUST/RESIDWALL04": $material = "css/de_dust/residwall04"; break;
case "DE_DUST/RESIDWALL05B": $material = "css/de_dust/residwall05b"; break;
case "DE_DUST/RESIDWALL06": $material = "css/de_dust/residwall06"; break;
case "DE_DUST/RESIDWALL06A": $material = "css/de_dust/residwall06a"; break;
case "DE_DUST/RESIDWALL06B": $material = "css/de_dust/residwall06b"; break;
case "DE_DUST/ROCKWALL_BLEND": $material = "css/de_dust/rockwall_blend"; break;
case "DE_DUST/SITEBWALL01": $material = "css/de_dust/sitebwall01"; break;
case "DE_DUST/SITEBWALL01A": $material = "css/de_dust/sitebwall01a"; break;
case "DE_DUST/SITEBWALL01B": $material = "css/de_dust/sitebwall01b"; break;
case "DE_DUST/SITEBWALL02": $material = "css/de_dust/sitebwall02"; break;
case "DE_DUST/SITEBWALL03B": $material = "css/de_dust/sitebwall03b"; break;
case "DE_DUST/SITEBWALL05": $material = "css/de_dust/sitebwall05"; break;
case "DE_DUST/SITEBWALL05A": $material = "css/de_dust/sitebwall05a"; break;
case "DE_DUST/SITEBWALL05C": $material = "css/de_dust/sitebwall05c"; break;
case "DE_DUST/SITEBWALL10": $material = "css/de_dust/sitebwall10"; break;
case "DE_DUST/SITEBWALL10A": $material = "css/de_dust/sitebwall10a"; break;
case "DE_DUST/SITEBWALL10B": $material = "css/de_dust/sitebwall10b"; break;
case "DE_DUST/SITEBWALL11": $material = "css/de_dust/sitebwall11"; break;
case "DE_DUST/SITEBWALL11A": $material = "css/de_dust/sitebwall11a"; break;
case "DE_DUST/SITEBWALL11B": $material = "css/de_dust/sitebwall11b"; break;
case "DE_DUST/SITEBWALL12": $material = "css/de_dust/sitebwall12"; break;
case "DE_DUST/SITEBWALL12A": $material = "css/de_dust/sitebwall12a"; break;
case "DE_DUST/SITEBWALL12B": $material = "css/de_dust/sitebwall12b"; break;
case "DE_DUST/SITEBWALL13": $material = "css/de_dust/sitebwall13"; break;
case "DE_DUST/SITEBWALL13A": $material = "css/de_dust/sitebwall13a"; break;
case "DE_DUST/SITEBWALL13B": $material = "css/de_dust/sitebwall13b"; break;
case "DE_DUST/SITEBWALL14": $material = "css/de_dust/sitebwall14"; break;
case "DE_DUST/SITEBWALL14A": $material = "css/de_dust/sitebwall14a"; break;
case "DE_DUST/SITEBWALL14B": $material = "css/de_dust/sitebwall14b"; break;
case "DE_DUST/STONESTEP01": $material = "css/de_dust/stonestep01"; break;
case "DE_DUST/STONESTEP02": $material = "css/de_dust/stonestep02"; break;
case "DE_DUST/STONESTEP03": $material = "css/de_dust/stonestep03"; break;
case "DE_DUST/STONESTEP04": $material = "css/de_dust/stonestep04"; break;
case "DE_DUST/STONEWALL02": $material = "css/de_dust/stonewall02"; break;
case "DE_DUST/STONEWALL02A": $material = "css/de_dust/stonewall02a"; break;
case "DE_DUST/STONEWALL02B": $material = "css/de_dust/stonewall02b"; break;
case "DE_DUST/STONEWALL02C": $material = "css/de_dust/stonewall02c"; break;
case "DE_DUST/TEMPLEWALL02": $material = "css/de_dust/templewall02"; break;
case "DE_DUST/TEMPLEWALL02A": $material = "css/de_dust/templewall02a"; break;
case "DE_DUST/TEMPLEWALL02B": $material = "css/de_dust/templewall02b"; break;
case "DE_DUST/TEMPLEWALL02C": $material = "css/de_dust/templewall02c"; break;
case "DE_DUST/TEMPLEWALL02D": $material = "css/de_dust/templewall02d"; break;
case "DE_DUST/TEMPLEWALL02E": $material = "css/de_dust/templewall02e"; break;
case "DE_DUST/TEMPLEWALL03": $material = "css/de_dust/templewall03"; break;
case "DE_DUST/TEMPLEWALL03B": $material = "css/de_dust/templewall03b"; break;
case "DE_DUST/TEMPLEWALL04": $material = "css/de_dust/templewall04"; break;
case "DE_DUST/TEMPLEWALL04A": $material = "css/de_dust/templewall04a"; break;
case "DE_DUST/TEMPLEWALL04B": $material = "css/de_dust/templewall04b"; break;
case "DE_DUST/TILEFLOOR01": $material = "css/de_dust/tilefloor01"; break;
case "DE_DUST/TILEFLOOR02": $material = "css/de_dust/tilefloor02"; break;
// case "DEV/DEV_MEASURESTAIRS01A": $material = "notexture"; break;
// case "NATURE/ROCKWALL009B": $material = "notexture"; break;
// case "SPRITES/LIGHT_GLOW02_ADD_NOZ": $material = "notexture"; break;
default:
// only print once at end:
$missingTextures[$materialname] = true;
break;
}
return $material;
}
$name = "de_dust2_d";
$map = convertVMF2Map($name . ".vmf");
if (!$map)
die("ERROR: Converting failed.\n");
$textureNames = array_keys($missingTextures);
foreach ($textureNames as $textureName)
echo "WARNING: no texture for $textureName\n" . "<br>\n";
file_put_contents($name.".map", $map);
?>
and here is a video