Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export animation to glTF format #6

Merged
merged 13 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.

# Coding style
## Coding style

Please use clang-format tool with --style=Google parameter to format your code.

Expand Down
53 changes: 49 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,58 @@
# Monster Mash: New Sketch-Based Modeling and Animation Tool

## Introduction

This is the open-source version of Monster Mash.

Monster Mash is a new sketch-based modeling and animation tool that allows you to quickly sketch a character, inflate it into 3D, and promptly animate it. You can perform all interactions in the sketching plane. No 3D manipulation is required.

The source code and web demo (http://MonsterMash.zone) accompanies a paper **Dvorožňák et al.: Monster Mash: A Single-View Approach to Casual 3D Modeling and Animation** published in ACM Transactions on Graphics 39(6):214 and presented at SIGGRAPH Asia 2020 conference.

The source code is licensed under Apache License, Version 2.0. See the LICENSE file for more details.
The web demo (http://MonsterMash.zone) and its source code that is available here accompanies a paper **Dvorožňák et al.: Monster Mash: A Single-View Approach to Casual 3D Modeling and Animation** published in ACM Transactions on Graphics 39(6):214 and presented at SIGGRAPH Asia 2020 conference. (See the [project page](https://dcgi.fel.cvut.cz/home/sykorad/monster_mash) for more details.)

Monster Mash uses the Triangle library (https://www.cs.cmu.edu/~quake/triangle.html) which is not a part of this repository. Before compiling the project, please download the source code of the library and place it in the third_party/triangle directory. Please check the license of the Triangle library before doing so.
The demo uses a combination of web technologies (mainly for UI) and C++ code.

Disclaimer: This is not an officially supported Google product.

## License

The source code in the "src" directory is licensed under Apache License, Version 2.0. See the LICENSE file for more details. Note that third party code located in the "third_party" directory may be licensed under more restrictive licenses.

## Building

This project uses CMake (https://cmake.org) for building. Some third party libraries are not part of this repository and must be installed in advance:
* SDL library v. 2.0 (https://www.libsdl.org).
* Triangle library (https://www.cs.cmu.edu/~quake/triangle.html): Before compiling the project, please download the source code of the library and place it in the "third_party/triangle" directory. Please check the license of the Triangle library before doing so.

You can build the complete web application using emscripten (https://emscripten.org/), or a simplified desktop version (i.e., only a canvas without a web-based UI) using clang (https://clang.llvm.org/) or gcc (https://gcc.gnu.org/).

### Building on Linux

#### Instructions for building on Ubuntu 20.04

* Download and install the necessary dependencies by running:
```
sudo apt-get install build-essential cmake libsdl2-dev wget unzip git python3
```
*(You can remove `python3` if you only want the desktop version.)*
* Clone this repository into your home directory and change directory to the repo:
```
git clone https://github.com/google/monster-mash.git ~/monster-mash && cd ~/monster-mash
```
* Download the Triangle library and unzip it into the appropriate directory:
```
wget http://www.netlib.org/voronoi/triangle.zip && unzip triangle.zip -d third_party/triangle
```
* *(Skip if you only want the desktop version.)* Download and install emscripten by following instructions on https://emscripten.org/docs/getting_started/downloads.html
* Create a directory for building and change to it:
```
mkdir -p ./build/Release && cd ./build/Release
```
* Build the project:
* For the complete web version, build the project using emscripten:
```
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=PATH_TO_EMSDK/upstream/emscripten/emcc -DCMAKE_CXX_COMPILER=PATH_TO_EMSDK/upstream/emscripten/em++ ../../src && make
```
(Replace PATH_TO_EMSDK with the path to your emsdk directory.)
* For the desktop version, build the project using clang/gcc:
```
cmake -DCMAKE_BUILD_TYPE=Release ../../src && make
```
11 changes: 11 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set(SOURCES
mypainter.cpp
mywindow.cpp
def3dsdl.cpp
exportgltf.cpp
../third_party/ir3d-utils/regionToMesh.cpp
../third_party/ir3d-utils/MeshBuilder.cpp
../third_party/image/imageReadWrite.cpp
Expand All @@ -40,6 +41,7 @@ set(SOURCES
../third_party/zip-mod/zip.c
../third_party/SDL2_gfx-mod/SDL2_gfxPrimitives-mod.c
../third_party/SDL2_gfx/SDL2_rotozoom.c
../third_party/tinygltf/tinygltf.cpp
)

set(HEADERS
Expand All @@ -53,6 +55,7 @@ set(HEADERS
mywindow.h
def3dsdl.h
macros.h
exportgltf.h
../third_party/ir3d-utils/regionToMesh.h
../third_party/image/image.h
../third_party/image/imageReadWrite.hpp
Expand All @@ -79,6 +82,9 @@ if (CMAKE_CXX_COMPILER MATCHES "em\\+\\+$")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")

# Dirty hack: FE_UNDERFLOW is missing in emscripten (https://github.com/emscripten-core/emscripten/commit/3d6116296e8bc2ed601f109edcbbd9e33ed3b705)
set(DEFINES ${DEFINES} FE_UNDERFLOW=16)
else()
message("Compiling for Linux")
# SDL2
Expand Down Expand Up @@ -121,6 +127,10 @@ set(DEFINES ${DEFINES}
EIGEN_MPL2_ONLY
EIGEN_SPARSESOLVERBASE_H
_SDL2_gfxPrimitives_h
TINYGLTF_NO_STB_IMAGE
TINYGLTF_NO_STB_IMAGE_WRITE
TINYGLTF_NO_EXTERNAL_IMAGE
TINYGLTF_USE_CPP14
APP_VERSION=${APP_VERSION_VAR}
)

Expand All @@ -139,6 +149,7 @@ set(INCLUDEPATH
../third_party/zip-mod
../third_party/SDL2_gfx
../third_party/SDL2_gfx-mod
../third_party/tinygltf
${SDL2_INCLUDE_DIRS}
)

Expand Down
4 changes: 2 additions & 2 deletions src/commonStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ struct RecData {
bool interiorDepthConditions = false;
};

typedef struct {
struct PauseStatus {
bool defPaused = false;
bool animPaused = false;
} PauseStatus;
};

struct CameraData {
bool ortho = true;
Expand Down
4 changes: 2 additions & 2 deletions src/cpanim.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

class CPAnim {
public:
typedef struct {
struct Keypose {
Eigen::Vector3d p;
int timestamp;
bool empty = true;
bool display = false;
bool have_timestamp = true;
} Keypose;
};

CPAnim();
CPAnim(unsigned int length, const Eigen::Vector3d &p);
Expand Down