/usr/share/pyshared/soya/spc_material.py is in python-soya 0.15~rc1-10.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | # -*- indent-tabs-mode: t -*-
# Soya 3D
# Copyright (C) 2005 Jean-Baptiste LAMY -- jiba@tuxfamily.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import math
import soya, soya.opengl as opengl
class MovingMaterial(soya.PythonMainLoopingMaterial):
def __init__(self, texture = None, dtex_x = 0.0, dtex_y = 0.0, tex_x0 = 0.0, tex_y0 = 0.0):
soya.PythonMainLoopingMaterial.__init__(self, texture)
self.dtex_x = dtex_x
self.dtex_y = dtex_y
self._tex_x = tex_x0
self._tex_y = tex_y0
def advance_time(self, proportion):
self._tex_x += proportion * self.dtex_x
self._tex_y += proportion * self.dtex_y
def activated(self):
opengl.glMatrixMode(opengl.GL_TEXTURE)
opengl.glLoadIdentity() # Needed, because activated() may be called several time without inactivated being called
opengl.glTranslatef(self._tex_x, self._tex_y, 0.0)
opengl.glMatrixMode(opengl.GL_MODELVIEW)
def inactivated(self):
opengl.glMatrixMode(opengl.GL_TEXTURE)
opengl.glLoadIdentity()
opengl.glMatrixMode(opengl.GL_MODELVIEW)
class RotatingMaterial(soya.PythonMainLoopingMaterial):
def __init__(self, texture = None, amplitude = 0.2, speed = 0.1):
soya.PythonMainLoopingMaterial.__init__(self, texture)
self.amplitude = amplitude
self.speed = speed
self._angle = 0.0
def advance_time(self, proportion):
self._angle += proportion * self.speed
def activated(self):
opengl.glMatrixMode(opengl.GL_TEXTURE)
opengl.glLoadIdentity() # Needed, because activated() may be called several time without inactivated being called
opengl.glTranslatef(self.amplitude * math.cos(self._angle), self.amplitude * math.sin(self._angle), 0.0)
opengl.glMatrixMode(opengl.GL_MODELVIEW)
def inactivated(self):
opengl.glMatrixMode(opengl.GL_TEXTURE)
opengl.glLoadIdentity()
opengl.glMatrixMode(opengl.GL_MODELVIEW)
class ZoomingMaterial(soya.PythonMainLoopingMaterial):
def __init__(self, texture = None, speed = 0.1, amplitude = 0.1):
soya.PythonMainLoopingMaterial.__init__(self, texture)
self.angle = 0.0
self.speed = speed
self.amplitude = amplitude
def advance_time(self, proportion):
self.angle += proportion * self.speed
def activated(self):
f1 = self.amplitude * (math.cos(self.angle) + 1.0)
f2 = 1.0 - 2.0 * f1
opengl.glMatrixMode(opengl.GL_TEXTURE)
opengl.glLoadIdentity() # Needed, because activated() may be called several time without inactivated being called
opengl.glTranslatef(f1, f1, 0.0)
opengl.glScalef(f2, f2, 1.0)
opengl.glMatrixMode(opengl.GL_MODELVIEW)
def inactivated(self):
opengl.glMatrixMode(opengl.GL_TEXTURE)
opengl.glLoadIdentity()
opengl.glMatrixMode(opengl.GL_MODELVIEW)
|