Skip to content

Commit

Permalink
Release 1.2.0
Browse files Browse the repository at this point in the history
Merge pull request #31 from papagiannakis/develop
  • Loading branch information
kamarianakis authored Sep 11, 2023
2 parents d6d16d5 + a443478 commit 74b698f
Show file tree
Hide file tree
Showing 397 changed files with 506,956 additions and 1,056 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,5 @@ dmypy.json
imgui.ini
.DS_Store
data/GeometricShapes
*.off
*.pt
2 changes: 1 addition & 1 deletion Elements/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# 1) we don't load dependencies by storing it in __init__.py
# 2) we can import it in setup.py for the same reason
# 3) we can import it into your module
__version__ = '1.0.0'
__version__ = '1.2.0'
10 changes: 10 additions & 0 deletions Elements/definitions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os

ROOT_DIR = os.path.dirname(os.path.abspath(__file__))

MODEL_DIR = os.path.join(ROOT_DIR, "files", "models")
TEXTURE_DIR = os.path.join(ROOT_DIR, "files", "textures")
SCENES_DIR = os.path.join(ROOT_DIR, "files", "scenes")
SCV_DIR = os.path.join(ROOT_DIR, "files", "scv")
ATLAS_DIR = os.path.join(ROOT_DIR, "files", "atlas_files")
PICKLES_DIR = os.path.join(ROOT_DIR, "files", "pickles")
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

while running:
gWindow.display()
running = gWindow.event_input_process(running)
running = gWindow.event_input_process()
gWindow.display_post()
gWindow.shutdown()
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
running = True
while running:
gGUI.display()
running = gGUI.event_input_process(running)
running = gGUI.event_input_process()
gGUI.display_post()
gGUI.shutdown()
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

import Elements.pyECSS.utilities as util
import Elements.pyECSS.math_utilities as util
from Elements.pyECSS.Entity import Entity
from Elements.pyECSS.Component import RenderMesh
from Elements.pyGLV.GL.Scene import Scene
Expand All @@ -9,6 +9,8 @@
from Elements.pyGLV.GL.VertexArray import VertexArray


winWidth = 1024
winHeight = 768

scene = Scene()

Expand Down Expand Up @@ -99,14 +101,14 @@

running = True
# MAIN RENDERING LOOP
scene.init(imgui=False, windowWidth = 1024, windowHeight = 768, windowTitle = "A Cube Scene via ECSS")
scene.init(imgui=False, windowWidth = winWidth, windowHeight = winHeight, windowTitle = "A Cube Scene via ECSS")

# pre-pass scenegraph to initialise all GL context dependent geometry, shader classes
# needs an active GL context
scene.world.traverse_visit(initUpdate, scene.world.root)

while running:
running = scene.render(running)
running = scene.render()
scene.world.traverse_visit(renderUpdate, scene.world.root)
scene.render_post()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import numpy as np

import Elements.pyECSS.utilities as util
import Elements.pyECSS.math_utilities as util
from Elements.pyECSS.Entity import Entity
from Elements.pyECSS.Component import BasicTransform, RenderMesh
from Elements.pyECSS.System import TransformSystem
from Elements.pyECSS.Component import BasicTransform, Camera, RenderMesh
from Elements.pyECSS.System import TransformSystem, CameraSystem
from Elements.pyGLV.GL.Scene import Scene
from Elements.pyGLV.GUI.Viewer import RenderGLStateSystem
from Elements.pyGLV.GUI.Viewer import RenderGLStateSystem, ImGUIecssDecorator

from Elements.pyGLV.GL.Shader import InitGLShaderSystem, Shader, ShaderGLDecorator, RenderGLShaderSystem
from Elements.pyGLV.GL.VertexArray import VertexArray

from Elements.utils.terrain import generateTerrain

from OpenGL.GL import GL_LINES

winWidth = 1024
winHeight = 768

scene = Scene()

Expand All @@ -21,10 +25,18 @@
scene.world.addEntityChild(rootEntity, entityCam1)
trans1 = scene.world.addComponent(entityCam1, BasicTransform(name="trans1", trs=util.identity()))

eye = util.vec(1, 0.54, 1.0)
target = util.vec(0.02, 0.14, 0.217)
up = util.vec(0.0, 1.0, 0.0)
view = util.lookat(eye, target, up)
projMat = util.perspective(50.0, 1.0, 1.0, 10.0)
m = np.linalg.inv(projMat @ view)

entityCam2 = scene.world.createEntity(Entity(name="entityCam2"))
scene.world.addEntityChild(entityCam1, entityCam2)
trans2 = scene.world.addComponent(entityCam2, BasicTransform(name="trans2", trs=util.identity()))
# orthoCam = scene.world.addComponent(entityCam2, Camera(util.ortho(-100.0, 100.0, -100.0, 100.0, 1.0, 100.0), "orthoCam","Camera","500"))
orthoCam = scene.world.addComponent(entityCam2, Camera(m, "orthoCam","Camera","500"))

node4 = scene.world.createEntity(Entity(name="node4"))
scene.world.addEntityChild(rootEntity, node4)
Expand Down Expand Up @@ -103,7 +115,7 @@

# Systems
transUpdate = scene.world.createSystem(TransformSystem("transUpdate", "TransformSystem", "001"))
# camUpdate = scene.world.createSystem(CameraSystem("camUpdate", "CameraUpdate", "200"))
camUpdate = scene.world.createSystem(CameraSystem("camUpdate", "CameraUpdate", "200"))
renderUpdate = scene.world.createSystem(RenderGLShaderSystem())
initUpdate = scene.world.createSystem(InitGLShaderSystem())

Expand All @@ -119,7 +131,7 @@


# Generate terrain
from Elements.pyGLV.utils.terrain import generateTerrain

vertexTerrain, indexTerrain, colorTerrain= generateTerrain(size=4,N=20)
# Add terrain
terrain = scene.world.createEntity(Entity(name="terrain"))
Expand Down Expand Up @@ -152,7 +164,7 @@
# MAIN RENDERING LOOP

running = True
scene.init(imgui=True, windowWidth = 1024, windowHeight = 768, windowTitle = "Elements: A Working Event Manager", openGLversion = 4)
scene.init(imgui=True, windowWidth = winWidth, windowHeight = winHeight, windowTitle = "Elements: A Working Event Manager", customImGUIdecorator = ImGUIecssDecorator, openGLversion = 4)

# pre-pass scenegraph to initialise all GL context dependent geometry, shader classes
# needs an active GL context
Expand Down Expand Up @@ -198,8 +210,11 @@
# model_terrain_axes = util.translate(0.0,0.0,0.0) ## COMPLETELY OVERRIDE OBJECT's TRS

while running:
running = scene.render(running)
running = scene.render()
scene.world.traverse_visit(renderUpdate, scene.world.root)
scene.world.traverse_visit_pre_camera(camUpdate, orthoCam)
scene.world.traverse_visit(camUpdate, scene.world.root)

view = gWindow._myCamera # updates view via the imgui
mvp_cube = projMat @ view @ model_cube
mvp_terrain_axes = projMat @ view @ model_terrain_axes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import numpy as np

import Elements.pyECSS.utilities as util
import Elements.pyECSS.math_utilities as util
from Elements.pyECSS.Entity import Entity
from Elements.pyECSS.Component import BasicTransform, Camera, RenderMesh
from Elements.pyECSS.System import TransformSystem, CameraSystem
Expand All @@ -15,9 +15,9 @@
from OpenGL.GL import GL_LINES
import OpenGL.GL as gl

import Elements.pyGLV.utils.normals as norm
from Elements.pyGLV.utils.terrain import generateTerrain
from Elements.pyGLV.utils.obj_to_mesh import obj_to_mesh
import Elements.utils.normals as norm
from Elements.utils.terrain import generateTerrain
from Elements.utils.obj_to_mesh import obj_to_mesh


#Light
Expand All @@ -31,6 +31,8 @@
Mshininess = 0.4
Mcolor = util.vec(0.8, 0.0, 0.8)

winWidth = 1200
winHeight = 800

scene = Scene()

Expand Down Expand Up @@ -182,7 +184,7 @@
# MAIN RENDERING LOOP

running = True
scene.init(imgui=True, windowWidth = 1200, windowHeight = 800, windowTitle = "Elements: Let There Be Light", openGLversion = 4, customImGUIdecorator = ImGUIecssDecorator)
scene.init(imgui=True, windowWidth = winWidth, windowHeight = winHeight, windowTitle = "Elements: Let There Be Light", openGLversion = 4, customImGUIdecorator = ImGUIecssDecorator)

# pre-pass scenegraph to initialise all GL context dependent geometry, shader classes
# needs an active GL context
Expand All @@ -209,7 +211,7 @@
view = util.lookat(eye, target, up)
# projMat = util.ortho(-10.0, 10.0, -10.0, 10.0, -1.0, 10.0)
# projMat = util.perspective(90.0, 1.33, 0.1, 100)
projMat = util.perspective(50.0, 1200/800, 0.01, 100.0)
projMat = util.perspective(50.0, winWidth/winHeight, 0.01, 100.0)

gWindow._myCamera = view # otherwise, an imgui slider must be moved to properly update

Expand All @@ -219,7 +221,7 @@


while running:
running = scene.render(running)
running = scene.render()
scene.world.traverse_visit(renderUpdate, scene.world.root)
scene.world.traverse_visit_pre_camera(camUpdate, orthoCam)
scene.world.traverse_visit(camUpdate, scene.world.root)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import numpy as np

import Elements.pyECSS.utilities as util
import Elements.pyECSS.math_utilities as util
from Elements.pyECSS.Entity import Entity
from Elements.pyECSS.Component import BasicTransform, Camera, RenderMesh
from Elements.pyECSS.System import TransformSystem, CameraSystem
Expand All @@ -11,13 +11,14 @@

from Elements.pyGLV.GL.Shader import InitGLShaderSystem, Shader, ShaderGLDecorator, RenderGLShaderSystem
from Elements.pyGLV.GL.VertexArray import VertexArray
from Elements.definitions import MODEL_DIR

from OpenGL.GL import GL_LINES
import OpenGL.GL as gl

import Elements.pyGLV.utils.normals as norm
from Elements.pyGLV.utils.terrain import generateTerrain
from Elements.pyGLV.utils.obj_to_mesh import obj_to_mesh
import Elements.utils.normals as norm
from Elements.utils.terrain import generateTerrain
from Elements.utils.obj_to_mesh import obj_to_mesh


#Light
Expand All @@ -30,7 +31,8 @@
#Material
Mshininess = 0.4
Mcolor = util.vec(0.8, 0.0, 0.8)

winWidth = 1200
winHeight = 800

scene = Scene()

Expand Down Expand Up @@ -108,12 +110,11 @@


## object load
dirname = os.path.dirname(__file__)

# NOTICE THAT OBJECTS WITH UVs are currently NOT SUPPORTED
# obj_to_import = os.path.join(dirname, "models", "teapot.obj")
obj_to_import = os.path.join(dirname, "models", "cow.obj")
# obj_to_import = os.path.join(dirname, "models", "teddy.obj")
obj_to_import = os.path.join(MODEL_DIR, "teapot.obj")
# obj_to_import = os.path.join(models_dirname, "cow.obj")
# obj_to_import = os.path.join(models_dirname, "teddy.obj")

obj_color = [168/255, 168/255 , 210/255, 1.0]
vert , ind, col = obj_to_mesh(obj_to_import, color=obj_color)
Expand Down Expand Up @@ -163,7 +164,7 @@
# MAIN RENDERING LOOP

running = True
scene.init(imgui=True, windowWidth = 1200, windowHeight = 800, windowTitle = "Elements: Tea anyone?", openGLversion = 4, customImGUIdecorator = ImGUIecssDecorator)
scene.init(imgui=True, windowWidth = winWidth, windowHeight = winHeight, windowTitle = "Elements: Tea anyone?", openGLversion = 4)

# pre-pass scenegraph to initialise all GL context dependent geometry, shader classes
# needs an active GL context
Expand All @@ -190,7 +191,7 @@
view = util.lookat(eye, target, up)
# projMat = util.ortho(-10.0, 10.0, -10.0, 10.0, -1.0, 10.0)
# projMat = util.perspective(90.0, 1.33, 0.1, 100)
projMat = util.perspective(50.0, 1200/800, 0.01, 100.0)
projMat = util.perspective(50.0, winWidth/winHeight, 0.01, 100.0)

gWindow._myCamera = view # otherwise, an imgui slider must be moved to properly update

Expand All @@ -200,19 +201,19 @@


while running:
running = scene.render(running)
running = scene.render()
scene.world.traverse_visit(renderUpdate, scene.world.root)
scene.world.traverse_visit_pre_camera(camUpdate, orthoCam)
scene.world.traverse_visit(camUpdate, scene.world.root)
view = gWindow._myCamera # updates view via the imgui
# mvp_cube = projMat @ view @ model_cube
mvp_cube = projMat @ view @ trans4.trs
#mvp_cube = projMat @ view @ model_cube
mvp_object = projMat @ view @ trans4.trs
mvp_terrain = projMat @ view @ terrain_trans.trs
mvp_axes = projMat @ view @ axes_trans.trs
axes_shader.setUniformVariable(key='modelViewProj', value=mvp_axes, mat4=True)
terrain_shader.setUniformVariable(key='modelViewProj', value=mvp_terrain, mat4=True)

shaderDec4.setUniformVariable(key='modelViewProj', value=mvp_cube, mat4=True)
shaderDec4.setUniformVariable(key='modelViewProj', value=mvp_object, mat4=True)
shaderDec4.setUniformVariable(key='model',value=model_cube,mat4=True)
shaderDec4.setUniformVariable(key='ambientColor',value=Lambientcolor,float3=True)
shaderDec4.setUniformVariable(key='ambientStr',value=Lambientstr,float1=True)
Expand Down
Loading

0 comments on commit 74b698f

Please sign in to comment.