private function createGroupFromText($text, $materials = array(), $vertex_count = 0, $normal_count = 0, $texture_count = 0) { $lines = explode(PHP_EOL, $text); $this->vertex_count = $vertex_count; $this->normal_count = $normal_count; $this->texture_count = $texture_count; $mesh_text = ''; foreach ($lines as $line) { $line = trim($line); if (strpos($line, 'g ') === 0) { $this->name = trim(substr($line, 2)); } elseif ($line == 'g') { $this->name = 'default'; } elseif (strpos($line, 'usemtl ') === 0) { // Start of a new mesh. // Store the old mesh first. if (!empty($mesh_text)) { $mesh = new Mesh($mesh_text, $materials); if ($error = $mesh->getError()) { $this->error = $error; return; } $this->meshes[] = $mesh; } $mesh_text = $line; } elseif (!empty($line) && strpos($line, '#') !== 0) { $mesh_text .= PHP_EOL . $line; } } if (!empty($mesh_text)) { $mesh = new Mesh($mesh_text, $materials); if ($error = $mesh->getError()) { $this->error = $error; return; } $this->meshes[] = $mesh; } }
Author: Jared Novack + Upstatement Version: 0.0.1 Author URI: http://upstatement.com/ */ class Mesh { public static function autoload() { require_once 'lib/mesh-object.php'; require_once 'lib/mesh-post.php'; require_once 'lib/mesh-image.php'; require_once 'lib/mesh-user.php'; require_once 'lib/mesh-term.php'; require_once 'lib/mesh-json-loader.php'; } public static function add_actions() { add_action('wp_login', array('Mesh', 'load_json')); } public static function load_json() { $file = trailingslashit(get_stylesheet_directory()) . 'mesh.json'; $file = apply_filters('mesh/load_json', $file); if (file_exists($file)) { $loader = new Mesh\JSON_Loader($file); } } } Mesh::autoload(); Mesh::add_actions();