Created
October 26, 2017 09:54
-
-
Save apleonhardt/7dc628a5183a199932354add4d061e28 to your computer and use it in GitHub Desktop.
Panda3D/Cubemapping VR
This file contains hidden or 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
<CoordinateSystem> { Z-up } | |
<Comment> { "Egg laid by Chicken for Blender, version R85" } | |
<Material> Material { | |
<Scalar> diffr {0.800000011921} | |
<Scalar> diffg {0.800000011921} | |
<Scalar> diffb {0.800000011921} | |
<Scalar> specr {0.25} | |
<Scalar> specg {0.25} | |
<Scalar> specb {0.25} | |
<Scalar> shininess {12.5} | |
} | |
<Group> Cube { | |
<VertexPool> Cube { | |
<Vertex> 0 { | |
1.0 0.999999940395 -1.0 | |
<UV> { | |
0.000000 0.000000 | |
<Tangent> { 0.707107 -0.707107 0.000000 } | |
<Binormal> { 0.707107 0.707107 0.000000 } | |
} | |
} | |
<Vertex> 1 { | |
1.0 -1.0 -1.0 | |
<UV> { | |
0.000000 -1.000000 | |
<Tangent> { 1.000000 0.000000 0.000000 } | |
<Binormal> { -0.000000 1.000000 -0.000000 } | |
} | |
} | |
<Vertex> 2 { | |
-1.00000011921 -0.999999821186 -1.0 | |
<UV> { | |
-1.000000 -1.000000 | |
<Tangent> { 1.000000 0.000000 0.000000 } | |
<Binormal> { -0.000000 1.000000 -0.000000 } | |
} | |
} | |
<Vertex> 3 { | |
-0.999999642372 1.00000035763 -1.0 | |
<UV> { | |
-1.000000 0.000000 | |
<Tangent> { 1.000000 0.000000 0.000000 } | |
<Binormal> { -0.000000 1.000000 -0.000000 } | |
} | |
} | |
<Vertex> 4 { | |
1.00000047684 0.999999463558 1.0 | |
<UV> { | |
0.000000 1.000000 | |
<Tangent> { -0.894427 -0.447213 0.000000 } | |
<Binormal> { -0.447213 0.894427 0.000000 } | |
} | |
} | |
<Vertex> 5 { | |
-0.999999940395 1.0 1.0 | |
<UV> { | |
-1.000000 1.000000 | |
<Tangent> { -1.000000 0.000000 -0.000000 } | |
<Binormal> { 0.000000 1.000000 -0.000000 } | |
} | |
} | |
<Vertex> 6 { | |
-1.00000035763 -0.999999642372 1.0 | |
<UV> { | |
-1.000000 0.000000 | |
<Tangent> { -1.000000 0.000000 0.000000 } | |
<Binormal> { 0.000000 1.000000 -0.000000 } | |
} | |
} | |
<Vertex> 7 { | |
0.999999344349 -1.00000059605 1.0 | |
<UV> { | |
-0.000000 -0.000000 | |
<Tangent> { -1.000000 0.000000 0.000000 } | |
<Binormal> { 0.000000 1.000000 -0.000000 } | |
} | |
} | |
<Vertex> 8 { | |
1.0 0.999999940395 -1.0 | |
<UV> { | |
0.000000 0.000000 | |
<Tangent> { 0.707107 -0.707107 0.000000 } | |
<Binormal> { -0.000000 -0.000000 0.707107 } | |
} | |
} | |
<Vertex> 9 { | |
1.00000047684 0.999999463558 1.0 | |
<UV> { | |
-0.000000 1.000000 | |
<Tangent> { -0.894427 -0.447213 0.000000 } | |
<Binormal> { -0.000000 0.000000 0.447214 } | |
} | |
} | |
<Vertex> 10 { | |
0.999999344349 -1.00000059605 1.0 | |
<UV> { | |
-1.000000 1.000000 | |
<Tangent> { -0.000000 -1.000000 0.000000 } | |
<Binormal> { -0.000000 0.000000 1.000000 } | |
} | |
} | |
<Vertex> 11 { | |
1.0 -1.0 -1.0 | |
<UV> { | |
-1.000000 0.000000 | |
<Tangent> { 0.000000 -1.000000 -0.000000 } | |
<Binormal> { -0.000000 -0.000000 1.000000 } | |
} | |
} | |
<Vertex> 12 { | |
1.0 -1.0 -1.0 | |
<UV> { | |
0.000000 0.000000 | |
<Tangent> { -1.000000 0.000000 0.000000 } | |
<Binormal> { -0.000000 -0.000000 1.000000 } | |
} | |
} | |
<Vertex> 13 { | |
0.999999344349 -1.00000059605 1.0 | |
<UV> { | |
-0.000000 1.000000 | |
<Tangent> { -1.000000 0.000000 0.000000 } | |
<Binormal> { -0.000000 -0.000000 1.000000 } | |
} | |
} | |
<Vertex> 14 { | |
-1.00000035763 -0.999999642372 1.0 | |
<UV> { | |
-1.000000 1.000000 | |
<Tangent> { -1.000000 0.000000 0.000000 } | |
<Binormal> { -0.000000 -0.000000 1.000000 } | |
} | |
} | |
<Vertex> 15 { | |
-1.00000011921 -0.999999821186 -1.0 | |
<UV> { | |
-1.000000 0.000000 | |
<Tangent> { -1.000000 0.000000 -0.000000 } | |
<Binormal> { -0.000000 -0.000000 1.000000 } | |
} | |
} | |
<Vertex> 16 { | |
-1.00000011921 -0.999999821186 -1.0 | |
<UV> { | |
0.000000 0.000000 | |
<Tangent> { 0.000000 1.000000 0.000000 } | |
<Binormal> { -0.000000 0.000000 1.000000 } | |
} | |
} | |
<Vertex> 17 { | |
-1.00000035763 -0.999999642372 1.0 | |
<UV> { | |
0.000000 1.000000 | |
<Tangent> { 0.000000 1.000000 0.000000 } | |
<Binormal> { -0.000000 0.000000 1.000000 } | |
} | |
} | |
<Vertex> 18 { | |
-0.999999940395 1.0 1.0 | |
<UV> { | |
1.000000 1.000000 | |
<Tangent> { 0.000000 1.000000 0.000000 } | |
<Binormal> { -0.000000 0.000000 1.000000 } | |
} | |
} | |
<Vertex> 19 { | |
-0.999999642372 1.00000035763 -1.0 | |
<UV> { | |
1.000000 0.000000 | |
<Tangent> { 0.000000 1.000000 -0.000000 } | |
<Binormal> { -0.000000 0.000000 1.000000 } | |
} | |
} | |
<Vertex> 20 { | |
1.00000047684 0.999999463558 1.0 | |
<UV> { | |
0.000000 0.000000 | |
<Tangent> { 1.000000 -0.000000 0.000000 } | |
<Binormal> { -0.000000 -0.000000 1.000000 } | |
} | |
} | |
<Vertex> 21 { | |
1.0 0.999999940395 -1.0 | |
<UV> { | |
0.000000 -1.000000 | |
<Tangent> { 1.000000 -0.000000 0.000000 } | |
<Binormal> { -0.000000 -0.000000 1.000000 } | |
} | |
} | |
<Vertex> 22 { | |
-0.999999642372 1.00000035763 -1.0 | |
<UV> { | |
-1.000000 -1.000000 | |
<Tangent> { 1.000000 -0.000000 0.000000 } | |
<Binormal> { -0.000000 -0.000000 1.000000 } | |
} | |
} | |
<Vertex> 23 { | |
-0.999999940395 1.0 1.0 | |
<UV> { | |
-1.000000 0.000000 | |
<Tangent> { 1.000000 -0.000000 0.000000 } | |
<Binormal> { -0.000000 -0.000000 1.000000 } | |
} | |
} | |
} | |
<Polygon> { | |
<MRef> { Material } | |
<Normal> { 0.000000 0.000000 -1.000000 | |
} | |
<VertexRef> { 0 1 2 3 <Ref> { Cube } } | |
} | |
<Polygon> { | |
<MRef> { Material } | |
<Normal> { 0.000000 -0.000000 1.000000 | |
} | |
<VertexRef> { 4 5 6 7 <Ref> { Cube } } | |
} | |
<Polygon> { | |
<MRef> { Material } | |
<Normal> { 1.000000 -0.000000 0.000000 | |
} | |
<VertexRef> { 8 9 10 11 <Ref> { Cube } } | |
} | |
<Polygon> { | |
<MRef> { Material } | |
<Normal> { -0.000000 -1.000000 -0.000000 | |
} | |
<VertexRef> { 12 13 14 15 <Ref> { Cube } } | |
} | |
<Polygon> { | |
<MRef> { Material } | |
<Normal> { -1.000000 0.000000 -0.000000 | |
} | |
<VertexRef> { 16 17 18 19 <Ref> { Cube } } | |
} | |
<Polygon> { | |
<MRef> { Material } | |
<Normal> { 0.000000 1.000000 0.000000 | |
} | |
<VertexRef> { 20 21 22 23 <Ref> { Cube } } | |
} | |
} |
This file contains hidden or 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 * | |
import numpy as np | |
class MyApp(ShowBase): | |
def __init__(self): | |
ShowBase.__init__(self) | |
self.environment = loader.loadModel('environment') | |
self.environment.reparentTo(self.render) | |
self.environment.setZ(-2) | |
self.environment.setScale(*[0.1]*3) | |
# Set up environment: | |
self.screen = loader.loadModel('cube') | |
self.screen.reparentTo(self.render) | |
self.screen.setScale(1.0, 0.0000001, 1.0) | |
self.screen.setPos(0.0, -2, 0.0) | |
self.panda = loader.loadModel('panda') | |
self.panda.reparentTo(self.render) | |
self.panda.setScale(*[0.05]*3) | |
self.teapot = loader.loadModel('teapot') | |
self.teapot.reparentTo(self.render) | |
self.teapot.setScale(*[0.1]*3) | |
self.teapot.setPos(0, -1, 0) | |
self.teapot2 = loader.loadModel('teapot') | |
self.teapot2.reparentTo(self.render) | |
self.teapot2.setScale(*[0.1]*3) | |
self.teapot2.setPos(0, -5, 0) | |
# Cubemapping: | |
self.rig = NodePath('rig') | |
buffer = base.win.makeCubeMap('env', 1024, self.rig) | |
self.rig.reparentTo(self.render) | |
for child in self.rig.getChildren(): | |
child.node().setCameraMask(BitMask32.bit(1)) | |
self.screen.hide(BitMask32.bit(1)) | |
self.screen.setTexGen(TextureStage.getDefault(), TexGenAttrib.MWorldPosition) | |
self.screen.setTexture(buffer.getTexture()) | |
self.screen.setTexProjector(TextureStage.getDefault(), self.screen, self.rig) | |
taskMgr.add(self.loop, "Bla") | |
def loop(self, task): | |
# Animate: | |
t = task.time | |
xpos = 0.8 * np.sin(2 * np.pi * 0.5 * t) | |
ypos = 0.0 * np.sin(2 * np.pi * 0.5 * t) | |
zpos = 0.8 * np.cos(2 * np.pi * 0.5 * t) | |
spos = 0.0 * np.sin(2 * np.pi * 0.5 * t) - 3.0 | |
self.panda.setPos(xpos, 1, zpos) | |
self.rig.setPos(xpos, 1, zpos) | |
self.screen.setPos(0, spos, 0) | |
# self.camera.setPos(xpos, 1, zpos) | |
# self.camera.setHpr(180, 0, 0) | |
self.camera.setPos(6, 7, 2) | |
self.camera.lookAt(self.screen) | |
return task.cont | |
app = MyApp() | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment