Source for file 3dsChunks.php
Documentation is available at 3dsChunks.php
const EDIT3DS = 0x3D3D; // this is the start of the editor config
const KEYF3DS = 0xB000; // this is the start of the keyframer config
//>------ sub defines of EDIT3DS
const EDIT_MATERIAL = 0xAFFF;
const EDIT_CONFIG1 = 0x0100;
const EDIT_CONFIG2 = 0x3E3D;
const EDIT_VIEW_P1 = 0x7012;
const EDIT_VIEW_P2 = 0x7011;
const EDIT_VIEW_P3 = 0x7020;
const EDIT_VIEW1 = 0x7001;
const EDIT_BACKGR = 0x1200;
const EDIT_AMBIENT = 0x2100;
const EDIT_OBJECT = 0x4000;
//>------ sub defines of EDIT_OBJECT
const OBJ_TRIMESH = 0x4100;
const OBJ_LIGHT = 0x4600;
const OBJ_CAMERA = 0x4700;
const OBJ_UNKNWN01 = 0x4010;
const OBJ_UNKNWN02 = 0x4012;
//>------ sub defines of OBJ_CAMERA
const CAM_UNKNWN01 = 0x4710;
const CAM_UNKNWN02 = 0x4720;
//>------ sub defines of OBJ_LIGHT
const LIT_UNKNWN01 = 0x465A;
//>------ sub defines of OBJ_TRIMESH
const TRI_VERTEXL = 0x4110;
const TRI_FACEL2 = 0x4111;
const TRI_FACEL1 = 0x4120;
const TRI_SMOOTH = 0x4150;
const TRI_LOCAL = 0x4160;
const TRI_VISIBLE = 0x4165;
//>>------ sub defs of KEYF3DS
const KEYF_UNKNWN01 = 0xB009;
const KEYF_UNKNWN02 = 0xB00A;
const KEYF_FRAMES = 0xB008;
const KEYF_OBJDES = 0xB002;
//>>------ these define the different color chunk types
//>>------ defines for viewport chunks
$this->type = (int) $type;
$length = $this->size - 6;
while ($position <= $length) {
$position += $chunkLength;
public function debug() {
protected function getWord($string) {
return (ord($string{1 }) << 8 ) | ord($string{0 });
return ord($string{0 }) | (ord($string{1 }) << 8 ) | (ord($string{2 }) << 16 ) | (ord($string{3 }) << 32 );
return (ord($string{0 }) << 8 ) | ord($string{1 });
// Convert C-Float to PHP-Float
return (ord($string{3 }) & 128 ? -1 : 1 ) * (1 + (float) (ord($string{2 }) & 127 ) / 127 + (float) (ord($string{1 })) / 256 / 127 + (float) (ord($string{0 })) / 256 / 256 / 127 ) * pow(2. , ((((ord($string{3 }) & 127 ) << 1 ) | (ord($string{2 }) >> 7 )) - 127 ));
foreach ($this->chunks as $chunk) if ($chunk->getType () === $type) return $chunk;
foreach ($this->chunks as $chunk) if ($chunk->getType () === $type) $chunks[] = $chunk;
parent ::__construct ($type, $content);
while ((ord($this->content{$i}) !== 0 ) && ($i < $this->size )) $this->name .= $this->content {$i++ };
$this->content = substr($this->content , $i + 1 );
public function readChunks(Image_3D_Object_3ds $k3ds)
$subtype = $this->getWord (substr($this->content , 0 , 2 ));
$subcontent = substr($this->content , 6 );
$object = $k3ds->addObject ($this->name );
public function debug() {
echo 'Object: ', $this->name , "\n";
public function __construct($type, $content, $object) {
parent ::__construct ($type, $content);
foreach ($vertexlists as $vertexlist) {
$points = $vertexlist->getContent ();
$count = $this->getWord (substr($points, 0 , 2 ));
for ($i = 0; $i < $count; $i++ ) {
$x = $this->getFloat (substr($points, 0 , 4 ));
$y = $this->getFloat (substr($points, 4 , 4 ));
$z = $this->getFloat (substr($points, 8 , 4 ));
$this->object->newPoint ($x, $y, $z);
$points = substr($points, 12 );
foreach ($facelists as $facelist) {
$faces = $facelist->getContent ();
$count = $this->getWord (substr($faces, 0 , 2 ));
for ($i = 0; $i < $count; $i++ ) {
$p1 = $this->getWord (substr($faces, 0 , 2 ));
$p2 = $this->getWord (substr($faces, 2 , 2 ));
$p3 = $this->getWord (substr($faces, 4 , 2 ));
$this->object->newPolygon ($p1, $p2, $p3);
foreach ($translists as $translist) {
$trans = $translist->getContent ();
echo "Trans: " . strlen($trans), "\n";
public function debug() {
printf("Trimesh with %d (0x%04x) points - Pointsize: %.2f\n", $this->pointCount, $this->pointCount, $this->size / $this->pointCount);
// echo "New Point: $x, $y, $z -> ", count($this->_points), "\n";
// printf("ERROR: Unknown point (%d, %d, %d of %d)\n", $p1, $p2, $p3, count($this->_points) - 1);
// echo "New Polygon: $p1, $p2, $p3 -> ", count($this->_polygones), "\n";
public function debug() {
Documentation generated on Mon, 11 Mar 2019 15:48:13 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|