diff --git a/src/core/LoardObj.php b/src/core/LoardObj.php new file mode 100644 index 0000000..0d7c754 --- /dev/null +++ b/src/core/LoardObj.php @@ -0,0 +1,139 @@ +file = $objFile; + $this->flipYZ = $flipYZ; + } + + public function toPly() + { + return $this->plyFile; + } + + /** + * + */ + public function readObj() + { + $handle = null; + $line = true; + + + if( !file_exists($this->objFile) ) + { + throw new \Exception($this->objFile." file does not exist"); + } + else + { + $handle = fopen($this->file,'r'); + } + + + if( !$handle ) + { + throw new \Exception("File ".$this->objFile." open failed"); + } + else + { + + fseek($handle, 0); + while( !feof($handle) ) // 读取所有的 顶点坐标、UV坐标、顶点法线,并存入到相应的数组 + { + $line = fgets( $handle ); + $line = ltrim( $line ); + if( $line[0] == '#' ) continue; + + switch( explode(' ', $line)[0] ) + { + case 'v': + $this->vertexs[] = $line; + + case 'vn': + $this->normals[] = $line; + + case 'vt': + $this->textureUV[] = $line; + } + } + + fseek($handle, 0); + while( !feof($handle) ) // 读取 顶点坐标、UV坐标、顶点法线,并存入到相应的数组 + { + $line = fgets( $handle ); + $line = ltrim( $line ); + if( $line[0] == '#' ) continue; + + if ( explode(' ', $line)[0] == 'o' ) + } + + } + + + + + + + } + +}