Example #1
0
 def init(self,
          parent,
          name,
          scene,
          shape_type,
          shape_props,
          mass,
          center_of_mass=Ogre.Vector3.ZERO,
          inertia=None,
          position=Ogre.Vector3.ZERO,
          orientation=Ogre.Quaternion.IDENTITY):
     """
     @type  scene: ram.sim.scene.Scene
     @param scene: The scene to create the body in
     
     @type  shape_type: str
     @param shape_type: Denotes, the type of shape, like 'box' or 'sphere'
     
     @type  shape_props: Dict
     @param shape_props: Maps paramater name to value for the shapes 
                         constructor.
     """
     Object.init(self, parent, name)
     Body._create(self, scene, shape_type, shape_props, mass,
                  center_of_mass, inertia, position, orientation)
Example #2
0
    def load(self, data_object):
        """
        @type  data_object: tuple
        @param data_object: (scene, parent, kml_node)
        """
        scene, parent, node = data_object
        
        # Load Object based values
        Object.load(self, (parent, node))

        physical_node = node.get('Physical', None)
        if physical_node is None:
            msg = 'Object "%s" needs a "Phsyical" section' % node['name']
            raise PhysicsError(msg)

        # Find shape type and its properties
        shape_node = physical_node.get('Shape', None)
        if shape_node is None:
            msg = 'Object "%s" needs a "Physical.Shape" section' % node['name']
            raise PhysicsError(msg)
        
        shape_type = shape_node['type'].lower() 
        shape_props = {}
        for param, value in shape_node.iteritems():
            if param != 'type':
                shape_props[param] = value

        scale = shape_node.get('mesh_scale', None)
        if scale is not None:
            shape_props['mesh_scale'] = scale
        else:
            gfx_node = node.get('Graphical', {})
            shape_props['mesh_scale'] = gfx_node.get('scale', [1,1,1])
                    
        # Grab and validate Mass
        mass = physical_node.get('mass', 0)
        if (type(mass) is not int) and (type(mass) is not float):
            raise SimulationError('Mass must be an interger of float')
        
        position, orientation = parse_position_orientation(node)
        
        # Inertia and COM
        center_of_mass = physical_node.get('center_of_mass',Ogre.Vector3.ZERO)
        inertia = physical_node.get('inertia', None)
        
 
        Body._create(self, scene, shape_type, shape_props, mass, center_of_mass,
                     inertia, position, orientation)
        
        # Small hack, this should be integrated integrated better
        # I should probably reduce the number of constructor parameters as well
        material = physical_node.get('material', None)
        if material is not None:
            self._material = material
            material_id = scene.world.get_material_id(material)
            self._body.setMaterialGroupID(material_id)
Example #3
0
    def load(self, data_object):
        """
        @type  data_object: tuple
        @param data_object: (scene, parent, kml_node)
        """
        scene, parent, node = data_object

        # Load Object based values
        Object.load(self, (parent, node))

        gfx_node = node["Graphical"]
        mesh = gfx_node["mesh"]
        material = gfx_node.get("material", None)
        scale = sim.OgreVector3(gfx_node.get("scale", Ogre.Vector3(1, 1, 1)))

        # Handle special mesh generation
        if mesh.startswith("PLANE"):
            if ":" in mesh:
                mesh = mesh.split(":")[1]
            else:
                mesh = "Plane" + str(Visual._plane_count)

            norm = gfx_node["normal"]
            width = gfx_node["width"]
            height = gfx_node["height"]
            upvec = gfx_node.get("upvec", Ogre.Vector3.UNIT_Y)
            utile = gfx_node.get("utile", 1)
            vtile = gfx_node.get("vtile", 1)

            plane = Ogre.Plane(norm, 0)
            group_name = gfx_node.get("group", Ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)

            xsegments = int(width)
            ysegments = int(height)

            Ogre.MeshManager.getSingletonPtr().createPlane(
                mesh,
                group_name,
                plane,
                width,
                height,
                upVector=upvec,
                uTile=utile,
                vTile=vtile,
                xsegments=xsegments,
                ysegments=ysegments,
            )
            Visual._plane_count += 1

        # Orientation defaults: IDENTITY, Position: (0,0,0)
        position, orientation = parse_position_orientation(node)
        Visual._create(self, scene, mesh, material, position, orientation, scale)

        # Check visibility
        if not gfx_node.get("visible", True):
            self._node.setVisible(False)
Example #4
0
 def init(self,
          parent,
          name,
          scene,
          mesh,
          material,
          position=Ogre.Vector3.ZERO,
          orientation=Ogre.Quaternion.IDENTITY,
          scale=Ogre.Vector3(1, 1, 1)):
     Object.init(parent, name)
     Visual._create(self, scene, mesh, material, position, orientation,
                    scale)
Example #5
0
 def init(
     self,
     parent,
     name,
     scene,
     mesh,
     material,
     position=Ogre.Vector3.ZERO,
     orientation=Ogre.Quaternion.IDENTITY,
     scale=Ogre.Vector3(1, 1, 1),
 ):
     Object.init(parent, name)
     Visual._create(self, scene, mesh, material, position, orientation, scale)
Example #6
0
 def init(self, parent, name, scene, direction, min_force, max_force,
          material, position = Ogre.Vector3.ZERO, 
          orientation = Ogre.Quaternion.IDENTITY,
          scale = Ogre.Vector3(1,1,1)):
     
     core.verifyClass(IPart, parent)
     #Visual.init(self, parent, name, scene, mesh, material, position, 
     #            orietnation, scale)
     # Switch me back after the scene node issue is fixed
     Object.init(parent, name)
     
     Thruster._create(self, scene, min_force, max_force, direction, mesh, 
                      material, position, orientation, scale)
Example #7
0
    def load(self, data_object):
        """
        @type  data_object: tuple
        @param data_object: (scene, parent, kml_node)
        """
        scene, parent, node = data_object

        # Load Object based values
        Object.load(self, (parent, node))

        gfx_node = node['Graphical']
        mesh = gfx_node['mesh']
        material = gfx_node.get('material', None)
        scale = sim.OgreVector3(gfx_node.get('scale', Ogre.Vector3(1, 1, 1)))

        # Handle special mesh generation
        if mesh.startswith('PLANE'):
            if ':' in mesh:
                mesh = mesh.split(':')[1]
            else:
                mesh = 'Plane' + str(Visual._plane_count)

            norm = gfx_node['normal']
            width = gfx_node['width']
            height = gfx_node['height']
            upvec = gfx_node.get('upvec', Ogre.Vector3.UNIT_Y)
            utile = gfx_node.get('utile', 1)
            vtile = gfx_node.get('vtile', 1)

            plane = Ogre.Plane(norm, 0)
            group_name = gfx_node.get(
                'group', Ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)

            xsegments = int(width)
            ysegments = int(height)

            Ogre.MeshManager.getSingletonPtr().createPlane(mesh, \
                group_name, plane, width, height, upVector = upvec,
                uTile = utile, vTile = vtile, xsegments = xsegments,
                ysegments = ysegments)
            Visual._plane_count += 1

        # Orientation defaults: IDENTITY, Position: (0,0,0)
        position, orientation = parse_position_orientation(node)
        Visual._create(self, scene, mesh, material, position, orientation,
                       scale)

        # Check visibility
        if not gfx_node.get('visible', True):
            self._node.setVisible(False)
Example #8
0
 def __init__(self):
     """
     If you call this, make sure to call create, before using the object
     """
     self._force = Ogre.Vector3(0,0,0)
     self._omega = Ogre.Vector3(0,0,0)
     self._torque = Ogre.Vector3(0,0,0)
     self._gravity = defaults.gravity
     self._local_force = []
     self._global_force = []
     self._buoyancy_plane = None
     self._body = None
     self._material = None
     self._old_velocity = Ogre.Vector3.ZERO
     self._previous_omega = Ogre.Vector3.ZERO
 
     Object.__init__(self)
Example #9
0
 def init(self, parent, name, scene, shape_type, shape_props, mass,
          center_of_mass = Ogre.Vector3.ZERO, inertia = None,
          position = Ogre.Vector3.ZERO, 
          orientation = Ogre.Quaternion.IDENTITY):
     """
     @type  scene: ram.sim.scene.Scene
     @param scene: The scene to create the body in
     
     @type  shape_type: str
     @param shape_type: Denotes, the type of shape, like 'box' or 'sphere'
     
     @type  shape_props: Dict
     @param shape_props: Maps paramater name to value for the shapes 
                         constructor.
     """  
     Object.init(self, parent, name)
     Body._create(self, scene, shape_type, shape_props, mass, center_of_mass,
                  inertia, position, orientation)
Example #10
0
 def load(self, data_object):
     #Visual.load(self, data_object)
     # Remove me when scene node parenting issue is fixed
     scene, parent, kml_node = data_object
     Object.load(self, (parent, kml_node))
     
     gfx_node = kml_node['Graphical'] 
     mesh = gfx_node['mesh']
     material = gfx_node['material']
     scale = sim.OgreVector3(gfx_node['scale'])
     
     position, orientation = parse_position_orientation(kml_node)
     self._force_pos = sim.OgreVector3(position)
     
     direction = sim.OgreVector3(kml_node['direction'])
     min_force = kml_node['min_force']
     max_force = kml_node['max_force']
     Thruster._create(self, scene, direction, min_force, max_force, mesh, 
                      material, position, orientation, scale)
Example #11
0
    def load(self, data_object):
        #Visual.load(self, data_object)
        # Remove me when scene node parenting issue is fixed
        scene, parent, kml_node = data_object
        Object.load(self, (parent, kml_node))

        gfx_node = kml_node['Graphical']
        mesh = gfx_node['mesh']
        material = gfx_node['material']
        scale = sim.OgreVector3(gfx_node['scale'])

        position, orientation = parse_position_orientation(kml_node)
        self._force_pos = sim.OgreVector3(position)

        direction = sim.OgreVector3(kml_node['direction'])
        min_force = kml_node['min_force']
        max_force = kml_node['max_force']
        Thruster._create(self, scene, direction, min_force, max_force, mesh,
                         material, position, orientation, scale)
Example #12
0
    def init(self,
             parent,
             name,
             scene,
             direction,
             min_force,
             max_force,
             material,
             position=Ogre.Vector3.ZERO,
             orientation=Ogre.Quaternion.IDENTITY,
             scale=Ogre.Vector3(1, 1, 1)):

        core.verifyClass(IPart, parent)
        #Visual.init(self, parent, name, scene, mesh, material, position,
        #            orietnation, scale)
        # Switch me back after the scene node issue is fixed
        Object.init(parent, name)

        Thruster._create(self, scene, min_force, max_force, direction, mesh,
                         material, position, orientation, scale)
Example #13
0
 def __init__(self):
     self._node = None
     Object.__init__(self)
Example #14
0
 def __init__(self):
     self._node = None
     Object.__init__(self)