.comment-link {margin-left:.6em;}

PROYECTO UTOPIA

jueves, mayo 04, 2006

oFusion

Ogre dispone de una de las mejores herramientas de exportación que he visto en años: oFusion. Únicamente he encontrado un pequeño problema, y es que el compilador octree de ogre funciona con ficheros en formato scene y oFusion exporta los archivos en formato osm. Pero por suerte tiene fácil solución ya que ambos archivos, que no son mas que una descripción bastante general de la escena, están en formato XML. Gracias a cygwin me preparé un pequeño script en perl para hacer la conversión:


#!/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.

3 Comments:

  • A mi no me engañas julandron ¡eres Victor!

    By Blogger Néstor Nélida, at 26 julio, 2006 07:49  

  • Bueno en realidad no era muy dificil darse cuenta, porque has puesto el nombre despues de copyright 2006... jejeje, pero lo hubiera sabido igual!

    By Blogger Néstor Nélida, at 26 julio, 2006 07:52  

  • Que tal Somos Forging Sounds Productions , realizamos Musica y SFX de cualquier tipo , aqui les dejo un link a nuestra pagina www.forgingsounds.com.ar , ahi encontraran algunos demos y curriculums un saludo

    Christian Fernando Perucchi

    By Blogger Unknown, at 13 agosto, 2007 06:48  

Publicar un comentario

<< Home