Esempio 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
Esempio 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)
Esempio 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
Esempio n. 4
0
"""
shader effect sample
"""

import igeCore as core
from igeCore.apputil import graphicsHelper
import igeVmath as vmath

from igeCore import devtool
devtool.convertAssets('.', '.', core.TARGET_PLATFORM_ANDROID, 0.1)

core.window(True, 480, 640)

shader = core.shaderGenerator()
shader.setColorTexture(True)  #use color texture
shader.setDistortion(True)  #add distortion effect
shader.setUVScroll(1, True)  #start uv scroll at uv channel 1
shader.setNormalTextureUVSet(1, 1)  #change normal texture uv channel to 1
shader.setProjectionMapping(1, True)  #projection mapping mode at uv channel 1

print(shader)  #print shader program

shadowSprite = graphicsHelper.createSprite(200, 200, "fire", shader=shader)

#set uv scroll speed for uv set 1
shadowSprite.setMaterialParam("mate", "ScrollSpeedSet1", (0.0, -0.08))

#set distortion strength
shadowSprite.setMaterialParam("mate", "DistortionStrength", (0.02, ))

#set normal texture for distortion
Esempio n. 5
0
character with shadow

"""
import igeCore as core
from igeCore import devtool
from igeCore.apputil import graphicsHelper
import igeVmath as vmath
import os.path
from char import Character
from cam import TargetCamera
from controller import Controller

devtool.convertAssets('.', '.', core.TARGET_PLATFORM_MOBILE)
core.window(True, 480, 640)

core.shaderGenerator().globalShadowBias = 0.001

#core.autoSaveShader('shaders')

#The character shadow is specified to be set at the time of conversion by figure.conf.
#See Sapphiart/figure.conf
char = Character()

cam = TargetCamera()
controller = Controller()

ground = graphicsHelper.createSprite(20.0,
                                     20.0,
                                     texture='images/Dirt-2290',
                                     normal=(0, 1, 0))
#add shadow shader