Example #1
0
 def GetElementWorldLocation(self, ElementKey):
     """Returns the location of the specified element in world coordinates."""
     assert ElementKey in self._elementDict
     self._elementDict.get(ElementKey).SetVisible(isVisible)
     localPos = self.GetElement(ElementKey).pos
     xAxis = ivisual.norm(self._myFrame.axis)
     zAxis = ivisual.norm(ivisual.cross(self._myFrame.axis, self._myFrame.up))
     yAxis = ivisual.norm(ivisual.cross(z_axis, x_axis))
     worldPos = self._myFrame.pos + (localPos.x * xAxis) + (localPos.y * yAxis) + (localPos.z * zAxis)
     return worldPos
Example #2
0
 def GetElementWorldLocation(self, ElementKey):
     """Returns the location of the specified element in world coordinates."""
     assert ElementKey in self._elementDict
     self._elementDict.get(ElementKey).SetVisible(isVisible)
     localPos = self.GetElement(ElementKey).pos
     xAxis = ivisual.norm(self._myFrame.axis)
     zAxis = ivisual.norm(
         ivisual.cross(self._myFrame.axis, self._myFrame.up))
     yAxis = ivisual.norm(ivisual.cross(z_axis, x_axis))
     worldPos = self._myFrame.pos + (localPos.x * xAxis) + (
         localPos.y * yAxis) + (localPos.z * zAxis)
     return worldPos
Example #3
0
    def build(self, Verticies, Faces, Colors=None, Normals=None, IsSoft=False):
        """Build a displayable tri-mesh object.  This is an overload of ode.TriMeshData.build()."""
        # Fill out our TriMeshData object properties by calling the parent
        ode.TriMeshData.build(self, Verticies, Faces)

        self._verticies = []
        self._colors = []
        self._normals = []

        # Expand the mesh to make it suitable for use with Visual
        for face in Faces:
            for index, vertex in enumerate(face):
                self._verticies.append(Verticies[vertex])
                if Colors is not None:
                    self._colors.append(Colors[vertex])
                else:
                    # Assign a default
                    self._colors.append(ivisual.color.white)
                if Normals is not None:
                    self._normals.append(Normals[vertex])
                else:
                    # Compute the normals using cross products
                    normal = ivisual.norm(
                        ivisual.cross(Verticies[face[index]],
                                      Verticies[face[(index + 1) % 3]]))
                    self._normals.append(normal)

        if IsSoft:
            # Need to go back and average normals -- implement later
            pass
Example #4
0
    def build(self, Verticies, Faces, Colors=None, Normals=None, IsSoft=False):
        """Build a displayable tri-mesh object.  This is an overload of ode.TriMeshData.build()."""
        # Fill out our TriMeshData object properties by calling the parent
        ode.TriMeshData.build(self, Verticies, Faces)

        self._verticies = []
        self._colors = []
        self._normals = []

        # Expand the mesh to make it suitable for use with Visual
        for face in Faces:
            for index, vertex in enumerate(face):
                self._verticies.append(Verticies[vertex])
                if Colors is not None:
                    self._colors.append(Colors[vertex])
                else:
                    # Assign a default
                    self._colors.append(ivisual.color.white)
                if Normals is not None:
                    self._normals.append(Normals[vertex])
                else:
                    # Compute the normals using cross products
                    normal = ivisual.norm(ivisual.cross(Verticies[face[index]], Verticies[face[(index + 1) % 3]]))
                    self._normals.append(normal)

        if IsSoft:
            # Need to go back and average normals -- implement later
            pass