#!/usr/bin/env python # Copyright (C) 2002-2003 Gideon May (gideon@computer.org) # # Permission to copy, use, sell and distribute this software is granted # provided this copyright notice appears in all copies. # Permission to modify the code and to distribute modified code is granted # provided this copyright notice appears in all copies, and a notice # that the code was modified is included with the copyright notice. # # This software is provided "as is" without express or implied warranty, # and with no claim as to its suitability for any purpose. # -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield # # This application is open source and may be redistributed and/or modified # freely and without restriction, both in commericial and non commericial applications, # as long as this copyright notice is maintained. # # This application is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # import sys import math from PyOSG import * # include the call which creates the shadowed subgraph. from CreateShadowedScene import createShadowedScene # for the grid data.. from terrain_coords import vertex def createAnimationPath(center, radius, looptime): # set up the animation path animationPath = osg.AnimationPath() animationPath.setLoopMode(osg.AnimationPath.LOOP) numSamples = 40 yaw = 0.0 yaw_delta = 2.0*osg.PI/float(numSamples-1.0) roll = osg.inDegrees(30.0) time=0.0 time_delta = looptime/float(numSamples) for i in range(numSamples): position = center + osg.Vec3(math.sin(yaw)*radius,math.cos(yaw)*radius,0.0) rotation = osg.Quat(roll,osg.Vec3(0.0,1.0,0.0))*osg.Quat(-(yaw+osg.inDegrees(90.0)),osg.Vec3(0.0,0.0,1.0)) animationPath.insert(time,osg.AnimationPath.ControlPoint(position,rotation)) yaw += yaw_delta time += time_delta return animationPath def createBase( center, radius): geode = osg.Geode() # set up the texture of the base. stateset = osg.StateSet() image = osgDB.readImageFile("Images/lz.rgb") if image: texture = osg.Texture2D() texture.setImage(image) stateset.setTextureAttributeAndModes(0,texture,osg.StateAttribute.ON) geode.setStateSet( stateset ) grid = osg.HeightField() grid.allocate(38,39) grid.setOrigin(center+osg.Vec3(-radius,-radius,0.0)) grid.setXInterval(radius*2.0/float(38-1)) grid.setYInterval(radius*2.0/float(39-1)) minHeight = 1.0e38 maxHeight = -1.0e38 for r in range(39): for c in range(38): h = vertex[r+c*39][2] if (h>maxHeight): maxHeight=h if (h