oFusion
#!/usr/bin/env perl
# The author(s) have made the contents of this file
# available under a CC-GNU-GPL license:
#
# http://creativecommons.org/licenses/GPL/2.0/
#
# A copy of the full license can be found as part of this
# distribution in the file COPYING.
#
# You may use this software in accordance with the
# terms of this license. You agree that you are solely
# responsible for your use of this software and you
# represent and warrant to the author(s) that your use
# of this software will comply with the CC-GNU-GPL.
#
# Copyright 2006, Victor Marzo (samsaga2@gmail.com)
#
# USE: osm2scene.pl < demo.osm > demo.scene
use XML::Simple;
use XML::Writer;
use Data::Dumper;
my $xml_osm = XMLin('-');
my $xml_scene = new XML::Writer(DATA_MODE => true, DATA_INDENT => 4);
$xml_scene->startTag('scene', 'formatVersion' => '0.0');
my $id = 0;
for my $entities ($xml_osm->{entities}) {
$xml_scene->startTag('nodes');
for my $entity_name (keys %{$entities->{entity}}) {
my $entity = $entities->{entity}->{$entity_name};
$id++;
$xml_scene->startTag('node',
'name' => $entity_name,
'id' => $id);
$xml_scene->emptyTag('position',
'x' => $entity->{position}->{x},
'y' => $entity->{position}->{y},
'z' => $entity->{position}->{z});
$xml_scene->emptyTag('rotation',
'qx' => $entity->{rotation}->{x},
'qy' => $entity->{rotation}->{y},
'qz' => $entity->{rotation}->{z},
'qw' => $entity->{rotation}->{w});
$xml_scene->emptyTag('scale',
'x' => $entity->{scale}->{x},
'y' => $entity->{scale}->{y},
'z' => $entity->{scale}->{z});
$xml_scene->emptyTag('entity',
'name' => $entity_name,
'id' => $id,
'meshFile' => $entity->{filename},
'castShadows' => $entity->{CastShadows});
$xml_scene->endTag('node');
}
$xml_scene->endTag('nodes');
}
$xml_scene->endTag('scene');
Tendréis que instalaros los modules XML::Simple y XML::Writer pero usando el CPAN del perl no deberíais tener ningún problema.