Skip to content

Commit

Permalink
Merge pull request #29 from skylicht-lab/feature/#24-add-camera-and-r…
Browse files Browse the repository at this point in the history
…ender-pipeline

feat: #24 Move build command to sub folder, update ci package folder
  • Loading branch information
ducphamhong authored Dec 14, 2019
2 parents e5308dd + 65a80ac commit 8e79b82
Show file tree
Hide file tree
Showing 55 changed files with 2,121 additions and 336 deletions.
29 changes: 19 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ jobs:
type Version.txt
set /p CONFIG_VERSION=<Version.txt
set file_version=%CONFIG_VERSION:.=_%
set output=Build\SkylichtDemo_%file_version%_Emscripten.zip
7z a %output% Bin\MainApp*
7z a %output% Bin\*.zip
set output=SkylichtDemo_%file_version%_Emscripten.zip
cd Bin
7z a %output% *.zip
7z a %output% MainApp*
cd..
copy Bin\%output% Build
- name: Result
uses: actions/upload-artifact@v1
with:
Expand Down Expand Up @@ -81,8 +84,11 @@ jobs:
type Version.txt
set /p CONFIG_VERSION=<Version.txt
set file_version=%CONFIG_VERSION:.=_%
set output=Build\SkylichtDemo_%file_version%_UWP.zip
7z a %output% PrjUWP\Projects\MainApp\AppPackages\MainApp\MainApp_1.0.0.0_x64_Test\*.*
set output=SkylichtDemo_%file_version%_UWP.zip
pushd PrjUWP\Projects\MainApp\AppPackages\MainApp\MainApp_1.0.0.0_x64_Test
7z a %output% .\*.*
popd
copy PrjUWP\Projects\MainApp\AppPackages\MainApp\MainApp_1.0.0.0_x64_Test\%output% Build
- name: Result
uses: actions/upload-artifact@v1
with:
Expand All @@ -95,8 +101,8 @@ jobs:
- uses: actions/checkout@v1
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libglfw3-dev libsdl2-dev
sudo apt-get update -y -qq
sudo apt-get install -y libglfw3-dev libsdl2-dev
sudo apt remove --purge --auto-remove cmake
wget -q https://github.com/Kitware/CMake/releases/download/v3.15.5/cmake-3.15.5-Linux-x86_64.tar.gz
tar -zxvf cmake-3.15.5-Linux-x86_64.tar.gz
Expand All @@ -117,9 +123,12 @@ jobs:
ls -l Bin
version=$(cat "Version.txt")
file_version=${version//./_}
output=Build/SkylichtDemo_${file_version}_Linux.zip
7z a ${output} Bin/MainApp*
7z a ${output} Bin/*.zip
output=SkylichtDemo_${file_version}_Linux.zip
cd Bin
7z a ${output} *.zip
7z a ${output} MainApp*
cd ..
cp Bin/${output} Build
- name: Result
uses: actions/upload-artifact@v1
with:
Expand Down
1 change: 0 additions & 1 deletion Assets/BuildAssetBundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def compress(dirName):
if needCompress(file):
print("%s <-- %s - %s" %(outputZip, root, file))
z.write(os.path.join(root, file))

z.close

def main():
Expand Down
1 change: 1 addition & 0 deletions BuildAndroidNDK.cmd → BuildCommand/BuildAndroidNDK.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set NDK=C:\android-ndk-r20b
set ABI="armeabi-v7a with NEON"
set MINSDKVERSION=24
cd..
cmake -S . -B ./PrjAndroidNDK -G "MinGW Makefiles" -DTARGET_ARCH=ANDROID -DCMAKE_TOOLCHAIN_FILE=%NDK%/build/cmake/android.toolchain.cmake -DANDROID_ABI=%ABI% -DANDROID_ARM_NEON=ON -DANDROID_NATIVE_API_LEVEL=%MINSDKVERSION%
mingw32-make -C PrjAndroidNDK
1 change: 1 addition & 0 deletions BuildCygwin.cmd → BuildCommand/BuildCygwin.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cd..
cmake -S . -B ./PrjCygwin
cd Assets
python BuildAssetBundles.py
Expand Down
1 change: 1 addition & 0 deletions BuildEmscripten.cmd → BuildCommand/BuildEmscripten.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cd..
call C:\emsdk\emsdk_env.bat
call emcmake cmake -S . -B ./PrjEmscripten
cd Assets
Expand Down
3 changes: 2 additions & 1 deletion BuildMinGW.cmd → BuildCommand/BuildMinGW.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake -S . -B ./PrjMinGW -G "MinGW Makefiles"
cd..
cmake -S . -B ./PrjMinGW -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND"
cd Assets
python BuildAssetBundles.py
cd ..
Expand Down
1 change: 1 addition & 0 deletions GenerateUWPrj.cmd → BuildCommand/GenerateUWPrj.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cd..
cd Assets
python BuildAssetBundles.py
cd ..
Expand Down
4 changes: 4 additions & 0 deletions GenerateVCPrj.cmd → BuildCommand/GenerateVCPrj.cmd
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
cd..
cd Assets
python BuildAssetBundles.py
cd ..
cmake -S . -B ./PrjVisualStudio -G "Visual Studio 15 2017" -A WIN32
10 changes: 4 additions & 6 deletions Documents/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Do some thing 2

Remember tag your issues id ex: #282 on your commit message, and branch name
## Code style
- We try to adhere to the existing [**Irrlicht code style**](http://irrlicht.sourceforge.net/?page_id=140) and mix some code style from Microsoft Foundation Classes, Java style.
- We try to adhere to the existing [**Irrlicht code style**](http://irrlicht.sourceforge.net/?page_id=140) and mix some code style from Microsoft , Java style.
- You can use your code style in your local project `Projects/{YourProject}`. But if you fix bug or commit a feature on `Projects/Skylicht*`, try to follow our style.
### Code formation
Use **TAB Indent** instead 2 space for C/C++ code.
Expand All @@ -32,7 +32,6 @@ Use **TAB Indent** instead 2 space for C/C++ code.
### Example code style
**`NOT RECOMMENDED`**
```
// Dont try optimize your code lines because your function is too long
void function(int foo){
...
if (condition){
Expand All @@ -42,8 +41,7 @@ void function(int foo){
```
**`GOOD`**
```
// Create more function.
// Each function is short enough in screen view.
// Use hot key `Ctrl` + `K` + `D` (Visual Studio) to format this style
void function(int foo)
{
...
Expand Down Expand Up @@ -77,7 +75,7 @@ void MODULE_func_style_c_name()
```
**`GOOD`**
```
void funcStyleJavaName()
void functionJavaNameStyle()
{
int variable = 0;
}
Expand All @@ -90,7 +88,7 @@ void functionName(int foo)
..
}
```
- **C** for *`class`*, **E** for *`enum`*, **S** for *`struct`*, **I** for abstract class
- Prefix **C** for *`class`*, Prefix **E** for *`enum`*, Prefix **S** for *`struct`*, Prefix **I** for *`abstract class`*
```
class IInterfaceExample
{
Expand Down
3 changes: 3 additions & 0 deletions Documents/Media/Platforms/android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions Documents/Media/Platforms/apple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Documents/Media/Platforms/html5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Documents/Media/Platforms/ubuntu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Documents/Media/Platforms/uwp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 27 additions & 6 deletions Projects/Demo/Source/Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ void installApplication(const std::vector<std::string>& argv)
getApplication()->registerAppEvent("Demo", demo);
}

Demo::Demo()
Demo::Demo():
m_scene(NULL),
m_zone(NULL),
m_camera(NULL),
m_rendering(NULL)
{

}

Demo::~Demo()
{
delete m_scene;
delete m_rendering;
}

io::path Demo::getBuiltInPath(const char *name)
Expand All @@ -34,22 +41,36 @@ io::path Demo::getBuiltInPath(const char *name)
void Demo::onInitApp()
{
io::IFileSystem* fileSystem = getApplication()->getFileSystem();

// Add built in data
fileSystem->addFileArchive(getBuiltInPath("BuiltIn.zip"), false, false);

// load basic shader
CShaderManager::getInstance()->initBasicShader();

initScene();
}

void Demo::onUpdate()
void Demo::initScene()
{
CBaseApp *app = getApplication();

m_scene = new CScene();
m_zone = m_scene->createZone();

CGameObject *cameraObj = m_zone->createEmptyObject();
m_camera = cameraObj->addComponent<CCamera>();
cameraObj->initComponent();

m_rendering = new CForwardRP();
m_rendering->initRender(app->getWidth(), app->getHeight());
}

void Demo::onRender()
void Demo::onUpdate()
{
m_scene->update();
}

void Demo::onRender()
{
m_rendering->render(m_camera, m_zone->getEntityManager(), false);
}

void Demo::onPostRender()
Expand Down
20 changes: 20 additions & 0 deletions Projects/Demo/Source/Demo.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
#include "IApplicationEventReceiver.h"

#include "Scene/CScene.h"
#include "GameObject/CZone.h"
#include "Components/Camera/CCamera.h"

#include "RenderPipeline/CForwardRP.h"
#include "RenderPipeline/CDeferredRP.h"

#include "Entity/CEntityManager.h"

class Demo : public IApplicationEventReceiver
{
protected:
CScene *m_scene;
CZone *m_zone;
CCamera *m_camera;

CBaseRP *m_rendering;

protected:
io::path getBuiltInPath(const char *name);

Expand All @@ -22,4 +38,8 @@ class Demo : public IApplicationEventReceiver
virtual void onInitApp();

virtual void onQuitApp();

protected:

void initScene();
};
111 changes: 111 additions & 0 deletions Projects/SkylichtEngine/Source/Components/Camera/CCamera.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
!@
MIT License
Copyright (c) 2019 Skylicht Technology CO., LTD
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 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 Software.
THE SOFTWARE IS 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file is part of the "Skylicht Engine".
https://github.com/skylicht-lab/skylicht-engine
!#
*/

#include "pch.h"
#include "CCamera.h"
#include "GameObject/CGameObject.h"

namespace Skylicht
{
CCamera::CCamera() :
m_projectionType(CCamera::Perspective)
{
m_nearValue = 0.05f;
m_farValue = 1500;
m_fov = 54.0f;
}

CCamera::~CCamera()
{

}

void CCamera::initComponent()
{
recalculateProjectionMatrix();
}

void CCamera::updateComponent()
{

}

void CCamera::applyTransform()
{
m_viewArea.getTransform(video::ETS_VIEW) = m_gameObject->getTransform()->getMatrixTransform();

video::IVideoDriver* driver = getVideoDriver();
if (driver)
{
driver->setTransform(video::ETS_PROJECTION, m_viewArea.getTransform(video::ETS_PROJECTION));
driver->setTransform(video::ETS_VIEW, m_viewArea.getTransform(video::ETS_VIEW));
}
}

const core::matrix4& CCamera::getProjectionMatrix() const
{
return m_viewArea.getTransform(video::ETS_PROJECTION);
}

const core::matrix4& CCamera::getViewMatrix() const
{
return m_viewArea.getTransform(video::ETS_VIEW);
}

void CCamera::lookAt(const core::vector3df& position, const core::vector3df& target, const core::vector3df& up)
{
CTransformEuler *t = m_gameObject->getTransformEuler();
if (t != NULL)
{
core::vector3df rot = position - target;
t->setOrientation(rot, up);
t->setPosition(position);
}
}

void CCamera::lookAt(const core::vector3df& target, const core::vector3df& up)
{
CTransformEuler *t = m_gameObject->getTransformEuler();
if (t != NULL)
{
core::vector3df rot = t->getPosition() - target;
t->setOrientation(rot, up);
}
}

void CCamera::recalculateProjectionMatrix()
{
if (m_projectionType == CCamera::Perspective)
{
core::dimension2du screenSize = getVideoDriver()->getCurrentRenderTargetSize();
float aspect = (float)screenSize.Width / (float)screenSize.Height;

m_viewArea.getTransform(video::ETS_PROJECTION).buildProjectionMatrixPerspectiveFovLH(
m_fov * core::DEGTORAD,
aspect,
m_nearValue,
m_farValue);
}
}
}
Loading

0 comments on commit 8e79b82

Please sign in to comment.