[Python-ogre-commit] SF.net SVN: python-ogre: [411] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2007-10-06 10:45:01
|
Revision: 411 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=411&view=rev Author: andy_miller Date: 2007-10-06 03:45:04 -0700 (Sat, 06 Oct 2007) Log Message: ----------- Updates to the 1.1 release -- a few last minute demo fixes Modified Paths: -------------- trunk/python-ogre/SConstruct trunk/python-ogre/demos/navi/Demo_navi.py trunk/python-ogre/demos/plib/Demo_Client.py trunk/python-ogre/demos/plib/Demo_Server.py trunk/python-ogre/demos/qgui/Demo_QuickGUI01.py trunk/python-ogre/environment.py Added Paths: ----------- trunk/python-ogre/SourceSnapShots/Python-Ogre-V1.1-SnapShot.7z trunk/python-ogre/demos/ogre/Demo_Water.py trunk/python-ogre/demos/ogre/WaterMesh.py Removed Paths: ------------- trunk/python-ogre/packages_2.5/ogre/renderer/OGREdshow/ Modified: trunk/python-ogre/SConstruct =================================================================== --- trunk/python-ogre/SConstruct 2007-10-05 13:06:34 UTC (rev 410) +++ trunk/python-ogre/SConstruct 2007-10-06 10:45:04 UTC (rev 411) @@ -157,10 +157,13 @@ ## ugly hack - scons returns a list of targets from SharedLibrary - we have to choose the one we want index = 0 # this is the index into a list of targets - '0' should be the platform default - - ## and lets have it install the output into the 'package_dir_name/ModuleName' dir and rename to the PydName - _env.AddPostAction(package,\ - 'mt.exe -nologo -manifest %(name)s.manifest -outputresource:%(name)s;2' % { 'name':package[index] } ) + if os.name=="nt" + ## and lets have it install the output into the 'package_dir_name/ModuleName' dir and rename to the PydName + _env.AddPostAction(package,\ + 'mt.exe -nologo -manifest %(name)s.manifest -outputresource:%(name)s;2' % { 'name':package[index] } ) + else: + _env.AddPostAction(package,\ + '-strip --debug %(name)s' % { 'name':package[index] } ) _env.InstallAs(os.path.join(environment.package_dir_name, cls.parent, cls.ModuleName, cls.PydName), Added: trunk/python-ogre/SourceSnapShots/Python-Ogre-V1.1-SnapShot.7z =================================================================== (Binary files differ) Property changes on: trunk/python-ogre/SourceSnapShots/Python-Ogre-V1.1-SnapShot.7z ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/python-ogre/demos/navi/Demo_navi.py =================================================================== --- trunk/python-ogre/demos/navi/Demo_navi.py 2007-10-05 13:06:34 UTC (rev 410) +++ trunk/python-ogre/demos/navi/Demo_navi.py 2007-10-06 10:45:04 UTC (rev 411) @@ -19,7 +19,7 @@ def _createScene(self): sceneManager = self.sceneManager camera = self.camera - self.naviMgr = navi.NaviManager.Get() + self.naviMgr = navi.NaviManager(self.renderWindow) self.shouldQuit = False # flag to allow the app to do a shutdown sceneManager.ambientLight = ogre.ColourValue(0.5, 0.5, 0.5) @@ -41,8 +41,8 @@ node.scale=(.2, .2, .2) ## Startup, create, and manage Navis - self.naviMgr.Startup(self.renderWindow) - +# # self.naviMgr.Startup(self.renderWindow) + self.naviMgr.createNavi("menubar", "local://menubar.html", navi.NaviPosition(navi.BottomCenter), 1024, 128, False) self.naviMgr.setNaviMask("menubar", "navimenu_bg.png") self.naviMgr.bind("menubar", "turnOn", self, "turnOn", ["name"] ) Added: trunk/python-ogre/demos/ogre/Demo_Water.py =================================================================== --- trunk/python-ogre/demos/ogre/Demo_Water.py (rev 0) +++ trunk/python-ogre/demos/ogre/Demo_Water.py 2007-10-06 10:45:04 UTC (rev 411) @@ -0,0 +1,619 @@ +# 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. +# ----------------------------------------------------------------------------- +# */ +# /* Static water simulation by eru +# * Started 29.05.2003, 20:54:37 +# */ + +#include "ExampleApplication.h" +import ogre.renderer.OGRE as Ogre +import ogre.io.OIS as OIS +import WaterMesh as WaterMesh +import math +import SampleFramework as sf +import random +import ctypes as ctypes + +# AnimationState* self.mAnimState + +## Mesh stuff +MESH_NAME ="WaterMesh" +ENTITY_NAME ="waterEntity" +MATERIAL_PREFIX ="Examples/Water" +MATERIAL_NAME ="Examples/Water0" +COMPLEXITY =64 ## watch out - number of polys is 2*ACCURACY*ACCURACY ! +PLANE_SIZE =3000.0 + +circles_MATERIAL ="Examples/Water/self.circles" + +## +## Note that this function makes use of CTypes and def ptr casting to access Ogre Library functions +## +def prepareCircleMaterial(): + global circles_MATERIAL + + storageclass = ctypes.c_byte * (256 * 256 * 4) + bmap=storageclass(1) # you just need to put some value in this to get it started... + ctypes.memset ( bmap, 127, 256 * 256 * 4 ) + + for b in range(16): + x0 = b % 4 + y0 = b >> 2 + radius = 4.0 + 1.4 * b + for x in range(64): + for y in range (64) : + dist = math.sqrt((x-32)*(x-32)+(y-32)*(y-32)) ## 0..ca.45 + dist = math.fabs(dist-radius-2) / 2.0 + dist = dist * 255 + if (dist>255): + dist=255 + colour = 255-dist + colour = int (((15-b))/15.0 * colour ) + + bmap[4*(256*(y+64*y0)+x+64*x0)+0]=colour + bmap[4*(256*(y+64*y0)+x+64*x0)+1]=colour + bmap[4*(256*(y+64*y0)+x+64*x0)+2]=colour + bmap[4*(256*(y+64*y0)+x+64*x0)+3]=colour + + ### Need to pass the address to MemoryDataStream + ## + imgstream = Ogre.MemoryDataStream(pMem=Ogre.CastVoidPtr(ctypes.addressof(bmap)), size = int(256 * 256 *4) ) + print dir (imgstream) + print imgstream.size() + Ogre.TextureManager.getSingleton().loadRawData(circles_MATERIAL, + Ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, + imgstream, 256, 256 , Ogre.PixelFormat.PF_A8R8G8B8 ) + + material = Ogre.MaterialManager.getSingleton().create( circles_MATERIAL, + Ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME) + texLayer = material.getTechnique(0).getPass(0).createTextureUnitState( circles_MATERIAL ) + texLayer.setTextureAddressingMode( Ogre.TextureUnitState.TAM_CLAMP ) + material.setSceneBlending( Ogre.SceneBlendType.SBT_ADD ) + material.setDepthWriteEnabled( False ) + material.load() + + + +# /* =========================================================================*/ +# /* WaterCircle class */ +# /* =========================================================================*/ +CIRCLE_SIZE = 500.0 +CIRCLE_TIME = 0.5 +class WaterCircle: + def __init_(self): + self.name = "" +# SceneNode *node +# MeshPtr mesh +# SubMesh *subMesh +# Entity *entity +# Real tm +# static bool first +# ## some buffers shared by all self.circles +# static HardwareVertexBufferSharedPtr posnormVertexBuffer +# static HardwareIndexBufferSharedPtr indexBuffer ## indices for 2 faces +# static HardwareVertexBufferSharedPtr *texcoordsVertexBuffers + +# float *texBufData + self.headNode = None + self.waterOverlay = None + self.particleSystem = None + self.particleEmitter = None + self.sceneMgr = None + + _prepareMesh() + + mesh = Ogre.MeshManager.getSingleton().createManual(name, + Ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME) + subMesh = mesh.createSubMesh() + subMesh.useSharedVertices=False + numVertices = 4 + first = True + + if (first) : ## first Circle, create some static common data: + first = False + + ## static buffer for position and normals + size = 2 * Ogre.VertexElement.getTypeSize(Ogre.VertexElementType.VET_FLOAT3) ## 6 * float + posnormVertexBuffer = \ + Ogre.HardwareBufferManager.getSingleton().createVertexBuffer( + size, ## size of one vertex data 6 * float + 4, ## number of vertices + Ogre.HardwareBuffer.HBU_STATIC_WRITE_ONLY, ## usage + False) ## no shadow buffer + posnormBufData = posnormVertexBuffer.lock(Ogre.HardwareBuffer.HBL_DISCARD) + + buff=[] + for i in range(numVertices): + buf.append(((i%2)-0.5)*CIRCLE_SIZE ) ## pos X + buf.append(0) ## pos Y + buf.append(((i/2)-0.5)*CIRCLE_SIZE ) ## pos Z + buf.append(0) ## normal X + buf.append(1) ## normal Y + buf.append(0) ## normal Z + Ogre.setFloat( posnormBufData , buff ) # write unsigned ints... + posnormVertexBuffer.unlock() + + ## static buffers for 16 sets of texture coordinates + texcoordsVertexBuffers = [] + for lvl in range (16): + texcoordsVertexBuffers.append( + Ogre.HardwareBufferManager.getSingleton().createVertexBuffer( + Ogre.VertexElement.getTypeSize(Ogre.VertexElementType.VET_FLOAT2), ## size of one vertex data + numVertices, ## number of vertices + Ogre.HardwareBuffer.HBU_STATIC_WRITE_ONLY, ## usage + False) ## no shadow buffer + ) + texcoordsBufData = texcoordsVertexBuffers[lvl].lock(Ogre.HardwareBuffer.HBL_DISCARD) + x0 = (lvl % 4) * 0.25 + y0 = (lvl / 4) * 0.25 + y0 = 0.75-y0 ## upside down + for i in range (4): + texcoordsBufData[i*2 + 0]= \ + x0 + 0.25 * (i%2) + texcoordsBufData[i*2 + 1]= \ + y0 + 0.25 * (i/2) + + texcoordsVertexBuffers[lvl].unlock() + + + ## Index buffer for 2 faces + faces[6] = (2,1,0, 2,3,1) + indexBuffer = \ + Ogre.HardwareBufferManager.getSingleton().createIndexBuffer( + Ogre.HardwareIndexBuffer.IT_16BIT, + 6, + Ogre.HardwareBuffer.HBU_STATIC_WRITE_ONLY) + indexBuffer.writeData(0, + indexBuffer.getSizeInBytes(), + faces, + True) ## true? + + + ## Initialize vertex data + subMesh.vertexData = Ogre.VertexData() + subMesh.vertexData.vertexStart = 0 + subMesh.vertexData.vertexCount = 4 + ## first, set vertex buffer bindings + vbind = subMesh.vertexData.vertexBufferBinding + vbind.setBinding(0, posnormVertexBuffer) + vbind.setBinding(1, texcoordsVertexBuffers[0]) + ## now, set vertex buffer declaration + vdecl = subMesh.vertexData.vertexDeclaration + vdecl.addElement(0, 0, Ogre.VET_FLOAT3, VOgre.ES_POSITION) + vdecl.addElement(0, 3*4, Ogre.VET_FLOAT3, Ogre.VES_NORMAL) + vdecl.addElement(1, 0, Ogre.VET_FLOAT2, Ogre.VES_TEXTURE_COORDINATES) + + ## Initialize index data + subMesh.indexData.indexBuffer = indexBuffer + subMesh.indexData.indexStart = 0 + subMesh.indexData.indexCount = 6 + + ## set mesh bounds + circleBounds(-CIRCLE_SIZE/2.0, 0, -CIRCLE_SIZE/2.0, + CIRCLE_SIZE/2.0, 0, CIRCLE_SIZE/2.0) + mesh._setBounds(circleBounds) + mesh.load() + mesh.touch() + + def setTextureLevel(): + subMesh.vertexData.vertexBufferBinding.setBinding(1, texcoordsVertexBuffers[lvl]) + + def WaterCircle( name, x, y): + + self.name = name + _prepareMesh() + node = self.sceneMgr.getRootSceneNode().createChild(name) + node.translate(x*(PLANE_SIZE/COMPLEXITY), 10, y*(PLANE_SIZE/COMPLEXITY)) + entity = self.sceneMgr.createEntity(name, name) + entity.setMaterialName(self.circles_MATERIAL) + node.attachObject(entity) + tm = 0 + lvl = 0 + setTextureLevel() + + def __del__(self, ): + Ogre.MeshManager.getSingleton().remove(mesh.getHandle()) + self.sceneMgr.destroyEntity(entity.getName()) + self.sceneMgr.getRootSceneNode().removeChildnode.getName() + + def animate(self, timeSinceLastFrame): + lastlvl = lvl + tm += timeSinceLastFrame + lvl = (int) ( (Real)(tm)/CIRCLE_TIME * 16 ) + if (lvl<16 and lvl!=lastlvl) : + setTextureLevel() + + + def clearStaticBuffers(self): + posnormVertexBuffer = Ogre.HardwareVertexBufferSharedPtr() + indexBuffer = Ogre.HardwareIndexBufferSharedPtr() + for i in range (16): + texcoordsVertexBuffers[i] = Ogre.HardwareVertexBufferSharedPtr() + + del texcoordsVertexBuffers + + +# bool WaterCircle.first = True +# HardwareVertexBufferSharedPtr WaterCircle.posnormVertexBuffer = +# HardwareVertexBufferSharedPtr() +# HardwareIndexBufferSharedPtr WaterCircle.indexBuffer = +# HardwareIndexBufferSharedPtr() +# HardwareVertexBufferSharedPtr* WaterCircle.texcoordsVertexBuffers = 0 + +# /* =========================================================================*/ +# /* WaterListener class */ +# /* =========================================================================*/ +## Event handler +class WaterListener(sf.FrameListener): + + def processcircles(self,timeSinceLastFrame): + + for i in self.circles : + self.circles[i].animate(timeSinceLastFrame) + +# # # do : +# # # found = False +# # # for it = self.circles : +# # # it != self.circles.end() +# # # ++it) { +# # # if ((*it).lvl>=16) {: +# # # delete (*it) +# # # self.circles.erase(it) +# # # found = True +# # # break + + +# # # while (found) + + + def processParticles(self): + global PLANE_SIZE, COMPLEXITY, RAIN_HEIGHT_RANDOM, RAIN_HEIGHT_CONSTANT + + ## Sorry this isn't currently supported by ogre - haven't exposed Ogre::ParticleIterator + return + + + pit = self.app.particleSystem._getIterator() + while not pit.end(): + particle = pit.getNext() + ppos = particle.position + if ppos.y<=0 and particle.timeToLive>0 : ## hits the water!: + ## delete particle + particle.timeToLive = 0.0 + ## push the water + x = ppos.x / PLANE_SIZE * COMPLEXITY + y = ppos.z / PLANE_SIZE * COMPLEXITY + h = random.random() % RAIN_HEIGHT_RANDOM + RAIN_HEIGHT_CONSTANT + if (x<1): + x=1 + if (x>COMPLEXITY-1): + x=COMPLEXITY-1 + if (y<1): + y=1 + if (y>COMPLEXITY-1): + y=COMPLEXITY-1 + self.WaterMesh.push(x,y,-h) + circle = WaterCircle( + "Circle#"+str(self.pindex), + x, y) + self.pindex+=1 + self.circles.push_back(circle) + + + + + ## Head animation */ + def animateHead(self, timeSinceLastFrame): + + ## sine track? :) + for i in range(4): + self.sines[i]+=self.adds[i]*timeSinceLastFrame + + tx = ((math.sin(self.sines[0]) + math.sin(self.sines[1])) / 4 + 0.5 ) * (COMPLEXITY-2) + 1 + ty = ((math.sin(self.sines[2]) + math.sin(self.sines[3])) / 4 + 0.5 ) * (COMPLEXITY-2) + 1 + self.WaterMesh.push(tx,ty, -self.headDepth) + step = PLANE_SIZE / COMPLEXITY + self.app.headNode.resetToInitialState() + 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) + self.oldPos = newPos + self.app.headNode.translate(newPos) + self.app.headNode.rotate(headRotation) + + + ## GUI updaters + def updateInfoParamC(self): + Ogre.OverlayManager.getSingleton().getOverlayElement("Example/Water/Param_C") \ + .setCaption("[1/2]Ripple speed: "+str(self.WaterMesh.PARAM_C)) + + def updateInfoParamD(self): + Ogre.OverlayManager.getSingleton().getOverlayElement("Example/Water/Param_D") \ + .setCaption("[3/4]Distance: "+str(self.WaterMesh.PARAM_D)) + + def updateInfoParamU(self): + Ogre.OverlayManager.getSingleton().getOverlayElement("Example/Water/Param_U") \ + .setCaption("[5/6]Viscosity: "+str(self.WaterMesh.PARAM_U)) + + def updateInfoParamT(self): + Ogre.OverlayManager.getSingleton().getOverlayElement("Example/Water/Param_T") \ + .setCaption("[7/8]Frame time: "+str(self.WaterMesh.PARAM_T)) + + def updateInfoNormals(self): + cap = "[N]Normals: " + if self.WaterMesh.useFakeNormals: + cap += "fake" + else: cap += "real" + Ogre.OverlayManager.getSingleton().getOverlayElement("Example/Water/Normals") \ + .setCaption(cap) + + def switchNormals(self): + self.WaterMesh.useFakeNormals = not self.WaterMesh.useFakeNormals + self.updateInfoNormals() + + def updateInfoHeadDepth(self): + Ogre.OverlayManager.getSingleton().getOverlayElement("Example/Water/Depth").setCaption("[U/J]Head depth: "+str(self.headDepth)) + + def updateInfoSkyBox(self): + cap = "[B]SkyBox: " + if self.skyBoxOn: + cap += "On" + else: cap += "Off" + Ogre.OverlayManager.getSingleton().getOverlayElement("Example/Water/SkyBox").setCaption(cap) + + def updateMaterial(self): + global MATERIAL_PREFIX + materialName = MATERIAL_PREFIX+str(self.materialNumber) + material = Ogre.MaterialManager.getSingleton().getByName(materialName) + if not material: + if(self.materialNumber): + self.materialNumber = 0 + self.updateMaterial() + return + else: + Ogre.OGRE_EXCEPT(Exception.ERR_INTERNAL_ERROR, + "Material "+materialName+"doesn't exist!", + "WaterListener.updateMaterial") + + self.waterEntity.setMaterialName(materialName) + Ogre.OverlayManager.getSingleton().getOverlayElement("Example/Water/Material").setCaption("[M]Material: "+materialName) + + + def switchMaterial(self): + self.materialNumber+=1 + self.updateMaterial() + + def switchSkyBox(self): + self.skyBoxOn = not self.skyBoxOn + self.app.sceneManager.setSkyBox(self.skyBoxOn, "Examples/SceneSkyBox2") + self.updateInfoSkyBox() + + + def __init__(self, renderWindow, camera, WaterMesh, waterEntity, app ): + + sf.FrameListener.__init__(self, renderWindow, camera) + self.app = app + self.camera = camera + self.WaterMesh = WaterMesh + self.waterEntity = waterEntity + self.materialNumber = 8 + self.timeoutDelay = 0.0 + self.headDepth = 2.0 + self.skyBoxOn = False + RAIN_HEIGHT_RANDOM = 5 + 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.pindex = 0 + self.headDepth =0.0 + self.circles = [] + + self.updateMaterial() + self.updateInfoParamC() + self.updateInfoParamD() + self.updateInfoParamU() + self.updateInfoParamT() + self.updateInfoNormals() + self.updateInfoHeadDepth() + self.updateInfoSkyBox() + + + def __del__ ( self ): + ## If when you finish the application is still raining there + ## are water self.circles that are still being processed + activecircles = self.circles.size () + + ## Kill the active water self.circles + for i in range ( activecircles ): + del (self.circles[i]) + + + def frameStarted(self, frameEvent): + result = sf.FrameListener.frameStarted(self,frameEvent) + evt = frameEvent + + if( result == False ): + ## check if we are exiting, if so, clear static HardwareBuffers to adef segfault + WaterCircle.clearStaticBuffers() + return False + + self.app.mAnimState.addTime(evt.timeSinceLastFrame) + + ## process keyboard events + changeSpeed = evt.timeSinceLastFrame + + ## adjust keyboard speed with SHIFT (increase) and CONTROL (decrease) + if (self.Keyboard.isKeyDown(OIS.KC_LSHIFT) or self.Keyboard.isKeyDown(OIS.KC_RSHIFT)): + changeSpeed *= 10.0 + + if (self.Keyboard.isKeyDown(OIS.KC_LCONTROL)): + changeSpeed /= 10.0 + + ## rain + self.processcircles(evt.timeSinceLastFrame) + if (self.Keyboard.isKeyDown(OIS.KC_SPACE)): + self.app.particleEmitter.setEmissionRate(20.0) + else: + self.app.particleEmitter.setEmissionRate(0.0) + + self.processParticles() + + ## adjust values (some macros for faster change + def ADJUST_RANGE(_value,_plus,_minus,_minVal,_maxVal,_change,_macro): + if (self.Keyboard.isKeyDown(_plus)): + _value+=_change + if (_value>=_maxVal): + _value = _maxVal + _macro + if (self.Keyboard.isKeyDown(_minus)): + _value-=_change + if (_value<=_minVal): + _value = _minVal + _macro + + + ADJUST_RANGE(self.headDepth, OIS.KC_U, OIS.KC_J, 0, 10, 0.5*changeSpeed, self.updateInfoHeadDepth()) + + ADJUST_RANGE(self.WaterMesh.PARAM_C, OIS.KC_2, OIS.KC_1, 0, 10, 0.1*changeSpeed, self.updateInfoParamC()) + + ADJUST_RANGE(self.WaterMesh.PARAM_D, OIS.KC_4, OIS.KC_3, 0.1, 10, 0.1*changeSpeed, self.updateInfoParamD()) + + ADJUST_RANGE(self.WaterMesh.PARAM_U, OIS.KC_6, OIS.KC_5, -2, 10, 0.1*changeSpeed, self.updateInfoParamU()) + + ADJUST_RANGE(self.WaterMesh.PARAM_T, OIS.KC_8, OIS.KC_7, 0, 10, 0.1*changeSpeed, self.updateInfoParamT()) + + self.timeoutDelay-=evt.timeSinceLastFrame + if (self.timeoutDelay<=0): + self.timeoutDelay = 0 + + def SWITCH_VALUE(_key,_timeDelay, _macro): + if (self.Keyboard.isKeyDown(_key) and self.timeoutDelay==0) : + self.timeoutDelay = _timeDelay + _macro + + SWITCH_VALUE(OIS.KC_N, 0.5, self.switchNormals()) + + SWITCH_VALUE(OIS.KC_M, 0.5, self.switchMaterial()) + + SWITCH_VALUE(OIS.KC_B, 0.5, self.switchSkyBox()) + + self.animateHead(evt.timeSinceLastFrame) + + self.WaterMesh.updateMesh(evt.timeSinceLastFrame) + + return True + + + +class WaterApplication(sf.Application,Ogre.RenderTargetListener): + +## Just override the mandatory create scene method + def _createScene(self): + global PLANE_SIZE, MESH_NAME, COMPLEXITY, ENTITY_NAME + print "\n\n\n***********" + sceneManager = self.sceneManager + camera = self.camera + ## Set ambient light + sceneManager.setAmbientLight(Ogre.ColourValue(0.75, 0.75, 0.75)) + + ## Create a light + l = sceneManager.createLight("MainLight") + ## Accept default settings: point light, white diffuse, just set position + l.setPosition(200,300,100) + +# ## Create water mesh and entity + self.WaterMesh = WaterMesh.WaterMesh(MESH_NAME, PLANE_SIZE, COMPLEXITY) + self.waterEntity = sceneManager.createEntity(ENTITY_NAME, MESH_NAME) + + ## self.waterEntity.setMaterialName(MATERIAL_NAME) + waterNode = sceneManager.getRootSceneNode().createChildSceneNode() +# waterNode.attachObject(self.waterEntity) + + ## Add a head, give it it's own node + self.headNode = waterNode.createChildSceneNode() + ent = sceneManager.createEntity("head", "ogrehead.mesh") + self.headNode.attachObject(ent) + + ## Make sure the camera track self node + ## self.camera.setAutoTracking(True, self.headNode) + + ## Create the camera node, set its position & attach camera + camNode = sceneManager.getRootSceneNode().createChildSceneNode() + camNode.translate(0, 500, PLANE_SIZE) + camNode.yaw(Ogre.Degree(-45)) + camNode.attachObject(self.camera) + + ## Create light node + lightNode = sceneManager.getRootSceneNode().createChildSceneNode() + lightNode.attachObject(l) + + ## set up spline animation of light node + anim = sceneManager.createAnimation("WaterLight", 20) + + ## create a random spline for light + track = anim.createNodeTrack(0, lightNode) + key = track.createNodeKeyFrame(0) + for ff in range (1,20): + key = track.createNodeKeyFrame(ff) + lpos = Ogre.Vector3( + random.random()%PLANE_SIZE , ##- PLANE_SIZE/2, + random.random()%300+100, + random.random()%PLANE_SIZE ##- PLANE_SIZE/2 + ) + key.setTranslate(lpos) + + key = track.createNodeKeyFrame(20) + + ## Create a new animation state to track self + self.mAnimState = sceneManager.createAnimationState("WaterLight") + self.mAnimState.setEnabled(True) + + ## Put in a bit of fog for the hell of it + ##sceneManager.setFog(FOG_EXP, ColourValue.White, 0.0002) + + ## show overlay + self.waterOverlay = Ogre.OverlayManager.getSingleton().getByName("Example/WaterOverlay") + self.waterOverlay.show() + + ## Let there be rain + self.particleSystem = sceneManager.createParticleSystem("rain", + "Examples/Water/Rain") + self.particleEmitter = self.particleSystem.getEmitter(0) + rNode = sceneManager.getRootSceneNode().createChildSceneNode() + rNode.translate(PLANE_SIZE/2.0, 3000, PLANE_SIZE/2.0) + rNode.attachObject(self.particleSystem) + ## Fast-forward the rain so it looks more natural + self.particleSystem.fastForward(20) + ## It can't be set in .particle file, and we need it ) +# static_cast<BillboardParticleRenderer*>(self.particleSystem.getRenderer()).setBillboardOrigin(BBO_BOTTOM_CENTER) + + prepareCircleMaterial() + print "\n\n\n***********" + + +# ## Create new frame listener + def _createFrameListener(self): + self.frameListener = WaterListener(self.renderWindow, self.camera, + self.WaterMesh, self.waterEntity, self) + self.root.addFrameListener(self.frameListener) + + + +if __name__ == '__main__': +# try: + application = WaterApplication() + application.go() +# except Ogre.Exception, e: +# print e + Added: trunk/python-ogre/demos/ogre/WaterMesh.py =================================================================== --- trunk/python-ogre/demos/ogre/WaterMesh.py (rev 0) +++ trunk/python-ogre/demos/ogre/WaterMesh.py 2007-10-06 10:45:04 UTC (rev 411) @@ -0,0 +1,341 @@ +# /* +# ----------------------------------------------------------------------------- +# 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. +# ----------------------------------------------------------------------------- +# */ + +import ctypes as ctypes +import math +import ogre.renderer.OGRE as Ogre +import random + +ANIMATIONS_PER_SECOND = 100.0 +class WaterMesh: + def __init__ ( self, meshName, planeSize, complexity ): + self.meshName = meshName + self.complexity = complexity + self.numFaces = 2 * complexity * complexity + self.numVertices = (complexity + 1) * (complexity + 1) + self.lastTimeStamp = 0 + self.lastAnimationTimeStamp = 0 + self.lastFrameTime = 0 + self.vNormals=[] + + ## initialize algorithm parameters + self.PARAM_C = 0.3 ## ripple speed + self.PARAM_D = 0.4 ## distance + self.PARAM_U = 0.05 ## viscosity + self.PARAM_T = 0.13 ## time + self.useFakeNormals = False + + ## allocate space for normal calculation + self.vNormals=[] + for x in range ( self.numVertices ): + self.vNormals.append(Ogre.Vector3() ) + + ## create mesh and submesh + mesh = Ogre.MeshManager.getSingleton().createManual(meshName, + Ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME) + subMesh = mesh.createSubMesh() + subMesh.useSharedVertices=False + + ## Vertex buffers + subMesh.vertexData = Ogre.VertexData() + subMesh.vertexData.vertexStart = 0 + subMesh.vertexData.vertexCount = self.numVertices + + vdecl = subMesh.vertexData.vertexDeclaration + vbind = subMesh.vertexData.vertexBufferBinding + + + vdecl.addElement(0, 0, Ogre.VertexElementType.VET_FLOAT3, Ogre.VertexElementSemantic.VES_POSITION) + vdecl.addElement(1, 0, Ogre.VertexElementType.VET_FLOAT3, Ogre.VertexElementSemantic.VES_NORMAL) + vdecl.addElement(2, 0, Ogre.VertexElementType.VET_FLOAT2, Ogre.VertexElementSemantic.VES_TEXTURE_COORDINATES) + + ## Prepare buffer for positions - todo: first attempt, slow + self.posVertexBuffer = \ + Ogre.HardwareBufferManager.getSingleton().createVertexBuffer( + 3 * ctypes.sizeof(ctypes.c_float), + self.numVertices, + Ogre.HardwareBuffer.HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE) + vbind.setBinding(0, self.posVertexBuffer) + + ## Prepare buffer for normals - write only + self.normVertexBuffer = \ + Ogre.HardwareBufferManager.getSingleton().createVertexBuffer( + 3*ctypes.sizeof(ctypes.c_float), + self.numVertices, + Ogre.HardwareBuffer.HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE) + vbind.setBinding(1, self.normVertexBuffer) + + ## Prepare texture coords buffer - static one + ## todo: optimize to write directly into buffer + storageclass = ctypes.c_float * (self.numVertices*2) + texcoordsBufData=storageclass(1.1) + + for y in range (complexity) : + for x in range(complexity) : + texcoordsBufData[2*(y*(complexity+1)+x)+0] = x / complexity + texcoordsBufData[2*(y*(complexity+1)+x)+1] = 1.0 - (y / (complexity)) + + + texcoordsVertexBuffer = \ + Ogre.HardwareBufferManager.getSingleton().createVertexBuffer( + 2*ctypes.sizeof(ctypes.c_float), + self.numVertices, + Ogre.HardwareBuffer.HBU_STATIC_WRITE_ONLY) + texcoordsVertexBuffer.writeData(0, + texcoordsVertexBuffer.getSizeInBytes(), + ctypes.addressof(texcoordsBufData), + True) ## true? + vbind.setBinding(2, texcoordsVertexBuffer) + + ## Prepare buffer for indices + self.indexBuffer = \ + Ogre.HardwareBufferManager.getSingleton().createIndexBuffer( + Ogre.HardwareIndexBuffer.IT_16BIT, + 3*self.numFaces, + Ogre.HardwareBuffer.HBU_STATIC, True) + + ## get the address of the self.indexBuffer + faceVertexIndices = self.indexBuffer.lock(0, self.numFaces*3*2, Ogre.HardwareBuffer.HBL_DISCARD) + faceVertexIndices = Ogre.CastInt ( faceVertexIndices ) + for y in range (complexity) : + for x in range (complexity ) : + twoface = faceVertexIndices + (y*complexity+x)*2*3 + p0 = y*(complexity+1) + x + p1 = y*(complexity+1) + x + 1 + p2 = (y+1)*(complexity+1) + x + p3 = (y+1)*(complexity+1) + x + 1 + ctypes.memset ( twoface + 0, p2, 1 ) + ctypes.memset ( twoface + 1, p1, 1 ) + ctypes.memset ( twoface + 2, p0, 1 ) + ctypes.memset ( twoface + 3, p2, 1 ) + ctypes.memset ( twoface + 4, p3, 1 ) + ctypes.memset ( twoface + 5, p1, 1 ) + self.indexBuffer.unlock() + ## Set index buffer for self submesh + subMesh.indexData.indexBuffer = self.indexBuffer + subMesh.indexData.indexStart = 0 + subMesh.indexData.indexCount = 3*self.numFaces + + # prepare vertex positions + # note - we use 3 vertex buffers, since algorighm uses two last phases + # to calculate the next one + storageclass2 = ctypes.c_float * (self.numVertices*3* 3 ) + self.vertexBuffers = storageclass2 (1.1) + + + ## Note that in the C++ code self.vertexBuffers is a float * array[3], whcih indexes into float*numverticies*3 + ## we have made a single array bige nough to cope + self.vertexIndexSize = self.numVertices*3 + + for b in range(3) : + for y in range(complexity) : + for x in range (complexity) : + numPoint = y*(complexity+1) + x +# # vertex = self.vertexBuffers[b] + 3.0*numPoint + VertexPos = (self.vertexIndexSize * b) + 3 * numPoint + self.vertexBuffers[VertexPos + 0] = x / (complexity * planeSize ) + self.vertexBuffers[VertexPos + 1] = 0 + self.vertexBuffers[VertexPos + 2] = y / (complexity * planeSize ) + + meshBounds = Ogre.AxisAlignedBox(0,0,0, planeSize,0, planeSize) + mesh._setBounds(meshBounds) + + self.currentBufNumber = 0 + self.posVertexBuffer.writeData(0, + self.posVertexBuffer.getSizeInBytes(), ## size + ctypes.addressof(self.vertexBuffers) + self.currentBufNumber*self.vertexIndexSize, ## source + True) ## discard? + + mesh.load() + mesh.touch() + + # ========================================================================= + def __del__ (self): + pass + + # =========================================================================== +# /** "pushes" a mesh at position [x,y]. Note, that x,y are float, hence +# * 4 vertices are actually pushed +# * @note +# * This should be replaced by push with 'radius' parameter to simulate +# * big objects falling into water +# */ + + def push( self, x, y, depth, absolute=False): + buf = self.vertexBuffers[self.currentBufNumber*self.vertexIndexSize]+1 + ## scale pressure according to time passed + depth = depth * self.lastFrameTime * ANIMATIONS_PER_SECOND + self._PREP(0,0) + self._PREP(0,1) + self._PREP(1,0) + self._PREP(1,1) + + def _PREP(self, addx,addy) : + return +# *vertex=buf+3*((int)(y+addy)*(complexity+1)+(int)(x+addx)) +# diffy = y - floor(y+addy) +# diffx = x - floor(x+addx) +# dist=sqrt(diffy*diffy + diffx*diffx) +# power = 1 - dist +# if (power<0): +# power = 0 +# if (absolute): +# *vertex = depth*power +# else: +# *vertex += depth*power + + def hat(self, _x,_y): + self.buf[3*(_y*(complexity+1)+(_x))] + + + # /* ========================================================================= */ + # gets height at given x and y, takes average value of the closes nodes */ + + def getHeight(self, x, y): + + self.buf = self.vertexBuffers[self.currentBufNumber*self.vertexIndexSize] + xa = floor(x) + xb = xa + 1 + ya = floor(y) + yb = ya + 1 + yaxavg = hat(xa,ya) * (1.0-fabs(xa-x)) + hat(xb,ya) * (1.0-fabs(xb-x)) + ybxavg = hat(xa,yb) * (1.0-fabs(xa-x)) + hat(xb,yb) * (1.0-fabs(xb-x)) + yavg = yaxavg * (1.0-fabs(ya-y)) + ybxavg * (1.0-fabs(yb-y)) + return yavg + +# /* ========================================================================= */ + def calculateFakeNormals(self): + return ## AJM + buf = self.currentBufNumber*self.vertexIndexSize + 1 + pNormals = self.normVertexBuffer.lock( + 0,self.normVertexBuffer.getSizeInBytes(), Ogre.HardwareBuffer.HBL_DISCARD) + for y in range (self.complexity) : +# # # nrow = pNormals + 3*y*(complexity+1) + row = buf + 3 * y * (self.complexity+1) + rowup = buf + 3*(y-1)*(self.complexity+1) + rowdown = buf + 3*(y+1)*(self.complexity+1) + for x in range (self.complexity) : + xdiff = row+ 3*x+3 - row +3*x-3 + ydiff = rowup + 3*x - rowdown+3*x-3 + norm = Ogre.Vector3(xdiff,30,ydiff) + norm.normalise() + buf.append( norm.x ) + buf.append( norm.y ) + buf.append( norm.z ) +# # # nrow[3*x+0] = norm.x +# # # nrow[3*x+1] = norm.y +# # # nrow[3*x+2] = norm.z + + Ogre.setUint16 ( pNormals, buf ) + self.normVertexBuffer.unlock() + +# /* ========================================================================= */ + def calculateNormals(self): + buf = self.vertexBuffers[self.currentBufNumber*self.vertexIndexSize] + 1 + ## zero normals + + for i in range(self.numVertices) : + self.vNormals.append( Ogre.Vector3().ZERO_Copy ) + return ## AJM + ## first, calculate normals for faces, add them to proper vertices + buf = self.vertexBuffers[self.currentBufNumber*self.vertexIndexSize] + vinds = self.indexBuffer.lock( + 0, self.indexBuffer.getSizeInBytes(), Ogre.HardwareBuffer.HBL_READ_ONLY) + pNormals = self.normVertexBuffer.lock( + 0, self.normVertexBuffer.getSizeInBytes(), Ogre.HardwareBuffer.HBL_DISCARD) + for i in range(self.numFaces) : + p0 = vinds[3*i] + p1 = vinds[3*i+1] + p2 = vinds[3*i+2] + v0=Ogre.Vector3 (buf[3*p0], buf[3*p0+1], buf[3*p0+2]) + v1 = Ogre.Vector3 (buf[3*p1], buf[3*p1+1], buf[3*p1+2]) + v3 = Ogre.Vector3 (buf[3*p2], buf[3*p2+1], buf[3*p2+2]) + diff1 = v2 - v1 + diff2 = v0 - v1 + fn = diff1.crossProduct(diff2) + self.vNormals[p0] += fn + self.vNormals[p1] += fn + self.vNormals[p2] += fn + + ## now normalize vertex normals + for y in (self.complexity) : + for x in (self.complexity) : + numPoint = y*(self.complexity+1) + x + n = self.vNormals[numPoint] + n.normalise() + normal = pNormals + 3*numPoint + normal[0]=n.x + normal[1]=n.y + normal[2]=n.z + + + self.indexBuffer.unlock() + self.normVertexBuffer.unlock() + +# /* ======================================================================== */ + def updateMesh(self, timeSinceLastFrame): + self.lastFrameTime = timeSinceLastFrame + self.lastTimeStamp += timeSinceLastFrame + + ## do rendering to get ANIMATIONS_PER_SECOND + while(self.lastAnimationTimeStamp <= self.lastTimeStamp): + + ## switch buffer numbers + self.currentBufNumber = (self.currentBufNumber + 1) % 3 + +# buf = self.vertexBuffers[self.currentBufNumber*self.vertexIndexSize] + 1 ## +1 for Y coordinate + + buf = self.currentBufNumber*self.vertexIndexSize + 1 + buf1 = (((self.currentBufNumber+2)%3) * self.vertexIndexSize) + 1 + buf2 = (((self.currentBufNumber+1)%3) * self.vertexIndexSize) + 1 + + # /* we use an algorithm from + # * http:##collective.valve-erc.com/index.php?go=water_simulation + # * The params could be dynamically changed every frame ofcourse + # */ + C = self.PARAM_C ## ripple speed + D = self.PARAM_D ## distance + U = self.PARAM_U ## viscosity + T = self.PARAM_T ## time + TERM1 = ( 4.0 - 8.0*C*C*T*T/(D*D) ) / (U*T+2) + TERM2 = ( U*T-2.0 ) / (U*T+2.0) + TERM3 = ( 2.0 * C*C*T*T/(D*D) ) / (U*T+2) + for y in range(self.complexity) : ## don't do anything with border values + row = buf + 3*y*(self.complexity+1) + row1 = buf1 + 3*y*(self.complexity+1) + row1up = buf1 + 3*(y-1)*(self.complexity+1) + row1down = buf1 + 3*(y+1)*(self.complexity+1) + row2 = buf2 + 3*y*(self.complexity+1) + for x in range (self.complexity) : + self.vertexBuffers[row+(3*x)] =\ + TERM1 * self.vertexBuffers[row1 + 3*x ] +\ + TERM2 * self.vertexBuffers[row2 + 3*x ] +\ + TERM3 * ( self.vertexBuffers[row1 + 3*x -3] +\ + self.vertexBuffers[row1 + 3*x +3] +\ + self.vertexBuffers[row1up + 3*x] +\ + self.vertexBuffers[row1down + 3*x] + ) + self.lastAnimationTimeStamp += (1.0 / ANIMATIONS_PER_SECOND) + + if (self.useFakeNormals): + self.calculateFakeNormals() + else : + self.calculateNormals() + + ## set vertex buffer + self.posVertexBuffer.writeData(0, + self.posVertexBuffer.getSizeInBytes(), ## size + ctypes.addressof (self.vertexBuffers) + self.currentBufNumber*self.vertexIndexSize, ## source + True) ## discard? + Modified: trunk/python-ogre/demos/plib/Demo_Client.py =================================================================== --- trunk/python-ogre/demos/plib/Demo_Client.py 2007-10-05 13:06:34 UTC (rev 410) +++ trunk/python-ogre/demos/plib/Demo_Client.py 2007-10-06 10:45:04 UTC (rev 411) @@ -2,20 +2,20 @@ import ctypes plib.netInit () + +sock = plib.netSocket () sock = plib.netSocket () -sock.open ( False ) +if not sock.open ( False ): + raise RuntimeError ("Unable to open a socket") sock.setBlocking ( False ) -sock.bind ( "127.0.0.1", 4444 ) +if sock.connect ( "127.0.0.1", 4444 ) == -1: + raise RuntimeError ("Unable to connect socket") + +count = 0 +print "Sending data." +while ( count < 10 ): + msg = "Hello :" + str ( count ) + ret = sock.send ( msg, 0 ) + count +=1 -maxlen = 8096 -storageclass = ctypes.c_char * (maxlen) -buffer_in=storageclass(" ") -ctypes.memset ( buffer_in, 0, maxlen ) # just showing how this can be done - - -while ( 1 ): - buffer_in = sock.recv( maxlen, 0 ) - if len(buffer_in) >= 0 : - print "Data in ("+str(len(buffer_in))+"):"+ buffer_in - sock.close () Modified: trunk/python-ogre/demos/plib/Demo_Server.py =================================================================== --- trunk/python-ogre/demos/plib/Demo_Server.py 2007-10-05 13:06:34 UTC (rev 410) +++ trunk/python-ogre/demos/plib/Demo_Server.py 2007-10-06 10:45:04 UTC (rev 411) @@ -1,26 +1,19 @@ import ogre.addons.plib as plib -import ctypes plib.netInit () - -sock = plib.netSocket () -sock.open ( False ) +sock = plib.netSocket () +if not sock.open ( False ): + raise RuntimeError ("Unable to open a socket") sock.setBlocking ( False ) -sock.connect ( "127.0.0.1", 4444 ) +if sock.bind ( "127.0.0.1", 4444 ) == -1: + raise RuntimeError ("Unable to bind socket") +print "Waiting to receive data." +while ( True ): + # use recv to recive the input data as a list of invidual bytes -- suitable for binary data etc + # use recv_str to receive the input data as a string + # specify maxlen if you need to receive greater than 2048 ie recv(4096) + buffer_in = sock.recv_str( ) + if len(buffer_in) >0 : + print "Received:", buffer_in -count = 0 -maxlen = 256 -storageclass = ctypes.c_char * (maxlen) -buffer_out=storageclass(" ") -ctypes.memset ( buffer_out, 39, maxlen ) # just showing how this can be done - - -while ( count < 10 ): - msg = "Hello :" + str ( count ) - print msg - buffer_out[:len(msg)] = msg - ret = sock.send ( ctypes.addressof(buffer_out), len(msg), 0 ) - print ret - count +=1 - sock.close () Modified: trunk/python-ogre/demos/qgui/Demo_QuickGUI01.py =================================================================== --- trunk/python-ogre/demos/qgui/Demo_QuickGUI01.py 2007-10-05 13:06:34 UTC (rev 410) +++ trunk/python-ogre/demos/qgui/Demo_QuickGUI01.py 2007-10-06 10:45:04 UTC (rev 411) @@ -65,13 +65,13 @@ if( self.mGUIManager != None ) : self.mGUIManager .injectTime(evt.timeSinceLastFrame) - if(self.mouseOverTB != None): - self.mouseOverTB.setText(self.mGUIManager.getMouseOverWidget().getInstanceName()) - - if(self.debugTB == None): - self.debugTB = self.mGUIManager.getActiveSheet().getTextBox("DebugTextBox") - else: - self.debugTB.setText(self.mGUIManager.getDebugString()) +# if(self.mouseOverTB != None): +# self.mouseOverTB.setText(self.mGUIManager.getMouseOverWidget().getInstanceName()) +# +# if(self.debugTB == None): +# self.debugTB = self.mGUIManager.getActiveSheet().getTextBox("DebugTextBox") +# else: +# self.debugTB.setText(self.mGUIManager.getDebugString()) return sf.FrameListener.frameStarted(self,evt) @@ -214,7 +214,8 @@ self.mSheet.setDefaultFont ("acmesa.12") ## Main Menu and it's MenuLists - topMenu = self.mSheet.createMenu(Rect(0,0,800,25)) + topMenu = self.mSheet.createMenu() + topMenu.setDimensions(Rect(0,0,800,25)) fileList = topMenu.addMenuList("File",0,60) exitListItem = fileList.addListItem("Exit") @@ -261,19 +262,29 @@ toggleRenderStats.addEventHandler(gui.Widget.EVENT_MOUSE_BUTTON_UP,self.MakeCallback(self.evtHndlr_toggleDebugDisplay)) ## Logos - logoImage = self.mSheet.createImage(Rect(16,42,240,180)) - logoLabel = self.mSheet.createLabel(Rect(60,240,120,30)) + logoImage = self.mSheet.createImage() + logoImage.setDimensions(Rect(16,42,240,180)) + + logoLabel = self.mSheet.createLabel() + logoLabel.setDimensions(Rect(60,240,120,30)) logoLabel.getText().setCaption("Click Me >") - self.imageToggleButton = self.mSheet.createNStateButton("HotDang",Rect(180,240,40,30)) + self.imageToggleButton = self.mSheet.createNStateButton() + self.imageToggleButton.setDimensions(Rect(180,240,40,30)) self.imageToggleButton.addState("OgreLogo","qgui.checked.png") self.imageToggleButton.addState("SimpleGUILogo","qgui.unchecked.png") ## RTT Example Use - rttImage = self.mSheet.createImage(Rect(600,42,160,90),"self.rttTex") + rttImage = self.mSheet.createImage() + rttImage.setDimensions(Rect(600,42,160,90)) + rttImage.setTexture("RttTex") # rttImage.setBorderWidth(10) - ninjaWindow = self.mSheet.createWindow(Rect(600,150,160,120)) + + ninjaWindow = self.mSheet.createWindow() ninjaWindow.hideTitlebar() - animToggleButton = ninjaWindow.createNStateButton(Rect(8,7.5,144,30)) + ninjaWindow.setDimensions(Rect(600,150,160,120)) + + animToggleButton = ninjaWindow.createNStateButton() + animToggleButton.setDimensions(Rect(8,7.5,144,30)) ## populate NStateButton with States - robot animations casi = self.robot.getAllAnimationStates().getAnimationStateIterator() state = 0 @@ -290,62 +301,94 @@ # animToggleButton.addEventHandler(gui.Widget.EVENT_MOUSE_BUTTON_UP,self.MakeCallback(self.evtHndlr_changeAnimations) ) animToggleButton.addOnStateChangedEventHandler(self.MakeCallback(self.evtHndlr_changeAnimations) ) - hurtButton = ninjaWindow.createButton(Rect(8,45,144,30)) + hurtButton = ninjaWindow.createButton() + hurtButton.setDimensions(Rect(8,45,144,30)) hurtButton.getText().setCaption("Hurt") hurtButton.addEventHandler(gui.Widget.EVENT_MOUSE_BUTTON_UP,self.MakeCallback(self.evtHndlr_hurt) ) - healButton = ninjaWindow.createButton(Rect(8,82.5,144,30)) + + healButton = ninjaWindow.createButton() + healButton.setDimensions(Rect(8,82.5,144,30)) healButton.getText().setCaption("Heal") healButton.addEventHandler(gui.Widget.EVENT_MOUSE_BUTTON_UP,self.MakeCallback(self.evtHndlr_heal) ) ## TrackBar Setup - tb1 = self.mSheet.createHorizontalTrackBar(Rect(320,60,160,24)) + tb1 = self.mSheet.createHorizontalTrackBar() + tb1.setDimensions(Rect(320,60,160,24)) tb1.setNumRegions(3) - #tb1.setTickPosition(4) # Does not work! 3 regions -> ticks: 0/1/2/3 - tb2 = self.mSheet.createVerticalTrackBar(Rect(320,90,24,120)) + #tb1.setTickPosition(4) # Does not work! 3 regions . ticks: 0/1/2/3 + tb2 = self.mSheet.createVerticalTrackBar() + tb2.setDimensions(Rect(320,90,24,120)) tb2.setNumTicks(10) #tb2.setTickPosition(9) ## Progress Bar Setup - self.lifeBar = self.mSheet.createProgressBar(Rect(320,330,160,18)) + self.lifeBar = self.mSheet.createProgressBar() + self.lifeBar.setDimensions(Rect(320,330,160,18)) self.lifeBar.setInitialPixelOffset(0) - HPLabel = self.mSheet.createLabel(Rect(320,315,56,42),"") + HPLabel = self.mSheet.createLabel() + HPLabel.setDimensions(Rect(320,315,56,42)) + HPLabel.setTexture("") HPLabel.getText().setCaption("HP") HPLabel.appearOverWidget(self.lifeBar) - self.lifeBarValueLabel = self.mSheet.createLabel(Rect(440,315,56,42),"") + + self.lifeBarValueLabel = self.mSheet.createLabel() + self.lifeBarValueLabel.setDimensions(Rect(440,315,56,42)) + self.lifeBarValueLabel.setTexture("") self.lifeBarValueLabel.getText().setCaption("100") self.lifeBarValueLabel.appearOverWidget(self.lifeBar) ## Mouse Over window - mouseOverWindow = self.mSheet.createWindow("Mouse Over Window",Rect(480,420,320,60)) + mouseOverWindow = self.mSheet.createWindow() + mouseOverWindow.setDimensions(Rect(480,420,320,60)) mouseOverWindow.hideTitlebar() - mouseOverLabel = mouseOverWindow.createLabel(Rect(0,0,320,30)) + + mouseOverLabel = mouseOverWindow.createLabel() + mouseOverLabel.setDimensions(Rect(0,0,320,30)) mouseOverLabel.getText().setCaption("Mouse Over Widget:") s = mouseOverLabel.getSize() - self.mouseOverTB = mouseOverWindow.createTextBox(Rect(0,s.height,320,30)) + self.mouseOverTB = mouseOverWindow.createTextBox() + self.mouseOverTB.setDimensions(Rect(0,s.height,320,30)) self.mouseOverTB.setReadOnly(True) ## Login Portion - self.mSheet.createLabel(Rect(16,360,160,30)).getText().setCaption("User Name:") - self.mSheet.createLabel(Rect(16,390,160,30)).getText().setCaption("Password:") - self.usernameTB = self.mSheet.createTextBox(Rect(180,360,200,30)) + l=self.mSheet.createLabel() + l.setDimensions(Rect(16,360,160,30)) + l.getText().setCaption("User Name:") + + l=self.mSheet.createLabel() + l.setDimensions(Rect(16,390,160,30)) + l.getText().setCaption("Password:") + + self.usernameTB = self.mSheet.createTextBox() + self.usernameTB.setDimensions(Rect(180,360,200,30)) self.usernameTB.setText("\tThe quick brown fox jumped over the red fence.") - self.passwordTB = self.mSheet.createTextBox(Rect(180,390,200,30)) + self.passwordTB = self.mSheet.createTextBox() + self.passwordTB.setDimensions(Rect(180,390,200,30)) self.passwordTB.maskUserInput(ord('*')) - loginButton = self.mSheet.createButton(Rect(100,420,200,42)) + + loginButton = self.mSheet.createButton() + loginButton.setDimensions(Rect(100,420,200,42)) loginButton.getText().setCaption("Login") loginButton.addEventHandler(gui.Widget.EVENT_MOUSE_BUTTON_UP,self.MakeCallback(self.evtHndlr_login) ) - self.loginResultLabel = self.mSheet.createLabel(Rect(0.0,462,480,30), "") - + self.loginResultLabel = self.mSheet.createLabel() + self.loginResultLabel.setDimensions(Rect(0.0,462,480,30)) + self.loginResultLabel.setTexture("") + ## Set Text Window - self.stWindow = self.mSheet.createWindow(Rect(560,270,240,120)) + self.stWindow = self.mSheet.createWindow() + self.stWindow.setDimensions(Rect(560,270,240,120)) self.stWindow.hide() self.stWindow.getTitleBar().setCaption("Set Text Color:") closeButton = self.stWindow.getTitleBar().getCloseButton() - self.stWindow.createLabel(Rect(40,30,60,30)).getText().setCaption("Color:") - colorCB = self.stWindow.createComboBox(Rect(125,30,100,30)) + l=self.stWindow.createLabel() + l.setDimensions(Rect(40,30,60,30)) + l.getText().setCaption("Color:") + + colorCB = self.stWindow.createComboBox() + colorCB.setDimensions(Rect(125,30,100,30)) colorCBdropList = colorCB.getDropDownList() colorCBdropList.setNumberOfVisibleItems(6) @@ -357,21 +400,26 @@ colorCBdropList.addListItem("Yellow") colorCBdropList.addListItem("Purple") colorCBdropList.addListItem("Brown") - setTextButton = self.stWindow.createButton(Rect(80,70,50,30)) + + setTextButton = self.stWindow.createButton() + setTextButton.setDimensions(Rect(80,70,50,30)) setTextButton.setCaption("Apply") setTextButton.addEventHandler(gui.Widget.EVENT_MOUSE_BUTTON_UP,self.MakeCallback(self.evtHndlr_setTextColor) ) - # colorCB->clearList(); + # colorCB.clearList() # colorCBdropList.removeListItem(2) - testButton = self.mSheet.createButton("TestButton1",Rect(1200,800,100,50)) + testButton = self.mSheet.createButton() + testButton.setDimensions(Rect(1200,800,100,50)) testButton.getText().setCaption("TEST") testButton.addEventHandler(gui.Widget.EVENT_MOUSE_BUTTON_UP,self.MakeCallback(self.test)) - testButton2 = self.stWindow.createButton("TestButton2",Rect(500,190,100,50)) + testButton2 = self.stWindow.createButton() + testButton2.setDimensions(Rect(500,190,100,50)) testButton2.getText().setCaption("TEST") testButton2.addEventHandler(gui.Widget.EVENT_MOUSE_BUTTON_UP,self.MakeCallback(self.test)) - self.mSheet.createTextBox("DebugTextBox",Rect(480,480,320,30)) + tb=self.mSheet.createTextBox() + tb.setDimensions(Rect(480,480,320,30)) def test(self, args): Modified: trunk/python-ogre/environment.py =================================================================== --- trunk/python-ogre/environment.py 2007-10-05 13:06:34 UTC (rev 410) +++ trunk/python-ogre/environment.py 2007-10-06 10:45:04 UTC (rev 411) @@ -329,8 +329,22 @@ CheckIncludes = ['boost/python.hpp', 'Opcode.h'] active=True +class caelum: + version="0.2.1" + parent="ogre/addons" + cflags = "" + include_dirs = [ Config.PATH_Boost, + Config.PATH_INCLUDE_Ogre, + Config.PATH_caelum + ] + lib_dirs = [Config.PATH_LIB_Boost, + Config.PATH_LIB_Ogre_OgreMain + ] + CheckIncludes=[] + libs=[ Config.LIB_Boost, 'OgreMain' ] + ModuleName="caelum" + active=True - class newton: version= "1.0" active=False @@ -385,7 +399,7 @@ ] CheckIncludes=[] libs=[ Config.LIB_Boost, 'OgreMain' ] - ModuleName="quickgui" + ModuleName="QuickGUI" active=True class navi: @@ -562,11 +576,17 @@ if os.name =='nt': CCFLAGS = ' -DOgreAL_Export="" -DWIN32 -DNDEBUG -D_LIB -D_WIN32 -D_WINDOWS -DVORBIS_IEEE_FLOAT32 -D_USE_NON_INTEL_COMPILER ' - libs=[Config.LIB_Boost, 'OgreMain', - 'ogg_static', - 'alut', - 'vorbis_static','vorbisfile_static','vorbisenc_static', - 'OpenAL32', 'EFX-Util'] ## 'OgreAL' -- going to compile OgreAL ourselves + libs=[Config.LIB_Boost, 'OgreMain', + 'ogg_static', + 'alut', + 'vorbis_static','vorbisfile_static','vorbisenc_static', + 'OpenAL32', 'EFX-Util'] ## 'OgreAL' -- going to compile OgreAL ourselves + else: + libs=[Config.LIB_Boost, 'OgreMain', + 'ogg', + 'alut', + 'vorbis','vorbisfile','vorbisenc', + 'openal'] ## 'OgreAL' -- going to compile OgreAL ourselves ModuleName = 'OgreAL' CheckIncludes = ['OgreAL.h'] active=True @@ -730,6 +750,7 @@ , 'ogrebulletd' : ogrebulletd , 'ogreforests' : ogreforests , 'et' : et + , 'caelum' : caelum } # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |