def getTextureForMaterial(self, material): materialName = material.Name if materialName in self.textureData['materials']: materialConfig = self.textureData['materials'][materialName] imageFile = py2_utils.textureFileString(materialConfig['file']) bumpMapFile = None bumpMap = None if 'bumpMap' in materialConfig: bumpMapFile = py2_utils.textureFileString( materialConfig['bumpMap']) if imageFile not in self.textureCache: tex = coin.SoTexture2() tex.filename = imageFile self.textureCache[imageFile] = tex if bumpMapFile is not None: if bumpMapFile not in self.bumpMapCache: bumpMap = coin.SoBumpMap() bumpMap.filename.setValue(bumpMapFile) self.bumpMapCache[bumpMapFile] = bumpMap bumpMap = self.bumpMapCache[bumpMapFile] texture = self.textureCache[imageFile] return (texture, bumpMap, materialConfig) return (None, None, None)
def updateData(self, fp, prop): if prop in GEOMETRY_COORDINATES: self.updatePanoramaCoordinates() self.updateSkyCoordinates() self.updateGroundCoordinates() self.updatePanoramaTextureCoordinates() elif prop == 'SkyOverlap': self.updateSkyCoordinates() elif prop == 'PanoramaType': self.updatePanoramaTextureCoordinates() elif prop in TRANSFORM_PARAMETERS: self.updateTransformNode() self.updatePanoramaTextureCoordinates() elif prop == 'PanoramaImage': self.panoramaTexture.filename = py2_utils.textureFileString( self.Object.PanoramaImage) self.updateNodeVisibility() elif prop == 'SkyImage': self.skyTexture.filename = py2_utils.textureFileString( self.Object.SkyImage) self.updateNodeVisibility() elif prop == 'GroundImage': self.groundTexture.filename = py2_utils.textureFileString( self.Object.GroundImage) self.updateNodeVisibility()
def setupSkyNode(self): skyNode = coin.SoSeparator() self.skyCoordinates = coin.SoCoordinate3() self.skyTexture = coin.SoTexture2() self.skyTexture.filename = py2_utils.textureFileString( self.Object.SkyImage) self.skyTexture.model = coin.SoMultiTextureImageElement.REPLACE self.skyTextureCoordinates = coin.SoTextureCoordinate2() faceset = coin.SoFaceSet() faceset.numVertices.set1Value(0, 4) faceset.numVertices.set1Value(1, 4) faceset.numVertices.set1Value(2, 4) faceset.numVertices.set1Value(3, 4) faceset.numVertices.set1Value(4, 3) faceset.numVertices.set1Value(5, 4) skyNode.addChild(self.skyCoordinates) skyNode.addChild(self.skyTextureCoordinates) skyNode.addChild(self.skyTexture) skyNode.addChild(faceset) return skyNode
def setupGroundNode(self): groundNode = coin.SoSeparator() self.groundCoordinates = coin.SoCoordinate3() self.groundTexture = coin.SoTexture2() self.groundTexture.filename = py2_utils.textureFileString( self.Object.GroundImage) self.groundTexture.model = coin.SoMultiTextureImageElement.REPLACE groundTextureCoordinates = coin.SoTextureCoordinate2() groundTextureCoordinates.point.set1Value(0, 0, 0) groundTextureCoordinates.point.set1Value(1, 1, 0) groundTextureCoordinates.point.set1Value(2, 1, 1) groundTextureCoordinates.point.set1Value(3, 0, 1) faceset = coin.SoFaceSet() faceset.numVertices.set1Value(0, 4) groundNode.addChild(self.groundCoordinates) groundNode.addChild(groundTextureCoordinates) groundNode.addChild(self.groundTexture) groundNode.addChild(faceset) return groundNode
def setupPanoramaNode(self): panoramaNode = coin.SoSeparator() self.panoramaCoordinates = coin.SoCoordinate3() self.panoramaTextureCoordinates = coin.SoTextureCoordinate2() self.panoramaTexture = coin.SoTexture2() self.panoramaTexture.filename = py2_utils.textureFileString( self.Object.PanoramaImage) self.panoramaTexture.model = coin.SoMultiTextureImageElement.REPLACE faceset = coin.SoFaceSet() faceset.numVertices.set1Value(0, 4) faceset.numVertices.set1Value(1, 4) faceset.numVertices.set1Value(2, 4) panoramaNode.addChild(self.panoramaCoordinates) panoramaNode.addChild(self.panoramaTextureCoordinates) panoramaNode.addChild(self.panoramaTexture) panoramaNode.addChild(faceset) return panoramaNode