Skip to content

Commit

Permalink
Merge pull request #56 from papagiannakis/develop
Browse files Browse the repository at this point in the history
Release 1.3.0
  • Loading branch information
kamarianakis authored Nov 13, 2023
2 parents 7b8c140 + a79bbf2 commit f9c0f93
Show file tree
Hide file tree
Showing 48 changed files with 2,084 additions and 784 deletions.
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.2.1'
__version__ = '1.3.0'
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from Elements.pyGLV.GUI.Viewer import SDL2Window, ImGUIDecorator

from Elements.utils.helper_function import displayGUI_text
from Elements.utils.Shortcuts import displayGUI_text
example_description = "This is a simple empty scene with ImGUI enabled. Feel free to add your own widgets!"


Expand Down
4 changes: 2 additions & 2 deletions Elements/examples/1.Introductory/example_3_cube_lookAt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from Elements.pyGLV.GL.Shader import InitGLShaderSystem, Shader, ShaderGLDecorator, RenderGLShaderSystem
from Elements.pyGLV.GL.VertexArray import VertexArray

from Elements.utils.helper_function import displayGUI_text
from Elements.utils.Shortcuts import displayGUI_text
example_description = \
"This is a scene with some simple geometry, i.e., a colored cube. \n\
The cube and axes are rendered with a simple shader. \n\
The cube is rendered via the simplest vertex and fragment shader. \n\
You cannot move the camera through the GUI. Hit ESC OR Close the window to quit."

winWidth = 1024
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@

from OpenGL.GL import GL_LINES

from Elements.utils.helper_function import displayGUI_text
from Elements.utils.Shortcuts import displayGUI_text
example_description = \
"This is a scene with a cube, a terrain and axes. \n\
The cube and axes are rendered with a simple shader. \n\
You move the camera through the GUI or the camera. Hit ESC OR Close the window to quit."
that allow camera movement too, via the Elements GUI. \n\n\
An ECSS Graph shows the Entities and Components of the \n\
scene, in read only way, i.e., you cannot manipulate \n\
any information via the ECSS Graph GUI. \n\n\
You can move the camera through the Elements GUI \n\
or the mouse. Hit ESC OR Close the window to quit."

winWidth = 1024
winHeight = 768
Expand Down
2 changes: 1 addition & 1 deletion Elements/examples/1.Introductory/example_5_lights_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from Elements.utils.terrain import generateTerrain
from Elements.utils.obj_to_mesh import obj_to_mesh

from Elements.utils.helper_function import displayGUI_text
from Elements.utils.Shortcuts import displayGUI_text
example_description = \
"This is a scene with a cube, a terrain and axes. The scene is being lit using \n\
the Blinn-Phong algorithm. You may move the camera using the mouse or the GUI. \n\
Expand Down
32 changes: 11 additions & 21 deletions Elements/examples/1.Introductory/example_6_import_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
from Elements.utils.terrain import generateTerrain
from Elements.utils.obj_to_mesh import obj_to_mesh

from Elements.utils.helper_function import displayGUI_text
from Elements.utils.Shortcuts import displayGUI_text
example_description = \
"This is a scene with the famous Newell teapot. This example demonstrates the \n\
ability to load complex objects instead of inputing them manually. \n\
The scene is being lit using the Blinn-Phong algorithm. \n\
You may move the camera using the mouse or the GUI. \n\
You may see the ECS Scenegraph showing Entities & Components of the scene and \n\
various information about them. Hit ESC OR Close the window to quit."
various information about them (read-only). Hit ESC OR Close the window to quit."

#Light
Lposition = util.vec(2.0, 5.5, 2.0) #uniform lightpos
Expand Down Expand Up @@ -58,14 +58,6 @@
# projMat = util.perspective(90.0, 1.33, 0.1, 100)
projMat = util.perspective(50.0, 1.0, 1.0, 10.0)

m = np.linalg.inv(projMat @ view)


entityCam2 = scene.world.createEntity(Entity(name="Entity_Camera"))
scene.world.addEntityChild(entityCam1, entityCam2)
trans2 = scene.world.addComponent(entityCam2, BasicTransform(name="Camera_TRS", 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="Object"))
scene.world.addEntityChild(rootEntity, node4)
Expand Down Expand Up @@ -111,7 +103,6 @@

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

Expand Down Expand Up @@ -172,7 +163,7 @@
# MAIN RENDERING LOOP

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

# pre-pass scenegraph to initialise all GL context dependent geometry, shader classes
# needs an active GL context
Expand Down Expand Up @@ -204,26 +195,24 @@
gWindow._myCamera = view # otherwise, an imgui slider must be moved to properly update

model_terrain_axes = util.translate(0.0,0.0,0.0)
model_cube = util.scale(0.1) @ util.translate(0.0,0.5,0.0)
model_teapot = util.scale(0.1) @ util.translate(0.0,0.5,0.0)



while running:
running = scene.render()
displayGUI_text(example_description)
scene.world.traverse_visit(renderUpdate, scene.world.root)
scene.world.traverse_visit_pre_camera(camUpdate, orthoCam)
scene.world.traverse_visit(camUpdate, scene.world.root)
scene.world.traverse_visit(transUpdate, scene.world.root)
view = gWindow._myCamera # updates view via the imgui
#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

mvp_object = projMat @ view @ trans4.l2world
mvp_terrain = projMat @ view @ terrain_trans.l2world
mvp_axes = projMat @ view @ axes_trans.l2world
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_object, mat4=True)
shaderDec4.setUniformVariable(key='model',value=model_cube,mat4=True)
shaderDec4.setUniformVariable(key='model',value=trans4.l2world,mat4=True)
shaderDec4.setUniformVariable(key='ambientColor',value=Lambientcolor,float3=True)
shaderDec4.setUniformVariable(key='ambientStr',value=Lambientstr,float1=True)
shaderDec4.setUniformVariable(key='viewPos',value=LviewPos,float3=True)
Expand All @@ -234,6 +223,7 @@
shaderDec4.setUniformVariable(key='matColor',value=Mcolor,float3=True)


scene.world.traverse_visit(renderUpdate, scene.world.root)
scene.render_post()

scene.shutdown()
Expand Down
29 changes: 8 additions & 21 deletions Elements/examples/2.Intermediate/example_10_cube_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from Elements.definitions import TEXTURE_DIR

from Elements.utils.helper_function import displayGUI_text
from Elements.utils.Shortcuts import displayGUI_text
example_description = \
"This example demonstrates the cube map texture, i.e., \n\
we encapsulate the scene into a huge cube and apply texture to them\n\
Expand All @@ -27,30 +27,20 @@

winWidth = 1024
winHeight = 768
scene = Scene()

# Scenegraph with Entities, Components
rootEntity = scene.world.createEntity(Entity(name="RooT"))
entityCam1 = scene.world.createEntity(Entity(name="entityCam1"))
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"))
# Scenegraph with Entities, Components
scene = Scene()
rootEntity = scene.world.createEntity(Entity(name="RooT"))

skybox = scene.world.createEntity(Entity(name="Skybox"))
scene.world.addEntityChild(rootEntity, skybox)
transSkybox = scene.world.addComponent(skybox, BasicTransform(name="transSkybox", trs=util.identity)) #util.identity()
transSkybox = scene.world.addComponent(skybox, BasicTransform(name="transSkybox", trs=util.identity())) #util.identity()
meshSkybox = scene.world.addComponent(skybox, RenderMesh(name="meshSkybox"))

node4 = scene.world.createEntity(Entity(name="node4"))
Expand Down Expand Up @@ -102,7 +92,6 @@

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

Expand Down Expand Up @@ -172,24 +161,22 @@
shaderSkybox.setUniformVariable(key='cubemap', value=face_data, texture3D=True)
shaderDec4.setUniformVariable(key='cubemap', value=face_data_2, texture3D=True)

model_cube = util.translate(0.0,0.5,0.0)

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

view = gWindow._myCamera # updates view via the imgui

shaderDec4.setUniformVariable(key='Proj', value=projMat, mat4=True)
shaderDec4.setUniformVariable(key='View', value=view, mat4=True)
shaderDec4.setUniformVariable(key='model', value=model_cube, mat4=True)
shaderDec4.setUniformVariable(key='model', value=trans4.l2world, mat4=True)

shaderSkybox.setUniformVariable(key='Proj', value=projMat, mat4=True)
shaderSkybox.setUniformVariable(key='View', value=view, mat4=True)

scene.world.traverse_visit(renderUpdate, scene.world.root)
scene.render_post()

scene.shutdown()
2 changes: 1 addition & 1 deletion Elements/examples/2.Intermediate/example_7_cameraSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from Elements.utils.normals import Convert
from OpenGL.GL import GL_LINES

from Elements.utils.helper_function import displayGUI_text
from Elements.utils.Shortcuts import displayGUI_text
example_description = \
"This is the first examples that demonstrates the usage of the Camera System \n\
instead of the use of the lookAt function to create the view matrix. \n\
Expand Down
30 changes: 7 additions & 23 deletions Elements/examples/2.Intermediate/example_8_textures.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from OpenGL.GL import GL_LINES

from Elements.utils.helper_function import displayGUI_text
from Elements.utils.Shortcuts import displayGUI_text
example_description = \
"This example demonstrates the ability to apply image textures to geometry. \n\
You may move the camera using the mouse or the GUI. \n\
Expand All @@ -31,34 +31,19 @@

# Scenegraph with Entities, Components
rootEntity = scene.world.createEntity(Entity(name="RooT"))
entityCam1 = scene.world.createEntity(Entity(name="entityCam1"))
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)
trans4 = scene.world.addComponent(node4, BasicTransform(name="trans4", trs=util.translate(0,0.5,0))) #util.identity()
mesh4 = scene.world.addComponent(node4, RenderMesh(name="mesh4"))


axes = scene.world.createEntity(Entity(name="axes"))
scene.world.addEntityChild(rootEntity, axes)
axes_trans = scene.world.addComponent(axes, BasicTransform(name="axes_trans", trs=util.identity()))
axes_mesh = scene.world.addComponent(axes, RenderMesh(name="axes_mesh"))

# a simple triangle
vertexData = np.array([
[0.0, 0.0, 0.0, 1.0],
Expand Down Expand Up @@ -116,7 +101,6 @@

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

Expand Down Expand Up @@ -214,14 +198,14 @@
running = scene.render()
displayGUI_text(example_description)
scene.world.traverse_visit(renderUpdate, scene.world.root)
scene.world.traverse_visit_pre_camera(camUpdate, orthoCam)
scene.world.traverse_visit(camUpdate, scene.world.root)
scene.world.traverse_visit(transUpdate, scene.world.root)

view = gWindow._myCamera # updates view via the imgui
mvp_terrain_axes = projMat @ view @ model_terrain_axes

axes_shader.setUniformVariable(key='modelViewProj', value=mvp_terrain_axes, mat4=True)
terrain_shader.setUniformVariable(key='modelViewProj', value=mvp_terrain_axes, mat4=True)
mvp_terrain = projMat @ view @ terrain_trans.l2world
mvp_axes = projMat @ view @ axes_trans.l2world
model_cube = trans4.l2world
axes_shader.setUniformVariable(key='modelViewProj', value=mvp_axes, mat4=True)
terrain_shader.setUniformVariable(key='modelViewProj', value=mvp_terrain, mat4=True)
shaderDec4.setUniformVariable(key='model', value=model_cube, mat4=True)
shaderDec4.setUniformVariable(key='View', value=view, mat4=True)
shaderDec4.setUniformVariable(key='Proj', value=projMat, mat4=True)
Expand Down
Loading

0 comments on commit f9c0f93

Please sign in to comment.