Skip to content

Instantly share code, notes, and snippets.

@cortical-iv
Last active January 31, 2019 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cortical-iv/62b7d0825cf8f5206708a895bec1d675 to your computer and use it in GitHub Desktop.
Save cortical-iv/62b7d0825cf8f5206708a895bec1d675 to your computer and use it in GitHub Desktop.
Tex wrapping mode workspace
"""
Trying to get repeated texture
"""
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker
import numpy as np
#Create texture
texSize = 64
texture = 210*np.ones((texSize, texSize), dtype = np.uint8)
texture[4:10,:] = 50
texture[:, 30:35] = 255
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
#CREATE TEXTURES
self.texture = Texture("snow")
self.texture.setup2dTexture(texSize, texSize, Texture.T_unsigned_byte, Texture.F_luminance)
self.texture.setRamImage(texture)
#Set wrap mode
self.texture.setWrapU(Texture.WM_repeat) #mirror, repeat, clamp
self.texture.setWrapV(Texture.WM_repeat)
#CREATE CARDS/SCENEGRAPH
cm = CardMaker('card1')
cm.setUvRange((0,0,), (10,5))
self.card1 = self.aspect2d.attachNewNode(cm.generate())
self.card1.setTexture(self.texture)
app = MyApp()
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment