Hi, i'm new with Ogre and i tried puting a spotlight in a basic scene and the light goes throught the model and doesn't cast shadow.
Code: Select all
from Ogre._Ogre import PF_X8R8G8B8, PF_DEPTH16, PF_DEPTH32
import Ogre
import Ogre.Bites
import Ogre.RTShader
def main():
ctx = Ogre.Bites.ApplicationContext("PySample")
ctx.initApp()
root = ctx.getRoot()
scn_mgr = root.createSceneManager()
scn_mgr.shadowTechnique = Ogre.SHADOWTYPE_STENCIL_ADDITIVE
shadergen = Ogre.RTShader.ShaderGenerator.getSingleton()
shadergen.addSceneManager(scn_mgr) # must be done before we do anything with the scene
scn_mgr.setShadowTextureCountPerLightType(Ogre.Light.LT_SPOTLIGHT, 1 )
scn_mgr.setShadowTextureSettings(1024, 1, PF_X8R8G8B8);
scn_mgr.setShadowFarDistance(500)
scn_mgr.setShadowTexturePixelFormat(PF_DEPTH32)
scn_mgr.setShadowCameraSetup(Ogre.FocusedShadowCameraSetup.create())
light = scn_mgr.createLight("MainLight",Ogre.Light.LT_SPOTLIGHT)
light.setCastShadows(True)
light.diffuseColour = (0.0, 0.0, 1.0)
light.specularColour = (0.0, 0.0, 1.0)
lightnode = scn_mgr.getRootSceneNode().createChildSceneNode()
lightnode.setPosition(0, 2, 5)
lightnode.attachObject(light)
cam = scn_mgr.createCamera("myCam")
cam.setNearClipDistance(5)
cam.setAutoAspectRatio(True)
camnode = scn_mgr.getRootSceneNode().createChildSceneNode()
camnode.setPosition(0, 20, 0)
camnode.attachObject(cam)
# map input events to camera controls
camman = Ogre.Bites.CameraMan(camnode)
camman.setStyle(Ogre.Bites.CS_ORBIT)
#camman.setYawPitchDist(0, 0.3, 50)
ctx.addInputListener(camman)
# and tell it to render into the main window
vp = ctx.getRenderWindow().addViewport(cam)
vp.setBackgroundColour((.3, .3, .3))
# finally something to render
ent = scn_mgr.createEntity("Sinbad.mesh")
ent.setCastShadows(True)
node = scn_mgr.getRootSceneNode().createChildSceneNode()
node.attachObject(ent)
node3 = scn_mgr.getRootSceneNode().createChildSceneNode()
plane = Ogre.Plane((0, 1, 0,0))
mm = Ogre.MeshManager.getSingleton()
mm.createPlane('ground', Ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
plane, 100, 100, 20, 20, True, 1, 1, 1, (0, 0, 1))
ent3 = scn_mgr.createEntity("GroundEntity", "ground")
ent3.setMaterialName("Examples/GrassFloor")
ent3.setCastShadows(True)
node3.attachObject(ent3)
node3.translate((0, 0, -5))
root.startRendering() # blocks until queueEndRendering is called
ctx.closeApp()
if __name__ == "__main__":
main()
What do i miss ?