workspace instancing

This commit is contained in:
floralrainfall 2023-07-11 20:26:25 -04:00
parent b9a19068b7
commit 4125f878ee
66 changed files with 489 additions and 25735 deletions

View File

@ -0,0 +1,38 @@
#include "OgreUnifiedShader.h"
struct RasterizerData
{
vec4 pos [[position]];
vec2 uv;
};
struct Vertex
{
IN(vec3 pos, POSITION);
IN(vec2 uv, TEXCOORD0);
};
struct Uniform
{
mat4 mvpMtx;
mat4 texMtx;
};
// first 15 slots are reserved for the vertex attributes
#define UNIFORM_INDEX_START 16
vertex RasterizerData default_vp(Vertex in [[stage_in]],
constant Uniform& u [[buffer(UNIFORM_INDEX_START)]])
{
RasterizerData out;
out.pos = u.mvpMtx * vec4(in.pos, 1);
out.uv = (u.texMtx * vec4(in.uv,1,1)).xy;
return out;
}
fragment half4 default_fp(RasterizerData in [[stage_in]],
metal::texture2d<half> tex [[texture(0)]],
metal::sampler s [[sampler(0)]])
{
return tex.sample(s, in.uv);
}

View File

@ -0,0 +1,85 @@
// This file is part of the OGRE project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at https://www.ogre3d.org/licensing.
material Ogre/TextureShadowCaster
{
receive_shadows false
technique
{
pass
{
// Lighting has to be on, because we need shadow coloured objects
// Note that because we can't predict vertex programs, we'll have to
// bind light values to those, and so we bind White to ambient
// reflectance, and we'll set the ambient colour to the shadow colour
ambient 1 1 1
diffuse 0 0 0
specular 0 0 0 1
emissive 0 0 0
fog_override true none
// set depth bias in case this is used with PF_DEPTH
depth_bias -1 -1
}
}
}
material Ogre/StencilShadowModulationPass
{
technique
{
pass
{
lighting off
scene_blend modulate
depth_write off
depth_check off
cull_hardware none
vertex_program_ref Ogre/ShadowBlendVP {}
fragment_program_ref Ogre/ShadowBlendFP {}
texture_unit {}
}
}
}
material Ogre/StencilShadowVolumes
{
technique
{
pass
{
// program will be set dynamically to match light type
vertex_program_ref Ogre/ShadowExtrudeDirLightFinite
{
// however, the parameters here are shared between all programs
param_named_auto worldviewproj_matrix worldviewproj_matrix
param_named_auto light_position_object_space light_position_object_space 0
param_named_auto shadow_extrusion_distance shadow_extrusion_distance 0
}
fragment_program_ref Ogre/ShadowBlendFP {}
}
}
}
material Ogre/Debug/ShadowVolumes
{
technique
{
pass
{
depth_write off
scene_blend add
cull_hardware none
// program will be set dynamically to match light type
vertex_program_ref Ogre/ShadowExtrudeDirLight
{
// however, the parameters here are shared between all programs
param_named_auto worldviewproj_matrix worldviewproj_matrix
param_named_auto light_position_object_space light_position_object_space 0
}
fragment_program_ref Ogre/ShadowBlendFP {}
}
}
}

View File

@ -0,0 +1,11 @@
#include <OgreUnifiedShader.h>
OGRE_UNIFORMS(
uniform vec4 shadowColor;
)
MAIN_PARAMETERS
MAIN_DECLARATION
{
gl_FragColor = shadowColor;
}

View File

@ -0,0 +1,12 @@
#include <OgreUnifiedShader.h>
OGRE_UNIFORMS(
uniform mat4 worldViewProj;
)
MAIN_PARAMETERS
IN(vec4 vertex, POSITION)
MAIN_DECLARATION
{
gl_Position = mul(worldViewProj, vertex);
}

View File

@ -0,0 +1,18 @@
#include <OgreUnifiedShader.h>
// Directional light extrude
uniform mat4 worldviewproj_matrix;
uniform vec4 light_position_object_space; // homogenous, object space
MAIN_PARAMETERS
IN(vec4 uv0, TEXCOORD0)
IN(vec4 position, POSITION)
MAIN_DECLARATION
{
// Extrusion in object space
// Vertex unmodified if w==1, extruded if w==0
vec4 newpos =
(uv0.xxxx * (position + light_position_object_space)) - light_position_object_space;
gl_Position = mul(worldviewproj_matrix, newpos);
}

View File

@ -0,0 +1,22 @@
#include <OgreUnifiedShader.h>
// Directional light extrude - FINITE
uniform mat4 worldviewproj_matrix;
uniform vec4 light_position_object_space; // homogenous, object space
uniform float shadow_extrusion_distance; // how far to extrude
MAIN_PARAMETERS
IN(vec4 uv0, TEXCOORD0)
IN(vec4 position, POSITION)
MAIN_DECLARATION
{
// Extrusion in object space
// Vertex unmodified if w==1, extruded if w==0
vec3 extrusionDir = - light_position_object_space.xyz;
extrusionDir = normalize(extrusionDir);
vec4 newpos = vec4(position.xyz +
((1.0 - uv0.x) * shadow_extrusion_distance * extrusionDir), 1.0);
gl_Position = mul(worldviewproj_matrix, newpos);
}

View File

@ -0,0 +1,19 @@
#include <OgreUnifiedShader.h>
// Point light shadow volume extrude
uniform mat4 worldviewproj_matrix;
uniform vec4 light_position_object_space; // homogenous, object space
MAIN_PARAMETERS
IN(vec4 uv0, TEXCOORD0)
IN(vec4 position, POSITION)
MAIN_DECLARATION
{
// Extrusion in object space
// Vertex unmodified if w==1, extruded if w==0
vec4 newpos =
(uv0.xxxx * light_position_object_space) +
vec4(position.xyz - light_position_object_space.xyz, 0.0);
gl_Position = mul(worldviewproj_matrix, newpos);
}

View File

@ -0,0 +1,22 @@
#include <OgreUnifiedShader.h>
// Point light shadow volume extrude - FINITE
uniform mat4 worldviewproj_matrix;
uniform vec4 light_position_object_space; // homogenous, object space
uniform float shadow_extrusion_distance; // how far to extrude
MAIN_PARAMETERS
IN(vec4 uv0, TEXCOORD0)
IN(vec4 position, POSITION)
MAIN_DECLARATION
{
// Extrusion in object space
// Vertex unmodified if w==1, extruded if w==0
vec3 extrusionDir = position.xyz - light_position_object_space.xyz;
extrusionDir = normalize(extrusionDir);
vec4 newpos = vec4(position.xyz +
((1.0 - uv0.x) * shadow_extrusion_distance * extrusionDir), 1.0);
gl_Position = mul(worldviewproj_matrix, newpos);
}

View File

@ -0,0 +1,41 @@
// This file is part of the OGRE project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at https://www.ogre3d.org/licensing.
vertex_program Ogre/ShadowBlendVP glsl glsles hlsl glslang
{
source ShadowBlend.vert
default_params
{
param_named_auto worldViewProj worldviewproj_matrix
}
}
fragment_program Ogre/ShadowBlendFP glsl glsles hlsl glslang
{
source ShadowBlend.frag
default_params
{
param_named_auto shadowColor shadow_colour
}
}
vertex_program Ogre/ShadowExtrudePointLight glsl glsles hlsl
{
source ShadowExtrudePointLight.vert
}
vertex_program Ogre/ShadowExtrudeDirLight glsl glsles hlsl
{
source ShadowExtrudeDirLight.vert
}
vertex_program Ogre/ShadowExtrudePointLightFinite glsl glsles hlsl
{
source ShadowExtrudePointLightFinite.vert
}
vertex_program Ogre/ShadowExtrudeDirLightFinite glsl glsles hlsl
{
source ShadowExtrudeDirLightFinite.vert
}

Binary file not shown.

BIN
Content/RNR/fonts/Cube.mesh Normal file

Binary file not shown.

View File

@ -1,4 +1,4 @@
// generated by blender2ogre 0.8.3 on 2023-07-10 20:18:50
// generated by blender2ogre 0.8.3 on 2023-07-11 17:36:32
material Material {
receive_shadows on
technique {

View File

@ -0,0 +1,21 @@
17:36:32: XMLMeshSerializer reading mesh data from /home/caesium/projects/rbxnu/Content/RNR/fonts/Cube.mesh.xml...
17:36:32: Reading geometry...
17:36:32: Geometry done...
17:36:32: Reading submeshes...
17:36:32: Submeshes done.
17:36:32: Reading mesh names...
17:36:32: Mesh names done.
17:36:32: XMLMeshSerializer import successful.
17:36:32: MeshSerializer writing mesh data to stream /home/caesium/projects/rbxnu/Content/RNR/fonts/Cube.mesh...
17:36:32: File header written.
17:36:32: Writing mesh data...
17:36:32: Writing submesh...
17:36:32: Exporting submesh texture aliases...
17:36:32: Submesh texture aliases exported.
17:36:32: Submesh exported.
17:36:32: Exporting bounds information....
17:36:32: Bounds information exported.
17:36:32: Exporting submesh name table...
17:36:32: Submesh name table exported.
17:36:32: Mesh data exported.
17:36:32: MeshSerializer export successful.

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -0,0 +1,41 @@
//---------------------------------------------------------------------------
//These materials/shaders are part of the NEW InstanceManager implementation
//Written by Matias N. Goldberg ("dark_sylinc")
//---------------------------------------------------------------------------
material materials/part_shadow_caster
{
technique
{
pass
{
rtshader_system
{
lighting_stage gbuffer depth
transform_stage instanced
}
}
}
}
material materials/partinstanced
{
receive_shadows on
technique
{
shadow_caster_material materials/part_shadow_caster
pass
{
specular 1 1 1 1 12.5
lighting on
rtshader_system
{
transform_stage instanced
lighting_stage per_pixel
}
}
}
}

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

View File

@ -1,21 +0,0 @@
20:18:50: XMLMeshSerializer reading mesh data from /home/caesium/projects/rbxnu/Content/fonts/Cube.mesh.xml...
20:18:50: Reading geometry...
20:18:50: Geometry done...
20:18:50: Reading submeshes...
20:18:50: Submeshes done.
20:18:50: Reading mesh names...
20:18:50: Mesh names done.
20:18:50: XMLMeshSerializer import successful.
20:18:50: MeshSerializer writing mesh data to stream /home/caesium/projects/rbxnu/Content/fonts/Cube.mesh...
20:18:50: File header written.
20:18:50: Writing mesh data...
20:18:50: Writing submesh...
20:18:50: Exporting submesh texture aliases...
20:18:50: Submesh texture aliases exported.
20:18:50: Submesh exported.
20:18:50: Exporting bounds information....
20:18:50: Bounds information exported.
20:18:50: Exporting submesh name table...
20:18:50: Submesh name table exported.
20:18:50: Mesh data exported.
20:18:50: MeshSerializer export successful.

View File

@ -1,10 +0,0 @@
project(GLAD)
add_library(GLAD STATIC
Header/glad/glad.h
Header/KHR/khrplatform.h
Source/glad.c
)
target_include_directories(GLAD PUBLIC Header)

View File

@ -1,311 +0,0 @@
#ifndef __khrplatform_h_
#define __khrplatform_h_
/*
** Copyright (c) 2008-2018 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Khronos platform-specific types and definitions.
*
* The master copy of khrplatform.h is maintained in the Khronos EGL
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
* The last semantic modification to khrplatform.h was at commit ID:
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
*
* Adopters may modify this file to suit their platform. Adopters are
* encouraged to submit platform specific modifications to the Khronos
* group so that they can be included in future versions of this file.
* Please submit changes by filing pull requests or issues on
* the EGL Registry repository linked above.
*
*
* See the Implementer's Guidelines for information about where this file
* should be located on your system and for more details of its use:
* http://www.khronos.org/registry/implementers_guide.pdf
*
* This file should be included as
* #include <KHR/khrplatform.h>
* by Khronos client API header files that use its types and defines.
*
* The types in khrplatform.h should only be used to define API-specific types.
*
* Types defined in khrplatform.h:
* khronos_int8_t signed 8 bit
* khronos_uint8_t unsigned 8 bit
* khronos_int16_t signed 16 bit
* khronos_uint16_t unsigned 16 bit
* khronos_int32_t signed 32 bit
* khronos_uint32_t unsigned 32 bit
* khronos_int64_t signed 64 bit
* khronos_uint64_t unsigned 64 bit
* khronos_intptr_t signed same number of bits as a pointer
* khronos_uintptr_t unsigned same number of bits as a pointer
* khronos_ssize_t signed size
* khronos_usize_t unsigned size
* khronos_float_t signed 32 bit floating point
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
* nanoseconds
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
* khronos_boolean_enum_t enumerated boolean type. This should
* only be used as a base type when a client API's boolean type is
* an enum. Client APIs which use an integer or other type for
* booleans cannot use this as the base type for their boolean.
*
* Tokens defined in khrplatform.h:
*
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
*
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
*
* Calling convention macros defined in this file:
* KHRONOS_APICALL
* KHRONOS_APIENTRY
* KHRONOS_APIATTRIBUTES
*
* These may be used in function prototypes as:
*
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
* int arg1,
* int arg2) KHRONOS_APIATTRIBUTES;
*/
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
# define KHRONOS_STATIC 1
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if defined(KHRONOS_STATIC)
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
* header compatible with static linking. */
# define KHRONOS_APICALL
#elif defined(_WIN32)
# define KHRONOS_APICALL __declspec(dllimport)
#elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C
#elif defined(__ANDROID__)
# define KHRONOS_APICALL __attribute__((visibility("default")))
#else
# define KHRONOS_APICALL
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIENTRY
*-------------------------------------------------------------------------
* This follows the return type of the function and precedes the function
* name in the function prototype.
*/
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
/* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall
#else
# define KHRONOS_APIENTRY
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIATTRIBUTES
*-------------------------------------------------------------------------
* This follows the closing parenthesis of the function prototype arguments.
*/
#if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp
#else
#define KHRONOS_APIATTRIBUTES
#endif
/*-------------------------------------------------------------------------
* basic type definitions
*-----------------------------------------------------------------------*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
/*
* Using <stdint.h>
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
/*
* To support platform where unsigned long cannot be used interchangeably with
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
* unsigned long long or similar (this results in different C++ name mangling).
* To avoid changes for existing platforms, we restrict usage of intptr_t to
* platforms where the size of a pointer is larger than the size of long.
*/
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
#define KHRONOS_USE_INTPTR_T
#endif
#endif
#elif defined(__VMS ) || defined(__sgi)
/*
* Using <inttypes.h>
*/
#include <inttypes.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
/*
* Win32
*/
typedef __int32 khronos_int32_t;
typedef unsigned __int32 khronos_uint32_t;
typedef __int64 khronos_int64_t;
typedef unsigned __int64 khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__sun__) || defined(__digital__)
/*
* Sun or Digital
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64)
typedef long int khronos_int64_t;
typedef unsigned long int khronos_uint64_t;
#else
typedef long long int khronos_int64_t;
typedef unsigned long long int khronos_uint64_t;
#endif /* __arch64__ */
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif 0
/*
* Hypothetical platform with no float or int64 support
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64 0
#define KHRONOS_SUPPORT_FLOAT 0
#else
/*
* Generic fallback
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#endif
/*
* Types that are (so far) the same on all platforms
*/
typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
/*
* Types that differ between LLP64 and LP64 architectures - in LLP64,
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
* to be the only LLP64 architecture in current use.
*/
#ifdef KHRONOS_USE_INTPTR_T
typedef intptr_t khronos_intptr_t;
typedef uintptr_t khronos_uintptr_t;
#elif defined(_WIN64)
typedef signed long long int khronos_intptr_t;
typedef unsigned long long int khronos_uintptr_t;
#else
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
#endif
#if defined(_WIN64)
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else
typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t;
#endif
#if KHRONOS_SUPPORT_FLOAT
/*
* Float type
*/
typedef float khronos_float_t;
#endif
#if KHRONOS_SUPPORT_INT64
/* Time types
*
* These types can be used to represent a time interval in nanoseconds or
* an absolute Unadjusted System Time. Unadjusted System Time is the number
* of nanoseconds since some arbitrary system event (e.g. since the last
* time the system booted). The Unadjusted System Time is an unsigned
* 64 bit value that wraps back to 0 every 584 years. Time intervals
* may be either signed or unsigned.
*/
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
typedef khronos_int64_t khronos_stime_nanoseconds_t;
#endif
/*
* Dummy value used to pad enum types to 32 bits.
*/
#ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif
/*
* Enumerated boolean type
*
* Values other than zero should be considered to be true. Therefore
* comparisons should not be made against KHRONOS_TRUE.
*/
typedef enum {
KHRONOS_FALSE = 0,
KHRONOS_TRUE = 1,
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t;
#endif /* __khrplatform_h_ */

15905
Dependencies/GLAD/Header/glad/glad.h generated vendored

File diff suppressed because one or more lines are too long

9431
Dependencies/GLAD/Source/glad.c generated vendored

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,7 @@ if(COMPILE_PLAYER OR COMPILE_STUDIO)
include(/usr/share/cmake/Modules/FindX11.cmake)
endif()
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets OpenGLWidgets)
set(QT6_LIBRARIES_INCL Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGLWidgets Qt6::GuiPrivate GLAD ${X11_X11_LIB})
set(QT6_LIBRARIES_INCL Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGLWidgets Qt6::GuiPrivate ${X11_X11_LIB})
add_subdirectory(Common)
if(COMPILE_PLAYER)

View File

@ -1,5 +1,3 @@
add_subdirectory(${DEPENDENCIES_DIR}/GLAD ${CMAKE_BINARY_DIR}/Dependencies/GLAD)
project(Common)
qt_standard_project_setup()

View File

@ -1,7 +1,5 @@
#pragma once
#include <cglm/cglm.h>
namespace GL
{
struct RenderContext

View File

@ -1,7 +1,5 @@
#pragma once
#include <glad/glad.h>
#include <QWidget>
#include <QOpenGLWidget>
#include <QOpenGLContext>
@ -9,6 +7,8 @@
#include <QResizeEvent>
#include <OGRE/Ogre.h>
#include <OGRE/RTShaderSystem/OgreShaderGenerator.h>
#include <App/V8/Tree/Instance.hpp>
#include <App/V8/World/World.hpp>>
#include <GL/Adorn.hpp>
@ -25,14 +25,16 @@ namespace RNR
double render_time;
Adorn* adorn;
RNR::World* world;
Ogre::Root* ogreRoot;
Ogre::RenderWindow* ogreWindow;
Ogre::SceneManager* ogreSceneManager;
Ogre::Camera* ogreCamera;
Ogre::Viewport* ogreViewport;
Ogre::RTShader::ShaderGenerator* ogreShaderGen;
void render();
void render();
void initializeOgre();
Ogre::NameValuePairList getRenderOptions();

View File

@ -34,39 +34,15 @@ namespace RNR
ogreWindow->setActive(true);
ogreWindow->setVisible(true);
ogreWindow->setAutoUpdated(true);
Ogre::ResourceGroupManager::getSingletonPtr()->addResourceLocation("../Content/Ogre/", "FileSystem", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::ResourceGroupManager::getSingletonPtr()->addResourceLocation("../Content/Ogre/RTShaderLib/GLSL/", "FileSystem", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::ResourceGroupManager::getSingletonPtr()->addResourceLocation("content", "FileSystem", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
Ogre::ResourceGroupManager::getSingletonPtr()->addResourceLocation("../Content", "FileSystem", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
Ogre::ResourceGroupManager::getSingletonPtr()->addResourceLocation("content/OgreInternal", "FileSystem", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME, true);
Ogre::ResourceGroupManager::getSingletonPtr()->addResourceLocation("../Content/OgreInternal", "FileSystem", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME, true);
Ogre::ResourceGroupManager::getSingletonPtr()->initialiseAllResourceGroups();
Ogre::MaterialManager::getSingletonPtr()->load("sky", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::MaterialManager::getSingletonPtr()->load("materials", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
//Ogre::ResourceGroupManager::getSingletonPtr()->addResourceLocation("../Content/OgrePrivate/RTShaderLib/GLSL/", "FileSystem", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); // rtshader path
//Ogre::ResourceGroupManager::getSingletonPtr()->initialiseAllResourceGroups();
ogreSceneManager = ogreRoot->createSceneManager();
ogreSceneManager->setSkyBox(true, "sky/null_plainsky512", 5.f);
ogreSceneManager->setAmbientLight(Ogre::ColourValue(0.5f,0.5f,0.5f));
if(Ogre::RTShader::ShaderGenerator::initialize())
{
ogreShaderGen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
ogreShaderGen->addSceneManager(ogreSceneManager);
OgreBites::SGTechniqueResolverListener* schemeNotFoundHandler = new OgreBites::SGTechniqueResolverListener(ogreShaderGen);
Ogre::MaterialManager::getSingleton().addListener(schemeNotFoundHandler);
}
else
printf("OgreWidget::initializeOgre: unable to initialize ShaderGenerator\n");
Ogre::Light* light = ogreSceneManager->createLight("SunLight");
Ogre::SceneNode* lightNode = ogreSceneManager->getRootSceneNode()->createChildSceneNode();
lightNode->setPosition(0, 10, 15);
lightNode->setDirection(-0.25, -0.5, -0.5);
lightNode->attachObject(light);
light->setDiffuseColour(0.9, 0.9, 1.0);
light->setSpecularColour(1.0, 1.0, 1.0);
light->setType(Ogre::Light::LT_DIRECTIONAL);
ogreSceneManager->setAmbientLight(Ogre::ColourValue(0.f,0.f,0.f));
Ogre::SceneNode* camNode = ogreSceneManager->getRootSceneNode()->createChildSceneNode();
camNode->setPosition(0, 0, 5);
@ -74,22 +50,62 @@ namespace RNR
ogreCamera = ogreSceneManager->createCamera("myCam");
ogreCamera->setNearClipDistance(0.1); // specific to this sample
ogreCamera->setFarClipDistance(1000.f);
ogreCamera->setFarClipDistance(5000.f);
ogreCamera->setAutoAspectRatio(true);
ogreCamera->setFOVy(Ogre::Degree(60.f));
camNode->attachObject(ogreCamera);
ogreWindow->addViewport(ogreCamera);
ogreViewport = ogreWindow->addViewport(ogreCamera);
if(Ogre::RTShader::ShaderGenerator::initialize())
{
ogreShaderGen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
ogreShaderGen->setShaderCachePath("ShaderCache/");
ogreShaderGen->addSceneManager(ogreSceneManager);
OgreBites::SGTechniqueResolverListener* technique_resolver = new OgreBites::SGTechniqueResolverListener(ogreShaderGen);
Ogre::MaterialManager::getSingleton().addListener(technique_resolver);
printf("OgreWidget::initializeOgre: initialized ShaderGenerator successfully\n");
}
else
printf("OgreWidget::initializeOgre: unable to initialize ShaderGenerator\n");
Ogre::ResourceGroupManager::getSingletonPtr()->addResourceLocation("../Content/RNR/", "FileSystem", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
Ogre::ResourceGroupManager::getSingletonPtr()->initialiseAllResourceGroups();
Ogre::Light* light = ogreSceneManager->createLight("SunLight");
Ogre::SceneNode* lightNode = ogreSceneManager->getRootSceneNode()->createChildSceneNode();
lightNode->setPosition(0, 10, 15);
lightNode->setDirection(-0.25, -0.5, -0.5);
lightNode->attachObject(light);
light->setCastShadows(true);
light->setDiffuseColour(0.9, 0.9, 1.0);
light->setSpecularColour(1.0, 1.0, 1.0);
light->setType(Ogre::Light::LT_DIRECTIONAL);
ogreSceneManager->setShadowTechnique(Ogre::ShadowTechnique::SHADOWTYPE_STENCIL_ADDITIVE);
ogreSceneManager->setShadowFarDistance(500.f);
Ogre::MaterialManager::getSingletonPtr()->reloadAll();
Ogre::MaterialManager::getSingletonPtr()->load("sky/null_plainsky512", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
ogreSceneManager->setSkyBox(true, "sky/null_plainsky512");
this->render_time = 0.0;
}
void OgreWidget::render()
{
if(!world)
return;
this->delta = ogreRoot->getTimer()->getMicroseconds() / 1000000.0;
this->render_time += ogreRoot->getTimer()->getMilliseconds() / 1000.0;
ogreRoot->getTimer()->reset();
ogreCamera->getParentSceneNode()->setPosition(Ogre::Vector3(sinf(this->render_time)*10,5.f,cosf(this->render_time)*10));
ogreCamera->getParentSceneNode()->lookAt(Ogre::Vector3(0,0,0), Ogre::Node::TS_PARENT);
ogreCamera->getParentSceneNode()->setPosition(world->getWorkspace()->getBoundingBox().getCorner(Ogre::AxisAlignedBox::FAR_LEFT_TOP));
ogreCamera->getParentSceneNode()->lookAt(world->getWorkspace()->getBoundingBox().getCenter(), Ogre::Node::TS_WORLD, Ogre::Vector3::NEGATIVE_UNIT_Z);
ogreRoot->renderOneFrame(this->delta);
}

View File

@ -22,6 +22,7 @@ int main(int argc, char** argv)
RNR::World* world = new RNR::World(window.ogreWidget->ogreRoot, window.ogreWidget->ogreSceneManager);
window.updateTree(world->getDatamodel());
window.ogreWidget->world = world;
while (window.isVisible())
{

View File

@ -9,6 +9,7 @@ add_library(Engine STATIC
Header/App/V8/DataModel/BasePart.hpp
Header/App/V8/Tree/Instance.hpp
Header/App/V8/Tree/PVInstance.hpp
Header/App/V8/Tree/Model.hpp
Header/App/V8/World/World.hpp
Header/App/V8/World/Workspace.hpp
Header/App/CoordinateFrame.hpp
@ -22,6 +23,7 @@ add_library(Engine STATIC
Source/App/V8/DataModel/BasePart.cpp
Source/App/V8/Tree/Instance.cpp
Source/App/V8/Tree/PVInstance.cpp
Source/App/V8/Tree/Model.cpp
Source/App/CoordinateFrame.cpp
Source/App/V8/World/World.cpp
Source/App/V8/World/Workspace.cpp

View File

@ -6,11 +6,12 @@ namespace RNR
class CoordinateFrame
{
Ogre::Vector3 m_position;
Ogre::Vector3 m_scale;
Ogre::Matrix3 m_rotation;
public:
CoordinateFrame();
void setRotation(Ogre::Matrix3 rotation) { m_rotation = rotation; }
void setPosition(Ogre::Vector3 position) { m_position = position; }
Ogre::Matrix3 getRotation() { return m_rotation; }
Ogre::Vector3 getPosition() { return m_position; }

View File

@ -2,6 +2,8 @@
#include <App/V8/Tree/PVInstance.hpp>
#include <OGRE/Ogre.h>
#define STUD_HEIGHT 1.18
namespace RNR
{
class BasePart : public PVInstance, public Ogre::Renderable
@ -10,12 +12,18 @@ namespace RNR
Ogre::Matrix4 m_matrix;
Ogre::Vector3 m_position;
Ogre::LightList m_nearbyLights;
Ogre::Vector3 m_size;
Ogre::Vector4 m_color;
static Ogre::MeshPtr m_partMesh;
public:
BasePart();
void updateMatrix();
void setSize(Ogre::Vector3 size) { m_size = size; }
Ogre::Vector3 getSize() { return m_size; }
Ogre::Vector4 getColor() { return m_color; }
virtual const Ogre::MaterialPtr& getMaterial() const;
virtual void getRenderOperation(Ogre::RenderOperation& op);
virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera* cam) const;

View File

@ -0,0 +1,18 @@
#pragma once
#include <App/V8/Tree/PVInstance.hpp>
namespace RNR
{
class Model : public PVInstance
{
public:
Model();
virtual void build();
Ogre::AxisAlignedBox getBoundingBox() { return m_boundingbox; }
private:
Ogre::AxisAlignedBox m_boundingbox;
void childAddBoundingBox(Instance* child);
};
}

View File

@ -11,7 +11,7 @@ namespace RNR
public:
PVInstance();
CoordinateFrame getCFrame() { return m_cframe; };
CoordinateFrame& getCFrame() { return m_cframe; };
void setCFrame(CoordinateFrame cframe) { m_cframe = cframe; };
Ogre::Vector3 getPosition() { return m_cframe.getPosition(); }

View File

@ -1,17 +1,21 @@
#pragma once
#include <App/V8/Tree/Instance.hpp>
#include <App/V8/Tree/Model.hpp>
#include <OGRE/Ogre.h>
#include <vector>
namespace RNR
{
class Workspace : public Instance
class Workspace : public Model
{
public:
Workspace();
void build();
virtual void build();
void clean();
private:
std::vector<Ogre::InstancedEntity*> m_objects;
Ogre::InstanceManager* m_instMan;
Ogre::SceneNode* m_worldspawn;

View File

@ -2,7 +2,7 @@
namespace RNR
{
CoordinateFrame::CoordinateFrame() : m_position(0.f,0.f,0.f), m_scale(1.f,1.f,1.f), m_rotation()
CoordinateFrame::CoordinateFrame() : m_position(0.f,0.f,0.f), m_rotation()
{
m_rotation.FromEulerAnglesXYZ(Ogre::Radian(0.f), Ogre::Radian(0.f), Ogre::Radian(0.f));
}
@ -10,7 +10,7 @@ namespace RNR
Ogre::Matrix4 CoordinateFrame::getMatrix()
{
Ogre::Matrix4 res = Ogre::Matrix4();
res.makeTransform(m_position, m_scale, Ogre::Quaternion(m_rotation));
res.makeTransform(m_position, Ogre::Vector3(1.f,1.f,1.f), Ogre::Quaternion(m_rotation));
return res;
}

View File

@ -5,14 +5,14 @@ namespace RNR
{
Ogre::MeshPtr BasePart::m_partMesh = 0;
BasePart::BasePart() : m_matrix(), PVInstance(), Ogre::Renderable()
BasePart::BasePart() : m_matrix(), PVInstance(), Ogre::Renderable(), m_size(2.f, STUD_HEIGHT, 4.f)
{
setName("Part");
updateMatrix();
m_nearbyLights = Ogre::LightList();
m_nearbyLights.insert(m_nearbyLights.begin(), world->getOgreSceneManager()->getLight("SunLight"));
m_color = Ogre::Vector4(0.63, 0.64, 0.63, 1.0);
if(m_partMesh == 0)
m_partMesh = Ogre::Root::getSingletonPtr()->getMeshManager()->load("fonts/Cube.mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
@ -21,7 +21,7 @@ namespace RNR
void BasePart::updateMatrix()
{
m_matrix = m_cframe.getMatrix();
m_matrix = m_cframe.getMatrix();
m_position = m_cframe.getPosition();
}

View File

@ -0,0 +1,27 @@
#include <App/V8/Tree/Model.hpp>
#include <App/V8/DataModel/BasePart.hpp>
namespace RNR
{
Model::Model() : PVInstance()
{
}
void Model::build()
{
m_boundingbox.setNull();
for(auto& child : *getChildren())
childAddBoundingBox(child);
}
void Model::childAddBoundingBox(Instance* child)
{
for(auto& child2 : *child->getChildren())
childAddBoundingBox(child2);
BasePart* child_pv = (BasePart*)child;
Ogre::Vector3 half_size = child_pv->getSize() / 2.0;
m_boundingbox.merge(child_pv->getPosition() + half_size);
m_boundingbox.merge(child_pv->getPosition() - half_size);
}
}

View File

@ -4,15 +4,17 @@
namespace RNR
{
Workspace::Workspace() : Instance()
Workspace::Workspace() : Model()
{
setName("Workspace");
m_instMan = world->getOgreSceneManager()->createInstanceManager("workspacePartInstanceManager", "fonts/Cube.mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::InstanceManager::InstancingTechnique::HWInstancingBasic, 255);
m_instMan->setNumCustomParams(2);
m_worldspawn = world->getOgreSceneManager()->getRootSceneNode()->createChildSceneNode();
}
void Workspace::build()
{
Model::build();
for(auto& child : *getChildren())
buildChild(child);
}
@ -25,12 +27,27 @@ namespace RNR
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)child->getObject();
if(!child_ent)
{
child_ent = m_instMan->createInstancedEntity("fonts/Material");
child_ent->setUserAny(child);
child_ent = m_instMan->createInstancedEntity("materials/partinstanced");
assert(child_ent != NULL);
child->setObject(child_ent);
m_objects.push_back(child_ent);
}
child_ent->setPosition(child_part->getCFrame().getPosition());
child_ent->setOrientation(Ogre::Quaternion(child_part->getCFrame().getRotation()));
child_ent->setOrientation(Ogre::Quaternion(child_part->getCFrame().getRotation()));
Ogre::Vector3 size = child_part->getSize();
child_ent->setScale(size);
child_ent->setCustomParam(0, Ogre::Vector4(
size.x,
size.y,
size.z,
0.0f
));
child_ent->setCustomParam(1, child_part->getColor());
child_ent->setCastShadows(true);
}
void Workspace::clean()
{
}
}

View File

@ -17,7 +17,17 @@ namespace RNR
Instance* test = new Instance();
BasePart* test2 = new BasePart();
test->setParent(m_datamodel);
test2->setSize(Ogre::Vector3(64,STUD_HEIGHT,64));
test2->setName("Baseplate");
test2->setParent(m_workspace);
for(int i = 1; i < 36; i++)
{
test2 = new BasePart();
test2->getCFrame().setPosition(Ogre::Vector3(i*2,i*STUD_HEIGHT,i*2));
test2->setSize(Ogre::Vector3(4,STUD_HEIGHT,4));
test2->setParent(m_workspace);
}
m_workspace->build();
}