This commit is contained in:
Harry-zklcdc 2019-09-10 19:15:01 +08:00
parent 970dcd58d0
commit 2bc511229b
11 changed files with 0 additions and 364 deletions

View File

@ -1,33 +0,0 @@
<?php
require '../tools/modelList.php';
require '../tools/modelTextures.php';
$modelList = new modelList();
$modelTextures = new modelTextures();
$modelList = $modelList->get_list();
$modelList = $modelList['models'];
foreach ($modelList as $modelName) {
if (!is_array($modelName) && file_exists('../model/'.$modelName.'/textures.cache')) {
$textures = $texturesNew = array();
$modelTexturesList = $modelTextures->get_list($modelName);
$modelNameTextures = $modelTextures->get_textures($modelName);
if (is_array($modelTexturesList)) foreach ($modelTexturesList['textures'] as $v) $textures[] = str_replace('\/', '/', json_encode($v));
if (is_array($modelNameTextures)) foreach ($modelNameTextures as $v) $texturesNew[] = str_replace('\/', '/', json_encode($v));
$texturesDiff = array_diff($texturesNew, $textures);
if (empty($textures)) continue; elseif (empty($texturesDiff)) {
echo '<p>'.$modelName.' / textures.cache / No Update.</p>';
} else {
foreach (array_values(array_unique(array_merge($textures, $texturesNew))) as $v) $texturesMerge[] = json_decode($v, 1);
file_put_contents('../model/'.$modelName.'/textures.cache', str_replace('\/', '/', json_encode($texturesMerge)));
echo '<p>'.$modelName.' / textures.cache / Updated.</p>';
}
}
elseif (is_array($modelName)) continue;
elseif ($modelTextures->get_list($modelName)) echo '<p>'.$modelName.' / textures.cache / Created.</p>';
}

View File

@ -1,54 +0,0 @@
<?php
isset($_GET['id']) ? $id = $_GET['id'] : exit('error');
require '../tools/modelList.php';
require '../tools/modelTextures.php';
require '../tools/jsonCompatible.php';
$modelList = new modelList();
$modelTextures = new modelTextures();
$jsonCompatible = new jsonCompatible();
$id = explode('-', $id);
$modelId = (int)$id[0];
$modelTexturesId = isset($id[1]) ? (int)$id[1] : 0;
$modelName = $modelList->id_to_name($modelId);
if (is_array($modelName)) {
$modelName = $modelTexturesId > 0 ? $modelName[$modelTexturesId-1] : $modelName[0];
$json = json_decode(file_get_contents('../model/'.$modelName.'/index.json'), 1);
} else {
$json = json_decode(file_get_contents('../model/'.$modelName.'/index.json'), 1);
if ($modelTexturesId > 0) {
$modelTexturesName = $modelTextures->get_name($modelName, $modelTexturesId);
if (isset($modelTexturesName)) $json['textures'] = is_array($modelTexturesName) ? $modelTexturesName : array($modelTexturesName);
}
}
$textures = json_encode($json['textures']);
$textures = str_replace('texture', '../model/'.$modelName.'/texture', $textures);
$textures = json_decode($textures, 1);
$json['textures'] = $textures;
$json['model'] = '../model/'.$modelName.'/'.$json['model'];
if (isset($json['pose'])) $json['pose'] = '../model/'.$modelName.'/'.$json['pose'];
if (isset($json['physics'])) $json['physics'] = '../model/'.$modelName.'/'.$json['physics'];
if (isset($json['motions'])) {
$motions = json_encode($json['motions']);
$motions = str_replace('sounds', '../model/'.$modelName.'/sounds', $motions);
$motions = str_replace('motions', '../model/'.$modelName.'/motions', $motions);
$motions = json_decode($motions, 1);
$json['motions'] = $motions;
}
if (isset($json['expressions'])) {
$expressions = json_encode($json['expressions']);
$expressions = str_replace('expressions', '../model/'.$modelName.'/expressions', $expressions);
$expressions = json_decode($expressions, 1);
$json['expressions'] = $expressions;
}
header("Content-type: application/json");
echo $jsonCompatible->json_encode($json);

View File

@ -1,44 +0,0 @@
{
"models": [
"Potion-Maker/Pio",
"Potion-Maker/Tia",
"bilibili-live/22",
"bilibili-live/33",
[
"ShizukuTalk/shizuku-48",
"ShizukuTalk/shizuku-pajama"
],
[
"HyperdimensionNeptunia/neptune_classic",
"HyperdimensionNeptunia/nepnep",
"HyperdimensionNeptunia/neptune_santa",
"HyperdimensionNeptunia/nepmaid",
"HyperdimensionNeptunia/nepswim",
"HyperdimensionNeptunia/noir_classic",
"HyperdimensionNeptunia/noir",
"HyperdimensionNeptunia/noir_santa",
"HyperdimensionNeptunia/noireswim",
"HyperdimensionNeptunia/blanc_classic",
"HyperdimensionNeptunia/blanc_normal",
"HyperdimensionNeptunia/blanc_swimwear",
"HyperdimensionNeptunia/vert_classic",
"HyperdimensionNeptunia/vert_normal",
"HyperdimensionNeptunia/vert_swimwear",
"HyperdimensionNeptunia/nepgear",
"HyperdimensionNeptunia/nepgear_extra",
"HyperdimensionNeptunia/nepgearswim",
"HyperdimensionNeptunia/histoire",
"HyperdimensionNeptunia/histoirenohover"
],
"KantaiCollection/murakumo"
],
"messages": [
"来自 Potion Maker 的 Pio 酱 ~",
"来自 Potion Maker 的 Tia 酱 ~",
"来自 Bilibili Live 的 22 哦 ~",
"来自 Bilibili Live 的 33 的说",
"Shizuku Talk !这里是 Shizuku ~",
"Nep! Nep! 超次元游戏:海王星 系列",
"艦隊これくしょん / 叢雲(むらくも)"
]
}

View File

@ -1,23 +0,0 @@
<?php
isset($_GET['id']) ? $modelId = (int)$_GET['id'] : exit('error');
require '../tools/modelList.php';
require '../tools/jsonCompatible.php';
$modelList = new modelList();
$jsonCompatible = new jsonCompatible();
$modelList = $modelList->get_list();
$modelRandNewId = true;
while ($modelRandNewId) {
$modelRandId = rand(0, count($modelList['models'])-1)+1;
$modelRandNewId = $modelRandId == $modelId ? true : false;
}
header("Content-type: application/json");
echo $jsonCompatible->json_encode(array('model' => array(
'id' => $modelRandId,
'name' => $modelList['models'][$modelRandId-1],
'message' => $modelList['messages'][$modelRandId-1]
)));

View File

@ -1,35 +0,0 @@
<?php
isset($_GET['id']) ? $id = $_GET['id'] : exit('error');
require '../tools/modelList.php';
require '../tools/modelTextures.php';
require '../tools/jsonCompatible.php';
$modelList = new modelList();
$modelTextures = new modelTextures();
$jsonCompatible = new jsonCompatible();
$id = explode('-', $id);
$modelId = (int)$id[0];
$modelTexturesId = isset($id[1]) ? (int)$id[1] : false;
$modelName = $modelList->id_to_name($modelId);
$modelTexturesList = is_array($modelName) ? array('textures' => $modelName) : $modelTextures->get_list($modelName);
if (count($modelTexturesList['textures']) <= 1) {
$modelTexturesNewId = 1;
} else {
$modelTexturesGenNewId = true;
if ($modelTexturesId == 0) $modelTexturesId = 1;
while ($modelTexturesGenNewId) {
$modelTexturesNewId = rand(0, count($modelTexturesList['textures'])-1)+1;
$modelTexturesGenNewId = $modelTexturesNewId == $modelTexturesId ? true : false;
}
}
header("Content-type: application/json");
echo $jsonCompatible->json_encode(array('textures' => array(
'id' => $modelTexturesNewId,
'name' => $modelTexturesList['textures'][$modelTexturesNewId-1],
'model' => is_array($modelName) ? $modelName[$modelTexturesNewId-1] : $modelName
)));

View File

@ -1,19 +0,0 @@
<?php
isset($_GET['id']) ? $modelId = (int)$_GET['id'] : exit('error');
require '../tools/modelList.php';
require '../tools/jsonCompatible.php';
$modelList = new modelList();
$jsonCompatible = new jsonCompatible();
$modelList = $modelList->get_list();
$modelSwitchId = $modelId + 1;
if (!isset($modelList['models'][$modelSwitchId-1])) $modelSwitchId = 1;
header("Content-type: application/json");
echo $jsonCompatible->json_encode(array('model' => array(
'id' => $modelSwitchId,
'name' => $modelList['models'][$modelSwitchId-1],
'message' => $modelList['messages'][$modelSwitchId-1]
)));

View File

@ -1,26 +0,0 @@
<?php
isset($_GET['id']) ? $id = $_GET['id'] : exit('error');
require '../tools/modelList.php';
require '../tools/modelTextures.php';
require '../tools/jsonCompatible.php';
$modelList = new modelList();
$modelTextures = new modelTextures();
$jsonCompatible = new jsonCompatible();
$id = explode('-', $id);
$modelId = (int)$id[0];
$modelTexturesId = isset($id[1]) ? (int)$id[1] : 0;
$modelName = $modelList->id_to_name($modelId);
$modelTexturesList = is_array($modelName) ? array('textures' => $modelName) : $modelTextures->get_list($modelName);
$modelTexturesNewId = $modelTexturesId == 0 ? 2 : $modelTexturesId + 1;
if (!isset($modelTexturesList['textures'][$modelTexturesNewId-1])) $modelTexturesNewId = 1;
header("Content-type: application/json");
echo $jsonCompatible->json_encode(array('textures' => array(
'id' => $modelTexturesNewId,
'name' => $modelTexturesList['textures'][$modelTexturesNewId-1],
'model' => is_array($modelName) ? $modelName[$modelTexturesNewId-1] : $modelName
)));

View File

@ -1,49 +0,0 @@
<?php class jsonCompatible {
public function json_encode($json) {
if (version_compare(PHP_VERSION,'5.4.0','<')) {
$json = json_encode($json);
$json = str_replace('\/', '/', $json);
$json = preg_replace_callback("/\\\u([0-9a-f]{4})/i", array($this,'json_preg_replace'), $json);
return $this->json_pretty_print($json, ' ');
} else return json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
protected function json_preg_replace($matchs) {
return iconv('UCS-2BE', 'UTF-8', pack('H4', $matchs[1]));
}
protected function json_pretty_print($json, $indent = "\t") {
$result = '';
$indentCount = 0;
$inString = false;
$len = strlen($json);
for ($c = 0; $c < $len; $c++) {
$char = $json[$c];
if ($char === '{' || $char === '[') {
if (!$inString) {
$indentCount++;
if ($char === '[' && $json[$c+1] == "]") $result .= $char . PHP_EOL;
elseif ($char === '{' && $json[$c+1] == "}") $result .= $char . PHP_EOL;
else $result .= $char . PHP_EOL . str_repeat($indent, $indentCount);
} else $result .= $char;
} elseif ($char === '}' || $char === ']') {
if (!$inString) {
$indentCount--;
$result .= PHP_EOL . str_repeat($indent, $indentCount) . $char;
} else $result .= $char;
} elseif ($char === ',') {
if (!$inString) $result .= ',' . PHP_EOL . str_repeat($indent, $indentCount);
else $result .= $char;
} elseif ($char === ':') {
if (!$inString) $result .= ': ';
else $result .= $char;
} elseif ($char === '"') {
if (($c > 0 && $json[$c - 1] !== '\\') || ($c > 1 && $json[$c - 2].$json[$c - 1] === '\\\\')) $inString = !$inString;
$result .= $char;
} else {
$result .= $char;
}
}
return $result;
}
}

View File

@ -1,21 +0,0 @@
<?php class modelList {
/* 获取模型列表 */
function get_list() {
return json_decode(file_get_contents('../model_list.json'), 1);
}
/* 获取模组名称 */
function id_to_name($id) {
$list = self::get_list();
return $list['models'][(int)$id-1];
}
/* 转换模型名称 */
function name_to_id($name) {
$list = self::get_list();
$id = array_search($name, $list['models']);
return is_numeric($id) ? $id + 1 : false;
}
}

View File

@ -1,45 +0,0 @@
<?php class modelTextures {
/* 获取材质名称 */
function get_name($modelName, $id) {
$list = self::get_list($modelName);
return $list['textures'][(int)$id-1];
}
/* 获取列表缓存 */
function get_list($modelName) {
if (file_exists('../model/'.$modelName.'/textures.cache')) {
$textures = json_decode(file_get_contents('../model/'.$modelName.'/textures.cache'), true);
} else {
$textures = self::get_textures($modelName);
if (!empty($textures)) file_put_contents('../model/'.$modelName.'/textures.cache', str_replace('\/', '/', json_encode($textures)));
} return isset($textures) ? array('textures' => $textures) : false;
}
/* 获取材质列表 */
function get_textures($modelName) {
if (file_exists('../model/'.$modelName.'/textures_order.json')) { // 读取材质组合规则
$tmp = array(); foreach (json_decode(file_get_contents('../model/'.$modelName.'/textures_order.json'), 1) as $k => $v) {
$tmp2 = array(); foreach ($v as $textures_dir) {
$tmp3 = array(); foreach (glob('../model/'.$modelName.'/'.$textures_dir.'/*') as $n => $m)
$tmp3['merge'.$n] = str_replace('../model/'.$modelName.'/', '', $m);
$tmp2 = array_merge_recursive($tmp2, $tmp3); }
foreach ($tmp2 as $v4) $tmp4[$k][] = str_replace('\/', '/', json_encode($v4));
$tmp = self::array_exhaustive($tmp, $tmp4[$k]); }
foreach ($tmp as $v) $textures[] = json_decode('['.$v.']', 1); return $textures;
} else {
foreach (glob('../model/'.$modelName.'/textures/*') as $v)
$textures[] = str_replace('../model/'.$modelName.'/', '', $v);
return empty($textures) ? null : $textures;
}
}
/* 数组穷举合并 */
function array_exhaustive($arr1, $arr2) {
foreach ($arr2 as $k => $v) {
if (empty($arr1)) $out[] = $v;
else foreach ($arr1 as $k2 => $v2) $out[] = str_replace('"["', '","', str_replace('"]"', '","', $v2.$v));
} return $out;
}
}

View File

@ -1,15 +0,0 @@
<?php
/* 批量转换 文件名为 小写英文 + 使用 连字符-替换-空格 */
$path = '../model/test-path';//<--- 在此输入目录路径,并执行本面页
/*-----------------------------------------------------------------*/
$path = str_replace('\\', '/', $path);
if (substr($path, -1) != '/') $path = $path . '/';
/*-----------------------------------------------------------------*/
foreach ( glob($path.'*') as $file ) {
$new_filename = str_replace(' ', '-', strtolower($file));
rename($file, $new_name); echo $file.' -> '.$new_name." ok. \n";
}
/*-----------------------------------------------------------------*/