dimanche 21 octobre 2007

COLLADA Import

-





The second step of my work consisted in importing some 3D data in PostGIS. I decided to import data from the Collada format. Collada (COLLAborative Design Asset) is a 3D format which was initially developed by Sony. Indeed, it's the official format of the Playstation 3. Its aim is to be an exchange format. Most of 3d design software such as Blender, Maya, 3DSMax, can export collada. It is also used by GoogleEarth to represent 3d models with informations about colors or textures. In KMZ archives, you can find a kml file or a collada file.
So I developed a command which creates a SQL file from a collada file named collada2pgsql.


Here is the help of this command:









__________________________________________________________

USAGE: collada2pgsql [options] colladafile [schema.]table

OPTIONS:
-s
Set the SRID field. If not specified it defaults to -1.
-d
Drops the table, then recreates it
with current collada file data.
-c
Appends shape file into current ta
ble, must be exactly the same table schema.
!!!: The options -d and -a are mutually exclusive.

-g
Specify the name of the geometry column (mostly useful in append mode).
-t
Import collada file data with informations about textures.
-dir
Specify the directory where the textures will be stored.
default: '/tmp/textures'

-I
Create a GiST index on the geometry column.
-?
Display this help screen.


__________________________________________________________










If the -g option is not given, the name of the geometry column will be 'the_geom'.


If the -t option is given, the import of the model will be done with information about textures: The user can specify the directory with -dir option, where he wants the textures to be stored (default : /tmp/textures). There also will be two others columns named 'the_texture' which contains the absolute path (or url) of a picture, and 'coorduv' which is a 2D geometry column giving relations between faces and textures.









EXAMPLE:




Let's see an example with the collada file 'pompidou.dae' providing from a GoogleEarth KMZ archive. You can find a lot of these kind of archives here.
Here is the command I have to execute if I want to import it with textures, stored in /home/textures/pompidou and if I want a give the SRID 27582 to my geometry:




_______________________________________________________________________________________________

collada2pgsql -t -dir /home/mleserre/Desktop/textures/pompidou -s 27582 pompidou.dae mytable
_______________________________________________________________________________________________



by executing this command, you'll see this in your window:


_____________________________________

COLLADA
version 1.4.1
building sql file...
------------------------------
file pompidou.sql has been created
_____________________________________






You must execute it from the directory where the collada file stands.


If you don't precise the target directory for the textures , they will be stored in /tmp/textures:


_________________________________________________

collada2pgsql -t -s 27582 pompidou.dae mytable
_________________________________________________





Here is the result, in a SQL file named pompidou.sql:





Now, we just have to execute the following command where MABASE is the name of the database in which I want to import my geometries :


_________________________________________

psql -U postgres MABASE < pompidou.sql
_________________________________________











If you want to see what stands in mytable, just try this command, after connecting to MABASE:



_____________________________________________________________________________

SELECT summary(the_geom), the_texture, summary(coorduv) from mytable;

_____________________________________________________________________________




and you'll see that in your window:













-

samedi 6 octobre 2007

FOSS4G 2007

-





This work has been exposed during the FOSS4G 2007. The FOSS4G (Free & Open Source Software For Geospatial) is an annual international conference where all the geospatial open source community can meet. This year, it took place in Victoria, in British Columbia state CANADA, the last week of september.

The presentation was made by Olivier Courtin from Camptocamp, and the slides of the presentation are available here.

It talks a lot about web applications using X3D, but unfortunatly, because X3D plugins don't seems to be enough matured, we decided to reorient the work on PostGIS 3D export and the texture problematic of 3D models.
The description of the presentation is availble here.





-