Login   Register  
PHP Classes
elePHPant
Icontem

File: main.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Charly Pache  >  VRML  >  main.php  >  Download  
File: main.php
Role: Example script
Content type: text/plain
Description: Show the use of the classes
Class: VRML
Provides basic classes to generate VRML files
Author: By
Last change: Author
Date: 2002-09-17 21:00
Size: 2,779 bytes
 

Contents

Class file image Download
<?php

// +----------------------------------------------------------------------+
// | Author: Charly Pache <3d@pache.ch>                                   |
// +----------------------------------------------------------------------+

require_once("classes.php");
$v = new Vrml("\"Titre\"",array("\"Infos 1\"","\"Infos 2\""));

$b1 = new Box("3 5 2");
$v->addNode($b1);

$m1 = new Material("0.3 0.5 0.8","0.2","0.0 0.0 0.0 ","0.0 0.0 0.0 ","0.2","0");
$a1 = new Appearance($m1);
$s1 = new Shape($a1,$b1);
$v->addNode($s1);

// test avec un transform :

$m2 = new Material("0.7 0.2 0.2","0.2","0.0 0.0 0.0 ","0.0 0.0 0.0 ","0.2","0.4");
$a2 = new Appearance($m2);
$b2 = new Box("4 4 4");
$s2 = new Shape($a2,$b2);

$sph1 = new Sphere("3");
$s3 = new Shape($a2,$sph1);

$m2->setTransparency("0");
$a3 = new Appearance($m2);
$cyl1 = new Cylinder("0.1","7");
$s4 = new Shape($a3,$cyl1);

$t1 = new Transform(array($s2,$s3));
$t1->setTranslation("-6 0 0");

$t2 = new Transform(array($s1));
$t2->setTranslation("6 0 0");

$t3 = new Transform(array($s4));
$t3->setTranslation("6 -3 0");

$v->addNode(array($t1,$t2,$t3));

$v->generate();

// links :

$page .= "<a name=top>
 Test PHP VRML generator :
 <br> <br>
 <a href=view.php target=_blank>Look at the result</a>
 <br> <br>
 <a href=#sourcemain>Look at the source code of the implementation</a>
  <br> <br>
  <a href=#sourceclasses>Look at the source code of the classes</a>
  <br> <br>
  <a href=#vrmlcode>Look at the generated vrml source code</a>
  <br> <br>
 Useful links :
 <br>
 <a href=http://www.lighthouse3d.com/vrml/tutorial target=_blank>tutorial</a>
 <br>
 <a href=http://www.vrml.org/technicalinfo/specifications/vrml97/part1/nodesRef.html#Material target=_blank>vrml97 reference</a>   
 <br>
 <a href=vrml97.hlp>reference vrml97 [.hlp]</a>
  <br>
 <a href=http://web3d.vapourtech.com/ target=_blank>tutorial cool</a>
 <br> <br>
"
;
$page .= "<a name=sourcemain><br><a href=#top>top</a><br>Source code of the implementation :<br>";
// source main :
ob_start();
    
show_source"main.php" );
    
$part ob_get_contents();
    
ob_end_clean();
    
$page .= ereg_replace"<br />" ,
"</li><li>" $part );

$page .= "<a name=sourceclasses><br><a href=#top>top</a><br>Source code of the classes :<br>";
// source classes :
ob_start();
    
show_source"classes.php" );
    
$part ob_get_contents();
    
ob_end_clean();
    
$page .= ereg_replace"<br />" ,
"</li><li>" $part );

$page .= "<a name=vrmlcode><br><a href=#top>top</a><br>Generated vrml source code : <br>";
// source vrml :
ob_start();
    
show_source"test.wrl" );
    
$part ob_get_contents();
    
ob_end_clean();
    
$page .= ereg_replace"<br />" ,
"</li><li>" $part );

echo 
$page;
?>