|
1 | | -from direct.interval.LerpInterval import LerpPosInterval |
2 | | -from panda3d.core import loadPrcFile, loadPrcFileData, LPoint3f, PointLight, Spotlight, PerspectiveLens |
3 | | -from direct.showbase.ShowBase import ShowBase, PTAFloat, AmbientLight, DirectionalLight, Shader, Texture, TextureStage, \ |
4 | | - SamplerState, FrameBufferProperties, WindowProperties, GraphicsPipe, GraphicsOutput, NodePath |
| 1 | +from panda3d.core import loadPrcFile, loadPrcFileData |
| 2 | +from direct.showbase.ShowBase import ShowBase |
5 | 3 |
|
6 | 4 | from Blobtory.Scripts.Pipeline.WindowCreator import WindowCreator |
| 5 | +from Blobtory.Scripts.game.SceneBuilder import SceneBuilder |
7 | 6 |
|
8 | 7 | # Description: |
9 | 8 | # This is the main program, and should thus be kept clean, |
|
14 | 13 | # |
15 | 14 | # Copyright (c) 2020 Daniel Kierkegaard Andersen. All rights reserved. |
16 | 15 | # https://github.com/Daxode/ComplexSoftwareProject |
17 | | -from Blobtory.Scripts.planet_former.PlanetGenerator import PlanetGenerator |
18 | 16 |
|
19 | 17 |
|
20 | 18 | class Main(ShowBase): |
21 | 19 | def __init__(self): |
22 | 20 | super().__init__() |
23 | 21 | self.winCreator = WindowCreator(self, enableRP=False, isFullscreen=False) |
24 | | - |
25 | | - self.planetGen: PlanetGenerator = PlanetGenerator(self.winCreator, 128, 500) |
26 | | - self.planetGen.cubeformer.mouseTime.setData(PTAFloat([10, 0, 0, 1])) |
27 | | - self.accept("a", self.planetGen.RegenPlanet) |
28 | | - |
29 | | - sphere = self.loader.loadModel("assets/models/icosphere") |
30 | | - sphere.reparentTo(self.render) |
31 | | - myShader: Shader = Shader.load(Shader.SL_GLSL, |
32 | | - vertex="assets/shaders/defaults/default.vert", |
33 | | - fragment="assets/shaders/defaults/default.frag") |
34 | | - #sphere.setShader(myShader, 1) |
35 | | - sphere.setScale(100) |
36 | | - sphere.setPos((0,50,600)) |
37 | | - |
38 | | - myToonLightTex = self.winCreator.base.loader.loadTexture( |
39 | | - "assets/textures/ramps/rampToonLight.png") |
40 | | - myToonLightTex.setWrapU(Texture.WM_clamp) |
41 | | - myToonLightTex.setWrapV(Texture.WM_clamp) |
42 | | - myToonLightTex.setMagfilter(SamplerState.FT_nearest) |
43 | | - myToonLightTex.setMinfilter(SamplerState.FT_nearest) |
44 | | - |
45 | | - stageToonLight = TextureStage("ToonLight") |
46 | | - stageToonLight.setSort(1) |
47 | | - sphere.setTexture(stageToonLight, myToonLightTex) |
48 | | - |
49 | | - # winprops = WindowProperties(size=(512, 512)) |
50 | | - # props = FrameBufferProperties() |
51 | | - # props.setRgbColor(1) |
52 | | - # props.setAlphaBits(1) |
53 | | - # props.setDepthBits(1) |
54 | | - # LBuffer = self.graphicsEngine.makeOutput( |
55 | | - # self.pipe, "offscreen buffer", -2, |
56 | | - # props, winprops, |
57 | | - # GraphicsPipe.BFRefuseWindow, |
58 | | - # self.win.getGsg(), self.win) |
59 | | - # |
60 | | - # Ldepthmap = Texture() |
61 | | - # LBuffer.addRenderTexture(Ldepthmap, GraphicsOutput.RTMBindOrCopy, |
62 | | - # GraphicsOutput.RTPDepthStencil) |
63 | | - |
64 | | - self.accept("v", self.bufferViewer.toggleEnable) |
65 | | - |
66 | | - alight = AmbientLight('alight') |
67 | | - alight.setColor((0.1, 0.1, 0.1, 1)) |
68 | | - alnp = self.render.attachNewNode(alight) |
69 | | - self.render.setLight(alnp) |
70 | | - |
71 | | - sun = DirectionalLight('TheSun') |
72 | | - sun.setShadowCaster(True, 2048, 2048) |
73 | | - |
74 | | - #sun.show_frustum() |
75 | | - sun.set_color((1, 1, 1, 1)) |
76 | | - sunNodePath = self.render.attachNewNode(sun) |
77 | | - sunNodePath.setPos(0, 200, 600) |
78 | | - sunNodePath.lookAt(0,0,0) |
79 | | - self.render.setLight(sunNodePath) |
80 | | - |
81 | | - size=512 |
82 | | - bmin, bmax = LPoint3f(-size,0, -size), LPoint3f(size, 10*size,size) |
83 | | - print(bmin,bmax) |
84 | | - lens = sun.get_lens(0) |
85 | | - lens.set_film_offset((bmin.xz + bmax.xz) * 0.5) |
86 | | - lens.set_film_size(bmax.xz - bmin.xz) |
87 | | - lens.set_near_far(bmin.y, bmax.y) |
88 | | - |
89 | | - # i = LerpPosInterval(sphere, 2, (0,-100,600),(0,100,600)) |
90 | | - # i.loop() |
91 | | - |
92 | | - dlight2 = DirectionalLight('my dlight2') |
93 | | - dlight2.setColor((0.05, 0.05, 0.05, 1)) |
94 | | - dlnp2 = self.render.attachNewNode(dlight2) |
95 | | - dlnp2.setPos(0, -200, -600) |
96 | | - dlnp2.lookAt(0, 0, 0) |
97 | | - self.render.setLight(dlnp2) |
| 22 | + self.scene: SceneBuilder = SceneBuilder(self.winCreator) |
98 | 23 |
|
99 | 24 |
|
100 | 25 | loadPrcFileData('', 'framebuffer-multisample 0') |
|
0 commit comments