meta-data

that’s when tian becomes protian

Archive for the ‘visualization’ Category

Output wave isosurface in whatever format

without comments

how to output wave profile in whatever format so that arcGIS and maya and Terragen can display?

in maya and Terragen, it can serve as a displacement map? but then that requires extracting only the land potion of the whole SWAN domain.

What about arcGIS?

Ok, now start converting SWAN output to STL then VRML. first, extract only positive Hsign points and triangulate them.

The output of this procedure is two files: 1. triangles in adcirc format. 2. triangles in stl format.

SWAN outputted data is written in layout 4 format: (from lower-left to upper-right, row by row)

1,1 2,1 … mxc+1, 1 1,2 2,2 … mxc+1,2 …

Writing python script “filter_swanoutput.py” which is derived from “extractswanpts.py”.

giarray[i,j] = global index of point i,j, =-999 for dry points

ilist[] = list of i indices of wet points

jlist[] = list of j indices of wet points

trianglelist[n] = array[global1, global2, global3] : a list of arrays, which contains the global indices of 3 vertices.

output as adcirc grid first for viewing and checking purpose

filename = “adcircout.grd”

adcirc grid format:

AGRID
NE, NP

for k=1 to NP
JN, X(JN), Y(JN), DP(JN)
end k loop

for k=1 to NE
JE, NHY, NM(JE,1), NM(JE,2), NM(JE,3)
end k loop

NOPE
NETA

for k=1 to NOPE
NVDLL(k), IBTYPEE(k)
for j=1 to NVDLL(k)
NBDV(k,j)
end j loop
end k loop

NBOU
NVEL

for k=1 to NBOU
NVELL(k), IBTYPE(k)
for j=1,NVELL(k)
NBVV(k,j) – include this line only if IBTYPE(k) = 0, 1, 2, 10, 11, 12, 20, 21, 22, 30
NBVV(k,j), BARLANHT(k,j), BARLANCFSP(k,j) – include this line only if IBTYPE(k) = 3, 13, 23
NBVV(k,j), IBCONN(k,j), BARINHT(k,j), BARINCFSB(k,j), BARINCFSP(k,j) – include this line only if IBTYPE(k) = 4, 24
end j loop
end k loop

ADCIRC output successful! by filtering out hsign = 0.

Next STL format:

STLA Examples:

solid MYSOLID
facet normal 0.4 0.4 0.2
outerloop
vertex  1.0 2.1 3.2
vertex  2.1 3.7 4.5
vertex  3.1 4.5 6.7
endloop
endfacet
...
facet normal 0.2 0.2 0.4
outerloop
vertex  2.0 2.3 3.4
vertex  3.1 3.2 6.5
vertex  4.1 5.5 9.0
endloop
endfacet

endsolid MYSOLID
Converted to VRML file iso-surface.wrl using IVCON. The converted file goes like:
#VRML V2.0 utf8

  WorldInfo {
    title "isosurface.wrl"
    info "WRL file generated by IVREAD."
    info "Original data in isosurface.stl"
  }

  Viewpoint {
    description "Initial view"
    position 0.000000 0.000000 9.000000
  }

  Group {
    children [
      Shape {
        appearance Appearance {
          material Material {
            diffuseColor   0.700000 0.700000 0.700000
            emissiveColor  0.700000 0.700000 0.700000
            shininess      1.000000
          }
        }
        geometry IndexedFaceSet {
          coord Coordinate {
            point [
              -92.000000 25.033333 -1.955000,
              -91.966667 25.033333 -1.959000,
              -91.966667 25.066668 -1.956000,
              -92.000000 25.033333 -1.955000,
              -91.966667 25.066668 -1.956000,
              -92.000000 25.066668 -1.950000,
              -92.000000 25.066668 -1.950000,
              -91.966667 25.066668 -1.956000,
              -91.966667 25.100000 -1.949000,
              -92.000000 25.066668 -1.950000,
              -91.966667 25.100000 -1.949000,
              -92.000000 25.100000 -1.941000,
              -92.000000 25.100000 -1.941000,
...
NOW, download a VRML editor to edit color, texture and stuff. First check if IVCON has this ability.

 

 

vrml_firstattempt.png

Now, how to color map and texture it?

VRML texture library

If the file you need is on the same server as your VRML files you can skip the “http://www.foo.com/” part. Here’s what that might look like if the file was in the same directory as your VRML files…

        url "someimage.jpg"

Written by protian

February 4, 2008 at 4:53 pm

Posted in python script, visualization

Tagged with

VRML at first glance

without comments

VRML: virtual reality modeling language

standard file format for representing 3-dimensional (3D) interactive vector graphics

ok, found an opensource tool to convert STL format to VRML format: IVCON 3D

then I need to find a VRML editor to change texture of the output, and an VRML viewer for testing as well

found a VRML game engine: Kambi VRML game engine which seems to be a powerful VRML editor and viewor. Let’s see. Right now reading the author’s master thesis.

There are two versions of VRML: 1.0 and 2.0. After online searches, it seems like ArcGIS 9.2 uses 2.0. Good.

Finished reading. “IndexedFaceSet node” can do the job of plotting iso-surface. (also it mentions something like “ElevationGrid node”, need to check out later). It says that if you don’t supply pre-generated normal vectors for your shapes, they will be calculated by the VRML brower. You can control how they will be calculated by the creaseAngle field: if the angle between adjacent faces will be less than specified creaseAngle, the normal vectors in appropriate pointes will be smooth. The higher the creaseAngle value, the greater the smoothness. Very good.

Here is an example:

#VRML V2.0 utf8

Viewpoint {

position 31.893 -69.771 89.662

orientation 0.999 0.022 -0.012 0.974

}

Switch {

choice DEF TowerCoordinates Coordinate {

point [

4.157832 4.157833 -1.00000,

4.889094 3.266788 -1.00000,

......

]

}

}

Transform {

children Shape {

appearance Appearance { material Material {} }

geometry IndexedFaceSet {

coordIndex [

63 0 31 32 -1,

31 30 33 32 -1,

......

]

coord USE TowerCoordinates

creaseAngle 4

}

}

}

So, everything looks perfect. Now chose only those “Water” points from SWAN output and convert it to STL first, then use the converter to make it VRML and see how it does the job. If it doesn’t compute the normals or materials, try use some editor (maybe the game engine really rules, who know?)

Texture in VRML

#VRML V2.0 utf8
Group {
  children      Shape {
    appearance  Appearance {
      texture ImageTexture {
        url     [ "mandrill.jpg" ]
      }
    }
    geometry Box { }
  }
}

Paraview crashes when loading image. Forget about fancy image texture, use color map instead.

VRML color map

Written by protian

February 4, 2008 at 4:33 pm