Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[X3D] Problems with displaying X3D files generated with PHP

232 views
Skip to first unread message

Jörg 'Yadgar' Bleimann

unread,
Mar 29, 2012, 5:04:44 PM3/29/12
to
Hi(gh)!

I just started learning X3D (after having played around with VRML ten
years ago), and as I have some experience with PHP, I already tried to
generate an X3D file this way... the Apache server in fact produces
correct X3D code (when viewed from Mozilla Firefox 11.0), but although
the Octaga Player is installed, it does not display any X3D file
generated via PHP, neither does Firefox. The only way to make the file
visible is to copy the displayed code from Firefox to a new .x3d file
and then start Octaga... what goes wrong here?

See you in Khyberspace!

Yadgar

Now playing: Schattenspiel (Zara-Thustra)

simon

unread,
Apr 1, 2012, 7:20:05 PM4/1/12
to
are you setting the sent content-type to one the types the browser plugin handles?

as a guess> header('Content-type: model/x3d+xml');

but check what types the browser is set to use the 3D plugin for.

also check your server is actually doing it, ie look at the incoming type.
(some servers are lazy at doing anything but the bog standard types.)

Joerg Scheurich aka MUFTI

unread,
Apr 2, 2012, 6:23:33 AM4/2/12
to
> I just started learning X3D (after having played around with VRML ten
> years ago), and as I have some experience with PHP, I already tried to
> generate an X3D file this way... the Apache server in fact produces
> correct X3D code (when viewed from Mozilla Firefox 11.0), but although
> the Octaga Player is installed, it does not display any X3D file
> generated via PHP, neither does Firefox. The only way to make the file
> visible is to copy the displayed code from Firefox to a new .x3d file
> and then start Octaga... what goes wrong here?

Maybe you forgotten to serve the right MIME type in the HTTP-Header.

E.g. http://tecfa.unige.ch/guides/php/examples/vrml-temple/vrml.phps

Starts with

<? Header("Content-type: model/vrml");
echo "#VRML V2.0 utf8";
?>

Similary to this, you would need e.g. for X3DV something like

<? Header("Content-type: model/x3d+vrml");
echo "#X3D V3.0 utf8";
echo "PROFILE Immersive";
?>

so long
MUFTI
--
Thu Jun 21 09:50:15 2001 [emerg] Error while opening the workers
(Apache Logmessage)

Joerg Scheurich aka MUFTI

unread,
Apr 2, 2012, 6:28:25 AM4/2/12
to
> I just started learning X3D (after having played around with VRML ten
> years ago), and as I have some experience with PHP, I already tried to
> generate an X3D file this way... the Apache server in fact produces
> correct X3D code (when viewed from Mozilla Firefox 11.0), but although
> the Octaga Player is installed, it does not display any X3D file
> generated via PHP, neither does Firefox. The only way to make the file
> visible is to copy the displayed code from Firefox to a new .x3d file
> and then start Octaga... what goes wrong here?

Jörg 'Yadgar' Bleimann

unread,
Apr 2, 2012, 6:52:30 AM4/2/12
to
Hi(gh)!

Am 02.04.2012 12:28, schrieb Joerg Scheurich aka MUFTI:

> Maybe you forgotten to serve the right MIME type in the HTTP-Header.
>
> E.g. http://tecfa.unige.ch/guides/php/examples/vrml-temple/vrml.phps
>
> Starts with
>
> <? Header("Content-type: model/vrml");
> echo "#VRML V2.0 utf8";
> ?>
>
> Similary to this, you would need e.g. for X3DV something like
>
> <? Header("Content-type: model/x3d+vrml");
> echo "#X3D V3.0 utf8";
> echo "PROFILE Immersive";
> ?>

I tried your suggestion - but all I got was this:


Loading file: 'http://localhost/x3d/city.php'
X3DParser:: Error at line 0, position 0, 'Error document empty.'
WARNING: Unable to load file: 'http://localhost/x3d/city.php'

Here is my code:

<?php
header ("Content-type:model/x3d+xml");
// require("x3dheader.php");
// x3dheader("city.php", "Yadgar");
echo "#X3D V3.0 utf8";
echo "PROFILE Interchange";

$heights = array(3.5, 7, 11, 9.6, 7.4, 15.6, 12, 8.5, 21.5, 19.7,
14.5, 10.3, 8.1, 5.6, 4.5, 7.4);
?>
<Scene>
<!-- Datenbereich für den Szenengraph -->
<?
for ($i=0; $i<count($heights); $i++)
{
echo '<Transform translation="';
echo 0.5+2*($i%4);
echo " ";
echo $heights[$i]/2;
echo " ";
echo 0.5+2*(integer)($i/4);
echo '">';
echo "\n";
echo " <Shape>\n";
echo ' <Box size="';
echo 1;
echo " ";
echo $heights[$i];
echo " ";
echo 1;
echo '"/>';
echo "\n";
echo " </Shape>\n";
echo "</Transform>\n";
}
?>
</Scene>
</X3D>

simon

unread,
Apr 2, 2012, 6:53:30 PM4/2/12
to
i dont know PHP but why is the "shape" tag inside an echo but not the "scene" or "x3d" tags?

actually you dont have a start "x3d" tag at all.

Jörg 'Yadgar' Bleimann

unread,
Apr 2, 2012, 7:03:06 PM4/2/12
to
Am 02.04.2012 01:20, schrieb simon:
> are you setting the sent content-type to one the types the browser plugin handles?
>
> as a guess> header('Content-type: model/x3d+xml');

I tried this, but see my last post in this thread - Octaga is not able
to load the script!
>
> but check what types the browser is set to use the 3D plugin for.
>

The browser uses Octage for model/x3d, model/x3d+vrml and model/x3d+xml!

> also check your server is actually doing it,

The Apache server in fact generates correct X3D code, as I see in the
page source code window!

Jörg 'Yadgar' Bleimann

unread,
Apr 2, 2012, 7:12:37 PM4/2/12
to
Am 03.04.2012 00:53, schrieb simon:
> i dont know PHP but why is the "shape" tag inside an echo but not the "scene" or "x3d" tags?
>
> actually you dont have a start "x3d" tag at all.

Oh yes, I see... so I completed the code:

<?php
echo "<X3D>";
header ("Content-type:model/x3d");
// require("x3dheader.php");
// x3dheader("city.php", "Yadgar");
echo "#X3D V3.0 utf8";
echo "PROFILE Interchange";

$heights = array(3.5, 7, 11, 9.6, 7.4, 15.6, 12, 8.5, 21.5, 19.7,
14.5, 10.3, 8.1, 5.6, 4.5, 7.4);?>
echo "<Scene>";
for ($i=0; $i<count($heights); $i++)
{
echo '<Transform translation="';
echo 0.5+2*($i%4);
echo " ";
echo $heights[$i]/2;
echo " ";
echo 0.5+2*(integer)($i/4);
echo '">';
echo "\n";
echo " <Shape>\n";
echo ' <Box size="';
echo 1;
echo " ";
echo $heights[$i];
echo " ";
echo 1;
echo '"/>';
echo "\n";
echo " </Shape>\n";
echo "</Transform>\n";
}
echo "</Scene>";
echo "</X3D>";
?>

- and this is what I got:


Warning: Cannot modify header information - headers already sent by
(output started at C:\Programme\xampp\htdocs\x3d\city.php:2) in
C:\Programme\xampp\htdocs\x3d\city.php on line 3
#X3D V3.0 utf8PROFILE Interchange echo ""; for ($i=0; $i'; echo "\n";
echo " \n"; echo ' '; echo "\n"; echo " \n"; echo "\n"; } echo ""; echo
""; ?>

Clueless...

simon

unread,
Apr 3, 2012, 2:01:17 PM4/3/12
to
now you have put the <x3d> start tag before the file id and profile, so this is not valid x3d.

if you where to take the output (page source) copy it to a file with the extension .x3d, then open that in the browser, you would straight away see it didn't work and so isolate the issue to a problem with the x3d code.

also, why not start with a single piece of fixed x3d content that you know works, for testing?

Joerg Scheurich aka MUFTI

unread,
Apr 4, 2012, 5:21:59 AM4/4/12
to
> Oh yes, I see... so I completed the code:

> <?php
> header ("Content-type:model/x3d");

HTTP/Mime Header for X3D/XML

> echo "<X3D>";

Not a typical header for a XML file

> echo "#X3D V3.0 utf8";
> echo "PROFILE Interchange";

Header for a X3DV (X3D/VRML) file

...

> echo "<Scene>";

X3D/XML content

> Warning: Cannot modify header information - headers already sent by
> (output started at C:\Programme\xampp\htdocs\x3d\city.php:2) in
> C:\Programme\xampp\htdocs\x3d\city.php on line 3
> #X3D V3.0 utf8PROFILE Interchange echo ""; for ($i=0; $i'; echo "\n";
> echo " \n"; echo ' '; echo "\n"; echo " \n"; echo "\n"; } echo ""; echo
> ""; ?>

Mixing X3D/VRML and X3D/XML in one file makes no sense.

A typical X3D/XML file usually looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN" "http://www.web3d.org/specifications/x3d-3.2.dtd">
<X3D profile='Interchange'>
<head>
</head>

<Scene>
<Transform >
<Shape >
<Appearance >
<Material >
</Material>
</Appearance>
<Box >
</Box>
</Shape>
</Transform>
</Scene>
</X3D>

so long
MUFTI
--
Portability is for people who cannot write new programs
(Linus Benedict Torvalds)

Jörg 'Yadgar' Bleimann

unread,
Apr 4, 2012, 10:06:43 AM4/4/12
to
Am 04.04.2012 11:21, schrieb Joerg Scheurich aka MUFTI:

> A typical X3D/XML file usually looks like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN" "http://www.web3d.org/specifications/x3d-3.2.dtd">
> <X3D profile='Interchange'>
> <head>
> </head>
>
> <Scene>
> <Transform>
> <Shape>
> <Appearance>
> <Material>
> </Material>
> </Appearance>
> <Box>
> </Box>
> </Shape>
> </Transform>
> </Scene>
> </X3D>
>
> so long
> MUFTI

I tried this, and here is what I've got:

Loading file: 'http://localhost/x3d/city.php'
X3DParser:: Error at line 0, position 0, 'Error document empty.'
WARNING: Unable to load file: 'http://localhost/x3d/city.php'

Not only that the Octaga screen remains dark, when starting it from
Firefox, there is not even any output code to copy to the editor!

The code:

<?php
// echo "<X3D>";
// header ("Content-type:model/x3d+xml");
// require("x3dheader.php");
// x3dheader("city.php", "Yadgar");
/* echo "#X3D V3.0 utf8";
echo "PROFILE Interchange"; */
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN"
"http://www.web3d.org/specifications/x3d-3.2.dtd">';
echo "<X3D profile='Interchange'>";
Probably I'm too stupid to code in X3D/PHP... or I need the *full*
version (30 €) of Octaga Player to get it running!

simon

unread,
Apr 4, 2012, 5:59:29 PM4/4/12
to
> echo "PROFILE Interchange"; */

this line is from x3dv not x3d

> echo "<X3D profile='Interchange'>";

this is how it looks in x3d, you have both formats mixed together
0 new messages