*
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
#ifndef BoundsView_h__
|
||||
#define BoundsView_h__
|
||||
|
||||
#include "ObjectsFactory.h"
|
||||
|
||||
LOBJECT(BoundsView, Component)
|
||||
public:
|
||||
void tick(float deltaTime) override {
|
||||
LEngine::Instance()->GetActiveScene()->GetGizmos().SetMatrix(transform()->GetGlobalTransform());
|
||||
LEngine::Instance()->GetActiveScene()->GetGizmos().DrawBounds(gameObject->GetComponent<MeshRenderer>()->GetMesh()->GetBounds());
|
||||
}
|
||||
};
|
||||
#endif // BoundsView_h__
|
||||
@@ -0,0 +1,67 @@
|
||||
#ifndef FreeCameraController_h__
|
||||
#define FreeCameraController_h__
|
||||
|
||||
#include "Component.h"
|
||||
#include "lframework/Input.h"
|
||||
#include <iostream>
|
||||
#include "Transform.h"
|
||||
#include "ObjectsFactory.h"
|
||||
|
||||
LOBJECT(FreeCameraController, Component)
|
||||
public:
|
||||
float mouse_speed;
|
||||
float move_speed = 3.0f;
|
||||
static constexpr float pi = 3.14159265358979f;
|
||||
|
||||
FreeCameraController() : mouse_speed(0.01f){
|
||||
_angle_x = _angle_y = 0.0f;
|
||||
}
|
||||
|
||||
virtual void tick(float deltaTime) override {
|
||||
auto mice = Input::Instance()->mice();
|
||||
auto mouse = mice[0];
|
||||
_angle_x += mouse_speed * mouse->GetDx();
|
||||
_angle_y += mouse_speed * mouse->GetDy();
|
||||
|
||||
_angle_y = clamp(_angle_y, -pi / 2.0f, pi / 2.0f);
|
||||
|
||||
auto rv = Quaternion_f::angleAxis(_angle_y, float3(1.0f, 0.0f, 0.0f));
|
||||
auto rh = Quaternion_f::angleAxis(_angle_x, float3(0.0f, 1.0f, 0.0f));
|
||||
|
||||
/* if (mouse->GetDx() != 0) {
|
||||
std::cout << "Mouse DX: " << mouse->GetDx() << std::endl;
|
||||
}
|
||||
if (mouse->GetDy() != 0) {
|
||||
std::cout << "Mouse DY: " << mouse->GetDy() << std::endl;
|
||||
}*/
|
||||
|
||||
gameObject->transform->SetLocalRotation(lm::mul(rh, rv));
|
||||
|
||||
|
||||
|
||||
auto keyboards = Input::Instance()->keyboards();
|
||||
auto keyboard = keyboards[0];
|
||||
|
||||
if(keyboard->GetKeyState(0x57)){
|
||||
gameObject->transform->SetLocalPosition(gameObject->transform->GetLocalPosition() + gameObject->transform->forward() * (deltaTime * move_speed));
|
||||
}
|
||||
|
||||
if (keyboard->GetKeyState(0x53)) {
|
||||
gameObject->transform->SetLocalPosition(gameObject->transform->GetLocalPosition() - gameObject->transform->forward() * (deltaTime * move_speed));
|
||||
}
|
||||
|
||||
if (keyboard->GetKeyState(0x41)) {
|
||||
gameObject->transform->SetLocalPosition(gameObject->transform->GetLocalPosition() - gameObject->transform->right() * (deltaTime * move_speed));
|
||||
}
|
||||
|
||||
if (keyboard->GetKeyState(0x44)) {
|
||||
gameObject->transform->SetLocalPosition(gameObject->transform->GetLocalPosition() + gameObject->transform->right() * (deltaTime * move_speed));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private:
|
||||
float _angle_x;
|
||||
float _angle_y;
|
||||
};
|
||||
#endif // FreeCameraController_h__
|
||||
Binary file not shown.
@@ -0,0 +1,167 @@
|
||||
#include <Windows.h>
|
||||
#include "LEditor.h"
|
||||
#include <tchar.h>
|
||||
#include "LEngine.h"
|
||||
#include "Ui.h"
|
||||
#include "Controls/UiHwndCoreWindow.h"
|
||||
#include "Controls/UiSwapChainWindow.h"
|
||||
#include "RenderTargetOutput.h"
|
||||
#include "SwapChainOutput.h"
|
||||
#include "Mesh.h"
|
||||
#include "GameObject.h"
|
||||
#include "SceneRenderer.h"
|
||||
#include "AssetManager.h"
|
||||
#include "ObjMeshLoader.h"
|
||||
#include "FreeCameraController.h"
|
||||
#include "Input.h"
|
||||
#include <chrono>
|
||||
#include "BoundsView.h"
|
||||
#include <objbase.h>
|
||||
#include "AssetDatabase.h"
|
||||
#include "AssetMetadata.h"
|
||||
#include "OutputArchive.h"
|
||||
#include "InputArchive.h"
|
||||
#include "Asset.h"
|
||||
#include "AssetFile.h"
|
||||
#include <sstream>
|
||||
|
||||
#pragma comment(lib, "lframework.lib")
|
||||
|
||||
GameObjectPtr CreateCube() {
|
||||
auto cubeObject = GameObject::create();
|
||||
cubeObject->AddComponent<MeshRenderer>()->SetMesh(Mesh::Create([](MeshPtr mesh) {MeshGenerator::Cube(mesh, true); }));
|
||||
return cubeObject;
|
||||
}
|
||||
|
||||
struct TestObject : public Object {
|
||||
uint8_t uint8_t_;
|
||||
uint16_t uint16_t_;
|
||||
uint32_t uint32_t_;
|
||||
uint64_t uint64_t_;
|
||||
std::string string_;
|
||||
std::wstring wstring_;
|
||||
|
||||
std::shared_ptr<TestObject> next;
|
||||
|
||||
virtual void serialize(Archive& archive) override {
|
||||
archive << uint8_t_ << uint16_t_ << uint32_t_;
|
||||
archive << uint64_t_ << string_ << wstring_;
|
||||
archive << std::static_pointer_cast<Object>(next);
|
||||
}
|
||||
};
|
||||
|
||||
void SaveScene(const std::wstring& path){
|
||||
AssetDatabase::get().open_asset_file(path);
|
||||
|
||||
AssetFile asset(Guid(1, 2, 3, 4), path);
|
||||
|
||||
//find all game objects
|
||||
auto scene_objects = Object::FindObjectsOfType<GameObject>();
|
||||
|
||||
//add all game objects and components to scene asset
|
||||
for(auto obj : scene_objects){
|
||||
asset.AddObject(obj);
|
||||
auto components = obj->GetComponents<Component>();
|
||||
for (auto component : components) {
|
||||
asset.AddObject(component);
|
||||
}
|
||||
}
|
||||
|
||||
asset.Save();
|
||||
}
|
||||
|
||||
void CreateTestScene(){
|
||||
auto cameraGo = GameObject::create();
|
||||
cameraGo->SetName(L"Main camera");
|
||||
cameraGo->AddComponent<Camera>()->fov = 45.0f;
|
||||
cameraGo->transform->SetLocalPosition(float3(0.0f, 4.0f, -4.0f));
|
||||
cameraGo->AddComponent<FreeCameraController>();
|
||||
}
|
||||
|
||||
void LoadScene(const std::wstring& path){
|
||||
auto archive = AssetDatabase::get().open_asset_file(path);
|
||||
}
|
||||
|
||||
|
||||
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
|
||||
AllocConsole();
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
|
||||
auto ints = Input::Instance();
|
||||
AssetDatabase::get().set_root_path(L"D:\\lengine\\Assets");
|
||||
|
||||
auto editorWindow = UiSwapChainWindow::Create(L"LEngineEditorWindow");
|
||||
auto engine = LEngine::Instance();
|
||||
engine->Init(L"D:/lengine/LEngine/");
|
||||
engine->LoadScene("");
|
||||
|
||||
std::wstring scene = L"TestScene.asset";
|
||||
|
||||
CreateTestScene();
|
||||
//SaveScene(scene);
|
||||
|
||||
//LoadScene(scene);
|
||||
|
||||
auto outputs = engine->GetRenderer()->EnumOutputs();
|
||||
auto modes = engine->GetRenderer()->GetDisplayModes(DXGI_FORMAT_B8G8R8A8_UNORM, outputs[0]);
|
||||
|
||||
editorWindow->size = UiSize(640, 480);
|
||||
|
||||
|
||||
auto output = std::make_shared<SwapChainOutput>(engine->GetRenderer(), editorWindow->GetWindow()->GetHwnd(), 640, 480, false);
|
||||
engine->AddOutput(output);
|
||||
|
||||
auto sceneRenderer = std::make_shared<SceneRenderer>();
|
||||
|
||||
ObjMeshLoader loader;
|
||||
auto ob = loader.Load(L"D:\\lengine\\Assets\\Boxes.obj");
|
||||
//ob[0]->AddComponent<BoundsView>();
|
||||
|
||||
auto mat = Material::Create(Shader::Create(L"shaders/shader.fx"), "");
|
||||
auto tex = AssetManager::Instance()->LoadTexture(L"textures/1_store.dds");
|
||||
mat->GetParametersBlock().SetTexture("diffuse", tex);
|
||||
|
||||
|
||||
for(auto o : ob)
|
||||
{
|
||||
o->GetComponent<MeshRenderer>()->SetMaterial(mat, 0);
|
||||
}
|
||||
|
||||
/*AssetMetadata meta(L"D:\\lengine\\Assets\\Boxes.obj");
|
||||
meta.Save();
|
||||
|
||||
auto& factory = ObjectsFactory::instance();
|
||||
|
||||
*/
|
||||
auto cameras = Object::FindObjectsOfType<Camera>();
|
||||
|
||||
auto cameraGo = cameras[0]->gameObject;
|
||||
|
||||
cameraGo->transform->SetLocalPosition(float3(0.0f, 0.0f, -4.0f));
|
||||
|
||||
typedef std::chrono::high_resolution_clock clock;
|
||||
|
||||
auto last_time = clock::now();
|
||||
float delta_time = 0.0f;
|
||||
|
||||
float totalTime = 0;
|
||||
while (true) {
|
||||
auto now_time = clock::now();
|
||||
delta_time = (float)((double)std::chrono::duration_cast<std::chrono::microseconds>(now_time - last_time).count() / 1000000.0);
|
||||
last_time = now_time;
|
||||
totalTime += delta_time;
|
||||
if(totalTime >= 30.0f)
|
||||
{
|
||||
//sceneRenderer->createPSO = false;
|
||||
}
|
||||
std::chrono::high_resolution_clock::now();
|
||||
LEngine::Instance()->GetActiveScene()->tick(delta_time);
|
||||
sceneRenderer->RenderScene(engine->GetRenderer(), engine->GetActiveScene(), cameraGo->GetComponent<Camera>(), output);
|
||||
editorWindow->Update(1);
|
||||
Input::Instance()->strobe();
|
||||
//output->Present();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource.h"
|
||||
+250091
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 418 KiB |
Binary file not shown.
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B7F1D57A-B85B-46CC-80F5-14DE9E2C69DA}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>LEditor</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>../LEngine;../../nativelinq/nativelinq/nativelinq;D:\directui\DirectUI;D:\github\lframework;%(AdditionalIncludeDirectories);D:\lmath\lmath;D:\github\lframework\lframework</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>../Debug;D:\directui\Debug;D:\github\lframework\Debug;D:\DirectXTex\DirectXTex\Bin\Desktop_2015_Win10\Win32\Debug</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>DXGUID.LIB;DXGI.lib;DirectXTex.lib;DirectUI.lib;d3d11.lib;d3d12.lib;LEngine.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>../LEngine;../../nativelinq/nativelinq/nativelinq;D:\directui\DirectUI;%(AdditionalIncludeDirectories);D:\lmath\lmath;D:\github\lframework\lframework</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>../Release;../../NettleCode/DirectUI/Release;%(AdditionalIncludeDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>DirectUI.lib;d3d12.lib;LEngine.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BoundsView.h" />
|
||||
<ClInclude Include="FreeCameraController.h" />
|
||||
<ClInclude Include="LEditor.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="LEditor.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="LEditor.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="LEditor.ico" />
|
||||
<Image Include="small.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,31 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by LEditor.rc
|
||||
//
|
||||
|
||||
#define IDS_APP_TITLE 103
|
||||
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDD_LEDITOR_DIALOG 102
|
||||
#define IDD_ABOUTBOX 103
|
||||
#define IDM_ABOUT 104
|
||||
#define IDM_EXIT 105
|
||||
#define IDI_LEDITOR 107
|
||||
#define IDI_SMALL 108
|
||||
#define IDC_LEDITOR 109
|
||||
#define IDC_MYICON 2
|
||||
#ifndef IDC_STATIC
|
||||
#define IDC_STATIC -1
|
||||
#endif
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#define _APS_NO_MFC 130
|
||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 418 KiB |
Reference in New Issue
Block a user