COLLADA Import



WHY?

This step applies the import of 3D data in PostGIS. The data will be import from COLLADA format.
COLLADA (COLLAboration Design Asset) is a 3D format which initially developed by Sony®. In fact, it's the official format of the PlayStation 3®.
The aim of this format is to be an EXCHANGE format. Indeed, most of 3D design software such as Blender, Maya or 3DSMAX can export COLLADA. It is also used by Google Earth to represent3D models with informations about colors or textures. Furthermore, in KMZ archives, you can find a kml file or a COLLADA file.

That's why a command which creates a SQL file from COLLADA file, named collada2pgsql has been developed.


MANUAL

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 table, 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.
____________________________________________________________________________________________________

Beware :

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.


EXAMPLES :

Let's see an example with the collada file 'Dubai.dae' providing from a GoogleEarth KMZ archive (3DVIA). 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/acarme/texture/Dubai and if I want a give the SRID 27582 to my geometry :

____________________________________________________________________________________________________

collada2pgsql -t -dir /home/acarme/texture/Dubai -s 27582 /home/acarme/Dubai/Dubai.dae mytable

_______________________________________________________________________________________________
_____


Beware, this table (mytable) mustn't exist : because it will be created by the SQL file.

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

____________________________________________________________________________________________________

COLLADA
version 1.4.1
building sql file...
--------------------
file /home/acarme/Dubai/Dubai.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 /home/acarme/Dubai/Dubai.dae mytable

____________________________________________________________________________________________________



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

















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

____________________________________________________________________________________________________

psql -U postgres MA_BASE < /home/acarme/Dubai/Dubai.sql
____________________________________________________________________________________________________


You can see on your window :

____________________________________________________________________________________________________

BEGIN
CREATE TABLE
addgeometrycolumn
----------------------------------------------------------
public.mytable.the_geom SRID:27582 TYPE:GEOMETRY DIMS:3

(1 row)

ALTER TABLE
addgeometrycolumn
------------------------------------------------------
public.mytable.coorduv SRID:-1 TYPE:GEOMETRY DIMS:2

(1 row)

INSERT 0 1
INSERT 0 1

INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
...
____________________________________________________________________________________________________


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

____________________________________________________________________________________________________

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

____________________________________________________________________________________________________


and you'll be able to see that in your window :