-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a49caf
commit e495d93
Showing
17 changed files
with
685 additions
and
446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[submodule "tinygltf"] | ||
path = tinygltf | ||
url = https://github.com/syoyo/tinygltf.git | ||
[submodule "luajit"] | ||
path = luajit | ||
url = https://luajit.org/git/luajit.git | ||
[submodule "Lua"] | ||
path = Lua | ||
url = https://github.com/himanshugoel2797/Lua.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule luajit
deleted from
983d66
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2021 Himanshu Goel | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
#include "scripting.h" | ||
#include "lua.hpp" | ||
|
||
namespace PVC = ProtoVoxel::Core; | ||
|
||
PVC::Script::Script(){ | ||
state = luaL_newstate(); | ||
luaL_openlibs(state); | ||
//load any standard libraries | ||
} | ||
|
||
PVC::Script::~Script() { | ||
lua_close(state); | ||
} | ||
|
||
void PVC::Script::LoadScript(const char* file) { | ||
luaL_loadfile(state, file); | ||
} | ||
|
||
void PVC::Script::Call(const char* func) { | ||
lua_getglobal(state, func); | ||
lua_call(state, 0, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2021 Himanshu Goel | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
#pragma once | ||
#include "lua.hpp" | ||
|
||
namespace ProtoVoxel::Core { | ||
class Script { | ||
private: | ||
lua_State* state; | ||
public: | ||
Script(); | ||
~Script(); | ||
void LoadScript(const char* file); | ||
void Call(const char* func); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) 2021 Himanshu Goel | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
#define TINYGLTF_IMPLEMENTATION | ||
#define STB_IMAGE_IMPLEMENTATION | ||
#define STB_IMAGE_WRITE_IMPLEMENTATION | ||
#include "tinygltf/tiny_gltf.h" | ||
#include "model.h" | ||
|
||
|
||
static tinygltf::TinyGLTF loader; | ||
|
||
int ProtoVoxel::Misc::Model::LoadModel(const char *file, ProtoVoxel::Misc::Model &m) | ||
{ | ||
tinygltf::Model mdl; | ||
bool sts = loader.LoadBinaryFromFile(&mdl, nullptr, nullptr, file); | ||
if (!sts) return -1; | ||
|
||
for (auto node : mdl.nodes) | ||
{ | ||
struct Mesh mesh; | ||
if (node.mesh != -1) | ||
{ | ||
auto mesh_l = mdl.meshes[node.mesh]; | ||
|
||
//Is a mesh, store the data | ||
//extract mesh data and arrange for rendering, compute AABB too | ||
//need texcoords, vertices and indices | ||
//TODO: extract and store materials (pbr textures + derivative map) | ||
//get mesh rendering working | ||
//setup lua for object simulation | ||
//rudimentary physics engine that simulates forces and gravity | ||
//raycasting object selection | ||
//basic imgui ui for adding parts | ||
//clipmap sphere rendering | ||
} | ||
|
||
//Store properties | ||
for (auto prop_key : node.extras.Keys()) { | ||
auto prop = node.extras.Get(prop_key); | ||
if (prop.IsString()) | ||
mesh.str_props[prop_key] = prop.Get<std::string>(); | ||
|
||
if (prop.IsNumber()) | ||
mesh.num_props[prop_key] = (float)prop.GetNumberAsDouble(); | ||
} | ||
m.meshes.push_back(mesh); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2021 Himanshu Goel | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
#pragma once | ||
#include <string> | ||
#include <vector> | ||
#include <map> | ||
|
||
namespace ProtoVoxel::Misc { | ||
struct Mesh { | ||
private: | ||
public: | ||
std::map<std::string, std::string> str_props; | ||
std::map<std::string, float> num_props; | ||
}; | ||
|
||
class Model { | ||
private: | ||
public: | ||
std::vector<struct ProtoVoxel::Misc::Mesh> meshes; | ||
Model() = default; | ||
static int LoadModel(const char *file, Model &m); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.