diff -Nru python-dartpy-0.0.3/dart/gui/vispy/frame_node.py python-dartpy-0.0.3/dart/gui/vispy/frame_node.py --- python-dartpy-0.0.3/dart/gui/vispy/frame_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/frame_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -from dart.gui.vispy.refreshable_node import RefreshableNode - - -class FrameNode(RefreshableNode): - def __init__(self, frame, parent=None): - self.index = 0 - super().__init__(parent=parent) - if frame is None: - raise ValueError("ShapeFrame is None.") - self._frame = frame - - self.name = self._frame.getName() - - def refresh(self): - if self.utilized: - return - self.utilized = True - print('A shape frame has been toRemove') diff -Nru python-dartpy-0.0.3/dart/gui/vispy/refreshable_node.py python-dartpy-0.0.3/dart/gui/vispy/refreshable_node.py --- python-dartpy-0.0.3/dart/gui/vispy/refreshable_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/refreshable_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -from vispy.scene import Node - - -class RefreshableNode(Node): - def __init__(self, **kwargs): - super().__init__(**kwargs) - self.stale = True - - def refresh(self): - self.stale = False - - def isStale(self): - return self.stale - - def isFresh(self): - return not self.stale - - def markStale(self): - self.stale = True - - def markFresh(self): - self.stale = False \ No newline at end of file diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shape_frame_node.py python-dartpy-0.0.3/dart/gui/vispy/shape_frame_node.py --- python-dartpy-0.0.3/dart/gui/vispy/shape_frame_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shape_frame_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -from dart import dynamics -from dart.gui.vispy.frame_node import FrameNode -from dart.gui.vispy.shapes.box_shape_node import BoxShapeNode -from dart.gui.vispy.shapes.capsule_shape_node import CapsuleShapeNode -from dart.gui.vispy.shapes.cylinder_shape_node import CylinderShapeNode -from dart.gui.vispy.shapes.mesh_shape_node import MeshShapeNode -from dart.gui.vispy.shapes.sphere_shape_node import SphereShapeNode -from vispy.visuals.transforms import MatrixTransform - - -class ShapeFrameNode(FrameNode): - def __init__(self, shapeFrame, parent=None): - super().__init__(frame=shapeFrame, parent=parent) - if shapeFrame is None: - raise ValueError("ShapeFrame is None.") - self.shapeFrame = shapeFrame - - self.shapeNode = None - - self.refresh() - - def getShapeFrame(self): - return self.shapeFrame - - def refresh(self): - self._refreshShapeNode(self.shapeFrame.getShape()) - self.markFresh() - - def _refreshShapeNode(self, shape): - if self.shapeNode: - # vispy uses row-major matrix while Eigen uses column-major matrix. - # self.shapeNode.transform.reset() - self.shapeNode.transform.matrix = self.shapeFrame.getTransform().transpose() - self.shapeNode.refresh() - else: - self._createShapeNode(shape) - - def _createShapeNode(self, shape): - shapeType = shape.getType() - if shapeType == dynamics.SphereShape.getStaticType(): - self.shapeNode = SphereShapeNode(shape, parent=self) - elif shapeType == dynamics.BoxShape.getStaticType(): - self.shapeNode = BoxShapeNode(shape, parent=self) - # elif shapeType == dynamics.EllipsoidShape.getStaticType(): - # print(shapeType) - elif shapeType == dynamics.CylinderShape.getStaticType(): - self.shapeNode = CylinderShapeNode(shape, parent=self) - elif shapeType == dynamics.CapsuleShape.getStaticType(): - self.shapeNode = CapsuleShapeNode(shape, parent=self) - # elif shapeType == dynamics.ConeShape.getStaticType(): - # print(shapeType) - # elif shapeType == dynamics.PlaneShape.getStaticType(): - # print(shapeType) - # elif shapeType == dynamics.MultiSphereConvexHullShape.getStaticType(): - # print(shapeType) - elif shapeType == dynamics.MeshShape.getStaticType(): - self.shapeNode = MeshShapeNode(shape, parent=self) - # elif shapeType == dynamics.SoftMeshShape.getStaticType(): - # print(shapeType) - # elif shapeType == dynamics.LineSegmentShape.getStaticType(): - # print(shapeType) - else: - print("{} is an unsupported shape type. Ping JS to implement this.") - - if self.shapeNode is None: - return - self.shapeNode.transform = MatrixTransform() diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shapes/assimp_mesh_node.py python-dartpy-0.0.3/dart/gui/vispy/shapes/assimp_mesh_node.py --- python-dartpy-0.0.3/dart/gui/vispy/shapes/assimp_mesh_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shapes/assimp_mesh_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -import warnings - -import numpy as np -import pyassimp as assimp -from vispy.geometry import MeshData -from vispy.scene.visuals import Mesh -from vispy.visuals.transforms import MatrixTransform - -from dart.gui.vispy.refreshable_node import RefreshableNode - - -class AssimpMeshNode(RefreshableNode): - def __init__(self, assimpMesh, assimpScene, parent=None): - super().__init__(parent=parent) - self.assimpMesh = assimpMesh - self.assimpScene = assimpScene - self.shapeVisualNode = None - self._updateShapeData(firstTime=True) - - def refresh(self): - self._updateShapeData(firstTime=False) - self.markFresh() - - def _updateShapeData(self, firstTime): - if firstTime: - self.shapeVisualNode = Mesh( - parent=self, - vertices=self.assimpMesh.vertices, - faces=self.assimpMesh.faces, - # vertex_colors=self.assimpMesh.colors, - shading='flat' - ) - material = self.assimpScene.materials[self.assimpMesh.materialindex] - - if material.properties['ambient']: - self.shapeVisualNode.ambient_light_color = material.properties['ambient'] - # if material.properties['shininess']: - # self.shapeVisualNode.shininess = material.properties['shininess'] - # if material.properties['diffuse']: - # self.shapeVisualNode.color = material.properties['diffuse'] - else: - pass - diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shapes/assimp_node_node.py python-dartpy-0.0.3/dart/gui/vispy/shapes/assimp_node_node.py --- python-dartpy-0.0.3/dart/gui/vispy/shapes/assimp_node_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shapes/assimp_node_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -import warnings - -import numpy as np -import pyassimp as assimp -from vispy.scene.visuals import Mesh -from vispy.visuals.transforms import MatrixTransform - -from dart.gui.vispy.refreshable_node import RefreshableNode -from dart.gui.vispy.shapes.assimp_mesh_node import AssimpMeshNode - - -def _fromAssimpMatrixToNumpyMatrix(assimpMat): - # vispy uses row-major matrix, but not sure which convention Assimp uses - # TODO(JS): Needs verification - mat = np.array([ - [assimpMat.a1, assimpMat.a2, assimpMat.a3, assimpMat.a4], - [assimpMat.b1, assimpMat.b2, assimpMat.b3, assimpMat.b4], - [assimpMat.c1, assimpMat.c2, assimpMat.c3, assimpMat.c4], - [assimpMat.d1, assimpMat.d2, assimpMat.d3, assimpMat.d4] - ]) - - return mat - - -class AssimpNodeNode(RefreshableNode): - def __init__(self, assimpNode, assimpScene, parent=None): - super().__init__(parent=parent) - self.assimpScene = assimpScene - self.assimpNode = assimpNode - self.shapeVisualNode = None - self.assimpChildNodes = [] - self.assimpMeshes = [] - self.assimpMeshNodes = [] - self._updateShapeData(firstTime=True) - - def refresh(self): - self._updateShapeData(firstTime=False) - self.markFresh() - - def _updateShapeData(self, firstTime): - if firstTime: - assimpMatrix = self.assimpNode.contents.mTransformation - self.transform = MatrixTransform() # TODO(JS): Necessary? - self.transform.matrix = _fromAssimpMatrixToNumpyMatrix(assimpMatrix) - for mesh in self.assimpNode.meshes: - self.assimpMeshNodes += [AssimpMeshNode(assimpMesh=mesh, assimpScene=self.assimpScene, parent=self)] - for child in self.assimpNode.children: - self.assimpChildNodes += [AssimpNodeNode(child, assimpScene=self.assimpScene, parent=self)] - else: - for assimpChildNode in self.assimpChildNodes: - assimpChildNode.refresh() - - diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shapes/box_shape_node.py python-dartpy-0.0.3/dart/gui/vispy/shapes/box_shape_node.py --- python-dartpy-0.0.3/dart/gui/vispy/shapes/box_shape_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shapes/box_shape_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -from vispy.scene.visuals import Box - -from dart.gui.vispy.shapes.shape_node import ShapeNode - - -class BoxShapeNode(ShapeNode): - def __init__(self, boxShape, parent=None): - super().__init__(shape=boxShape, parent=parent) - self.boxShape = boxShape - self.shapeVisualNode = None - self.refresh() - - def refresh(self): - if self.shapeVisualNode: - pass - else: - size = self.boxShape.getSize() - color = self.visualAspect.getRGBA().flat - - self.shapeVisualNode = Box( - parent=self, - width=size[0], height=size[2], depth=size[1], - width_segments=1, - height_segments=1, - depth_segments=1, - planes=None, - vertex_colors=None, - face_colors=None, - color=color, - edge_color="black", - ) - - self.markFresh() diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shapes/capsule_shape_node.py python-dartpy-0.0.3/dart/gui/vispy/shapes/capsule_shape_node.py --- python-dartpy-0.0.3/dart/gui/vispy/shapes/capsule_shape_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shapes/capsule_shape_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -from dart.gui.vispy.shapes.visuals.cylinder_visual import Cylinder -from dart.gui.vispy.shapes.shape_node import ShapeNode - - -class CapsuleShapeNode(ShapeNode): - def __init__(self, capsuleShape, parent=None): - super().__init__(shape=capsuleShape, parent=parent) - self.capsuleShape = capsuleShape - self.shapeVisualNode = None - self.refresh() - - def refresh(self): - if self.shapeVisualNode: - pass - else: - radius = self.capsuleShape.getRadius() - length = self.capsuleShape.getHeight() - color = self.visualAspect.getRGBA().flat - - # TODO(JS): Change this to Capsule - self.shapeVisualNode = Cylinder( - parent=self, - radius=[radius, radius], - length=length, - color=color, - edge_color="black", - ) - - self.markFresh() diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shapes/cylinder_shape_node.py python-dartpy-0.0.3/dart/gui/vispy/shapes/cylinder_shape_node.py --- python-dartpy-0.0.3/dart/gui/vispy/shapes/cylinder_shape_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shapes/cylinder_shape_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -from dart.gui.vispy.shapes.visuals.cylinder_visual import Cylinder -from dart.gui.vispy.shapes.shape_node import ShapeNode - - -class CylinderShapeNode(ShapeNode): - def __init__(self, cylinderShape, parent=None): - super().__init__(shape=cylinderShape, parent=parent) - self.cylinderShape = cylinderShape - self.shapeVisualNode = None - self.refresh() - - def refresh(self): - if self.shapeVisualNode: - pass - else: - radius = self.cylinderShape.getRadius() - length = self.cylinderShape.getHeight() - color = self.visualAspect.getRGBA().flat - - self.shapeVisualNode = Cylinder( - parent=self, - radius=[radius, radius], - length=length, - color=color, - edge_color="black", - ) - - self.markFresh() diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shapes/material.py python-dartpy-0.0.3/dart/gui/vispy/shapes/material.py --- python-dartpy-0.0.3/dart/gui/vispy/shapes/material.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shapes/material.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - - -class Material(object): - def __init__(self, assimpMaterial): - self.assimpMaterial = assimpMaterial - self._ambient = self.assimpMaterial.properties['ambient'] - self._diffuse = self.assimpMaterial.properties['diffuse'] - self._emission = self.assimpMaterial.properties['emissive'] - self._shininess = self.assimpMaterial.properties['shininess'] - self._name = self.assimpMaterial.properties['name'] - if 'file' in self.assimpMaterial.properties: - self._file = self.assimpMaterial.properties['file'] - else: - self._file = None - - @property - def ambient(self): - return self._ambient - - @property - def diffuse(self): - return self._diffuse - - @property - def emissive(self): - return self._emissive - - @property - def shininess(self): - return self._shininess - diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shapes/mesh_shape_node.py python-dartpy-0.0.3/dart/gui/vispy/shapes/mesh_shape_node.py --- python-dartpy-0.0.3/dart/gui/vispy/shapes/mesh_shape_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shapes/mesh_shape_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -import warnings -import pyassimp as assimp - -import dartpy - -from dart.gui.vispy.shapes.material import Material -from dart.gui.vispy.shapes.assimp_node_node import AssimpNodeNode -from dart.gui.vispy.shapes.shape_node import ShapeNode -from dart.gui.vispy.shapes.texture import Texture - - -class MeshShapeNode(ShapeNode): - def __init__(self, meshShape, parent=None): - super().__init__(shape=meshShape, parent=parent) - self.meshShape = meshShape - self.rootAssimpNodeNode = None - # self.materials = [] - # self.textureImages = [] - self._updateShapeData(True) - - def __del__(self): - if self.rootAssimpNodeNode: - assimp.release(self.rootAssimpNodeNode) - - def refresh(self): - self.markFresh() - if self.meshShape.getDataVariance() == dartpy.dynamics.Shape.DataVariance.STATIC: - return - self._updateShapeData(False) - - def _updateShapeData(self, firstTime): - if firstTime: - uri = self.meshShape.getMeshUri2() - retriever = self.meshShape.getResourceRetriever() - meshPath = retriever.getFilePath(uri) - try: - scene = assimp.load(meshPath) - except: - # TODO(JS): Better error handling - warnings.warn("Failed to load a mesh '{}'.".format(uri)) - return - - # Materials - # for material in scene.materials: - # self.materials += [Material(material)] - # - # # Texture images - # for texture in scene.textures: - # self.textures += [Texture(texture)] - - self.rootAssimpNodeNode = AssimpNodeNode(scene.rootnode, assimpScene=scene, parent=self) - else: - self.rootAssimpNodeNode.refresh() diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shapes/shape_node.py python-dartpy-0.0.3/dart/gui/vispy/shapes/shape_node.py --- python-dartpy-0.0.3/dart/gui/vispy/shapes/shape_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shapes/shape_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -from dart.gui.vispy.refreshable_node import RefreshableNode - - -class ShapeNode(RefreshableNode): - def __init__(self, shape, parent=None): - super().__init__(parent=parent) - if shape is None: - raise ValueError("Shape is None.") - self.shape = shape - self.parentShapeFrameNode = parent - self.shapeFrame = parent.getShapeFrame() - self.visualAspect = self.shapeFrame.getVisualAspect() - - def refresh(self): - self.markFresh() diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shapes/sphere_shape_node.py python-dartpy-0.0.3/dart/gui/vispy/shapes/sphere_shape_node.py --- python-dartpy-0.0.3/dart/gui/vispy/shapes/sphere_shape_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shapes/sphere_shape_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -from vispy.scene.visuals import Sphere - -from dart.gui.vispy.shapes.shape_node import ShapeNode - - -class SphereShapeNode(ShapeNode): - def __init__(self, sphereShape, parent=None): - super().__init__(shape=sphereShape, parent=parent) - self.sphereShape = sphereShape - self.shapeVisualNode = None - self.refresh() - - def refresh(self): - if self.shapeVisualNode: - pass - else: - radius = self.sphereShape.getRadius() - color = self.visualAspect.getRGBA().flat - - self.shapeVisualNode = Sphere( - parent=self, - radius=radius, - color=color, - method='ico', - edge_color="black", - ) - - self.markFresh() diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shapes/texture.py python-dartpy-0.0.3/dart/gui/vispy/shapes/texture.py --- python-dartpy-0.0.3/dart/gui/vispy/shapes/texture.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shapes/texture.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - - -class Texture(object): - def __init__(self, assimpTexture): - self.assimpTexture = assimpTexture - diff -Nru python-dartpy-0.0.3/dart/gui/vispy/shapes/visuals/cylinder_visual.py python-dartpy-0.0.3/dart/gui/vispy/shapes/visuals/cylinder_visual.py --- python-dartpy-0.0.3/dart/gui/vispy/shapes/visuals/cylinder_visual.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/shapes/visuals/cylinder_visual.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- -import numpy as np -from vispy.geometry import create_cylinder -from vispy.scene.visuals import create_visual_node -from vispy.visuals import CompoundVisual, MeshVisual -from vispy.visuals.transforms import MatrixTransform - - -class CylinderVisual(CompoundVisual): - """Visual that displays a box. - - Parameters - ---------- - rows : int - Number of rows. - cols : int - Number of columns. - radius : tuple of float - Cylinder radii. - length : float - Length of the cylinder. - offset : bool - Rotate each row by half a column. - vertex_colors : ndarray - Same as for `MeshVisual` class. See `create_plane` for vertex ordering. - face_colors : ndarray - Same as for `MeshVisual` class. See `create_plane` for vertex ordering. - color : Color - The `Color` to use when drawing the cube faces. - edge_color : tuple or Color - The `Color` to use when drawing the cube edges. If `None`, then no - cube edges are drawn. - """ - - def __init__(self, radius, length, rows=16, cols=16, - vertex_colors=None, face_colors=None, - color=(0.5, 0.5, 1, 1), edge_color=None, **kwargs): - mesh_data = create_cylinder( - rows, cols, radius, length, offset=False) - - self._mesh = MeshVisual( - mesh_data.get_vertices() + np.array([0, 0, -length*0.5]), - mesh_data.get_faces(), - vertex_colors, - face_colors, - color - ) - if edge_color: - self._border = MeshVisual( - mesh_data.get_vertices() + np.array([0, 0, -length*0.5]), - mesh_data.get_faces(), - color=edge_color, - mode='lines' - ) - else: - self._border = MeshVisual() - - CompoundVisual.__init__(self, [self._mesh, self._border], **kwargs) - self.mesh.set_gl_state(polygon_offset_fill=True, - polygon_offset=(1, 1), depth_test=True) - - @property - def mesh(self): - """The vispy.visuals.MeshVisual that used to fill in. - """ - return self._mesh - - @mesh.setter - def mesh(self, mesh): - self._mesh = mesh - - @property - def border(self): - """The vispy.visuals.MeshVisual that used to draw the border. - """ - return self._border - - @border.setter - def border(self, border): - self._border = border - - -Cylinder = create_visual_node(CylinderVisual) diff -Nru python-dartpy-0.0.3/dart/gui/vispy/skeleton_node.py python-dartpy-0.0.3/dart/gui/vispy/skeleton_node.py --- python-dartpy-0.0.3/dart/gui/vispy/skeleton_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/skeleton_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -from collections import deque -from dart.gui.vispy.refreshable_node import RefreshableNode -from dart.gui.vispy.shape_frame_node import ShapeFrameNode - - -class SkeletonNode(RefreshableNode): - def __init__(self, skeleton, parent=None): - super().__init__(parent=parent) - if skeleton is None: - raise ValueError("World is None.") - self.skeleton = skeleton - - self.utilized = False - - self.shapeFrameNameToNode = {} - - self.refresh() - - def refresh(self): - # self._markSkeletonNodesStale() - self._refreshFrames() - # self._removeStaleSkeletonNodes() - self.markFresh() - - def _unutilizeAllChildren(self): - pass - # for shapeFrameNode in self.shapeFrameNameToNode.values(): - # shapeFrameNode.markToRemove() - - def _refreshFrames(self): - for i in range(self.skeleton.getNumTrees()): - self._refreshFrameNodeFromRoot(self.skeleton.getRootBodyNode(i)) - - def _refreshFrameNodeFromRoot(self, rootBodyNode): - frames = deque([rootBodyNode]) - # rootBodyNode.getChildFrames() # TODO(JS): Fix binding - # rootBodyNode.getShapeNodes() # TODO(JS): Fix binding - while frames: - nextBodyNode = frames.pop() - - for i in range(nextBodyNode.getNumShapeNodes()): - shapeFrame = nextBodyNode.getShapeNode(i) - if shapeFrame.isShapeFrame() and shapeFrame.hasVisualAspect(): - self._refreshFrameNode(shapeFrame) - - for i in range(nextBodyNode.getNumChildBodyNodes()): - childBodyNode = nextBodyNode.getChildBodyNode(i) - frames.append(childBodyNode) - - # frames = deque([rootBodyNode]) - # while frames: - # nextFrame = frames.pop() - # if nextFrame.isShapeFrame(): - # self._refreshFrameNode(nextFrame) - # for i in range(nextFrame.getNumShapeNodes()): - # shapeNode = nextFrame.getShapeNode(i) - # frames.append(shapeNode) - - # for shapeNode in nextFrame.getShapeNodes(): - # pass - # TODO(JS): Waiting for https://github.com/personalrobotics/dartpy/pull/70 - # for child in nextFrame.getChildFrames(): - # frames.append(child) - - def _refreshFrameNode(self, shapeFrame): - # TODO(JS): Name uniqueness is assumed, which isn't true. Needs correct equality checking for ShapeFrame. - # TODO(JS): Use shape.getID() instead of name. - if shapeFrame.getShape().getID() in self.shapeFrameNameToNode: - self.shapeFrameNameToNode[shapeFrame.getShape().getID()].refresh() - else: - self.isModifyingShapeFrameNode = True - node = ShapeFrameNode(shapeFrame, parent=self) - self.shapeFrameNameToNode[shapeFrame.getShape().getID()] = node - self.isModifyingShapeFrameNode = False - - def _removeNotUtilizedChildren(self): - pass - # unusedSkeletonNames = [] - # for skeletonName, skeletonNode in self.skeletonNameToNode.items(): - # if not skeletonNode.needsToRemove(): - # unusedSkeletonNames += [skeletonName] - # - # self.isModifyingSkeletonNode = True - # for unusedSkeletonName in unusedSkeletonNames: - # skeletonNode = self.skeletonNameToNode[unusedSkeletonName] - # skeletonNode.parent = None - # del self.skeletonNameToNode[unusedSkeletonName] - # self.isModifyingSkeletonNode = False diff -Nru python-dartpy-0.0.3/dart/gui/vispy/viewer.py python-dartpy-0.0.3/dart/gui/vispy/viewer.py --- python-dartpy-0.0.3/dart/gui/vispy/viewer.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/viewer.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -from vispy import app -from vispy import scene - -from dart.gui.vispy.world_node import WorldNode - - -class Viewer(scene.SceneCanvas): - def __init__(self, world, title='Noname', show=True): - if world is None: - raise ValueError("World is None.") - - super().__init__(title=title, keys='interactive', size=(800, 550), show=show) - - self.unfreeze() - - self.viewBox = self.central_widget.add_view() - self.viewBox.bgcolor = '#efefef' - self.viewBox.camera = 'arcball' - self.viewBox.camera.fov = 50 - # self.viewBox.camera.distance = 1 - self.viewBox.padding = 0 - - self.axis = scene.visuals.XYZAxis(parent=self.viewBox.scene) - - self.world = None - self.worldNode = None - - self.freeze() - - self.setWorld(world) - - self.unfreeze() - self.events.key_press.connect(self.on_key_press) - - self.timer = app.Timer('auto', self.on_timer) - self.timer.start() - self.freeze() - - def on_timer(self, _): - self.update() - - def on_draw(self, event): - self._refreshWorldNode() - - super().on_draw(event=event) - - def on_key_press(self, event): - if event.key.name == 'S': - self.unfreeze() - self.show(True) - self.freeze() - if event.key.name == 'H': - self.unfreeze() - self.show(False) - self.freeze() - print('\'{}\' key pressed'.format(event.key.name)) - - def _refreshWorldNode(self): - if not self.worldNode: - return - self.worldNode.refresh() - - def setWorld(self, world): - if self.world == world: - return - - self.unfreeze() - self.world = world - self.freeze() - - if not self.world: - return - - self.unfreeze() - self.worldNode = WorldNode(self.world, parent=self.viewBox.scene) - self.freeze() - - def getFrame(self): - temp = self.render() - print('getFrame()') - return temp - - def startSimulation(self): - self.unfreeze() - self.worldNode = WorldNode(self.world, parent=self.viewBox.scene) - self.freeze() diff -Nru python-dartpy-0.0.3/dart/gui/vispy/world_node.py python-dartpy-0.0.3/dart/gui/vispy/world_node.py --- python-dartpy-0.0.3/dart/gui/vispy/world_node.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/gui/vispy/world_node.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -# ----------------------------------------------------------------------------- -# Copyright (c) 2015-2018, The dartpy development contributors -# All Rights Reserved. -# Distributed under the BSD 2-Clause License. See LICENSE for more info. -# ----------------------------------------------------------------------------- - -from vispy.scene import Node - -from dart.gui.vispy.skeleton_node import SkeletonNode - - -class WorldNode(Node): - def __init__(self, world, parent=None): - if world is None: - raise ValueError("World is None.") - self._world = world - - self._simulating = False - self.num_steps_per_cycle = 10 - - self.skeletonNameToNode = {} - - super().__init__(parent=parent) - - self.refresh() - - @property - def world(self): - return self._world - - def isSimulating(self): - return self._simulating - - def refresh(self): - self._markSkeletonNodesStale() - - if self._simulating: - for _ in range(self.num_steps_per_cycle): - self.world.step() - - self._refreshSkeletonNodes() - - self._removeStaleSkeletonNodes() - - def _markSkeletonNodesStale(self): - for node in self.skeletonNameToNode.values(): - node.markStale() - - def _refreshSkeletonNodes(self): - for i in range(self.world.getNumSkeletons()): - skel = self.world.getSkeleton(i) - name = skel.getName() # assumed unique name - if name in self.skeletonNameToNode: - self.skeletonNameToNode[name].refresh() - else: - node = SkeletonNode(skel, parent=self) - self.skeletonNameToNode[name] = node - - def _removeStaleSkeletonNodes(self): - staleSkeletonNames = [] - for name, node in self.skeletonNameToNode.items(): - if node.isStale(): - staleSkeletonNames += [name] - - for name in staleSkeletonNames: - node = self.skeletonNameToNode[name] - node.parent = None - del self.skeletonNameToNode[name] diff -Nru python-dartpy-0.0.3/dart/__init__.py python-dartpy-0.0.3/dart/__init__.py --- python-dartpy-0.0.3/dart/__init__.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/dart/__init__.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -from . import gui - -import dartpy.collision as collision -import dartpy.common as common -import dartpy.constraint as constraint -import dartpy.dynamics as dynamics -# import dartpy.gui as gui -import dartpy.integration as integration -import dartpy.lcpsolver as lcpsolver -import dartpy.math as math -import dartpy.optimizer as optimizer -import dartpy.simulation as simulation -import dartpy.utils as utils diff -Nru python-dartpy-0.0.3/debian/changelog python-dartpy-0.0.3/debian/changelog --- python-dartpy-0.0.3/debian/changelog 2018-10-15 02:49:26.000000000 +0000 +++ python-dartpy-0.0.3/debian/changelog 2018-10-16 02:46:51.000000000 +0000 @@ -1,8 +1,8 @@ -python-dartpy (0.0.3-144~201810150249~ubuntu18.04.1) bionic; urgency=low +python-dartpy (0.0.3-149~201810160246~ubuntu18.04.1) bionic; urgency=low * Auto build. - -- Jeongseok Lee Mon, 15 Oct 2018 02:49:26 +0000 + -- Jeongseok Lee Tue, 16 Oct 2018 02:46:51 +0000 python-dartpy (0.0.3) bionic; urgency=medium diff -Nru python-dartpy-0.0.3/debian/git-build-recipe.manifest python-dartpy-0.0.3/debian/git-build-recipe.manifest --- python-dartpy-0.0.3/debian/git-build-recipe.manifest 2018-10-15 02:49:26.000000000 +0000 +++ python-dartpy-0.0.3/debian/git-build-recipe.manifest 2018-10-16 02:46:51.000000000 +0000 @@ -1,3 +1,3 @@ -# git-build-recipe format 0.4 deb-version {debupstream}-144~201810150249 -lp:dartpy git-commit:524f64059f262247ab1ef5d69a789e06c07683f7 +# git-build-recipe format 0.4 deb-version {debupstream}-149~201810160246 +lp:dartpy git-commit:3535357b354b48919d9912c24aff37eff8d6e711 nest-part debian-branch lp:dartpy-debian bionic/debian debian git-commit:63f8dfdceab52d2b863b7561e0d16e8c5ccb874b diff -Nru python-dartpy-0.0.3/README.md python-dartpy-0.0.3/README.md --- python-dartpy-0.0.3/README.md 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/README.md 2018-10-16 02:46:46.000000000 +0000 @@ -26,12 +26,6 @@ $ sudo apt-get install python-dartpy # for Python 2 $ sudo apt-get install python3-dartpy # for Python 3 -$ sudo apt-get install qt4-default - -$ git clone https://github.com/personalrobotics/dartpy -$ cd dartpy -$ git checkout dart-6.5 -$ pip3 install -e . ``` **16.04 / 18.04** @@ -43,11 +37,6 @@ $ sudo apt-get install python-dartpy # for Python 2 $ sudo apt-get install python3-dartpy # for Python 3 - -$ git clone https://github.com/personalrobotics/dartpy -$ cd dartpy -$ git checkout dart-6.5 -$ pip3 install -e . ``` All set! Import `dartpy` in Python and enjoy! Please see [Usage](#usage) section for more information. diff -Nru python-dartpy-0.0.3/sandbox/vispy/sandbox.py python-dartpy-0.0.3/sandbox/vispy/sandbox.py --- python-dartpy-0.0.3/sandbox/vispy/sandbox.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/sandbox/vispy/sandbox.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- -# ----------------------------------------------------------------------------- -# Copyright (c) Vispy Development Team. All Rights Reserved. -# Distributed under the (new) BSD License. See LICENSE.txt for more info. -# ----------------------------------------------------------------------------- -""" -Tutorial: Creating Visuals -========================== -05. Camera location -------------------- -In this tutorial we will demonstrate how to determine the direction from which -a Visual is being viewed. -""" - -from vispy import app, gloo, visuals, scene, io - -vertex_shader = """ -varying vec4 color; -void main() { - vec4 visual_pos = vec4($position, 1); - vec4 doc_pos = $visual_to_doc(visual_pos); - gl_Position = $doc_to_render(doc_pos); - - vec4 visual_pos2 = $doc_to_visual(doc_pos + vec4(0, 0, -1, 0)); - vec4 view_direction = (visual_pos2 / visual_pos2.w) - visual_pos; - view_direction = vec4(normalize(view_direction.xyz), 0); - - color = vec4(view_direction.rgb, 1); -} -""" - -fragment_shader = """ -varying vec4 color; -void main() { - gl_FragColor = color; -} -""" - - -class MyMeshVisual(visuals.Visual): - """ - """ - - def __init__(self): - visuals.Visual.__init__(self, vertex_shader, fragment_shader) - - # Create an interesting mesh shape for demonstration. - fname = io.load_data_file('orig/triceratops.obj.gz') - vertices, faces, normals, tex = io.read_mesh(fname) - - self._ibo = gloo.IndexBuffer(faces) - - self.shared_program.vert['position'] = gloo.VertexBuffer(vertices) - # self.program.vert['normal'] = gloo.VertexBuffer(normals) - self.set_gl_state('additive', cull_face=False) - self._draw_mode = 'triangles' - self._index_buffer = self._ibo - - def _prepare_transforms(self, view): - # Note we use the "additive" GL blending settings so that we do not - # have to sort the mesh triangles back-to-front before each draw. - tr = view.transforms - view_vert = view.view_program.vert - view_vert['visual_to_doc'] = tr.get_transform('visual', 'document') - view_vert['doc_to_visual'] = tr.get_transform('document', 'visual') - view_vert['doc_to_render'] = tr.get_transform('document', 'render') - - -# Auto-generate a Visual+Node class for use in the scenegraph. -MyMesh = scene.visuals.create_visual_node(MyMeshVisual) - -# Finally we will test the visual by displaying in a scene. - -canvas = scene.SceneCanvas(keys='interactive', show=True) - -# Add a ViewBox to let the user zoom/rotate -view = canvas.central_widget.add_view() -view.camera = 'turntable' -view.camera.fov = 50 -view.camera.distance = 2 - -mesh = MyMesh(parent=view.scene) -mesh.transform = visuals.transforms.MatrixTransform() -# mesh.transform.translate([-25, -25, -25]) -mesh.transform.rotate(90, (1, 0, 0)) - -axis = scene.visuals.XYZAxis(parent=view.scene) - -# ..and optionally start the event loop -if __name__ == '__main__': - import sys - - if sys.flags.interactive != 1: - app.run() \ No newline at end of file diff -Nru python-dartpy-0.0.3/setup.py python-dartpy-0.0.3/setup.py --- python-dartpy-0.0.3/setup.py 2018-10-15 02:49:23.000000000 +0000 +++ python-dartpy-0.0.3/setup.py 2018-10-16 02:46:46.000000000 +0000 @@ -18,11 +18,11 @@ if system == 'Linux': distro = platform.linux_distribution()[1] if distro == '14.04': - install_requires = ['numpy', 'vispy', 'pyassimp', 'pytest'] + install_requires = ['numpy', 'pyassimp', 'pytest'] else: - install_requires = ['numpy', 'vispy', 'PyQt5', 'pyassimp', 'pytest'] + install_requires = ['numpy', 'pyassimp', 'pytest'] else: - install_requires = ['numpy', 'vispy', 'PyQt5', 'pyassimp', 'pytest'] + install_requires = ['numpy', 'pyassimp', 'pytest'] # See: http://www.astropython.org/snippet/2009/10/chdir-context-manager @@ -56,11 +56,12 @@ version='0.0.1', description=description, long_description=long_description, - ext_modules=[Extension('dart', sources=[])], + ext_modules=[Extension('dartpy', sources=[])], url='https://github.com/personalrobotics/dartpy', author='Michael Koval', author_email='mkoval@cs.cmu.edu', - packages=['dart'], + maintainer='Jeongseok Lee', + maintainer_email='jslee02@cs.uw.edu', license='BSD', keywords=['dartsim', 'physics', 'robotics', 'simulation'], classifiers=[