Revision: 471
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=471&view=rev
Author: andy_miller
Date: 2007-11-12 23:26:03 -0800 (Mon, 12 Nov 2007)
Log Message:
-----------
General merge to my working environment
Added Paths:
-----------
trunk/python-ogre/demos/bullet/
trunk/python-ogre/demos/bullet/test01.py
trunk/python-ogre/demos/nxogre/BetaGui.py.org
trunk/python-ogre/demos/ogre/1.py
trunk/python-ogre/demos/ogre/Julia.py
trunk/python-ogre/demos/ogre/Shadows.py
trunk/python-ogre/demos/ogre/ThingRenderable.py
trunk/python-ogre/demos/ogre/VolumeRenderable.py
trunk/python-ogre/demos/ogre/VolumeTex.py
trunk/python-ogre/demos/ogre/a1.py
trunk/python-ogre/demos/ogre/c.sed
trunk/python-ogre/demos/ogre/c1.sed
trunk/python-ogre/demos/ogre/demo_water_s.py
trunk/python-ogre/demos/ogre/name.xml
trunk/python-ogre/demos/ogre/sf_OIS.py
trunk/python-ogre/demos/ogre/tests/Test_ImageLoad.py
trunk/python-ogre/demos/ogre/tests/ogre.txt
trunk/python-ogre/demos/ogre/water1.py
trunk/python-ogre/demos/ogre/water_mesh_s.py
trunk/python-ogre/demos/qgui/resources.cfg.quickgui
Added: trunk/python-ogre/demos/bullet/test01.py
===================================================================
--- trunk/python-ogre/demos/bullet/test01.py (rev 0)
+++ trunk/python-ogre/demos/bullet/test01.py 2007-11-13 07:26:03 UTC (rev 471)
@@ -0,0 +1,34 @@
+import sys
+sys.path.insert(0,'..')
+import PythonOgreConfig
+
+import ogre.renderer.OGRE
+import ogre.physics.bullet as bullet
+t = bullet.btTransform()
+ms = bullet.btDefaultMotionState (t)
+s = bullet.btBoxShape(bullet.btVector3(10,10,10))
+body = bullet.btRigidBody(1, ms, s)
+print body
+
+
+collisionConfiguration = bullet.btDefaultCollisionConfiguration()
+dispatcher = bullet.btCollisionDispatcher (collisionConfiguration)
+
+worldAabbMin = bullet.btVector3(-1000,-1000,-1000)
+worldAabbMax = bullet.btVector3(1000,1000,1000)
+maxProxies = 32766
+
+broadphase = bullet.btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies)
+
+solver = bullet.btSequentialImpulseConstraintSolver()
+
+world = bullet.btDiscreteDynamicsWorld(dispatcher, broadphase , solver)
+world.getDispatchInfo().m_enableSPU = True
+world.setGravity(bullet.btVector3(0,-10,0))
+
+print world
+print solver
+print broadphase
+print dispatcher
+print collisionConfiguration
+
Added: trunk/python-ogre/demos/nxogre/BetaGui.py.org
===================================================================
--- trunk/python-ogre/demos/nxogre/BetaGui.py.org (rev 0)
+++ trunk/python-ogre/demos/nxogre/BetaGui.py.org 2007-11-13 07:26:03 UTC (rev 471)
@@ -0,0 +1,348 @@
+##/ Betajaen's GUI 015 Uncompressed
+##/ Written by Robin "Betajaen" Southern 07-Nov-2006, http:##www.ogre3d.org/wiki/index.php/BetaGUI
+##/ This code is under the Whatevar! licence. Do what you want but keep the original copyright header.
+
+## Converted to Python-Ogre By Andy Miller
+
+#include "Ogre.h"
+import ogre.renderer.OGRE as ogre
+
+from Enums import *
+
+wt = Enum ('NONE','MOVE','RESIZE','RESIZE_AND_MOVE')
+WindowPlacementType = Enum ( 'WPT_NONE','WPT_VERTICAL', 'WPT_HORIZONTAL' )
+WindowActivity = Enum ( 'WA_NONE', 'WA_MOVE', 'WA_RESIZE', 'WA_PRESS' )
+
+class GUI :
+ def __init__ (self, font, fontSize):
+ self.WindowToDestroy=None
+ self.PointerOverlay=None
+ self.Font = font
+ self.FontSize = fontSize
+ self.WindowCount=0
+ self.ButtonCount=0
+ self.TextCount=0
+ self.Overlay = ogre.OverlayManager.getSingleton().create("BetaGUI")
+ self.Overlay.show()
+ self.Windows=[]
+
+ def __del__ ( self ):
+ for w in self.Windows:
+ del w
+ del self.Windows
+
+ def injectMouse(self, x, y, LMB):
+ if (self.PointerOverlay):
+ self.PointerOverlay.setPosition(x,y)
+
+ if (self.WindowToDestroy) :
+ for i in range ( len (self.Windows)):
+ if self.WindowToDestroy == self.Windows[i] :
+ del self.WindowToDestroy
+ self.Windows.remove(i)
+ self.WindowToDestroy=0
+ return False
+
+ for w in self.Windows:
+ if w.check(x,y,LMB):
+ return True
+ return False
+
+ def injectKey(self, key, x, y):
+ for w in self.Windows:
+ if w.checkKey(key,x,y):
+ return True
+ return False
+
+ def injectBackspace(self, x, y):
+ self.in_jectKey("!b", x, y)
+
+ def createOverlay(self, name, position, dimensions, material="", caption="", autoAdd=True):
+ type="Panel"
+
+ if caption!="":
+ type="TextArea"
+
+ e=ogre.OverlayManager.getSingleton().createOverlayElement(type, name, False)
+
+ e.setMetricsMode(ogre.GMM_PIXELS)
+ e.setDimensions(dimensions.x, dimensions.y)
+ e.setPosition(position.x, position.y)
+
+ if material!="" :
+ e.setMaterialName(material)
+
+ if caption!="":
+ e.setCaption(caption)
+ e.setParameter("font_name",self.Font)
+ e.setParameter("char_height",str(self.FontSize))
+
+ if(autoAdd):
+ self.Overlay.add2D(e)
+ e.show()
+
+ return e
+
+ def createMousePointer(self, d, m) :
+ o = ogre.OverlayManager.getSingleton().create("BetaGUI.MP")
+ o.setZOrder(649)
+ self.PointerOverlay = self.createOverlay("bg.mp", ogre.Vector2(0,0), d, m, "", False)
+ o.add2D(self.PointerOverlay)
+ o.show()
+ self.PointerOverlay.show()
+ return self.PointerOverlay
+
+ def createWindow(self, Dimensions, Material, type_, caption=""):
+ window = Window(Dimensions, Material, type_, caption, self)
+ self.Windows.append(window)
+ return window
+
+
+
+class Window:
+
+ def hide(self ):
+ self.Overlay.hide()
+
+ def show( self ):
+ self.Overlay.show()
+
+ def isVisible(self):
+ return self.Overlay.isVisible()
+
+
+ def __init__(self, Dimensions, Material, t, caption, gui):
+ self.x =Dimensions.x
+ self.y =Dimensions.y
+ self.w =Dimensions.z
+ self.h =Dimensions.w
+ self.GUI = gui
+ self.Titlebar = None
+ self.Reziser=None
+ self.ActiveTextInput=None
+ self.ActiveButton=None
+ self.Buttons=[]
+ self.TextInputs=[]
+
+ self.Overlay = gui.createOverlay("BetaGUI.w" + str(gui.WindowCount),
+ ogre.Vector2(Dimensions.x,Dimensions.y), ogre.Vector2(Dimensions.z,Dimensions.w), Material)
+ gui.WindowCount += 1
+ if t >= 2:
+ c = Callback()
+ c.t=4
+ self.Reziser=self.createButton(ogre.Vector4(Dimensions.z-16,Dimensions.w-16,16,16),Material+".resize", "",c)
+
+ if t == 1 or t == 3 :
+ c=Callback()
+ c.t=3
+ self.Titlebar = self.createButton(ogre.Vector4(0,0,Dimensions.z,22),Material + ".titlebar", caption, c)
+
+
+ def __del__( self ):
+ for i in self.Buttons:
+ del i
+ del self.Buttons
+ for i in self.TextInputs:
+ del i
+ del self.TextInputs
+
+ self.GUI.Overlay.remove2D(self.Overlay)
+
+
+ def createButton(self, D, M, T, C):
+ x = Button(D, M, T, C, self)
+ self.Buttons.append(x)
+ return x
+
+ def createTextInput(self,D, M, V, L):
+ x = TextInput(D,M,V,L,self)
+ self.TextInputs.append(x)
+ return x
+
+ def createStaticText(self, D, T):
+ x = self.GUI.createOverlay(self.Overlay.getName() + str(self.GUI.TextCount),
+ ogre.Vector2(D.x,D.y),ogre.Vector2(D.z,D.w),"", T,False)
+ self.GUI.TextCount +=1
+ self.Overlay.addChild(x)
+ x.show()
+
+ def checkKey(self, k, px, py) :
+
+ if not self.Overlay.isVisible():
+ return False
+
+ if not(px>=self.x and py>=self.y) or not(px<=self.x+self.w and py<=self.y+self.h):
+ return False
+
+ if(self.ActiveTextInput == 0):
+ return False
+
+ if k=="!b" :
+ self.ActiveTextInput.setValue(self.ActiveTextInput.getValue[0,-1])
+ return True
+
+ if len (self.ActiveTextInput.getValue()) >= self.ActiveTextInput.length:
+ return True
+
+ self.ActiveTextInput.value+=k
+ self.ActiveTextInput.Caption.setCaption(self.ActiveTextInput.value)
+
+ return True
+
+ def check(self, px, py, LMB):
+ if not self.Overlay.isVisible():
+ return False
+
+ if ( not (px >= self.x and py >= self.y) or not(px <= self.x + self.w and py <= self.y + self.h)):
+ if (self.ActiveButton):
+ self.ActiveButton.activate(False)
+ return False
+
+ if self.ActiveButton :
+ self.ActiveButton.activate(False)
+ for i in range ( len (self.Buttons) ):
+ if (self.Buttons[i].in_(px,py,self.x,self.y)):
+ continue
+ if (self.ActiveButton):
+ self.ActiveButton.activate(False)
+
+ self.ActiveButton=self.Buttons[i]
+ self.ActiveButton.activate(True)
+
+ if not LMB:
+ return True
+
+ if self.ActiveTextInput:
+ self.ActiveTextInput.Overlay.setMaterialName(self.ActiveTextInput.MatNameNormal)
+ self.ActiveTextInput=0
+
+ tempt = self.ActiveButton.callback.t
+ if tempt ==1:
+ self.ActiveButton.callback.fp(self.ActiveButton)
+ return True
+ elif tempt ==2 :
+ self.ActiveButton.callback.LS.onButtonPress(self.ActiveButton)
+ return True
+ elif tempt ==4 :
+ self.x=px-(self.ActiveButton.w/2)
+ self.y=py-(self.ActiveButton.h/2)
+ self.Overlay.setPosition(self.x,self.y)
+ return True
+ elif tempt ==4 :
+ self.w=px-self.x+8
+ self.h=py-self.y+8
+ self.Overlay.setDimensions(self.w,self.h)
+ self.Reziser.x=w-16
+ self.Reziser.y=h-16
+ self.Reziser.self.Overlay.setPosition(self.Reziser.x,self.Reziser.y)
+ if(self.Titlebar):
+ self.Titlebar.w=self.w
+ self.Titlebar.self.Overlay.setWidth(self.Titlebar.w)
+ return True
+
+ if not LMB:
+ return True
+
+ for i in range ( len (self.TextInputs)):
+
+ if self.TextInputs[i].in_(px,py,self.x,self.y):
+ continue
+
+ self.ActiveTextInput=self.TextInputs[i]
+ self.ActiveTextInput.Overlay.setMaterialName(self.ActiveTextInput.MatNameActive)
+ return True
+
+ if self.ActiveTextInput :
+ self.ActiveTextInput.Overlay.setMaterialName(self.ActiveTextInput.MatNameNormal)
+ self.ActiveTextInput=0
+
+ return True
+
+
+class BetaGUIListener :
+ def __init__(self):
+ pass
+ def onButtonPress(self, ref):
+ pass
+
+class Callback :
+ def __init__ (self,Value=None):
+ ## Type of callback: 0 - None, 1 - FunctionPointer 2 - GUIListener, 3 - self.Overlayve Window, 4 - Resize
+ self.t=0
+ self.callbackvalue = Value
+
+
+class Button :
+
+ def __del__(self):
+ self.Overlay.getParent().reself.OverlayveChild(self.Overlay.getName())
+ self.Caption.getParent().reself.OverlayveChild(self.Caption.getName())
+
+ def activate(self, a):
+ if not a and self.MatNameNormal!="":
+ self.Overlay.setMaterialName(self.MatNameNormal)
+ if a and self.MatNameActive!="":
+ self.Overlay.setMaterialName(self.MatNameActive)
+
+ def in_(self, mx, my, px, py):
+ return ( not (mx >= x + px and my >= y + py)) or ( not (mx <= x + px + w and my <= y + py + h) )
+
+ def __init__ (self, Dimensions, m, Text, cb, parent):
+ self.x=Dimensions.x
+ self.y=Dimensions.y
+ self.w=Dimensions.z
+ self.h=Dimensions.w
+ self.MatNameNormal = m
+ self.MatNameActive = m
+# NXD("Button=" << self.MatNameNormal << ":" << self.MatNameActive)
+
+ ma=ogre.MaterialManager.getSingleton().getByName(self.MatNameNormal + ".active")
+ if not ma:
+ self.MatNameActive += ".active"
+
+ self.Overlay = parent.GUI.createOverlay(parent.Overlay.getName() + "b" + str(parent.GUI.ButtonCount),
+ ogre.Vector2(self.x,self.y),ogre.Vector2(self.w,self.h),m,"",False)
+ parent.GUI.ButtonCount +=1
+ self.Caption = parent.GUI.createOverlay(self.Overlay.getName() + "c",
+ ogre.Vector2(4,(self.h - parent.GUI.FontSize) / 2),ogre.Vector2(self.w, self.h),"",Text,False)
+ parent.Overlay.addChild(self.Overlay)
+ self.Overlay.show()
+ self.Overlay.addChild(self.Caption)
+ self.Caption.show()
+ self.callback = cb
+
+
+class TextInput :
+
+ def getValue(self):
+ return self.value
+
+ def setValue(self,v) :
+ self.value=v
+ self.Caption.setCaption(v)
+
+ def in_(self, mx, my, px, py) :
+ return ( not (mx >= x + px and my >= y + py)) or ( not (mx <= x + px + w and my <= y + py + h) )
+
+ def __init__ (self, D, M, V, L, P):
+ self.x = D.x
+ self.y = D.y
+ self.w = D.z
+ self.h = D.w
+ self.value = V
+ self.MatNameNormal = M
+ self.MatNameActive = M
+ self.length = L
+ ma=ogre.MaterialManager.getSingleton().getByName(self.MatNameNormal + ".active")
+ if not ma:
+ self.MatNameActive += ".active"
+
+ self.Overlay=P.GUI.createOverlay(P.Overlay.getName() + "t" + str(P.GUI.TextCount) ,
+ ogre.Vector2(self.x,self.y),ogre.Vector2(self.w,self.h),M,"",False)
+ P.GUI.TextCount += 1
+ self.Caption=P.GUI.createOverlay(self.Overlay.getName() + "c",
+ ogre.Vector2(4,(self.h - P.GUI.FontSize) / 2),ogre.Vector2(self.w,self.h),"",V,False)
+ P.Overlay.addChild(self.Overlay)
+ self.Overlay.show()
+ self.Overlay.addChild(self.Caption)
+ self.Caption.show()
Added: trunk/python-ogre/demos/ogre/1.py
===================================================================
--- trunk/python-ogre/demos/ogre/1.py (rev 0)
+++ trunk/python-ogre/demos/ogre/1.py 2007-11-13 07:26:03 UTC (rev 471)
@@ -0,0 +1,4 @@
+import time
+
+while True:
+ print "hello", time.localtime()
\ No newline at end of file
Added: trunk/python-ogre/demos/ogre/Julia.py
===================================================================
--- trunk/python-ogre/demos/ogre/Julia.py (rev 0)
+++ trunk/python-ogre/demos/ogre/Julia.py 2007-11-13 07:26:03 UTC (rev 471)
@@ -0,0 +1,98 @@
+# /* Original author: John C. Hare
+# * Date: June 26, 1996 (although I've had these around for at least 6 years)
+# * Adapted to C++ by W.J. van der Laan 2004
+# */
+
+/**
+ * Simple, fast, inline quaternion math functions
+ */
+class Quat:
+ r=0
+ i=0
+ j=0
+ k=0
+
+def qadd(a, b)
+ a.r += b.r
+ a.i += b.i
+ a.j += b.j
+ a.k += b.k
+
+
+def qmult(Quat &c, const Quat &a, const Quat &b)
+
+ c.r = a.r*b.r - a.i*b.i - a.j*b.j - a.k*b.k;
+ c.i = a.r*b.i + a.i*b.r + a.j*b.k - a.k*b.j;
+ c.j = a.r*b.j + a.j*b.r + a.k*b.i - a.i*b.k;
+ c.k = a.r*b.k + a.k*b.r + a.i*b.j - a.j*b.i;
+
+
+def qsqr(Quat &b, const Quat &a)
+
+ b.r = a.r*a.r - a.i*a.i - a.j*a.j - a.k*a.k;
+ b.i = 2.0f*a.r*a.i;
+ b.j = 2.0f*a.r*a.j;
+ b.k = 2.0f*a.r*a.k;
+
+
+/**
+ * Implicit function that evaluates the Julia set.
+ */
+class Julia
+private:
+ float global_real, global_imag, global_theta;
+ Quat oc,c,eio,emio;
+public:
+ Julia(float global_real, float global_imag, float global_theta);
+ inline float eval(float x, float y, float z)
+ Quat q, temp;
+ int i;
+
+ q.r = x;
+ q.i = y;
+ q.j = z;
+ q.k = 0.0;
+
+ for (i = 30; i > 0; i--)
+ qsqr(temp, q);
+ qmult(q, emio, temp);
+ qadd(q, c);
+
+ if (q.r*q.r + q.i*q.i + q.j*q.j + q.k*q.k > 8.0)
+ break;
+
+
+ return((float)i);
+
+ ;
+
+
+Julia::Julia(float global_real, float global_imag, float global_theta):
+ global_real(global_real), global_imag(global_imag), global_theta(global_theta)
+
+ oc.r = global_real;
+ oc.i = global_imag;
+ oc.j = oc.k = 0.0;
+
+ eio.r = cos(global_theta);
+ eio.i = sin(global_theta);
+ eio.j = 0.0;
+ eio.k = 0.0;
+
+ emio.r = cos(-global_theta);
+ emio.i = sin(-global_theta);
+ emio.j = 0.0;
+ emio.k = 0.0;
+
+ /***
+ *** multiply eio*c only once at the beginning of iteration
+ *** (since q |-> sqrt(eio*(q-eio*c)))
+ *** q -> e-io*q^2 - eio*c
+ ***/
+
+ qmult(c, eio,oc);
+
+
+
+
+#endif
Added: trunk/python-ogre/demos/ogre/Shadows.py
===================================================================
--- trunk/python-ogre/demos/ogre/Shadows.py (rev 0)
+++ trunk/python-ogre/demos/ogre/Shadows.py 2007-11-13 07:26:03 UTC (rev 471)
@@ -0,0 +1,1563 @@
+/*
+-----------------------------------------------------------------------------
+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"
+#include <crtdbg.h>
+#endi*/
+
+Entity* mAthene
+AnimationState* mAnimState = 0
+Entity* pPlaneEnt
+std.vector<Entity*> pColumns
+Light* mLight
+Light* mSunLight
+SceneNode* mLightNode = 0
+AnimationState* mLightAnimationState = 0
+ColourValue mMinLightColour(0.2, 0.1, 0.0)
+ColourValue mMaxLightColour(0.5, 0.3, 0.1)
+Real mMinFlareSize = 40
+Real mMaxFlareSize = 80
+
+## New depth shadowmapping
+String CUSTOM_ROCKWALL_MATERIAL("Ogre/DepthShadowmap/Receiver/RockWall")
+String CUSTOM_CASTER_MATERIAL("Ogre/DepthShadowmap/Caster/Float")
+String CUSTOM_RECEIVER_MATERIAL("Ogre/DepthShadowmap/Receiver/Float")
+String CUSTOM_ATHENE_MATERIAL("Ogre/DepthShadowmap/Receiver/Athene")
+
+String BASIC_ROCKWALL_MATERIAL("Examples/Rockwall")
+String BASIC_ATHENE_MATERIAL("Examples/Athene/NormalMapped")
+
+
+
+OverlayElement* mShadowTechniqueInfo
+OverlayElement* mMaterialInfo
+OverlayElement* mInfo
+
+
+/** This class 'wibbles' the light and billboard */
+class LightWibbler : public ControllerValue<Real>
+
+protected:
+ Light* mLight
+ Billboard* mBillboard
+ ColourValue mColourRange
+ ColourValue mMinColour
+ Real mMinSize
+ Real mSizeRange
+ Real intensity
+public:
+ LightWibbler(Light* light, Billboard* billboard, ColourValue& minColour,
+ ColourValue& maxColour, Real minSize, Real maxSize)
+
+ mLight = light
+ mBillboard = billboard
+ mMinColour = minColour
+ mColourRange.r = maxColour.r - minColour.r
+ mColourRange.g = maxColour.g - minColour.g
+ mColourRange.b = maxColour.b - minColour.b
+ mMinSize = minSize
+ mSizeRange = maxSize - minSize
+
+
+ virtual Real getValue (void)
+
+ return intensity
+
+
+ virtual void setValue (Real value)
+
+ intensity = value
+
+ ColourValue newColour
+
+ ## Attenuate the brightness of the light
+ newColour.r = mMinColour.r + (mColourRange.r * intensity)
+ newColour.g = mMinColour.g + (mColourRange.g * intensity)
+ newColour.b = mMinColour.b + (mColourRange.b * intensity)
+
+ mLight->setDiffuseColour(newColour)
+ mBillboard->setColour(newColour)
+ ## set billboard size
+ Real newSize = mMinSize + (intensity * mSizeRange)
+ mBillboard->setDimensions(newSize, newSize)
+
+
+
+
+Real timeDelay = 0
+#define KEY_PRESSED(_key,_timeDelay, _macro) \
+
+ if (mKeyboard->isKeyDown(_key) && timeDelay <= 0) \:
+
+ timeDelay = _timeDelay \
+ _macro \
+
+
+
+
+##---------------------------------------------------------------------------
+class GaussianListener: public Ogre.CompositorInstance::Listener
+
+protected:
+ int mVpWidth, mVpHeight
+ ## Array params - have to pack in groups of 4 since self is how Cg generates them
+ ## also prevents dependent texture read problems if ops don't require swizzle
+ float mBloomTexWeights[15][4]
+ float mBloomTexOffsetsHorz[15][4]
+ float mBloomTexOffsetsVert[15][4]
+public:
+ GaussianListener() {}
+ virtual ~GaussianListener() {}
+ void notifyViewportSize(int width, int height)
+
+ mVpWidth = width
+ mVpHeight = height
+ ## Calculate gaussian texture offsets & weights
+ float deviation = 3.0
+ float texelSize = 1.0 / (float)std.min(mVpWidth, mVpHeight)
+
+ ## central sample, no offset
+ mBloomTexOffsetsHorz[0][0] = 0.0
+ mBloomTexOffsetsHorz[0][1] = 0.0
+ mBloomTexOffsetsVert[0][0] = 0.0
+ mBloomTexOffsetsVert[0][1] = 0.0
+ mBloomTexWeights[0][0] = mBloomTexWeights[0][1] =
+ mBloomTexWeights[0][2] = Ogre.Math::gaussianDistribution(0, 0, deviation)
+ mBloomTexWeights[0][3] = 1.0
+
+ ## 'pre' samples
+ for(int i = 1 i < 8; ++i)
+
+ mBloomTexWeights[i][0] = mBloomTexWeights[i][1] =
+ mBloomTexWeights[i][2] = Ogre.Math::gaussianDistribution(i, 0, deviation)
+ mBloomTexWeights[i][3] = 1.0
+ mBloomTexOffsetsHorz[i][0] = i * texelSize
+ mBloomTexOffsetsHorz[i][1] = 0.0
+ mBloomTexOffsetsVert[i][0] = 0.0
+ mBloomTexOffsetsVert[i][1] = i * texelSize
+
+ ## 'post' samples
+ for(int i = 8 i < 15; ++i)
+
+ mBloomTexWeights[i][0] = mBloomTexWeights[i][1] =
+ mBloomTexWeights[i][2] = mBloomTexWeights[i - 7][0]
+ mBloomTexWeights[i][3] = 1.0
+
+ mBloomTexOffsetsHorz[i][0] = -mBloomTexOffsetsHorz[i - 7][0]
+ mBloomTexOffsetsHorz[i][1] = 0.0
+ mBloomTexOffsetsVert[i][0] = 0.0
+ mBloomTexOffsetsVert[i][1] = -mBloomTexOffsetsVert[i - 7][1]
+
+
+
+ virtual void notifyMaterialSetup(Ogre.uint32 pass_id, Ogre::MaterialPtr &mat)
+
+ ## Prepare the fragment params offsets
+ switch(pass_id)
+
+ case 701: ## blur horz
+
+ ## horizontal bloom
+ mat->load()
+ Ogre.GpuProgramParametersSharedPtr fparams =
+ mat->getBestTechnique()->getPass(0)->getFragmentProgramParameters()
+ Ogre.String& progName = mat->getBestTechnique()->getPass(0)->getFragmentProgramName()
+ ## A bit hacky - Cg & HLSL index arrays via [0], GLSL does not
+ fparams->setNamedConstant("sampleOffsets", mBloomTexOffsetsHorz[0], 15)
+ fparams->setNamedConstant("sampleWeights", mBloomTexWeights[0], 15)
+
+ break
+
+ case 700: ## blur vert
+
+ ## vertical bloom
+ mat->load()
+ Ogre.GpuProgramParametersSharedPtr fparams =
+ mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters()
+ Ogre.String& progName = mat->getBestTechnique()->getPass(0)->getFragmentProgramName()
+ fparams->setNamedConstant("sampleOffsets", mBloomTexOffsetsVert[0], 15)
+ fparams->setNamedConstant("sampleWeights", mBloomTexWeights[0], 15)
+
+ break
+
+
+
+
+ virtual void notifyMaterialRender(Ogre.uint32 pass_id, Ogre::MaterialPtr &mat)
+
+
+
+
+GaussianListener gaussianListener
+
+
+class ShadowsListener : public ExampleFrameListener, public OIS.MouseListener,
+ public OIS.KeyListener
+
+protected:
+ SceneManager* mSceneMgr
+ Viewport *mShadowVp
+ CompositorInstance* mShadowCompositor
+ bool mShutdownRequested
+ CEGUI.Window* mRootGuiPanel
+ bool mLMBDown
+ bool mRMBDown
+ bool mProcessMovement
+ bool mUpdateMovement
+ bool mMoveFwd
+ bool mMoveBck
+ bool mMoveLeft
+ bool mMoveRight
+ CEGUI.Point mLastMousePosition
+ bool mLastMousePositionSet
+ float mAvgFrameTime
+ Camera* mTexCam
+
+
+ ##----------------------------------------------------------------//
+ CEGUI.MouseButton convertOISMouseButtonToCegui(int buttonID)
+
+ switch (buttonID)
+
+ case 0: return CEGUI.LeftButton
+ case 1: return CEGUI.RightButton
+ case 2: return CEGUI.MiddleButton
+ case 3: return CEGUI.X1Button
+ default: return CEGUI.LeftButton
+
+
+public:
+ ShadowsListener(RenderWindow* win, Camera* cam, SceneManager* sm)
+ : ExampleFrameListener(win, cam, True, true)
+ , mSceneMgr(sm)
+ , mShadowVp(0)
+ , mShadowCompositor(0)
+ , mShutdownRequested(False)
+ , mLMBDown(False)
+ , mRMBDown(False)
+ , mProcessMovement(False)
+ , mUpdateMovement(False)
+ , mMoveFwd(False)
+ , mMoveBck(False)
+ , mMoveLeft(False)
+ , mMoveRight(False)
+ , mLastMousePositionSet(False)
+ , mAvgFrameTime(0.1)
+
+
+ mMouse->setEventCallback(self)
+ mKeyboard->setEventCallback(self)
+
+ mRootGuiPanel = CEGUI.WindowManager::getSingleton().getWindow("Shadows")
+
+ mMoveSpeed = 10.0
+
+ ## Set up a debug panel to display the shadow
+ MaterialPtr debugMat = MaterialManager.getSingleton().create(
+ "Ogre/DebugShadowMap0", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
+ debugMat->getTechnique(0)->getPass(0)->setLightingEnabled(False)
+ TexturePtr shadowTex = mSceneMgr->getShadowTexture(0)
+ TextureUnitState *t = debugMat->getTechnique(0)->getPass(0)->createTextureUnitState(shadowTex->getName())
+ t->setTextureAddressingMode(TextureUnitState.TAM_CLAMP)
+
+ debugMat = MaterialManager.getSingleton().create(
+ "Ogre/DebugShadowMap1", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
+ debugMat->getTechnique(0)->getPass(0)->setLightingEnabled(False)
+ shadowTex = mSceneMgr->getShadowTexture(1)
+ t = debugMat->getTechnique(0)->getPass(0)->createTextureUnitState(shadowTex->getName())
+ t->setTextureAddressingMode(TextureUnitState.TAM_CLAMP)
+
+ /* Uncomment self to display the shadow textures
+ OverlayContainer* debugPanel = (OverlayContainer*)
+ (OverlayManager.getSingleton().createOverlayElement("Panel", "Ogre/DebugShadowPanel0"))
+ debugPanel->_setPosition(0.8, 0)
+ debugPanel->_setDimensions(0.2, 0.2)
+ debugPanel->setMaterialName("Ogre/DebugShadowMap0")
+ Overlay* debugOverlay = OverlayManager.getSingleton().getByName("Core/DebugOverlay")
+ debugOverlay->add2D(debugPanel)
+
+ debugPanel = (OverlayContainer*)
+ (OverlayManager.getSingleton().createOverlayElement("Panel", "Ogre/DebugShadowPanel1"))
+ debugPanel->_setPosition(0.8, 0.2)
+ debugPanel->_setDimensions(0.2, 0.2)
+ debugPanel->setMaterialName("Ogre/DebugShadowMap1")
+ debugOverlay->add2D(debugPanel)
+ */
+
+
+
+
+
+ bool frameStarted( FrameEvent& evt)
+
+ CEGUI.System::getSingleton().injectTimePulse(evt.timeSinceLastFrame)
+
+ mMouse->capture()
+ mKeyboard->capture()
+
+ if (mShutdownRequested):
+ return False
+ else:
+
+ ## update movement process
+ if(mProcessMovement || mUpdateMovement):
+
+ mTranslateVector.x += mMoveLeft ? mAvgFrameTime * -mMoveSpeed : 0
+ mTranslateVector.x += mMoveRight ? mAvgFrameTime * mMoveSpeed : 0
+ mTranslateVector.z += mMoveFwd ? mAvgFrameTime * -mMoveSpeed : 0
+ mTranslateVector.z += mMoveBck ? mAvgFrameTime * mMoveSpeed : 0
+
+ mCamera->yaw(mRotX)
+ mCamera->pitch(mRotY)
+ mCamera->moveRelative(mTranslateVector)
+
+ mUpdateMovement = False
+ mRotX = 0
+ mRotY = 0
+ mTranslateVector = Ogre.Vector3::ZERO
+
+
+
+
+ return True
+
+
+ bool frameEnded( FrameEvent& evt)
+
+ if (mAnimState):
+ mAnimState->addTime(evt.timeSinceLastFrame)
+
+ if (mShutdownRequested):
+ return False
+ else:
+ return ExampleFrameListener.frameEnded(evt)
+
+
+ ##----------------------------------------------------------------//
+ bool mouseMoved( OIS.MouseEvent &arg )
+
+ CEGUI.System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel )
+ return True
+
+
+ ##----------------------------------------------------------------//
+ bool mousePressed( OIS.MouseEvent &arg, OIS::MouseButtonID id )
+
+ CEGUI.System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id))
+ return True
+
+
+ ##----------------------------------------------------------------//
+ bool mouseReleased( OIS.MouseEvent &arg, OIS::MouseButtonID id )
+
+ CEGUI.System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id))
+ return True
+
+
+ ##----------------------------------------------------------------//
+ bool keyPressed( OIS.KeyEvent &arg )
+
+ if( arg.key == OIS.KC_ESCAPE ):
+ mShutdownRequested = True
+
+ if (arg.key == OIS.KC_SYSRQ):
+ mWindow->writeContentsToTimestampedFile("screenshot", ".jpg")
+
+ CEGUI.System::getSingleton().injectKeyDown( arg.key )
+ CEGUI.System::getSingleton().injectChar( arg.text )
+ return True
+
+
+ ##----------------------------------------------------------------//
+ bool keyReleased( OIS.KeyEvent &arg )
+
+ CEGUI.System::getSingleton().injectKeyUp( arg.key )
+ return True
+
+ ##--------------------------------------------------------------------------
+ bool handleMouseMove( CEGUI.EventArgs& e)
+
+ CEGUI.MouseEventArgs& me = static_cast<const CEGUI::MouseEventArgs&>(e)
+
+ if( mLMBDown && !mRMBDown):
+
+ ## rotate camera
+ mRotX += Degree(-me.moveDelta.d_x * mAvgFrameTime * 3.0)
+ mRotY += Degree(-me.moveDelta.d_y * mAvgFrameTime * 3.0)
+ CEGUI.MouseCursor::getSingleton().setPosition( mLastMousePosition )
+ mUpdateMovement = True
+
+ else:
+
+ if( mRMBDown && !mLMBDown):
+
+ ## translate camera
+ mTranslateVector.x += me.moveDelta.d_x * mAvgFrameTime * mMoveSpeed
+ mTranslateVector.y += -me.moveDelta.d_y * mAvgFrameTime * mMoveSpeed
+ ##mTranslateVector.z = 0
+ CEGUI.MouseCursor::getSingleton().setPosition( mLastMousePosition )
+ mUpdateMovement = True
+
+ else:
+
+ if( mRMBDown && mLMBDown):
+
+ mTranslateVector.z += (me.moveDelta.d_x + me.moveDelta.d_y) * mAvgFrameTime * mMoveSpeed
+ CEGUI.MouseCursor::getSingleton().setPosition( mLastMousePosition )
+ mUpdateMovement = True
+
+
+
+
+
+ return True
+
+
+ ##--------------------------------------------------------------------------
+ bool handleMouseButtonUp( CEGUI.EventArgs& e)
+
+ CEGUI.MouseEventArgs& me = static_cast<const CEGUI::MouseEventArgs&>(e)
+
+ ##Window* wndw = (( WindowEventArgs&)e).window
+ if( me.button == CEGUI.LeftButton ):
+
+ mLMBDown = False
+
+
+ if( me.button == CEGUI.RightButton ):
+
+ mRMBDown = False
+
+ if( !mLMBDown && !mRMBDown ):
+
+ CEGUI.MouseCursor::getSingleton().show()
+ if(mLastMousePositionSet):
+
+ CEGUI.MouseCursor::getSingleton().setPosition( mLastMousePosition )
+ mLastMousePositionSet = False
+
+ mRootGuiPanel->releaseInput()
+
+
+ return True
+
+
+ ##--------------------------------------------------------------------------
+ bool handleMouseButtonDown( CEGUI.EventArgs& e)
+
+ CEGUI.MouseEventArgs& me = static_cast<const CEGUI::MouseEventArgs&>(e)
+
+ ##Window* wndw = (( WindowEventArgs&)e).window
+ if( me.button == CEGUI.LeftButton ):
+
+ mLMBDown = True
+
+
+ if( me.button == CEGUI.RightButton ):
+
+ mRMBDown = True
+
+
+ if( mLMBDown || mRMBDown ):
+
+ CEGUI.MouseCursor::getSingleton().hide()
+ if (!mLastMousePositionSet):
+
+ mLastMousePosition = CEGUI.MouseCursor::getSingleton().getPosition()
+ mLastMousePositionSet = True
+
+ mRootGuiPanel->captureInput()
+
+
+ return True
+
+
+ ##--------------------------------------------------------------------------
+ bool handleMouseWheelEvent( CEGUI.EventArgs& e)
+
+ CEGUI.MouseEventArgs& me = static_cast<const CEGUI::MouseEventArgs&>(e)
+ mTranslateVector.z += me.wheelChange * -5.0
+ mUpdateMovement = True
+
+ return True
+
+
+ ##--------------------------------------------------------------------------
+ void checkMovementKeys(CEGUI.Key::Scan scancode, bool state )
+
+
+ switch ( scancode )
+
+ case CEGUI.Key::A:
+ mMoveLeft = state
+ break
+
+ case CEGUI.Key::D:
+ mMoveRight = state
+ break
+
+ case CEGUI.Key::S:
+ mMoveBck = state
+ break
+
+ case CEGUI.Key::W:
+ mMoveFwd = state
+ break
+
+ default:
+ break
+
+
+
+ mProcessMovement = mMoveLeft || mMoveRight || mMoveFwd || mMoveBck
+
+
+ ##--------------------------------------------------------------------------
+ bool handleKeyDownEvent( CEGUI.EventArgs& e)
+
+ CEGUI.KeyEventArgs& ke = static_cast<const CEGUI::KeyEventArgs&>(e)
+
+ checkMovementKeys(ke.scancode , True)
+
+ return True
+
+
+ ##--------------------------------------------------------------------------
+ bool handleKeyUpEvent( CEGUI.EventArgs& e)
+
+ CEGUI.KeyEventArgs& ke = static_cast<const CEGUI::KeyEventArgs&>(e)
+ checkMovementKeys(ke.scancode, False )
+
+ return True
+
+
+
+
+
+
+
+class ShadowsApplication : public ExampleApplication
+
+protected:
+ enum ShadowProjection
+
+ UNIFORM,
+ UNIFORM_FOCUSED,
+ LISPSM,
+ PLANE_OPTIMAL
+
+
+ enum ShadowMaterial
+
+ MAT_STANDARD,
+ MAT_DEPTH_FLOAT,
+ MAT_DEPTH_FLOAT_PCF
+
+ CEGUI.OgreCEGUIRenderer* mGUIRenderer
+ CEGUI.System* mGUISystem
+ CEGUI.Window* mDescWindow
+ CEGUI.Scrollbar* mFixedBias
+ CEGUI.Scrollbar* mGradientBias
+ CEGUI.Scrollbar* mGradientClamp
+ CEGUI.Window* mDepthShadowTweak
+ CEGUI.Window* mFixedBiasText
+ CEGUI.Window* mGradientBiasText
+ CEGUI.Window* mGradientClampText
+
+
+ ShadowTechnique mCurrentShadowTechnique
+ ShadowProjection mCurrentProjection
+ ShadowMaterial mCurrentMaterial
+
+ GpuProgramParametersSharedPtr mCustomRockwallVparams
+ GpuProgramParametersSharedPtr mCustomRockwallFparams
+ GpuProgramParametersSharedPtr mCustomAtheneVparams
+ GpuProgramParametersSharedPtr mCustomAtheneFparams
+
+ ShadowCameraSetupPtr mCurrentShadowCameraSetup
+ ##/ Plane that defines plane-optimal shadow mapping basis
+ MovablePlane* mPlane
+ ## transient pointer to LiSPSM setup if present
+ LiSPSMShadowCameraSetup* mLiSPSMSetup
+
+ bool mIsOpenGL
+
+public:
+ ShadowsApplication() :
+ mGUIRenderer(0),
+ mGUISystem(0),
+ mPlane(0)
+
+
+
+
+
+ ~ShadowsApplication()
+
+ mDescWindow = 0
+
+ if(mGUISystem):
+
+ delete mGUISystem
+ mGUISystem = 0
+
+ if(mGUIRenderer):
+
+ delete mGUIRenderer
+ mGUIRenderer = 0
+
+
+ delete mPlane
+
+protected:
+
+ ## Override self to ensure FPU mode
+ bool configure(void)
+
+ ## Show the configuration dialog and initialise the system
+ ## You can skip self and use root.restoreConfig() to load configuration
+ ## settings if you were sure there are valid ones saved in ogre.cfg
+ if(mRoot->showConfigDialog()):
+
+ ## Custom option - to use PlaneOptimalShadowCameraSetup we must have
+ ## double-precision. Thus, set the D3D floating point mode if present,
+ ## no matter what was chosen
+ ConfigOptionMap& optMap = mRoot->getRenderSystem()->getConfigOptions()
+ ConfigOptionMap.iterator i = optMap.find("Floating-point mode")
+ if (i != optMap.end()):
+
+ if (i->second.currentValue != "Consistent"):
+
+ i->second.currentValue = "Consistent"
+ LogManager.getSingleton().logMessage("Demo_Shadows: overriding "
+ "D3D floating point mode to 'Consistent' to ensure precision "
+ "for plane-optimal camera setup option")
+
+
+
+
+ ## If returned True, user clicked OK so initialise
+ ## Here we choose to let the system create a default rendering window by passing 'True'
+ mWindow = mRoot->initialise(True)
+ return True
+
+ else:
+
+ return False
+
+
+
+ void generalSceneSetup()
+
+ ## do self first so we generate edge lists
+ mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE)
+ mCurrentShadowTechnique = SHADOWTYPE_STENCIL_ADDITIVE
+
+ ## Set ambient light off
+ mSceneMgr->setAmbientLight(ColourValue(0.0, 0.0, 0.0))
+
+ ## Fixed light, dim
+ mSunLight = mSceneMgr->createLight("SunLight")
+ mSunLight->setType(Light.LT_SPOTLIGHT)
+ mSunLight->setPosition(1500,1750,1300)
+ mSunLight->setSpotlightRange(Degree(30), Degree(50))
+ Vector3 dir
+ dir = -mSunLight->getPosition()
+ dir.normalise()
+ mSunLight->setDirection(dir)
+ mSunLight->setDiffuseColour(0.35, 0.35, 0.38)
+ mSunLight->setSpecularColour(0.9, 0.9, 1)
+
+ ## Point light, movable, reddish
+ mLight = mSceneMgr->createLight("Light2")
+ mLight->setDiffuseColour(mMinLightColour)
+ mLight->setSpecularColour(1, 1, 1)
+ mLight->setAttenuation(8000,1,0.0005,0)
+
+ ## Create light node
+ mLightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(
+ "MovingLightNode")
+ mLightNode->attachObject(mLight)
+ ## create billboard set
+ BillboardSet* bbs = mSceneMgr->createBillboardSet("lightbbs", 1)
+ bbs->setMaterialName("Examples/Flare")
+ Billboard* bb = bbs->createBillboard(0,0,0,mMinLightColour)
+ ## attach
+ mLightNode->attachObject(bbs)
+
+ ## create controller, after self is will get updated on its own
+ ControllerFunctionRealPtr func = ControllerFunctionRealPtr(
+ new WaveformControllerFunction(Ogre.WFT_SINE, 0.75, 0.5))
+ ControllerManager& contMgr = ControllerManager.getSingleton()
+ ControllerValueRealPtr val = ControllerValueRealPtr(
+ new LightWibbler(mLight, bb, mMinLightColour, mMaxLightColour,
+ mMinFlareSize, mMaxFlareSize))
+ Controller<Real>* controller = contMgr.createController(
+ contMgr.getFrameTimeSource(), val, func)
+
+ ##mLight->setPosition(Vector3(300,250,-300))
+ mLightNode->setPosition(Vector3(300,1750,-700))
+
+
+ ## Create a track for the light
+ Animation* anim = mSceneMgr->createAnimation("LightTrack", 20)
+ ## Spline it for nice curves
+ anim->setInterpolationMode(Animation.IM_SPLINE)
+ ## Create a track to animate the camera's node
+ NodeAnimationTrack* track = anim->createNodeTrack(0, mLightNode)
+ ## Setup keyframes
+ TransformKeyFrame* key = track->createNodeKeyFrame(0) ## A startposition
+ key->setTranslate(Vector3(300,750,-700))
+ key = track->createNodeKeyFrame(2) ##B
+ key->setTranslate(Vector3(150,800,-250))
+ key = track->createNodeKeyFrame(4) ##C
+ key->setTranslate(Vector3(-150,850,-100))
+ key = track->createNodeKeyFrame(6) ##D
+ key->setTranslate(Vector3(-400,700,-200))
+ key = track->createNodeKeyFrame(8) ##E
+ key->setTranslate(Vector3(-200,700,-400))
+ key = track->createNodeKeyFrame(10) ##F
+ key->setTranslate(Vector3(-100,850,-200))
+ key = track->createNodeKeyFrame(12) ##G
+ key->setTranslate(Vector3(-100,575,180))
+ key = track->createNodeKeyFrame(14) ##H
+ key->setTranslate(Vector3(0,750,300))
+ key = track->createNodeKeyFrame(16) ##I
+ key->setTranslate(Vector3(100,850,100))
+ key = track->createNodeKeyFrame(18) ##J
+ key->setTranslate(Vector3(250,800,0))
+ key = track->createNodeKeyFrame(20) ##K == A
+ key->setTranslate(Vector3(300,750,-700))
+ ## Create a new animation state to track self
+ mAnimState = mSceneMgr->createAnimationState("LightTrack")
+ mAnimState->setEnabled(True)
+ ## Make light node look at origin, self is for when we
+ ## change the moving light to a spotlight
+ mLightNode->setAutoTracking(True, mSceneMgr->getRootSceneNode())
+
+ ## Prepare athene mesh for normalmapping
+ MeshPtr pAthene = MeshManager.getSingleton().load("athene.mesh",
+ ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
+ unsigned short src, dest
+ if (!pAthene->suggestTangentVectorBuildParams(VES_TANGENT, src, dest)):
+
+ pAthene->buildTangentVectors(VES_TANGENT, src, dest)
+
+
+ SceneNode* node
+ node = mSceneMgr->getRootSceneNode()->createChildSceneNode()
+ mAthene = mSceneMgr->createEntity( "athene", "athene.mesh" )
+ mAthene->setMaterialName(BASIC_ATHENE_MATERIAL)
+ node->attachObject( mAthene )
+ node->translate(0,-27, 0)
+ node->yaw(Degree(90))
+
+ Entity* pEnt
+ ## Columns
+ for (int x = -2 x <= 2; ++x)
+
+ for (int z = -2 z <= 2; ++z)
+
+ if (x != 0 || z != 0):
+
+ StringUtil.StrStreamType str
+ str << "col" << x << "_" << z
+ node = mSceneMgr->getRootSceneNode()->createChildSceneNode()
+ pEnt = mSceneMgr->createEntity( str.str(), "column.mesh" )
+ pEnt->setMaterialName(BASIC_ROCKWALL_MATERIAL)
+ pColumns.push_back(pEnt)
+ node->attachObject( pEnt )
+ node->translate(x*300,0, z*300)
+
+
+
+
+
+
+
+ ## Skybox
+ mSceneMgr->setSkyBox(True, "Examples/StormySkyBox")
+
+ ## Floor plane (use POSM plane def)
+ mPlane = new MovablePlane("*mPlane")
+ mPlane->normal = Vector3.UNIT_Y
+ mPlane->d = 107
+ MeshManager.getSingleton().createPlane("Myplane",
+ ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, *mPlane,
+ 1500,1500,50,50,True,1,5,5,Vector3.UNIT_Z)
+ pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" )
+ pPlaneEnt->setMaterialName(BASIC_ROCKWALL_MATERIAL)
+ pPlaneEnt->setCastShadows(False)
+ mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt)
+
+ if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_HWRENDER_TO_TEXTURE)):
+
+ ## In D3D, use a 1024x1024 shadow texture
+ mSceneMgr->setShadowTextureSettings(1024, 2)
+
+ else:
+
+ ## Use 512x512 texture in GL since we can't go higher than the window res
+ mSceneMgr->setShadowTextureSettings(512, 2)
+
+ mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5))
+
+ ## incase infinite far distance is not supported
+ mCamera->setFarClipDistance(100000)
+
+ ##mSceneMgr->setShowDebugShadows(True)
+
+ mCamera->setPosition(250, 20, 400)
+ mCamera->lookAt(0, 10, 0)
+
+
+
+ ## Just override the mandatory create scene method
+ void createScene(void)
+
+ ## Need to detect D3D or GL for best depth shadowmapping
+ if (Root.getSingleton().getRenderSystem()->getName().find("GL") != String::npos):
+
+ mIsOpenGL = True
+
+ else:
+
+ mIsOpenGL = False
+
+
+ ## set up general scene (self defaults to additive stencils)
+ generalSceneSetup()
+
+ setupGUI()
+
+
+
+
+ ##/ Change basic shadow technique
+ void changeShadowTechnique(ShadowTechnique newTech)
+
+ mSceneMgr->setShadowTechnique(newTech)
+
+ ## Below is for projection
+ ##configureShadowCameras(mCurrentShadowTechnique, newTech)
+
+ configureLights(newTech)
+
+ ## Advanced modes - materials / compositors
+ ##configureCompositors(mCurrentShadowTechnique, newTech)
+ ##configureTextures(mCurrentShadowTechnique, newTech)
+ ##configureShadowCasterReceiverMaterials(mCurrentShadowTechnique, newTech)
+
+ updateGUI(newTech)
+
+ mCurrentShadowTechnique = newTech
+
+
+
+
+
+
+ void configureLights(ShadowTechnique newTech)
+
+ Vector3 dir
+ switch (newTech)
+
+ case SHADOWTYPE_STENCIL_ADDITIVE:
+ ## Fixed light, dim
+ mSunLight->setCastShadows(True)
+
+ ## Point light, movable, reddish
+ mLight->setType(Light.LT_POINT)
+ mLight->setCastShadows(True)
+ mLight->setDiffuseColour(mMinLightColour)
+ mLight->setSpecularColour(1, 1, 1)
+ mLight->setAttenuation(8000,1,0.0005,0)
+
+ break
+ case 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(Light.LT_POINT)
+ mLight->setCastShadows(True)
+ mLight->setDiffuseColour(mMinLightColour)
+ mLight->setSpecularColour(1, 1, 1)
+ mLight->setAttenuation(8000,1,0.0005,0)
+ break
+ case SHADOWTYPE_TEXTURE_MODULATIVE:
+ case SHADOWTYPE_TEXTURE_ADDITIVE:
+ ## Fixed light, dim
+ mSunLight->setCastShadows(True)
+
+ ## Change moving light to spotlight
+ ## Point light, movable, reddish
+ mLight->setType(Light.LT_SPOTLIGHT)
+ mLight->setDirection(Vector3.NEGATIVE_UNIT_Z)
+ mLight->setCastShadows(True)
+ mLight->setDiffuseColour(mMinLightColour)
+ mLight->setSpecularColour(1, 1, 1)
+ mLight->setAttenuation(8000,1,0.0005,0)
+ mLight->setSpotlightRange(Degree(80),Degree(90))
+
+
+ break
+ default:
+ break
+
+
+
+
+ void setupGUI()
+
+ ## setup GUI system
+ mGUIRenderer = new CEGUI.OgreCEGUIRenderer(mWindow,
+ Ogre.RENDER_QUEUE_OVERLAY, False, 3000, mSceneMgr)
+
+ mGUISystem = new CEGUI.System(mGUIRenderer)
+
+ CEGUI.Logger::getSingleton().setLoggingLevel(CEGUI::Informative)
+
+ ## load scheme and set up defaults
+ CEGUI.SchemeManager::getSingleton().loadScheme(
+ (CEGUI.utf8*)"TaharezLookSkin.scheme")
+ mGUISystem->setDefaultMouseCursor(
+ (CEGUI.utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow")
+ mGUISystem->setDefaultFont((CEGUI.utf8*)"BlueHighway-12")
+
+ CEGUI.Window* sheet =
+ CEGUI.WindowManager::getSingleton().loadWindowLayout(
+ (CEGUI.utf8*)"shadows.layout")
+ mGUISystem->setGUISheet(sheet)
+
+ ## Tooltips aren't big enough, do our own
+ ##mGUISystem->setDefaultTooltip("TaharezLook/Tooltip")
+
+ CEGUI.WindowManager& wmgr = CEGUI::WindowManager::getSingleton()
+ ## Get description window
+ mDescWindow = wmgr.getWindow("Shadows/Desc")
+
+ CEGUI.Window *wnd = wmgr.getWindow("Shadows/Stencil")
+ wnd->subscribeEvent(CEGUI.Window::EventMouseEnters,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseEnter, self))
+ wnd->subscribeEvent(CEGUI.Window::EventMouseLeaves,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseLeave, self))
+ wnd = wmgr.getWindow("Shadows/Texture")
+ wnd->subscribeEvent(CEGUI.Window::EventMouseEnters,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseEnter, self))
+ wnd->subscribeEvent(CEGUI.Window::EventMouseLeaves,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseLeave, self))
+ wnd = wmgr.getWindow("Shadows/Additive")
+ wnd->subscribeEvent(CEGUI.Window::EventMouseEnters,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseEnter, self))
+ wnd->subscribeEvent(CEGUI.Window::EventMouseLeaves,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseLeave, self))
+ wnd = wmgr.getWindow("Shadows/Modulative")
+ wnd->subscribeEvent(CEGUI.Window::EventMouseEnters,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseEnter, self))
+ wnd->subscribeEvent(CEGUI.Window::EventMouseLeaves,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseLeave, self))
+
+ ## Combo doesn't raise enter / exit itself, have to grab subcomponents?
+ CEGUI.Combobox* cbo = static_cast<CEGUI::Combobox*>(wmgr.getWindow("Shadows/Projection"))
+ cbo->subscribeEvent(CEGUI.Combobox::EventListSelectionAccepted,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleProjectionChanged, self))
+ cbo->getEditbox()->subscribeEvent(CEGUI.Window::EventMouseEnters,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseEnterCombo, self))
+ cbo->getEditbox()->subscribeEvent(CEGUI.Window::EventMouseLeaves,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseLeave, self))
+ cbo->getDropList()->subscribeEvent(CEGUI.Window::EventMouseEnters,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseEnterCombo, self))
+ cbo->getDropList()->subscribeEvent(CEGUI.Window::EventMouseLeaves,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseLeave, self))
+ cbo->getPushButton()->subscribeEvent(CEGUI.Window::EventMouseEnters,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseEnterCombo, self))
+ cbo->getPushButton()->subscribeEvent(CEGUI.Window::EventMouseLeaves,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseLeave, self))
+ ## Populate projection
+ ## Get a select image to be used for highlighting items in listbox when mouse moves over them
+ CEGUI.Image* selectImage = &CEGUI::ImagesetManager::getSingleton().getImageset("TaharezLook")->getImage("MultiListSelectionBrush")
+ CEGUI.ListboxTextItem* li = new CEGUI::ListboxTextItem("Uniform", UNIFORM)
+ li->setSelectionBrushImage(selectImage)
+ li->setTooltipText("Uniform: Shadows are rendered and projected using a uniform "
+ "frustum for the whole light coverage. Simple and lowest quality.")
+ cbo->addItem(li)
+ cbo->setItemSelectState(li, True)
+ cbo->setText("Uniform")
+ mCurrentProjection = UNIFORM
+ li = new CEGUI.ListboxTextItem("Uniform Focused", UNIFORM_FOCUSED)
+ li->setSelectionBrushImage(selectImage)
+ li->setTooltipText("Uniform Focused: As Uniform except that the frustum is "
+ "focused on the visible area of the camera. Better quality than Uniform "
+ "at the expense of some 'swimming'.")
+ cbo->addItem(li)
+ li = new CEGUI.ListboxTextItem("LiSPSM", LISPSM)
+ li->setSelectionBrushImage(selectImage)
+ li->setTooltipText("LiSPSM: The frustum is distorted to take into account "
+ "the perspective of the camera, and focused on the visible area. "
+ "Good quality & flexibility.")
+ cbo->addItem(li)
+ li = new CEGUI.ListboxTextItem("Plane Optimal", PLANE_OPTIMAL)
+ li->setSelectionBrushImage(selectImage)
+ li->setTooltipText("Plane Optimal: The frustum is optimised to project "
+ "shadows onto a plane of interest. Best possible quality for the "
+ "plane, less good for other receiver angles.")
+ cbo->addItem(li)
+
+
+ cbo = static_cast<CEGUI.Combobox*>(wmgr.getWindow("Shadows/Material"))
+ cbo->getEditbox()->subscribeEvent(CEGUI.Window::EventMouseEnters,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseEnterCombo, self))
+ cbo->getEditbox()->subscribeEvent(CEGUI.Window::EventMouseLeaves,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseLeave, self))
+ cbo->getDropList()->subscribeEvent(CEGUI.Window::EventMouseEnters,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseEnterCombo, self))
+ cbo->getDropList()->subscribeEvent(CEGUI.Window::EventMouseLeaves,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseLeave, self))
+ cbo->getPushButton()->subscribeEvent(CEGUI.Window::EventMouseEnters,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseEnterCombo, self))
+ cbo->getPushButton()->subscribeEvent(CEGUI.Window::EventMouseLeaves,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMouseLeave, self))
+ cbo->subscribeEvent(CEGUI.Combobox::EventListSelectionAccepted,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleMaterialChanged, self))
+
+ li = new CEGUI.ListboxTextItem("Standard", MAT_STANDARD)
+ li->setSelectionBrushImage(selectImage)
+ li->setTooltipText("Standard Material: Shadows are rendered into a simple RGB texture "
+ " and are received only by objects that are not themselves shadow casters "
+ " (no self-shadowing)")
+ cbo->addItem(li)
+ cbo->setItemSelectState(li, True)
+ cbo->setText("Standard")
+ mCurrentMaterial = MAT_STANDARD
+
+ ## Only add depth shadowmapping if supported
+ if (GpuProgramManager.getSingleton().isSyntaxSupported("ps_2_0") ||:
+ GpuProgramManager.getSingleton().isSyntaxSupported("glsl"))
+
+ li = new CEGUI.ListboxTextItem("Depth Shadowmap", MAT_DEPTH_FLOAT)
+ li->setSelectionBrushImage(selectImage)
+ li->setTooltipText("Depth Shadowmap: Shadow caster depth is rendered into a "
+ " floating point texture and a depth comparison is performed on receivers "
+ " (self-shadowing allowed). Requires floating point textures and shader support.")
+ cbo->addItem(li)
+
+ li = new CEGUI.ListboxTextItem("Depth Shadowmap (PCF)", MAT_DEPTH_FLOAT_PCF)
+ li->setSelectionBrushImage(selectImage)
+ li->setTooltipText("Depth Shadowmap (PCF): Shadow caster depth is rendered into a "
+ " floating point texture and a depth comparison is performed on receivers "
+ " (self-shadowing allowed), with a percentage closest filter. Requires "
+ "floating point textures and shader support.")
+ cbo->addItem(li)
+
+
+ CEGUI.RadioButton* radio = static_cast<CEGUI::RadioButton*>(
+ wmgr.getWindow("Shadows/Stencil"))
+ radio->setSelected(True)
+ radio->subscribeEvent(CEGUI.RadioButton::EventSelectStateChanged,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleShadowTypeChanged, self))
+ radio = static_cast<CEGUI.RadioButton*>(wmgr.getWindow("Shadows/Texture"))
+ radio->subscribeEvent(CEGUI.RadioButton::EventSelectStateChanged,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleShadowTypeChanged, self))
+ radio = static_cast<CEGUI.RadioButton*>(wmgr.getWindow("Shadows/Modulative"))
+ radio->subscribeEvent(CEGUI.RadioButton::EventSelectStateChanged,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleShadowTypeChanged, self))
+ radio = static_cast<CEGUI.RadioButton*>(wmgr.getWindow("Shadows/Additive"))
+ radio->setSelected(True)
+ radio->subscribeEvent(CEGUI.RadioButton::EventSelectStateChanged,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleShadowTypeChanged, self))
+
+
+
+ mFixedBias = static_cast<CEGUI.Scrollbar*>(wmgr.getWindow("Shadows/DepthShadowTweakGroup/FixedBias"))
+ mFixedBias->setScrollPosition(0.002)
+ mFixedBias->subscribeEvent(CEGUI.Scrollbar::EventScrollPositionChanged,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleParamsChanged, self))
+ mGradientBias = static_cast<CEGUI.Scrollbar*>(wmgr.getWindow("Shadows/DepthShadowTweakGroup/SlopeBias"))
+ mGradientBias->setScrollPosition(0.0008)
+ mGradientBias->subscribeEvent(CEGUI.Scrollbar::EventScrollPositionChanged,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleParamsChanged, self))
+ mGradientClamp = static_cast<CEGUI.Scrollbar*>(wmgr.getWindow("Shadows/DepthShadowTweakGroup/SlopeClamp"))
+ mGradientClamp->setScrollPosition(0.02)
+ mGradientClamp->subscribeEvent(CEGUI.Scrollbar::EventScrollPositionChanged,
+ CEGUI.Event::Subscriber(&ShadowsApplication::handleParamsChanged, self))
+
+ mDepthShadowTweak = wmgr.getWindow("Shadows/DepthShadowTweakGroup")
+ mDepthShadowTweak->setVisible(False)
+ mFixedBiasText = wmgr.getWindow("Shadows/DepthShadowTweakGroup/FixedBiasText")
+ mGradientBiasText = wmgr.getWindow("Shadows/DepthShadowTweakGroup/SlopeBiasText")
+ mGradientClampText = wmgr.getWindow("Shadows/DepthShadowTweakGroup/SlopeClampText")
+
+
+
+
+ updateGUI(mCurrentShadowTechnique)
+
+
+
+
+
+ void updateGUI(ShadowTechnique newTech)
+
+ bool isTextureBased = (newTech & SHADOWDETAILTYPE_TEXTURE) != 0
+
+ ## Stencil based technique, turn off the texture-specific options
+ CEGUI.WindowManager& wmgr = CEGUI::WindowManager::getSingleton()
+ CEGUI.Window* win = wmgr.getWindow("Shadows/Projection")
+ win->setEnabled(isTextureBased)
+ win = wmgr.getWindow("Shadows/Material")
+ win->setEnabled(isTextureBased)
+
+
+
+ ##/ callback when mouse enters a described field (non-combo)
+ bool handleMouseEnter( CEGUI.EventArgs& e)
+
+ CEGUI.WindowEventArgs& winargs =
+ static_cast< CEGUI.WindowEventArgs&>(e)
+ mDescWindow->setText(winargs.window->getTooltipText())
+
+ return True
+
+ ##/ callback when mouse leaves a described field
+ bool handleMouseLeave( CEGUI.EventArgs& e)
+
+ ##if (mDescWindow):
+ ## mDescWindow->setText("")
+
+ return True
+
+
+ void updateTipForCombo(CEGUI.Combobox* cbo)
+
+
+ CEGUI.String text = cbo->getTooltipText()
+
+ text.append(" ")
+ if (cbo->getSelectedItem()):
+ text.append(cbo->getSelectedItem()->getTooltipText())
+ mDescWindow->setText(text)
+
+
+ ##/ callback when mouse enters a described field (combo)
+ bool handleMouseEnterCombo( CEGUI.EventArgs& e)
+
+ CEGUI.WindowEventArgs& winargs =
+ static_cast< CEGUI.WindowEventArgs&>(e)
+ ## get tooltip from parent combo (events raised on contained components)
+ CEGUI.Combobox* cbo = static_cast<CEGUI::Combobox*>(winargs.window->getParent())
+ updateTipForCombo(cbo)
+
+ return True
+
+ ## Callback when a shadow type combo changed
+ bool handleShadowTypeChanged( CEGUI.EventArgs& e)
+
+ ## Only trigger change on selected
+ CEGUI.WindowEventArgs& we = static_cast<const CEGUI::WindowEventArgs&>(e)
+ CEGUI.RadioButton* radio = static_cast<CEGUI::RadioButton*>(we.window)
+ if (radio->isSelected()):
+
+ ShadowTechnique newTech = mCurrentShadowTechnique
+ switch (radio->getID())
+
+ case 1:
+ ## stencil
+ newTech = static_cast<ShadowTechnique>(
+ (newTech & ~SHADOWDETAILTYPE_TEXTURE) | SHADOWDETAILTYPE_STENCIL)
+ resetMaterials()
+ break
+ case 2:
+ ## texture
+ newTech = static_cast<ShadowTechnique>(
+ (newTech & ~SHADOWDETAILTYPE_STENCIL) | SHADOWDETAILTYPE_TEXTURE)
+ break
+ case 3:
+ ## additive
+ newTech = static_cast<ShadowTechnique>(
+ (newTech & ~SHADOWDETAILTYPE_MODULATIVE) | SHADOWDETAILTYPE_ADDITIVE)
+ break
+ case 4:
+ ## modulative
+ newTech = static_cast<ShadowTechnique>(
+ (newTech & ~SHADOWDETAILTYPE_ADDITIVE) | SHADOWDETAILTYPE_MODULATIVE)
+ break
+
+
+
+
+ changeShadowTechnique(newTech)
+
+
+
+ return True
+
+
+ bool handleProjectionChanged( CEGUI.EventArgs& e)
+
+ CEGUI.WindowEventArgs& winargs =
+ static_cast< CEGUI.WindowEventArgs&>(e)
+ CEGUI.Combobox* cbo = static_cast<CEGUI::Combobox*>(winargs.window)
+
+ if (cbo->getSelectedItem()):
+
+ ShadowProjection proj = (ShadowProjection)cbo->getSelectedItem()->getID()
+ if (proj != mCurrentProjection):
+
+ switch(proj)
+
+ case UNIFORM:
+ mCurrentShadowCameraSetup =
+ ShadowCameraSetupPtr(new DefaultShadowCameraSetup())
+ break
+ case UNIFORM_FOCUSED:
+ mCurrentShadowCameraSetup =
+ ShadowCameraSetupPtr(new FocusedShadowCameraSetup())
+ break
+ case LISPSM:
+
+ mLiSPSMSetup = new LiSPSMShadowCameraSetup()
+ ##mLiSPSMSetup->setUseAggressiveFocusRegion(False)
+ mCurrentShadowCameraSetup = ShadowCameraSetupPtr(mLiSPSMSetup)
+
+ break
+ case PLANE_OPTIMAL:
+ mCurrentShadowCameraSetup =
+ ShadowCameraSetupPtr(new PlaneOptimalShadowCameraSetup(mPlane))
+ break
+
+
+ mCurrentProjection = proj
+
+ mSceneMgr->setShadowCameraSetup(mCurrentShadowCameraSetup)
+
+ updateTipForCombo(cbo)
+ if (!mCustomRockwallVparams.isNull() && !mCustomRockwallFparams.isNull()):
+
+ ## set
+ setDefaultDepthShadowParams()
+
+
+
+
+
+ return True
+
+
+ void updateDepthShadowParams()
+
+ mCustomRockwallFparams->setNamedConstant("fixedDepthBias",
+ mFixedBias->getScrollPosition())
+ mCustomRockwallFparams->setNamedConstant("gradientScaleBias",
+ mGradientBias->getScrollPosition())
+ mCustomRockwallFparams->setNamedConstant("gradientClamp",
+ mGradientClamp->getScrollPosition())
+
+ mCustomAtheneFparams->setNamedConstant("fixedDepthBias",
+ mFixedBias->getScrollPosition())
+ mCustomAtheneFparams->setNamedConstant("gradientScaleBias",
+ mGradientBias->getScrollPosition())
+ mCustomAtheneFparams->setNamedConstant("gradientClamp",
+ mGradientClamp->getScrollPosition())
+
+
+ mFixedBiasText->setText(StringConverter.toString(
+ mFixedBias->getScrollPosition(), 4, 5, '0', std.ios::fixed))
+ mGradientBiasText->setText(StringConverter.toString(
+ mGradientBias->getScrollPosition(), 4, 5, '0', std.ios::fixed))
+ mGradientClampText->setText(StringConverter.toString(
+ mGradientClamp->getScrollPosition(), 4, 5, '0', std.ios::fixed))
+
+
+ void setDefaultDepthShadowParams()
+
+ switch(mCurrentProjection)
+
+ case UNIFORM:
+ case UNIFORM_FOCUSE...
[truncated message content] |