Ejemplo n.º 1
0
def createFigure():
    shader = core.shaderGenerator()
    shader.setBoneCondition(1, 1)
    shader.setAmbientType(core.AMBIENT_TYPE_AMBIENT)
    shader.setNumDirLamp(1)
    efig = core.editableFigure('figure')
    efig.addMaterial("mate", shader)
    efig.setMaterialParam("mate", "DiffuseColor", (1.0, 1.0, 1.0, 1.0))
    return efig
Ejemplo n.º 2
0
class Utils:
    _instance = None

    _texture = core.texture("checker", 512, 512, core.GL_RGB)
    _texture.setCheckeredImage(0, 1, 0)
    shader = core.shaderGenerator()
    shader.setColorTexture(True)
    shader.setNumDirLamp(1)
    shader.setBoneCondition(1, 100)
    _efig = core.editableFigure('bullet')
    _efig.addMaterial("mate", shader)

    def __init__(self):
        None

    def __new__(cls):
        if cls._instance is None:
            cls._instance = super().__new__(cls)
        return cls._instance

    def AddShapeMesh(self, shape: igeBullet.shape):

        meshName = "mesh{}".format(self._efig.numMeshes)
        jointName = "joint{}".format(self._efig.numMeshes)

        pos, nom, uv, idx = shape.getMeshData()
        numElem = len(pos) // 3
        idces = ((self._efig.numMeshes, 0, 0, 0), ) * numElem

        self._efig.addMesh(meshName, "mate")
        self._efig.setVertexElements(meshName, core.ATTRIBUTE_ID_POSITION, pos)
        self._efig.setVertexElements(meshName, core.ATTRIBUTE_ID_NORMAL, nom)
        self._efig.setVertexElements(meshName, core.ATTRIBUTE_ID_UV0, uv)
        self._efig.setVertexElements(meshName, core.ATTRIBUTE_ID_BLENDINDICES,
                                     idces)
        self._efig.setTriangles(meshName, idx)
        self._efig.setMaterialParam("mate", "DiffuseColor",
                                    (1.0, 1.0, 1.0, 1.0))
        self._efig.setMaterialParamTexture("mate",
                                           "ColorSampler",
                                           self._texture,
                                           wrap_s=core.SAMPLERSTATE_BORDER,
                                           wrap_t=core.SAMPLERSTATE_BORDER,
                                           minfilter=core.SAMPLERSTATE_LINEAR,
                                           magfilter=core.SAMPLERSTATE_LINEAR)
        self._efig.addJoint(jointName)

    def GetFigure(self):
        return self._efig

    def Update(self, world):
        for i in range(world.getNumCollisionObjects()):
            body = world.getRigidBody(i)
            self._efig.setJoint(i,
                                position=body.position,
                                rotation=body.rotation)
Ejemplo n.º 3
0
class Utils:
    _instance = None

    _texture = core.texture("checker", 512, 512, core.GL_RGB)
    _texture.setCheckeredImage(0, 1, 0)
    shader = core.shaderGenerator()
    shader.setColorTexture(True)
    shader.setNumDirLamp(1)
    shader.setAmbientType(core.AMBIENT_TYPE_AMBIENT)
    shader.setBoneCondition(1, 100)
    _efig = core.editableFigure('bullet')
    _efig.addMaterial("mate", shader)

    def __init__(self):
        None

    def __new__(cls):
        if cls._instance is None:
            cls._instance = super().__new__(cls)
        return cls._instance

    def AddShapeMesh(self, shape: igeBullet.shape):

        meshName = "mesh{}".format(self._efig.numMeshes)
        jointName = "joint{}".format(self._efig.numMeshes)

        pos, nom, uv, idx = shape.getMeshData()
        numElem = len(pos) // 3
        idces = ((self._efig.numMeshes, 0, 0, 0), ) * numElem

        self._efig.addMesh(meshName, "mate")
        self._efig.setVertexElements(meshName, core.ATTRIBUTE_ID_POSITION, pos)
        self._efig.setVertexElements(meshName, core.ATTRIBUTE_ID_NORMAL, nom)
        self._efig.setVertexElements(meshName, core.ATTRIBUTE_ID_UV0, uv)
        self._efig.setVertexElements(meshName, core.ATTRIBUTE_ID_BLENDINDICES,
                                     idces)
        self._efig.setTriangles(meshName, idx)
        self._efig.setMaterialParam("mate", "DiffuseColor",
                                    (1.0, 1.0, 1.0, 1.0))
        self._efig.setMaterialParamTexture("mate",
                                           "ColorSampler",
                                           self._texture,
                                           wrap_s=core.SAMPLERSTATE_BORDER,
                                           wrap_t=core.SAMPLERSTATE_BORDER,
                                           minfilter=core.SAMPLERSTATE_LINEAR,
                                           magfilter=core.SAMPLERSTATE_LINEAR)
        self._efig.setMaterialRenderState("mate", "cull_face_enable", False)
        self._efig.addJoint(jointName)

    def UpdateShapeMesh(self, shape: igeBullet.shape, meshNo):
        pos, _, _, _ = shape.getMeshData()
        self._efig.setVertexElements(meshNo, core.ATTRIBUTE_ID_POSITION, pos)

    def GetFigure(self):
        return self._efig
Ejemplo n.º 4
0
Convert fbx file to display
"""
import os.path
import igeCore as core
from igeCore import devtool as tools

core.window(True, 512, 512)

cam = core.camera()
cam.position = (0, 100, 600)
cam.target = (0, 100, 0)

convertOption = {"BASE_SCALE": 1}

#convert figure 01
fig = core.editableFigure("loader", True)
tools.loadModel("human/female01.fbx", fig, convertOption)
tools.findConvertReplaceTextures(fig, ".", ".", core.TARGET_PLATFORM_MOBILE)
fig.saveFigure("human/female01")

#convert figure 02
fig.clear()
tools.loadModel("human/female02.fbx", fig, convertOption)
tools.findConvertReplaceTextures(fig, ".", ".", core.TARGET_PLATFORM_MOBILE)
fig.saveFigure("human/female02")

#convert animation
fig.clear()
tools.loadModel("human/F_clap.FBX", fig, convertOption)
fig.saveAnimation("human/F_clap")