Revision: 761
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=761&view=rev
Author: andy_miller
Date: 2008-10-20 13:48:25 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
Updates to demos to work with Unittesting
Fixes to demos due to API changes in Ogre and Python-Ogre implementation
Added unittest script
Tweaks to sampleframework for unittest
Modified Paths:
--------------
trunk/python-ogre/demos/caelum/Demo_Caelum01.py
trunk/python-ogre/demos/caelum/resources.cfg
trunk/python-ogre/demos/ogre/Demo_Basic.py
trunk/python-ogre/demos/ogre/Demo_CameraTracking.py
trunk/python-ogre/demos/ogre/Demo_CelShading.py
trunk/python-ogre/demos/ogre/Demo_Fresnel.py
trunk/python-ogre/demos/ogre/Demo_Grass.py
trunk/python-ogre/demos/ogre/Demo_NetworkClient.py
trunk/python-ogre/demos/ogre/Demo_NetworkServer.py
trunk/python-ogre/demos/ogre/Demo_NodeListener.py
trunk/python-ogre/demos/ogre/Demo_OgreCollision02.py
trunk/python-ogre/demos/ogre/Demo_OneFish.py
trunk/python-ogre/demos/ogre/Demo_ParticleFX.py
trunk/python-ogre/demos/ogre/Demo_RenderToTexture.py
trunk/python-ogre/demos/ogre/Demo_RendererCreate.py
trunk/python-ogre/demos/ogre/Demo_SkeletalAnimation.py
trunk/python-ogre/demos/ogre/Demo_SkyBox.py
trunk/python-ogre/demos/ogre/Demo_SkyDome.py
trunk/python-ogre/demos/ogre/Demo_Spinner.py
trunk/python-ogre/demos/ogre/Demo_Terrain.py
trunk/python-ogre/demos/ogre/Demo_Video.py
trunk/python-ogre/demos/ogre/Demo_WX.py
trunk/python-ogre/demos/ogre/Demo_Water.py
trunk/python-ogre/demos/ogre/demo_water_s.py
trunk/python-ogre/packages_2.5/ogre/renderer/OGRE/sf_OIS.py
Added Paths:
-----------
trunk/python-ogre/scripts/UnitTest.py
Removed Paths:
-------------
trunk/python-ogre/demos/ogre/Demo_Shadows_Org.py
trunk/python-ogre/demos/ogre/Shadows.py
Modified: trunk/python-ogre/demos/caelum/Demo_Caelum01.py
===================================================================
--- trunk/python-ogre/demos/caelum/Demo_Caelum01.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/caelum/Demo_Caelum01.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -27,7 +27,7 @@
self.updateRay = ogre.Ray()
## basic terrain ray query
pos = camera.getPosition()
- d = ogre.Vector3.NEGATIVE_UNIT_Y
+ d = ogre.Vector3().NEGATIVE_UNIT_Y
self.raySceneQuery = sceneManager.createRayQuery(ogre.Ray( pos, d ))
## --------------------------------------------------------------
@@ -38,7 +38,7 @@
## clamp camera to terrain
self.updateRay.setOrigin (self.camera.getPosition())
- self.updateRay.setDirection (ogre.Vector3.NEGATIVE_UNIT_Y)
+ self.updateRay.setDirection (ogre.Vector3().NEGATIVE_UNIT_Y)
self.raySceneQuery.Ray = self.updateRay
for queryResult in self.raySceneQuery.execute():
if queryResult.worldFragment is not None:
@@ -154,8 +154,8 @@
print "deleted Listeners"
# t = self.caelumSystem.getSun().setSunPositionModel(None)
# print "Sun is None", t
- t = self.caelumSystem.getSun().getSunPositionModel()
- print "Sun is None", t
+# t = self.caelumSystem.getSun().getSunPositionModel()
+# print "Sun is None", t
@@ -205,7 +205,7 @@
self.camera.setFarClipDistance(0);
self.camera.setNearClipDistance(5);
- self.raySceneQuery = self.sceneManager.createRayQuery(ogre.Ray(self.camera.getPosition(), ogre.Vector3.NEGATIVE_UNIT_Y))
+ self.raySceneQuery = self.sceneManager.createRayQuery(ogre.Ray(self.camera.getPosition(), ogre.Vector3().NEGATIVE_UNIT_Y))
def _createScene(self):
@@ -224,18 +224,25 @@
ogre.CompositorManager.getSingleton().addCompositor(self.renderWindow.getViewport(0),"Bloom")
camera.setNearClipDistance(0.01)
componentMask = caelum.CaelumSystem.CaelumComponent(
- caelum.CaelumSystem.CAELUM_COMPONENT_SKY_COLOUR_MODEL |
+# caelum.CaelumSystem.CAELUM_COMPONENT_SKY_DOME |
# caelum.CaelumSystem.CAELUM_COMPONENT_SUN |
- caelum.CaelumSystem.CAELUM_COMPONENT_SOLAR_SYSTEM_MODEL |
- ## these cause run time errors on my crap laptop
-# caelum.CaelumSystem.CAELUM_COMPONENT_SKY_DOME |
-# caelum.CaelumSystem.CAELUM_COMPONENT_STARFIELD |
+# caelum.CaelumSystem.CAELUM_COMPONENT_MOON |
+# caelum.CaelumSystem.CAELUM_COMPONENT_IMAGE_STARFIELD |
+# caelum.CaelumSystem.CAELUM_COMPONENT_POINT_STARFIELD |
# caelum.CaelumSystem.CAELUM_COMPONENT_CLOUDS |
+# caelum.CaelumSystem.CAELUM_COMPONENT_PRECIPITATION |
+# caelum.CaelumSystem.CAELUM_COMPONENT_SCREEN_SPACE_FOG |
# caelum.CaelumSystem.CAELUM_COMPONENT_GROUND_FOG |
+
+# caelum.CaelumSystem.CAELUM_COMPONENTS_NONE |
+ caelum.CaelumSystem.CAELUM_COMPONENTS_DEFAULT |
+# caelum.CaelumSystem.CAELUM_COMPONENTS_ALL |
+
+
0 )
print componentMask
## Initialise Caelum
- self.caelumSystem = caelum.CaelumSystem(self.root.getSingletonPtr(), self.sceneManager ) ##,componentMask )
+ self.caelumSystem = caelum.CaelumSystem(self.root.getSingletonPtr(), self.sceneManager ,componentMask )
self.caelumSystem.setManageSceneFog(True)
self.caelumSystem.setSceneFogDensityMultiplier(0.0015)
@@ -244,7 +251,7 @@
## This is how you switch the sun implementation.
## This here is a no-op; but it's useful to test caelum doesn't crash when the second sun is created.
- self.spheresun = caelum.SphereSun(self.sceneManager, self.caelumSystem.getRootNode ())
+ self.spheresun = caelum.SphereSun(self.sceneManager, self.caelumSystem.getCaelumCameraNode ())
self.caelumSystem.setSun (self.spheresun)
## Setup sun options
@@ -261,11 +268,14 @@
# ## Setup cloud options.
# ## Tweak these settings to make the demo look pretty.
- if self.caelumSystem.getClouds ():
- self.caelumSystem.getClouds ().setCloudSpeed(ogre.Vector2(0.000005, -0.000009))
- self.caelumSystem.getClouds ().setCloudBlendTime(3600 * 24)
- self.caelumSystem.getClouds ().setCloudCover(0.3)
+ if self.caelumSystem.getCloudSystem ():
+
+ self.caelumSystem.getCloudSystem ().createLayerAtHeight(2000)
+ self.caelumSystem.getCloudSystem ().createLayerAtHeight(5000)
+ self.caelumSystem.getCloudSystem ().getLayer(0).setCloudSpeed(ogre.Vector2(0.000005, -0.000009))
+ self.caelumSystem.getCloudSystem ().getLayer(1).setCloudSpeed(ogre.Vector2(0.0000045, -0.0000085))
+
## Register caelum to the render target
self.renderWindow.addListener (self.caelumSystem)
Modified: trunk/python-ogre/demos/caelum/resources.cfg
===================================================================
--- trunk/python-ogre/demos/caelum/resources.cfg 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/caelum/resources.cfg 2008-10-20 13:48:25 UTC (rev 761)
@@ -1,26 +1,10 @@
-[Bootstrap]
+[Bootstrap]
+#Zip=..\..\samples\resources\OgreCore.zip
Zip=../media/packs/OgreCore.zip
+[Caelum]
+FileSystem=c:\development\caelum\trunk\caelum\main\resources\
+FileSystem=c:\development\caelum\trunk\caelum\samples\resources\
+[CEGUI]
+FileSystem=c:\development\caelum\trunk\caelum\samples\resources\gui\
-# Resource locations to be added to the default path
-[General]
-FileSystem=../media
-FileSystem=../media/fonts
-FileSystem=../media/sounds
-FileSystem=../media/Audio
-FileSystem=../media/materials/programs
-FileSystem=../media/materials/scripts
-FileSystem=../media/materials/textures
-FileSystem=../media/models
-FileSystem=../media/overlays
-FileSystem=../media/particle
-FileSystem=../media/gui
-Zip=../media/packs/cubemap.zip
-Zip=../media/packs/cubemapsJS.zip
-Zip=../media/packs/dragon.zip
-Zip=../media/packs/fresneldemo.zip
-Zip=../media/packs/ogretestmap.zip
-Zip=../media/packs/skybox.zip
-#Zip=../media/packs/chiropteraDM.pk3
-[Caelum]
-FileSystem=./media
Modified: trunk/python-ogre/demos/ogre/Demo_Basic.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_Basic.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_Basic.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -1,3 +1,4 @@
+# NO_UNITTEST
# This code is in the Public Domain
# -----------------------------------------------------------------------------
# This source file is part of Python-Ogre
@@ -19,7 +20,7 @@
import ogre.io.OIS as OIS
class OGREMain(ogre.Root):
- def __init__(self, plugins_path='plugins.cfg',resource_path='resources.cfg'):
+ def __init__(self, plugins_path='plugins.cfg',resource_path='../resources.cfg'):
ogre.Root.__init__(self, plugins_path)
self.plugins_path = plugins_path
self.resource_path = resource_path
@@ -96,7 +97,7 @@
def main():
- root = OGREMain(plugins_path='plugins.cfg')
+ root = OGREMain(plugins_path='../plugins.cfg')
weu = ogre.WindowEventUtilities()
while not root.window.isClosed():
weu.messagePump()
Modified: trunk/python-ogre/demos/ogre/Demo_CameraTracking.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_CameraTracking.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_CameraTracking.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -31,7 +31,7 @@
plane = ogre.Plane()
- plane.normal = ogre.Vector3.UNIT_Y
+ plane.normal = ogre.Vector3().UNIT_Y
plane.d = 200
mm = ogre.MeshManager.getSingleton()
mm.createPlane('FloorPlane', 'General', plane, 200000.0, 200000.0,
Modified: trunk/python-ogre/demos/ogre/Demo_CelShading.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_CelShading.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_CelShading.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -31,7 +31,7 @@
# Accept default settings: point light, white diffuse, just set position
light = sceneManager.createLight('MainLight')
- self.rotationNode = sceneManager.rootSceneNode.createChildSceneNode()
+ self.rotationNode = sceneManager.getRootSceneNode().createChildSceneNode()
self.rotationNode.createChildSceneNode((20,40,50)).attachObject(light)
# create head entity
@@ -67,7 +67,7 @@
sub.setCustomParameter(CUSTOM_DIFFUSE, (1.0, 1.0, 0.7, 1.0))
sub.setCustomParameter(CUSTOM_SPECULAR, (1.0, 1.0, 1.0, 1.0))
- sceneManager.rootSceneNode.createChildSceneNode().attachObject(entity)
+ sceneManager.getRootSceneNode().createChildSceneNode().attachObject(entity)
self.renderWindow.getViewport(0).backgroundColour = (1, 1, 1)
def _createFrameListener(self):
Modified: trunk/python-ogre/demos/ogre/Demo_Fresnel.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_Fresnel.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_Fresnel.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -105,15 +105,15 @@
direction = self.fishLastPosition[fish] - newPos
direction.normalise
#Test for opposite vectors
- d = 1.0 + ogre.Vector3.UNIT_X.dotProduct(direction)
+ d = 1.0 + ogre.Vector3().UNIT_X.dotProduct(direction)
if (math.fabs(d) < 0.00001):
#Diametrically opposed vectors
- orientation = ogre.Quaternion.IDENTITY
- orientation.FromAxes(ogre.Vector3.NEGATIVE_UNIT_X,
- ogre.Vector3.UNIT_Y, ogre.Vector3.NEGATIVE_UNIT_Z)
+ orientation = ogre.Quaternion().IDENTITY
+ orientation.FromAxes(ogre.Vector3().NEGATIVE_UNIT_X,
+ ogre.Vector3().UNIT_Y, ogre.Vector3().NEGATIVE_UNIT_Z)
self.fishNodes[fish].setOrientation (orientation) ## .orientation to SetOr..
else:
- self.fishNodes[fish].setOrientation (ogre.Vector3.UNIT_X.getRotationTo(direction))
+ self.fishNodes[fish].setOrientation (ogre.Vector3().UNIT_X.getRotationTo(direction))
self.fishLastPosition[fish] = newPos
return sf.FrameListener.frameStarted(self,frameEvent)
@@ -121,6 +121,7 @@
def __init__(self):
"Init Fresnel Application"
+ sf.Application.__init__(self)
self.frameListener = None
self.root = None
self.camera = None
@@ -188,7 +189,7 @@
#Create a point light
l = sceneManager.createLight("MainLight")
l.type = ogre.Light.LT_DIRECTIONAL
- l.setDirection (-ogre.Vector3.UNIT_Y)
+ l.setDirection (-ogre.Vector3().UNIT_Y)
# debug graphics card capabilities
# self.debugSupportedFormats()
@@ -227,7 +228,7 @@
#Define a floor plane mesh
self.reflectionPlane = ogre.Plane()
- self.reflectionPlane.normal = ogre.Vector3.UNIT_Y
+ self.reflectionPlane.normal = ogre.Vector3().UNIT_Y
self.reflectionPlane.d = 0
ogre.MeshManager.getSingleton().createPlane('ReflectPlane', "General",
@@ -259,7 +260,7 @@
pEnt.setMaterialName ("RomanBath/OgreStone")
headNode.attachObject(pEnt)
headNode.setPosition(-350,55,130)
- headNode.rotate(ogre.Vector3.UNIT_Y, ogre.Degree (90))
+ headNode.rotate(ogre.Vector3().UNIT_Y, ogre.Degree (90))
self.aboveWaterEnts.append(pEnt)
# create below Water Entities
Modified: trunk/python-ogre/demos/ogre/Demo_Grass.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_Grass.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_Grass.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -173,7 +173,7 @@
baseVec = ogre.Vector3(GRASS_WIDTH/2, 0, 0)
vec = baseVec
rot = ogre.Quaternion ()
- rot.FromAngleAxis(ogre.Degree(d=60), ogre.Vector3.UNIT_Y)
+ rot.FromAngleAxis(ogre.Degree(d=60), ogre.Vector3().UNIT_Y)
# change from the C++ demo - we build a buffer and then write it in one go
buffer=[]
@@ -357,11 +357,11 @@
self.setupLighting()
plane = ogre.Plane()
- plane.normal = ogre.Vector3.UNIT_Y
+ plane.normal = ogre.Vector3().UNIT_Y
plane.d = 0
ogre.MeshManager.getSingleton().createPlane("Myplane",
ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane,
- 14500,14500,10,10,True,1,50,50,ogre.Vector3.UNIT_Z)
+ 14500,14500,10,10,True,1,50,50,ogre.Vector3().UNIT_Z)
pPlaneEnt = self.sceneManager.createEntity( "plane", "Myplane" )
pPlaneEnt.setMaterialName("Examples/GrassFloor")
pPlaneEnt.setCastShadows(False)
@@ -386,7 +386,7 @@
orientation = ogre.Quaternion()
orientation.FromAngleAxis(
ogre.Degree(random.randrange(0, 359)),
- ogre.Vector3.UNIT_Y)
+ ogre.Vector3().UNIT_Y)
scale = ogre.Vector3( 1, random.random()*(1.15-0.85)+0.85, 1)
s.addEntity(e, pos, orientation, scale)
s.build()
Modified: trunk/python-ogre/demos/ogre/Demo_NetworkClient.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_NetworkClient.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_NetworkClient.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -1,3 +1,4 @@
+# NO_UNITTEST
"""
VERY simple and crude client code.
Assumes there is a server that will echo the sent data and when it's time to close
Modified: trunk/python-ogre/demos/ogre/Demo_NetworkServer.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_NetworkServer.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_NetworkServer.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -1,3 +1,4 @@
+# NO_UNITTEST
"""
VERY simple and crude Python server
@@ -8,6 +9,7 @@
import socket as s
import SocketServer as ss
+import sys
class Handler ( ss.BaseRequestHandler ):
def handle ( self ):
@@ -36,6 +38,10 @@
(family, socktype, proto, canonname, sockaddr) = s.getaddrinfo ( "127.0.0.1", 4444 )[0]
myServer = Server ( sockaddr, Handler )
myServer.closenow = False
-
- while not myServer.closenow:
- myServer.handle_request()
+ try:
+ while not myServer.closenow:
+ myServer.handle_request()
+ except KeyboardInterrupt:
+ sys.exit()
+ except:
+ sys.exit()
\ No newline at end of file
Modified: trunk/python-ogre/demos/ogre/Demo_NodeListener.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_NodeListener.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_NodeListener.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -60,7 +60,7 @@
light.setPosition (ogre.Vector3(20, 80, 50))
plane = ogre.Plane()
- plane.normal = ogre.Vector3.UNIT_Y
+ plane.normal = ogre.Vector3().UNIT_Y
plane.d = 200
mm = ogre.MeshManager.getSingleton()
Modified: trunk/python-ogre/demos/ogre/Demo_OgreCollision02.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_OgreCollision02.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_OgreCollision02.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -38,11 +38,11 @@
# create the floor
plane = ogre.Plane()
- plane.normal = ogre.Vector3.UNIT_Y
+ plane.normal = ogre.Vector3().UNIT_Y
plane.d = 200
mm = ogre.MeshManager.getSingleton()
mm.createPlane('FloorPlane', 'General', plane, 200000.0, 200000.0,
- 20, 20, True, 1, 50, 50, ogre.Vector3.UNIT_Z)
+ 20, 20, True, 1, 50, 50, ogre.Vector3().UNIT_Z)
entity = sceneManager.createEntity('floor', 'FloorPlane')
entity.setMaterialName('Examples/RustySteel')
sceneManager.getRootSceneNode().createChildSceneNode().attachObject(entity)
Modified: trunk/python-ogre/demos/ogre/Demo_OneFish.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_OneFish.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_OneFish.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -41,7 +41,7 @@
#Then, takes care of the direction that the fish has to face to
directionToGo = self.mAnimEntity[2].position - self.mAnimEntity[1].position
- src = self.mAnimEntity[0].Orientation * (-ogre.Vector3.UNIT_X)
+ src = self.mAnimEntity[0].Orientation * (-ogre.Vector3().UNIT_X)
quat = src.getRotationTo(directionToGo) #Calculates the quaternion of the appropriate rotation
self.mAnimEntity[0].rotate(quat) #Rotates, the fish. Here, we know that no rotation of 180
#degrees will occur so we do not have to care about it
Modified: trunk/python-ogre/demos/ogre/Demo_ParticleFX.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_ParticleFX.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_ParticleFX.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -43,13 +43,13 @@
particleSystem2 = sceneManager.createParticleSystem('fountain1', 'Examples/PurpleFountain')
node = self.fountainNode.createChildSceneNode()
node.translate(200.0, -100.0, 0.0)
- node.rotate(ogre.Vector3.UNIT_Z, ogre.Degree(20))
+ node.rotate(ogre.Vector3().UNIT_Z, ogre.Degree(20))
node.attachObject(particleSystem2)
particleSystem3 = sceneManager.createParticleSystem('fountain2', 'Examples/PurpleFountain')
node = self.fountainNode.createChildSceneNode()
node.translate(-200.0, -100.0, 0.0)
- node.rotate(ogre.Vector3.UNIT_Z, ogre.Degree(-20))
+ node.rotate(ogre.Vector3().UNIT_Z, ogre.Degree(-20))
node.attachObject(particleSystem3)
particleSystem4 = sceneManager.createParticleSystem('rain', 'Examples/Rain')
Modified: trunk/python-ogre/demos/ogre/Demo_RenderToTexture.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_RenderToTexture.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_RenderToTexture.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -89,19 +89,19 @@
# Create a prefab plane
self.mPlane = ogre.MovablePlane("ReflectPlane")
self.mPlane.d = 0
- self.mPlane.normal =ogre.Vector3.UNIT_Y
+ self.mPlane.normal =ogre.Vector3().UNIT_Y
# ogre.MeshManager.getSingleton().createPlane("ReflectionPlane",
# ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
# self.mPlane._getDerivedPlane(), 2000.0, 2000.0,
-# 1, 1, True, 1, 1.0, 1.0, ogre.Vector3.UNIT_Z,
+# 1, 1, True, 1, 1.0, 1.0, ogre.Vector3().UNIT_Z,
# ogre.HardwareBuffer.HBU_STATIC_WRITE_ONLY, ogre.HardwareBuffer.HBU_STATIC_WRITE_ONLY,
# True,True
# )
ogre.MeshManager.getSingleton().createPlane("ReflectionPlane",
ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
self.mPlane, 2000.0, 2000.0,
- 1, 1, True, 1, 1.0, 1.0, ogre.Vector3.UNIT_Z,
+ 1, 1, True, 1, 1.0, 1.0, ogre.Vector3().UNIT_Z,
ogre.HardwareBuffer.HBU_STATIC_WRITE_ONLY, ogre.HardwareBuffer.HBU_STATIC_WRITE_ONLY,
True,True
)
@@ -157,15 +157,15 @@
# create ViewPort
v = rttTex.addViewport( self.mReflectCam )
v.setClearEveryFrame ( True )
- v.setBackgroundColour (ogre.ColourValue.White)
+ v.setBackgroundColour (ogre.ColourValue().White)
mat = ogre.MaterialManager.getSingleton().create("RttMat",ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
t = mat.getTechnique(0).getPass(0).createTextureUnitState('RustedMetal.jpg')
t = mat.getTechnique(0).getPass(0).createTextureUnitState('RttTex') # creates the reflection...
# Blend with base texture
t.setColourOperationEx( ogre.LBX_BLEND_MANUAL, ogre.LBS_TEXTURE,
- ogre.LBS_CURRENT, ogre.ColourValue.White,
- ogre.ColourValue.White, 0.25)
+ ogre.LBS_CURRENT, ogre.ColourValue().White,
+ ogre.ColourValue().White, 0.25)
t.setTextureAddressingMode (ogre.TextureUnitState.TAM_CLAMP)
t.setProjectiveTexturing(True, self.mReflectCam)
Modified: trunk/python-ogre/demos/ogre/Demo_RendererCreate.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_RendererCreate.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_RendererCreate.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -1,3 +1,4 @@
+# NO_UNITTEST
# This code is in the Public Domain
# -----------------------------------------------------------------------------
# This source file is part of Python-Ogre
@@ -27,7 +28,7 @@
self.client = None
self.root = ogre.Root( sf.getPluginPath() )
config = ogre.ConfigFile()
- config.load('resources.cfg' )
+ config.load('../resources.cfg' )
## this is still ugly as we need to create a real python iterator...
Deleted: trunk/python-ogre/demos/ogre/Demo_Shadows_Org.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_Shadows_Org.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_Shadows_Org.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -1,564 +0,0 @@
-# This code is in the Public Domain
-# -----------------------------------------------------------------------------
-# This source file is part of Python-Ogre
-# For the latest info, see http://python-ogre.org/
-#
-# It is likely based on original code from OGRE and/or PyOgre
-# For the latest info, see http://www.ogre3d.org/
-#
-# You may use this sample code for anything you like, it is not covered by the
-# LGPL.
-# -----------------------------------------------------------------------------
-
-#
-# \file
-# Shadows.cpp
-# \brief
-# Shows a few ways to use ogre's shadowing techniques
-#
-import sys
-sys.path.insert(0,'..')
-import PythonOgreConfig
-
-import ogre.renderer.OGRE as ogre
-import SampleFramework as sf
-
-if ogre.OgreVersionString[:2] =="12":
- KC_O = ogre.KC_O
- KC_M = ogre.KC_M
-else:
- import ogre.io.OIS as OIS
- KC_O = OIS.KC_O
- KC_M = OIS.KC_M
-
-
-mAnimState = 0
-# Entity* pPlaneEnt
-mLight =0
-mSunLight =0
-# SceneNode* mLightNode = 0
-# AnimationState* mLightAnimationState = 0
-mMinLightColour = ogre.ColourValue(0.3, 0.0, 0)
-mMaxLightColour = ogre.ColourValue(0.5, 0.3, 0.1)
-mMinFlareSize = 40
-mMaxFlareSize = 80
-
-NUM_ATHENE_MATERIALS= 2
-mAtheneMaterials = [ "Examples/Athene/NormalMapped", "Examples/Athene/Basic" ]
-NUM_SHADOW_TECH = 6
-mShadowTechDescriptions = [
- "Stencil Shadows (Additive)",
- "Stencil Shadows (Modulative)",
- "Texture Shadows (Additive)",
- "Texture Shadows (Modulative)",
- "Texture Shadows (Soft Modulative)",
- "None"
-]
-mShadowTech = [
- ogre.SHADOWTYPE_STENCIL_ADDITIVE,
- ogre.SHADOWTYPE_STENCIL_MODULATIVE,
- ogre.SHADOWTYPE_TEXTURE_ADDITIVE,
- ogre.SHADOWTYPE_TEXTURE_MODULATIVE,
- ogre.SHADOWTYPE_TEXTURE_MODULATIVE, # soft shadows
- ogre.SHADOWTYPE_NONE
-]
-mShadowTechSoft = [
- False,
- False,
- False,
- False,
- True,
- False
-]
-mSoftShadowsSupported = True
-
-mCurrentAtheneMaterial = 0
-mCurrentShadowTechnique = 0
-SHADOW_COMPOSITOR_NAME = "Gaussian Blur"
-mAthene =0
-
-mShadowTechniqueInfo=0
-mMaterialInfo = 0
-# OverlayElement* mInfo
-
-global NUM_ATHENE_MATERIALS,mAtheneMaterials,NUM_SHADOW_TECH,mShadowTechDescriptions
-global mShadowTech,mShadowTechSoft,mSoftShadowsSupported,mCurrentAtheneMaterial,mCurrentShadowTechnique
-
-
-## This class 'wibbles' the light and billboard
-class LightWibbler ( ogre.ControllerValueFloat ):
- global NUM_ATHENE_MATERIALS,mAtheneMaterials,NUM_SHADOW_TECH,mShadowTechDescriptions
- global mShadowTech,mShadowTechSoft,mSoftShadowsSupported,mCurrentAtheneMaterial,mCurrentShadowTechnique
-
-
- def __init__(self, light, billboard, minColour, maxColour, minSize, maxSize):
- self.mLight = light
- self.mBillboard = billboard
- self.mMinColour = minColour
- self.mColourRange = ogre.ColourValue(0,0,0)
- self.mColourRange.r = maxColour.r - minColour.r
- self.mColourRange.g = maxColour.g - minColour.g
- self.mColourRange.b = maxColour.b - minColour.b
- self.mMinSize = minSize
- self.mSizeRange = maxSize - minSize
- self.intensity=0
- ogre.ControllerValueFloat.__init__(self)
-
-
-
- def getValue (self):
- return self.intensity
-
- def setValue ( self, value):
-
- self.intensity = value
-
- newColour = ogre.ColourValue(0,0,0)
-
- # Attenuate the brightness of the light
- newColour.r = self.mMinColour.r + (self.mColourRange.r * self.intensity)
- newColour.g = self.mMinColour.g + (self.mColourRange.g * self.intensity)
- newColour.b = self.mMinColour.b + (self.mColourRange.b * self.intensity)
-
- self.mLight.setDiffuseColour(newColour)
- self.mBillboard.setColour(newColour)
- # set billboard size
- newSize = self.mMinSize + (self.intensity * self.mSizeRange)
- self.mBillboard.setDimensions(newSize, newSize)
-
-
-# Real timeDelay = 0
-# #define KEY_PRESSED(_key,_timeDelay, _macro) \
-# { \
-# if (mInputDevice.isKeyDown(_key) && timeDelay <= 0) \
-# { \
-# timeDelay = _timeDelay \
-# _macro \
-# } \
-# }
-
-
-#---------------------------------------------------------------------------
-class GaussianListener (ogre.CompositorInstance.Listener):
- global NUM_ATHENE_MATERIALS,mAtheneMaterials,NUM_SHADOW_TECH,mShadowTechDescriptions
- global mShadowTech,mShadowTechSoft,mSoftShadowsSupported,mCurrentAtheneMaterial,mCurrentShadowTechnique
-# mVpWidth = 0
-# mVpHeight = 0
-# # Array params - have to pack in groups of 4 since this is how Cg generates them
- # also prevents dependent texture read problems if ops don't require swizzle
-# mBloomTexWeights=[15][4]
-# mBloomTexOffsetsHorz=[15][4]
-# mBloomTexOffsetsVert=[15][4]
-
- def __init__ (self):
- ogre.CompositorInstance.listener.__init__(self)
-
- def notifyViewportSize(width, height):
- self.mVpWidth = width
- self.mVpHeight = height
- # Calculate gaussian texture offsets & weights
- deviation = 3.0
- texelSize = 1.0 / min(self.mVpWidth, self.mVpHeight)
-
- # central sample, no offset
- self.mBloomTexOffsetsHorz[0][0] = 0.0
- self.mBloomTexOffsetsHorz[0][1] = 0.0
- self.mBloomTexOffsetsVert[0][0] = 0.0
- self.mBloomTexOffsetsVert[0][1] = 0.0
- self.mBloomTexWeights[0][0] = ogre.Math.gaussianDistribution(0, 0, deviation)
- self.mBloomTexWeights[0][1] = self.mBloomTexWeights[0][0]
- self.mBloomTexWeights[0][2] = self.mBloomTexWeights[0][0]
- self.mBloomTexWeights[0][3] = 1.0
-
- # 'pre' samples
- for i in range (1,8):
- self.mBloomTexWeights[i][0] = ogre.Math.gaussianDistribution(i, 0, deviation)
- self.mBloomTexWeights[i][1] = self.mBloomTexWeights[i][0]
- self.mBloomTexWeights[i][2] = self.mBloomTexWeights[i][0]
- self.mBloomTexWeights[i][3] = 1.0
- self.mBloomTexOffsetsHorz[i][0] = i * texelSize
- self.mBloomTexOffsetsHorz[i][1] = 0.0
- self.mBloomTexOffsetsVert[i][0] = 0.0
- self.mBloomTexOffsetsVert[i][1] = i * texelSize
- # 'post' samples
- for i in range (8, 15):
- self.mBloomTexWeights[i][0] = self.mBloomTexWeights[i - 7][0]
- self.mBloomTexWeights[i][1] = self.mBloomTexWeights[i][0]
- self.mBloomTexWeights[i][2] = self.mBloomTexWeights[i][0]
- self.mBloomTexWeights[i][3] = 1.0
-
- self.mBloomTexOffsetsHorz[i][0] = -self.mBloomTexOffsetsHorz[i - 7][0]
- self.mBloomTexOffsetsHorz[i][1] = 0.0
- self.mBloomTexOffsetsVert[i][0] = 0.0
- self.mBloomTexOffsetsVert[i][1] = -self.mBloomTexOffsetsVert[i - 7][1]
-
- def notifyMaterialSetup( pass_id, mat):
- # Prepare the fragment params offsets
- if pass_id == 701: #blur Horz
- # horizontal bloom
- mat.load()
- fparams = mat.getBestTechnique().getPass(0).getFragmentProgramParameters()
- progName = mat.getBestTechnique().getPass(0).getFragmentProgramName()
- # A bit hacky - Cg & HLSL index arrays via [0], GLSL does not
- if progName.find("GLSL") != ogre.String.npos:
- fparams.setNamedConstant("sampleOffsets", self.mBloomTexOffsetsHorz[0], 15)
- fparams.setNamedConstant("sampleWeights", self.mBloomTexWeights[0], 15)
- else:
- fparams.setNamedConstant("sampleOffsets[0]", self.mBloomTexOffsetsHorz[0], 15)
- fparams.setNamedConstant("sampleWeights[0]", self.mBloomTexWeights[0], 15)
- elif pass_id == 700: # blur vert
- # vertical bloom
- mat.load()
- fparams = mat.getTechnique(0).getPass(0).getFragmentProgramParameters()
- progName = mat.getBestTechnique().getPass(0).getFragmentProgramName()
- # A bit hacky - Cg & HLSL index arrays via [0], GLSL does not
- if progName.find("GLSL") != ogre.String.npos:
- fparams.setNamedConstant("sampleOffsets", self.mBloomTexOffsetsVert[0], 15)
- fparams.setNamedConstant("sampleWeights", self.mBloomTexWeights[0], 15)
- else:
- fparams.setNamedConstant("sampleOffsets[0]", self.mBloomTexOffsetsVert[0], 15)
- fparams.setNamedConstant("sampleWeights[0]", self.mBloomTexWeights[0], 15)
-
- def notifyMaterialRender(pass_id, mat):
- pass
-
-
-
-###GaussianListener gaussianListener
-
-
-class ShadowsListener (sf.FrameListener):
-
- def __init__ ( self, win, cam, sm):
- sf.FrameListener.__init__(self,win, cam)
- self.sceneManager = sm
- self.mShadowVp=0
- self.mShadowCompositor=None
- self.timeDelay=0
-
-# def frameStarted(self, frameEvent):
-# return sf.FrameListener.frameStarted(self, frameEvent)
-
- def changeShadowTechnique(self):
- global NUM_ATHENE_MATERIALS,mAtheneMaterials,NUM_SHADOW_TECH,mShadowTechDescriptions
- global mShadowTech,mShadowTechSoft,mSoftShadowsSupported,mCurrentAtheneMaterial,mCurrentShadowTechnique
- global mShadowTechniqueInfo, mSunLight, mLight, mMinLightColour, SHADOW_COMPOSITOR_NAME
-
- prevTech = mCurrentShadowTechnique ##TTT
-
- if mCurrentShadowTechnique < (NUM_SHADOW_TECH -1 ):
- mCurrentShadowTechnique+=1
- else : mCurrentShadowTechnique =0
-
-# if not SoftShadowsSupported and mShadowTechSoft[mCurrentShadowTechnique]:
-# # Skip soft shadows if not supported
-# mCurrentShadowTechnique = ++mCurrentShadowTechnique % NUM_SHADOW_TECH
-
-
- mShadowTechniqueInfo.setCaption(ogre.UTFString("Current: " + mShadowTechDescriptions[mCurrentShadowTechnique]))
-
- if mShadowTechSoft[prevTech] and not mShadowTechSoft[mCurrentShadowTechnique]:
- # Clean up compositors
- try:
- mShadowCompositor.removeListener(gaussianListener)
- except:
- pass
-##### ogre.CompositorManager.getSingleton().setCompositorEnabled(self.mShadowVp, SHADOW_COMPOSITOR_NAME, False)
- # Remove entire compositor chain
-##### ogre.CompositorManager.getSingleton().removeCompositorChain(self.mShadowVp)
- self.mShadowVp = 0
- self.mShadowCompositor = 0
-
- self.sceneManager.setShadowTechnique(mShadowTech[mCurrentShadowTechnique])
- ##Vector3 dir #TT
- if mShadowTech[mCurrentShadowTechnique] == ogre.SHADOWTYPE_STENCIL_ADDITIVE:
- # Fixed light, dim
- mSunLight.setCastShadows(True)
-
- # Point light, movable, reddish
- mLight.setType(ogre.Light.LT_POINT)
- mLight.setCastShadows(True)
- mLight.setDiffuseColour(mMinLightColour)
- mLight.setSpecularColour(1, 1, 1)
- mLight.setAttenuation(8000,1,0.0005,0)
- elif mShadowTech[mCurrentShadowTechnique] == ogre.SHADOWTYPE_STENCIL_MODULATIVE:
- # Multiple lights cause obvious silhouette edges in modulative mode
- # So turn off shadows on the direct light
- # Fixed light, dim
- mSunLight.setCastShadows(False)
-
- # Point light, movable, reddish
- mLight.setType(ogre.Light.LT_POINT)
- mLight.setCastShadows(True)
- mLight.setDiffuseColour(mMinLightColour)
- mLight.setSpecularColour(1, 1, 1)
- mLight.setAttenuation(8000,1,0.0005,0)
- #break
- elif (mShadowTech[mCurrentShadowTechnique]== ogre.SHADOWTYPE_TEXTURE_MODULATIVE) or (mShadowTech[mCurrentShadowTechnique] == ogre.SHADOWTYPE_TEXTURE_ADDITIVE) :
- # Fixed light, dim
- mSunLight.setCastShadows(not mShadowTechSoft[mCurrentShadowTechnique])
-
- # Change moving light to spotlight
- # Point light, movable, reddish
- mLight.setType(ogre.Light.LT_SPOTLIGHT)
- mLight.setDirection(ogre.Vector3.NEGATIVE_UNIT_Z)
- mLight.setCastShadows(True)
- mLight.setDiffuseColour(mMinLightColour)
- mLight.setSpecularColour(1, 1, 1)
- mLight.setAttenuation(8000,1,0.0005,0)
- mLight.setSpotlightRange(ogre.Degree(d=80),ogre.Degree(d=90))
-
-
- if mShadowTechSoft[mCurrentShadowTechnique]:
- # set up compositors
- shadowTex = ogre.TextureManager.getSingleton()
- print "###", shadowTex
- shadowTex = shadowTex.getByName(name="ogre/ShadowTexture0") ## returns a None object
- print "###", shadowTex
- if shadowTex:
- shadowRtt = shadowTex.getBuffer().getRenderTarget()
- mShadowVp = shadowRtt.getViewport(0)
- mShadowCompositor = ogre.CompositorManager.getSingleton().addCompositor(mShadowVp, SHADOW_COMPOSITOR_NAME)
- ogre.CompositorManager.getSingleton().setCompositorEnabled(self.mShadowVp, SHADOW_COMPOSITOR_NAME, True)
- mShadowCompositor.addListener(gaussianListener)
- gaussianListener.notifyViewportSize(self.mShadowVp.getActualWidth(), self.mShadowVp.getActualHeight())
-
- def changeAtheneMaterial(self):
- global mCurrentAtheneMaterial, mMaterialInfo, mAthene, mAtheneMaterials, NUM_ATHENE_MATERIALS
- if mCurrentAtheneMaterial < (NUM_ATHENE_MATERIALS-1):
- mCurrentAtheneMaterial += 1
- else:
- mCurrentAtheneMaterial=0
- mMaterialInfo.setCaption(ogre.UTFString("Current: " + mAtheneMaterials[mCurrentAtheneMaterial]))
- mAthene.setMaterialName(mAtheneMaterials[mCurrentAtheneMaterial])
-
- def CheckKeyPressed ( self, key, time, func):
- if self._isToggleKeyDown(key, time):
- self.timeDelay = time
- func()
-
- def frameEnded(self, evt):
- global mAnimState
- if (self.timeDelay >= 0) :
- self.timeDelay -= evt.timeSinceLastFrame
-
- if (mAnimState):
- mAnimState.addTime(evt.timeSinceLastFrame)
-
- self.CheckKeyPressed(KC_O, 1, self.changeShadowTechnique)
- self.CheckKeyPressed(KC_M, 0.5, self.changeAtheneMaterial)
-
- return sf.FrameListener.frameStarted(self, evt) and sf.FrameListener.frameEnded(self, evt)
-
-
-class ShadowsApplication ( sf.Application ):
- global NUM_ATHENE_MATERIALS,mAtheneMaterials,NUM_SHADOW_TECH,mShadowTechDescriptions
- global mShadowTech,mShadowTechSoft,mSoftShadowsSupported,mCurrentAtheneMaterial,mCurrentShadowTechnique
- global mCurrentAtheneMaterial, mMaterialInfo, mAthene, mAtheneMaterials
- global mAnimState
- def __init__(self):
- sf.Application.__init__(self)
-
- def _createScene(self):
- global NUM_ATHENE_MATERIALS,mAtheneMaterials,NUM_SHADOW_TECH,mShadowTechDescriptions
- global mShadowTech,mShadowTechSoft,mSoftShadowsSupported,mCurrentAtheneMaterial,mCurrentShadowTechnique
- global mCurrentAtheneMaterial, mMaterialInfo, mAthene, mAtheneMaterials
- global mShadowTechniqueInfo, mSunLight, mLight, mMinLightColour
- sceneManager = self.sceneManager
-
- # do this first so we generate edge lists
- sceneManager.setShadowTechnique(ogre.SHADOWTYPE_STENCIL_ADDITIVE)
- # Set the default Athene material
- # We'll default it to the normal map for ps_2_0 capable hardware
- # everyone else will default to the basic
-# if (GpuProgramManager.getSingleton().isSyntaxSupported("ps_2_0") or
-# GpuProgramManager.getSingleton().isSyntaxSupported("arbfp1")):
-# mCurrentAtheneMaterial = 0
-# else:
- mCurrentAtheneMaterial = 1
-
- # Set ambient light off
- sceneManager.setAmbientLight(ogre.ColourValue(0.0, 0.0, 0.0))
-
- # Fixed light, dim
- mSunLight = sceneManager.createLight("SunLight")
- mSunLight.setType(ogre.Light.LT_SPOTLIGHT)
- mSunLight.setPosition(1000,1250,500)
- mSunLight.setSpotlightRange(ogre.Degree(d=30), ogre.Degree(d=50))
- dirV = -mSunLight.getPosition()
- dirV.normalise()
- mSunLight.setDirection(dirV)
- mSunLight.setDiffuseColour(0.35, 0.35, 0.38)
- mSunLight.setSpecularColour(0.9, 0.9, 1)
-
- # Point light, movable, reddish
- mLight = sceneManager.createLight("Light2")
- mLight.setDiffuseColour(mMinLightColour)
- mLight.setSpecularColour(1, 1, 1)
- mLight.setAttenuation(8000,1,0.0005,0)
-
- # Create light node
- mLightNode = sceneManager.getRootSceneNode().createChildSceneNode("MovingLightNode")
- mLightNode.attachObject(mLight)
- # create billboard set
- bbs = sceneManager.createBillboardSet("lightbbs", 1)
- bbs.setMaterialName("Examples/Flare")
- bb = bbs.createBillboard(0,0,0,mMinLightColour)
- # attach
- mLightNode.attachObject(bbs)
-
- # create controller, after this is will get updated on its own
- self.func = ogre.WaveformControllerFunction(ogre.WFT_SINE, 0.75, 0.5)
- contMgr = ogre.ControllerManager.getSingleton()
- self.val = LightWibbler(mLight, bb, mMinLightColour, mMaxLightColour, mMinFlareSize, mMaxFlareSize)
- controller = contMgr.createController(contMgr.getFrameTimeSource(), self.val, self.func)
-
- #mLight.setPosition(Vector3(300,250,-300))
- mLightNode.setPosition(ogre.Vector3(300,250,-300))
-
- # Create a track for the light
- anim = sceneManager.createAnimation("LightTrack", 20)
- # Spline it for nice curves
- anim.setInterpolationMode(ogre.Animation.IM_SPLINE)
- # Create a track to animate the camera's node
- track = anim.createNodeTrack(0, mLightNode)
- # Setup keyframes
- key = track.createNodeKeyFrame(0) # A startposition
- key.setTranslate(ogre.Vector3(300,250,-300))
- key = track.createNodeKeyFrame(2)#B
- key.setTranslate(ogre.Vector3(150,300,-250))
- key = track.createNodeKeyFrame(4)#C
- key.setTranslate(ogre.Vector3(-150,350,-100))
- key = track.createNodeKeyFrame(6)#D
- key.setTranslate(ogre.Vector3(-400,200,-200))
- key = track.createNodeKeyFrame(8)#E
- key.setTranslate(ogre.Vector3(-200,200,-400))
- key = track.createNodeKeyFrame(10)#F
- key.setTranslate(ogre.Vector3(-100,150,-200))
- key = track.createNodeKeyFrame(12)#G
- key.setTranslate(ogre.Vector3(-100,75,180))
- key = track.createNodeKeyFrame(14)#H
- key.setTranslate(ogre.Vector3(0,250,300))
- key = track.createNodeKeyFrame(16)#I
- key.setTranslate(ogre.Vector3(100,350,100))
- key = track.createNodeKeyFrame(18)#J
- key.setTranslate(ogre.Vector3(250,300,0))
- key = track.createNodeKeyFrame(20)#K == A
- key.setTranslate(ogre.Vector3(300,250,-300))
- # Create a new animation state to track this
- mAnimState = sceneManager.createAnimationState("LightTrack")
- mAnimState.setEnabled(True)
- # Make light node look at origin, this is for when we
- # change the moving light to a spotlight
- mLightNode.setAutoTracking(True, sceneManager.getRootSceneNode())
-
- # Prepare athene mesh for normalmapping
- pAthene = ogre.MeshManager.getSingleton().load("athene.mesh",
- ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
- src = 0
- dest = 0
-# if (not pAthene.suggestTangentVectorBuildParams(outSourceCoordSet=src, outDestCoordSet=dest)):
-# pAthene.buildTangentVectors(src, dest)
-
- node = sceneManager.getRootSceneNode().createChildSceneNode()
- mAthene = sceneManager.createEntity( "athene", "athene.mesh" )
- mAthene.setMaterialName(mAtheneMaterials[mCurrentAtheneMaterial])
- node.attachObject( mAthene )
- node.translate(0,-20, 0)
- node.yaw(ogre.Degree(d=90))
-
- node = sceneManager.getRootSceneNode().createChildSceneNode()
- pEnt = sceneManager.createEntity( "col1", "column.mesh" )
- pEnt.setMaterialName("Examples/Rockwall")
- node.attachObject( pEnt )
- node.translate(200,0, -200)
-
- node = sceneManager.getRootSceneNode().createChildSceneNode()
- pEnt = sceneManager.createEntity( "col2", "column.mesh" )
- pEnt.setMaterialName("Examples/Rockwall")
- node.attachObject( pEnt )
- node.translate(200,0, 200)
-
- node = sceneManager.getRootSceneNode().createChildSceneNode()
- pEnt = sceneManager.createEntity( "col3", "column.mesh" )
- pEnt.setMaterialName("Examples/Rockwall")
- node.attachObject( pEnt )
- node.translate(-200,0, -200)
-
- node = sceneManager.getRootSceneNode().createChildSceneNode()
- pEnt = sceneManager.createEntity( "col4", "column.mesh" )
- pEnt.setMaterialName("Examples/Rockwall")
- node.attachObject( pEnt )
- node.translate(-200,0, 200)
- # Skybox
- sceneManager.setSkyBox(True, "Examples/StormySkyBox")
-
- # Floor plane
- plane = ogre.Plane()
- plane.normal = ogre.Vector3.UNIT_Y
- plane.d = 100
- ogre.MeshManager.getSingleton().createPlane("Myplane",
- ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane,
- 1500,1500,50,50,True,1,5,5,ogre.Vector3.UNIT_Z)
- pPlaneEnt = sceneManager.createEntity( "plane", "Myplane" )
- pPlaneEnt.setMaterialName("Examples/Rockwall")
- pPlaneEnt.setCastShadows(False)
- sceneManager.getRootSceneNode().createChildSceneNode().attachObject(pPlaneEnt)
-
- # show overlay
- pOver = ogre.OverlayManager.getSingleton().getByName("Example/ShadowsOverlay")
- print "\n\n\n"
- print dir (pOver )
- print pOver
- print "\n\n\n"
-
- mShadowTechniqueInfo = ogre.OverlayManager.getSingleton().getOverlayElement("Example/Shadows/ShadowTechniqueInfo")
- mMaterialInfo = ogre.OverlayManager.getSingleton().getOverlayElement("Example/Shadows/MaterialInfo")
- mInfo = ogre.OverlayManager.getSingleton().getOverlayElement("Example/Shadows/Info")
-
- mShadowTechniqueInfo.setCaption(ogre.UTFString("Current: " + mShadowTechDescriptions[mCurrentShadowTechnique]))
- mMaterialInfo.setCaption(ogre.UTFString("Current: " + mAtheneMaterials[mCurrentAtheneMaterial]))
- pOver.show()
-
-# if (sceneManager.getRootSceneNode().getRenderSystem().getCapabilities().hasCapability(ogre.RSC_HWRENDER_TO_TEXTURE)):
-# # In D3D, use a 1024x1024 shadow texture
-# sceneManager.setShadowTextureSettings(1024, 2)
-# else:
-# # Use 512x512 texture in GL since we can't go higher than the window res
-# sceneManager.setShadowTextureSettings(512, 2)
- sceneManager.setShadowTextureSettings(512, 2)
- sceneManager.setShadowColour(ogre.ColourValue(0.5, 0.5, 0.5))
-
- # incase infinite far distance is not supported
-# self.camera.setFarClipDistance(100000)
-
- #sceneManager.setShowDebugShadows(True)
- mSoftShadowsSupported = False
-
-# caps = Root.getSingleton().getRenderSystem().getCapabilities()
-# if (not caps.hasCapability(ogre.RSC_VERTEX_PROGRAM) or not (caps.hasCapability(ogre.RSC_FRAGMENT_PROGRAM))):
-# mSoftShadowsSupported = False
-# else:
-# if (not GpuProgramManager.getSingleton().isSyntaxSupported("glsl") and
-# not GpuProgramManager.getSingleton().isSyntaxSupported("ps_2_0")) :
-# mSoftShadowsSupported = False
-
- # Create new frame listener
- def _createFrameListener(self):
- self.frameListener= ShadowsListener(self.renderWindow, self.camera, self.sceneManager)
- self.frameListener.showDebugOverlay(True)
- self.root.addFrameListener(self.frameListener)
-
-
-
-if __name__ == '__main__':
- try:
- application = ShadowsApplication()
- application.go()
- except ogre.OgreException, e:
- print e
- print
- print "** FullDesc ", e.fullDescription
- print "** Source, File, Line ",e.source, e.file, e.line
-
-
Modified: trunk/python-ogre/demos/ogre/Demo_SkeletalAnimation.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_SkeletalAnimation.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_SkeletalAnimation.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -132,7 +132,7 @@
rot = 0.0
for i in range( NUM_JAIQUAS) :
q = ogre.Quaternion()
- q.FromAngleAxis(ogre.Radian(r=rot), ogre.Vector3.UNIT_Y)
+ q.FromAngleAxis(ogre.Radian(r=rot), ogre.Vector3().UNIT_Y)
mOrientations[i] = q
mBasePositions[i] = q * ogre.Vector3(0,0,-20)
ent = sceneManager.createEntity("jaiqua" + str(i), "jaiqua.mesh")
@@ -181,11 +181,11 @@
plane = ogre.Plane()
- plane.normal = ogre.Vector3.UNIT_Y
+ plane.normal = ogre.Vector3().UNIT_Y
plane.d = 100
ogre.MeshManager.getSingleton().createPlane("Myplane",
ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane,
- 1500,1500,20,20,True,1,60,60,ogre.Vector3.UNIT_Z)
+ 1500,1500,20,20,True,1,60,60,ogre.Vector3().UNIT_Z)
self.pPlaneEnt = sceneManager.createEntity( "plane", "Myplane" )
self.pPlaneEnt.setMaterialName("Examples/Rockwall")
self.pPlaneEnt.setCastShadows(False)
@@ -221,7 +221,7 @@
# Need to reposition the scene node origin since animation includes translation
# Calculate as an offset to the end position, rotated by the
# amount the animation turns the character
- rot = ogre.Quaternion(mAnimationRotation, ogre.Vector3.UNIT_Y)
+ rot = ogre.Quaternion(mAnimationRotation, ogre.Vector3().UNIT_Y)
startoffset = mSceneNode[i].getOrientation() * -mSneakStartOffset
endoffset = mSneakEndOffset
offset = rot * startoffset
Modified: trunk/python-ogre/demos/ogre/Demo_SkyBox.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_SkyBox.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_SkyBox.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -53,16 +53,16 @@
pEmit1.setTimeToLive( 0.2 )
pEmit1.setEmissionRate( 70 )
pEmit1.setParticleVelocity( 50 )
- pEmit1.setDirection(- ogre.Vector3.UNIT_Z)
- pEmit1.setColour( ogre.ColourValue.White, ogre.ColourValue.Red)
+ pEmit1.setDirection(- ogre.Vector3().UNIT_Z)
+ pEmit1.setColour( ogre.ColourValue().White, ogre.ColourValue().Red)
# Thruster 2
pEmit2.setAngle( ogre.Degree(d=3) )
pEmit2.setTimeToLive( 0.2 )
pEmit2.setEmissionRate( 70 )
pEmit2.setParticleVelocity( 50 )
- pEmit2.setDirection( -ogre.Vector3.UNIT_Z )
- pEmit2.setColour( ogre.ColourValue.White, ogre.ColourValue.Red )
+ pEmit2.setDirection( -ogre.Vector3().UNIT_Z )
+ pEmit2.setColour( ogre.ColourValue().White, ogre.ColourValue().Red )
# Set the position of the thrusters and attach to the craft
pEmit1.setPosition( ogre.Vector3( 5.7, 6.5, -70 ) )
Modified: trunk/python-ogre/demos/ogre/Demo_SkyDome.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_SkyDome.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_SkyDome.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -32,7 +32,7 @@
light.setPosition (ogre.Vector3(20, 80, 50))
plane = ogre.Plane()
- plane.normal = ogre.Vector3.UNIT_Y
+ plane.normal = ogre.Vector3().UNIT_Y
plane.d = 200
mm = ogre.MeshManager.getSingleton()
Modified: trunk/python-ogre/demos/ogre/Demo_Spinner.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_Spinner.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_Spinner.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -1,3 +1,4 @@
+# NO_UNITTEST
# This code is in the Public Domain
# -----------------------------------------------------------------------------
# This source file is part of Python-Ogre
@@ -20,8 +21,8 @@
class MyApp(object):
- def __init__(self, plugins_path='plugins.cfg',
- resource_path='resources.cfg'):
+ def __init__(self, plugins_path='../plugins.cfg',
+ resource_path='../resources.cfg'):
# keep track of the paths that are used
@@ -172,7 +173,7 @@
self.node = node.createChildSceneNode("ninja_node", start_coords)
self.node.attachObject(self.entity)
- src = self.node.Orientation * (ogre.Vector3.UNIT_Z)
+ src = self.node.Orientation * (ogre.Vector3().UNIT_Z)
directionToGo = ogre.Vector3(0,0,-1)
quat = src.getRotationTo(directionToGo)
self.node.Orientation=quat
Modified: trunk/python-ogre/demos/ogre/Demo_Terrain.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_Terrain.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_Terrain.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -53,7 +53,7 @@
# 5000 world units from the camera
plane.d = 5000
# Above the camera, facing down
- plane.normal = -ogre.Vector3.UNIT_Y
+ plane.normal = -ogre.Vector3().UNIT_Y
## Setup a nice starting position for the camera
camera.setPosition(707,2500,528)
@@ -71,7 +71,7 @@
self.sceneManager = sceneManager
self.moveSpeed = 50.0
self.raySceneQuery = sceneManager.createRayQuery(ogre.Ray(camera.getPosition(),
- ogre.Vector3.NEGATIVE_UNIT_Y))
+ ogre.Vector3().NEGATIVE_UNIT_Y))
self.camera = camera
#self.camera.setPosition (self.camera.getPosition() + ogre.Vector3(0.0, 10.0, 0.0))
@@ -79,7 +79,7 @@
# clamp to terrain
updateRay = ogre.Ray()
updateRay.setOrigin (self.camera.getPosition() + ogre.Vector3(0.0, 10.0, 0.0))
- updateRay.setDirection (ogre.Vector3.NEGATIVE_UNIT_Y)
+ updateRay.setDirection (ogre.Vector3().NEGATIVE_UNIT_Y)
self.raySceneQuery.Ray = updateRay
for queryResult in self.raySceneQuery.execute():
if queryResult.worldFragment is not None:
Modified: trunk/python-ogre/demos/ogre/Demo_Video.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_Video.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_Video.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -1,3 +1,6 @@
+# NO_UNITTEST
+#
+# NO LONGER SUPPORTED AS OgreDSHOW depreciated
# This code is in the Public Domain
# -----------------------------------------------------------------------------
# This source file is part of Python-Ogre
@@ -9,7 +12,9 @@
# You may use this sample code for anything you like, it is not covered by the
# LGPL.
# -----------------------------------------------------------------------------
+
import sys
+sys.exit()
sys.path.insert(0,'..')
import PythonOgreConfig
Modified: trunk/python-ogre/demos/ogre/Demo_WX.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_WX.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_WX.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -1,3 +1,4 @@
+# NO_UNITTEST
# This code is in the Public Domain
# -----------------------------------------------------------------------------
# This source file is part of Python-Ogre
@@ -137,7 +138,7 @@
#Then, takes care of the direction that the fish has to face to
directionToGo = self.sceneEntities.fishLookAtNode.Position - self.sceneEntities.fishAnimationNode.Position
- src = self.sceneEntities.fishNode.Orientation * (-ogre.Vector3.UNIT_X) #the fish is originally
+ src = self.sceneEntities.fishNode.Orientation * (-ogre.Vector3().UNIT_X) #the fish is originally
#facing the negative X direction
Modified: trunk/python-ogre/demos/ogre/Demo_Water.py
===================================================================
--- trunk/python-ogre/demos/ogre/Demo_Water.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Demo_Water.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -1,3 +1,4 @@
+# NO_UNITTEST
# This code is in the Public Domain
# -----------------------------------------------------------------------------
# This source file is part of Python-Ogre
@@ -331,7 +332,7 @@
self.app.headNode.setScale((3,3,3))
newPos = Ogre.Vector3(step*tx, self.headDepth, step*ty)
diffPos = newPos - self.oldPos
- headRotation = Ogre.Vector3.UNIT_Z.getRotationTo(diffPos)
+ headRotation = Ogre.Vector3().UNIT_Z.getRotationTo(diffPos)
self.oldPos = newPos
self.app.headNode.translate(newPos)
self.app.headNode.rotate(headRotation)
@@ -419,7 +420,7 @@
RAIN_HEIGHT_CONSTANT = 5
self.sines = [0,100,200,300]
self.adds=[0.3,-1.6,1.1,0.5]
- self.oldPos = Ogre.Vector3.UNIT_Z
+ self.oldPos = Ogre.Vector3().UNIT_Z
self.pindex = 0
self.headDepth =0.0
self.circles = []
Deleted: trunk/python-ogre/demos/ogre/Shadows.py
===================================================================
--- trunk/python-ogre/demos/ogre/Shadows.py 2008-10-19 12:06:32 UTC (rev 760)
+++ trunk/python-ogre/demos/ogre/Shadows.py 2008-10-20 13:48:25 UTC (rev 761)
@@ -1,1563 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
- (Object-oriented Graphics Rendering Engine)
-For the latest info, see http:##www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-You may use self sample code for anything you like, it is not covered by the
-LGPL like the rest of the engine.
------------------------------------------------------------------------------
-*/
-
-/**
- \file
- Shadows.cpp
- \brief
- Shows a few ways to use Ogre's shadowing techniques
-*/
-
-#include <CEGUI/CEGUIImageset.h>
-#include <CEGUI/CEGUISystem.h>
-#include <CEGUI/CEGUILogger.h>
-#include <CEGUI/CEGUISchemeManager.h>
-#include <CEGUI/CEGUIWindowManager.h>
-#include <CEGUI/CEGUIWindow.h>
-#include <CEGUI/elements/CEGUICombobox.h>
-#include <CEGUI/elements/CEGUIComboDropList.h>
-#include <CEGUI/elements/CEGUIEditbox.h>
-#include <CEGUI/elements/CEGUIListbox.h>
-#include <CEGUI/elements/CEGUIListboxTextItem.h>
-#include <CEGUI/elements/CEGUIPushButton.h>
-#include <CEGUI/elements/CEGUIScrollbar.h>
-#include <CEGUI/elements/CEGUIRadioButton.h>
-#include "OgreCEGUIRenderer.h"
-#include "OgreCEGUIResourceProvider.h"
-#include "ExampleApplication.h"
-
-/*
-#include "OgreNoMemoryMacros.h"
-#include <ode/odecpp.h>
-#include <ode/odecpp_collision.h>
-#include "OgreMemoryMacros.h"
-*/
-
-/*
-#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32:
-#include "OgreNoMemoryMacros.h"
-#inc...
[truncated message content] |