Beispiel #1
0
    def testGetColorsFromObjectAdvanced(self):
        modelId = '317'
        modelFilename = os.path.join(TEST_SUNCG_DATA_DIR, "object",
                                     str(modelId),
                                     str(modelId) + ".egg")
        assert os.path.exists(modelFilename)
        model = loadModel(modelFilename)
        model.setName('model-' + str(modelId))
        obj = NodePath('object-' + str(modelId))
        model.reparentTo(obj)
        colorDescriptions = MaterialColorTable.getColorsFromObject(
            obj, mode='advanced')
        self.assertTrue(len(colorDescriptions) == 1)
        self.assertTrue(colorDescriptions[0] == "navajo white")

        colorDescriptions = MaterialColorTable.getColorsFromObject(
            obj, mode='advanced', thresholdRelArea=0.0)
        self.assertTrue(len(colorDescriptions) == 2)
        self.assertTrue("navajo white" in colorDescriptions)
        self.assertTrue("dark slate gray" in colorDescriptions)

        modelId = '210'
        modelFilename = os.path.join(TEST_SUNCG_DATA_DIR, "object",
                                     str(modelId),
                                     str(modelId) + ".egg")
        assert os.path.exists(modelFilename)
        model = loadModel(modelFilename)
        model.setName('model-' + str(modelId))
        obj = NodePath('object-' + str(modelId))
        model.reparentTo(obj)
        colorDescriptions = MaterialColorTable.getColorsFromObject(
            obj, mode='advanced')
        self.assertTrue(len(colorDescriptions) == 2)
        self.assertTrue("dark gray" in colorDescriptions)
        self.assertTrue("cadet blue" in colorDescriptions)
Beispiel #2
0
    def testGetColorsFromObjectBasic(self):
        modelId = '317'
        modelFilename = os.path.join(TEST_SUNCG_DATA_DIR, "object",
                                     str(modelId),
                                     str(modelId) + ".egg")
        assert os.path.exists(modelFilename)
        model = loadModel(modelFilename)
        model.setName('model-' + str(modelId))
        obj = NodePath('object-' + str(modelId))
        model.reparentTo(obj)
        colorDescriptions = MaterialColorTable.getColorsFromObject(
            obj, mode='basic')
        self.assertTrue(len(colorDescriptions) == 1)
        self.assertTrue(colorDescriptions[0] == "silver")

        modelId = '83'
        modelFilename = os.path.join(TEST_SUNCG_DATA_DIR, "object",
                                     str(modelId),
                                     str(modelId) + ".egg")
        assert os.path.exists(modelFilename)
        model = loadModel(modelFilename)
        model.setName('model-' + str(modelId))
        obj = NodePath('object-' + str(modelId))
        model.reparentTo(obj)
        colorDescriptions = MaterialColorTable.getColorsFromObject(
            obj, mode='basic')
        self.assertTrue(len(colorDescriptions) == 1)
        self.assertTrue(colorDescriptions[0] == "white")
Beispiel #3
0
 def testGetColorsFromObjectTransparent(self):
     modelId = 'sphere'
     modelFilename = os.path.join(TEST_DATA_DIR, "models", "sphere.egg")
     assert os.path.exists(modelFilename)
     model = loadModel(modelFilename)
     model.setName('model-' + str(modelId))
     obj = NodePath('object-' + str(modelId))
     model.reparentTo(obj)
     colorDescriptions = MaterialColorTable.getColorsFromObject(
         obj, mode='basic')
     self.assertTrue(len(colorDescriptions) == 1)
     self.assertTrue(colorDescriptions[0] == "maroon")
Beispiel #4
0
def set_object_properties(obj):
    """
    Sets category, color and material properties of an object
    """
    semantic_world = SuncgSemanticWorld(TEST_SUNCG_DATA_DIR)

    obj.shape = semantic_world.categoryMapping.getCoarseGrainedCategoryForModelId(obj.modelId)
    obj.size = "normal"
    obj.color = MaterialColorTable.getBasicColorsFromObject(obj, mode='basic')[0]
    obj.material = ' '.join(MaterialTable.getMaterialNameFromObject(obj))

    return obj