Links

Content Skeleton

This Page

Previous topic

Collada XML layout

Next topic

Collada Materials

Meshtool

Meshtool provides PyCollada based utilities such as:

  1. viewing collada docs (via Panda3D)
  2. dumping info on collada docs

Invokation via bash function

Using system python 2.5.1 to enable panda3d usage:

simon:~ blyth$ meshtool-
simon:~ blyth$ t meshtool
meshtool is a function
meshtool ()
{
    /usr/bin/python -c "from meshtool.__main__ import main ; main() " $*
}

Start Geometry Web Server

simon:~ blyth$ vnode.py --webserver
2013-10-29 13:08:49,008 env.graphics.collada.pycollada.vnode INFO     /Users/blyth/env/bin/vnode.py
2013-10-29 13:08:49,012 env.graphics.collada.pycollada.vnode INFO     VNode.parse pycollada parse /usr/local/env/geant4/geometry/xdae/g4_01.dae
...
2013-10-29 13:09:02,654 env.graphics.collada.pycollada.vnode INFO     starting webserver
http://0.0.0.0:8080/

Grab some geometry and view

simon:~ blyth$ collada-
simon:~ blyth$ collada-cd
simon:collada blyth$ pwd
/usr/local/env/graphics/collada

simon:collada blyth$ curl -O http://localhost:8080/subcopy/__dd__Geometry__AD__lvOIL--pvAdPmtArray--pvAdPmtArrayRotated--pvAdPmtRingInCyl..1--pvAdPmtInRing..1--pvAdPmtUnit--pvAdPmt0xa8d92d8.0.dae
simon:collada blyth$ meshtool --load_collada __dd__Geometry__AD__lvOIL--pvAdPmtArray--pvAdPmtArrayRotated--pvAdPmtRingInCyl..1--pvAdPmtInRing..1--pvAdPmtUnit--pvAdPmt0xa8d92d8.0.dae --viewer

## `--collada_viewer` shows nothing visible, as have no cameras/lights in the file

To edit the DAE download first:

simon:collada blyth$ curl -sO http://localhost:8080/subcopy/3199.dae
simon:collada blyth$ meshtool --load_collada 3199.dae --viewer

Can also view direct from a subcopy URL:

simon:~ blyth$ meshtool --load_collada http://localhost:8080/subcopy/3199.dae --viewer

Meshtool dumping

Meshtool structure

Filter pipeline structure, /usr/local/env/graphics/collada/meshtool/meshtool/__main__.py:

35         order = ['Loading',
36                  'Printing',
37                  'Simplification',
38                  'Optimizations',
39                  'Visualizations',
40                  'Meta',
41                  'Operations',
42                  'Saving']

Meshtool panda3d viewer

/usr/local/env/graphics/collada/meshtool/meshtool/filters/panda_filters/viewer.py:

03 from pandacore import setupPandaApp, getBaseNodePath
04 from pandacontrols import KeyboardMovement, MouseDrag, MouseScaleZoom, MouseCamera, ButtonUtils
05
06 def runViewer(mesh):
07     p3dApp = setupPandaApp(mesh)
08     p3dApp.render.analyze()
09     KeyboardMovement()
10     ButtonUtils(getBaseNodePath(p3dApp.render))
11     MouseDrag(getBaseNodePath(p3dApp.render))
12     MouseScaleZoom(getBaseNodePath(p3dApp.render))
13     MouseCamera()
14     p3dApp.run()

controls

/usr/local/env/graphics/collada/meshtool/meshtool/filters/panda_filters/pandacontrols.py:

07 class KeyboardMovement(DirectObject):
08     def __init__(self, scale=1.0):
09         self.scale = scale
10         self.adjustSpeed()
11
12         #initial values for movement of the camera
13         self.cam_pos_x = 0
14         self.cam_pos_y = 0
15         self.cam_pos_z = 0
16         self.cam_h = 0
17         self.cam_p = 0
18         self.cam_r = 0
19
20         #Each input modifies x,y,z, h,p,r by an amount
..                  camera position x,y,z and camera yaw/pitch/roll
21         key_modifiers = [('w', [True, 0, 0.5, 0, 0, 0, 0]),   # w/s (arrow_up/arrow_down)   towards/away from object  +y/-y
22                          ('s', [True, 0, -0.5, 0, 0, 0, 0]),  #

23                          ('a', [True, -0.5, 0, 0, 0, 0, 0]),  # a/d camera left/right -x/+x
24                          ('d', [True, 0.5, 0, 0, 0, 0, 0]),   #          perspective change apparent

25                          ('r', [True, 0, 0, 0.5, 0, 0, 0]),   #
26                          ('f', [True, 0, 0, -0.5, 0, 0, 0]),  #

27                          ('arrow_up', [True, 0, 0.5, 0, 0, 0, 0]),
28                          ('arrow_down', [True, 0, -0.5, 0, 0, 0, 0]),

29                          ('arrow_left', [True, 0, 0, 0, 5, 0, 0]),
30                          ('arrow_right', [True, 0, 0, 0, -5, 0, 0])]
..
38         self.accept('escape', sys.exit)
39         self.accept('[', self.speedDown)      # multiple keypresses needed to effect much change
40         self.accept(']', self.speedUp)
..
..               w   r
..              a s d f
..

Panda3D coordinates

myNodePath.setPos(X, Y, Z)
myNodePath.setHpr(Yaw, Pitch, Roll)

By default in Panda3D, the X axis points to the right, the Y axis is forward, and Z is up. An object’s rotation is usually described using Euler angles called Heading, Pitch, and Roll (sometimes called Yaw, Pitch, and Roll in other packages) these specify angle rotations in degrees.