This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from direct.showbase.ShowBase import ShowBase | |
from panda3d.core import Texture, CardMaker, TextureStage, TransparencyAttrib | |
import numpy as np | |
from direct.gui.OnscreenText import OnscreenText | |
from direct.task import Task | |
#Create sin | |
texSize = 512 | |
frequency = 8 | |
def sin3d(X, freq = 1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def get_dpi(screen_num = 0): | |
"""Calculate the dpi of a given monitor, sensitive to | |
scaling factors they have set.""" | |
from PyQt5.QtWidgets import QApplication | |
app = QApplication(sys.argv) | |
screen = app.screens()[screen_num] | |
dpi = screen.physicalDotsPerInch() | |
app.quit() | |
return dpi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from direct.showbase.ShowBase import ShowBase | |
from panda3d.core import Texture, CardMaker, TextureStage | |
def rgb_texture_byte(texture_size = 512, rgb = (0, 0, 0)): | |
""" Return Could just set card's bg color but this has other uses.""" | |
if not (all([x >= 0 for x in rgb]) and all([x <= 255 for x in rgb])): | |
raise ValueError("rgb values must lie in [0,255]") | |
rgb_texture = np.zeros((texture_size, texture_size, 3), dtype = np.uint8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Want to combine (CMModulate) two texture stages from two cards, | |
but am just seeing the top card's texture stage. | |
""" | |
import numpy as np | |
from scipy import signal #for grating (square wave) | |
from direct.showbase.ShowBase import ShowBase | |
from panda3d.core import Texture, CardMaker, TextureStage | |
from panda3d.core import TransparencyAttrib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Goal: rotate mask so it stays centered on the X. | |
What happens: it rotates and shifts, as if the origin of the coordinate system is | |
not at the center of the window. | |
""" | |
import numpy as np | |
from direct.showbase.ShowBase import ShowBase | |
from panda3d.core import Texture, CardMaker, TextureStage | |
from direct.gui.OnscreenText import OnscreenText #for binocular stim | |
import matplotlib.pyplot as plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from direct.showbase.ShowBase import ShowBase | |
from panda3d.core import Texture, CardMaker, TextureStage, TransformState | |
from direct.gui.OnscreenText import OnscreenText #for binocular stim | |
import matplotlib.pyplot as plt | |
class CombineStages(ShowBase): | |
"""Trying to draw a mask stage over a stim stage and combine them (modulate) | |
Note debug variable is 1 to print vars, 2 to print vars and display mask from | |
matplotlib""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Why is this mask not rotating around the X? It is rotating in a circle around the origin. | |
Problem with trs_transform(), where trs = translate, rotate, scale. | |
With mask_position = (0, 0) it works fine. Once we move from the origin...yikes. | |
""" | |
import numpy as np | |
from direct.showbase.ShowBase import ShowBase | |
from panda3d.core import Texture, CardMaker, TextureStage, TransformState | |
from direct.gui.OnscreenText import OnscreenText #for binocular stim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from direct.showbase.ShowBase import ShowBase | |
from panda3d.core import Texture, CardMaker, TextureStage | |
from direct.task import Task | |
def make_circle_tex(texture_size = 512, circle_center = (0, 0), circle_radius = 50): | |
x = np.linspace(-texture_size/2, texture_size/2, texture_size) | |
y = np.linspace(-texture_size/2, texture_size/2, texture_size) | |
X, Y = np.meshgrid(x, y) | |
circle_texture = np.zeros((texture_size, texture_size), dtype = np.uint8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
texture that scales over time. | |
Thanks go rdb for help | |
""" | |
import numpy as np | |
from direct.showbase.ShowBase import ShowBase | |
from panda3d.core import Texture, CardMaker, TextureStage | |
from direct.task import Task | |
from panda3d.core import TransformState |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
cube of concentric sinusoids: one shown in matplotlib, then in panda3d statically, then | |
in task manager in sequence when they turn dark. | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from direct.showbase.ShowBase import ShowBase | |
from panda3d.core import Texture, CardMaker, TextureStage | |
from direct.task import Task | |
from direct.showbase import ShowBaseGlobal #global vars defined by p3d |