Skip to content

Commit

Permalink
add compat for SMPL
Browse files Browse the repository at this point in the history
  • Loading branch information
FishWoWater committed Apr 25, 2022
0 parents commit e469f1c
Show file tree
Hide file tree
Showing 2,897 changed files with 2,441,123 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# vscode
.vscode*
.VSCode*
# compiled stuff
build*/
.vscode*
# other stuff
*.kdev4
*~
.ipynb_checkpoints
__pycache__
*.pch
*.tags*
*TAGS*
*tags*

*XDG_CACHE_HOME*

backup_local/*
47 changes: 47 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
cmake_minimum_required(VERSION 3.0)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")

project(arcsim-hylc LANGUAGES CXX VERSION 1.0)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -Wall -Wno-ignored-attributes -Wno-sign-compare -Wno-unused-function -Wno-narrowing -pthread")#-std=c++14

# Visual studio solution directories.
set_property(GLOBAL PROPERTY USE_FOLDERS on)

# Enable simultaneous compilation of source files.
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif(WIN32)

FIND_PACKAGE( OpenMP REQUIRED)
if(OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

if(NOT WIN32)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build,
options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
endif(NOT WIN32)

# Put all executables and libraries into a common directory.
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin")
set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin")


# enable_language(Fortran) # required for fitpackpp

add_subdirectory(dependencies/alglib)
add_subdirectory(dependencies/jsoncpp)
# add_subdirectory(dependencies/fitpackpp)
if(WIN32)
add_subdirectory(dependencies/zlib)
add_subdirectory(dependencies/freeglut)
endif(WIN32)

add_subdirectory(v0.2.1)
# add_subdirectory(v0.3.0)
51 changes: 51 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Copyright (c)2013 The Regents of the University of California
(Regents). All Rights Reserved. Permission to use, copy, modify, and
distribute this software and its documentation for educational,
research, and not-for-profit purposes, without fee and without a
signed licensing agreement, is hereby granted, provided that the
following conditions are met:

1) The text of this license shall appear in all copies,
modifications, and distributions.

2) Programs built on this software will display a copy of this
license when run.

3) Any publication based on work that makes use of this software
shall acknowledge such use and cite:

Rahul Narain, Armin Samii, and James F. O'Brien, "Adaptive
Anisotropic Remeshing for Cloth Simulation", ACM Transactions on
Graphics, 31(6):147:1-10, November 2012, Proceedings of ACM SIGGRAPH
Asia 2012, Singapore.

Rahul Narain, Tobias Pfaff, and James F. O'Brien. "Folding and
Crumpling Adaptive Sheets". ACM Transactions on Graphics,
32(4):51:1-8, July 2013. Proceedings of ACM SIGGRAPH 2013, Anaheim.

4) Any film, video, short, or other animation produced with this
software shall include an acknowledgment of such use in the credits.

Contact The Office of Technology Licensing, UC Berkeley, 2150 Shattuck
Avenue, Suite 510, Berkeley, CA 94720-1620, (510) 643-7201, for
commercial licensing opportunities.

This software was created by Rahul Narain, Armin Samii, Tobias Pfaff,
and James F. O'Brien in the Computer Science Division, Department of
Electrical Engineering and Computer Science, at the University of
California, Berkeley. Contains code and data by Huamin Wang, Ravi
Ramamoorthi, Victor Zordan, Nick Van Der Horst, Min Tang, Dinesh
Manocha, Alexander Reshetov, and Alexei Soupikov, distributed with
permission.

IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF
ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION
TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
MODIFICATIONS.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**A fork version of ARCSim-HYLC() to support SMPL Model**
34 changes: 34 additions & 0 deletions README_HYLC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Homogenized Yarn-Level Cloth - ARCSim

This repository contains the macro-scale/cloth-simulation part of 'Homogenized Yarn-Level Cloth' (Siggraph 2020).

[Project Page: https://visualcomputing.ist.ac.at/publications/2020/HYLC/](https://visualcomputing.ist.ac.at/publications/2020/HYLC/)

For the micro-scale/pattern-optimization part, see the separate repository ["HYLC"](https://git.ist.ac.at/gsperl/HYLC/).

This is a fork / modified version of [ARCSim](http://graphics.berkeley.edu/resources/ARCSim/). The original readme file can be found [here](README_arcsim).

This repository includes source code within `v0.2.1/` (modified from the original ARCSim, especially the `hylc/` subfolder), the already fitted homogenized energies stored in `hylcmaterials/`, the simulation configuration files in `tests/`, and several additions to the `meshes/` folder.

## Usage

Check/call `exec.py` for how to compile and run a single simulation. The simulation config files are found in `tests/` subfolders.
E.g.: `python exec.py tests/2D/conf/stock_stretchX.json` (press space to start the simulation)

`python run_folder.py` can be used to (order and) simulate an entire folder of config files.

## Citation

Note that the [license](LICENSE) of ARCSim requires citing their work.
In addition, please consider citing our work if you find our modified version to be useful:
```bibtex
@article{sperl2020hylc,
author = {Sperl, Georg and Narain, Rahul and Wojtan, Chris},
title = {Homogenized Yarn-Level Cloth},
journal = {ACM Transactions on Graphics (TOG)},
number = {4},
volume = {39},
year = {2020},
publisher = {ACM}
}
```
189 changes: 189 additions & 0 deletions README_arcsim
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
**********************************************************************
ARCSim v0.3.0: Adaptive Refining and Coarsening Simulator

Rahul Narain, Armin Samii, Tobias Pfaff, and James O'Brien
{narain,samii,tpfaff,job}@cs.berkeley.edu
**********************************************************************

This software is provided freely for non-commercial use. See the
LICENSE file for details. If you use the software in your research,
please cite the following papers:

Rahul Narain, Armin Samii, and James F. O'Brien. "Adaptive Anisotropic
Remeshing for Cloth Simulation". ACM Transactions on Graphics,
31(6):147:1-10, November 2012. Proceedings of ACM SIGGRAPH Asia 2012,
Singapore.

Rahul Narain, Tobias Pfaff, and James F. O'Brien. "Folding and
Crumpling Adaptive Sheets". ACM Transactions on Graphics,
32(4):51:1-8, July 2013. Proceedings of ACM SIGGRAPH 2013, Anaheim.

Tobias Pfaff, Rahul Narain, Juan Miguel de Joya, and James F. O'Brien.
"Adaptive Tearing and Cracking of Thin Sheets". ACM Transaction on
Graphics, 33(4):110:1-9, August 2014. Proceedings of ACM SIGGRAPH
2014, Vancouver.

======================================================================
Usage
======================================================================

For compilation instructions, see the INSTALL file. If you're on a
Mac, make sure you have the latest gcc, as described there.

The simulator has various modes, which are called by running it with
the format

bin/arcsim <command> [<args>]

The various command and their inputs can be discovered by running the
executable with no arguments. The main simulation-related commands are
as follows.

* simulate <scene-file> [<out-dir>]

Reads the simulation description given in <scene-file> (try
conf/sphere.json, then see "Scene files" below) and runs the
simulation while displaying the results in an OpenGL window. Press
Space to run the simulation once the window opens, or 'S' to
advance one timestep at a time. If <out-dir> is given, the results
of the simulation are saved in that directory. The format of the
output is described in "Output files".

* simulateoffline <scene-file> [<out-dir>]

Same as 'simulate' but without the OpenGL display. (And you don't
have to press Space to start the simulation.) Useful for running
on a remote server over SSH.

* resume <out-dir> <resume-frame>

Resumes an incomplete simulation saved in <out-dir>, starting at
the given frame number. (Note that if the original scene file has
been changed since the simulation was first run, those changes
will not be respected in the resumed simulation.)

* resumeoffline <out-dir> <resume-frame>

Same as 'resume' but without the OpenGL display.

* replay <out-dir> [<sshot-dir>]

Replays the results of the simulation stored in <out-dir>. The
left and right arrow keys step through the frames; Shift+arrow and
Alt+arrow jump 10 and 100 frames. Hitting Space plays back all the
frames as fast as possible. The Home key returns to frame 0. If
<sshot-dir> is given, the rendered images are also saved there
upon playback.

* generate <out-dir>

Reads the simulation state of a previous "simulate" run, and
generates obj files which can be used for rendering.

----------------------------------------------------------------------
Using the OpenGL interface
----------------------------------------------------------------------

Space: start simulation/playback
Left drag: rotate
Middle drag: translate
Scroll wheel: scale
Esc: exit

----------------------------------------------------------------------
Scene files
----------------------------------------------------------------------

The scene configuration files are written in JSON syntax
(http://www.json.org/). A number of example scenes are provided in the
conf/ directory. The sphere interaction example, conf/sphere.json, is
a good "hello world" scene to check that the simulator is working.

A scene file consists of a single JSON object containing many
name/value pairs describing the parameters and contents of the
simulation. For a full description of all the options, see the file
conf/sphere-annotated.json, which is a heavily commented version of
conf/sphere.json and describes all the settings that can be used.

======================================================================
Creating meshes for simulation
======================================================================

Simulation meshes are saved as OBJ files, with the parametrization
space embedding stored in texture coordinates, and other simulation
data (node velocities, plasticity data, etc.) in custom fields. These
meshes can be imported or viewed as usual in 3D software.

If you want to use a flat sheet of material cut in an arbitrary shape,
as specified by a triangle mesh in the xy-plane, this requires no
extra effort. The simulator will simply assume the rest shape to be
identical to the initial input. For this to work correctly, however,
(i) the input mesh must have no texture coordinates specified; (ii)
the mesh should lie in the xy-plane (its initial pose in the scene can
be changed using the scene file); and (iii) all faces should be
positively oriented, i.e. their vertices must be listed in
counter-clockwise order.

Simulating a garment composed of multiple panels sewn together
requires a little initial setting-up. At present, we only support
garments that form manifolds with consistent orientation. Having more
than two faces meeting along an edge, as occurs with pockets, or
joining the back side of one panel with the front side of another,
will break the simulation.

First, we model the panels laid flat and positively oriented in the
xy-plane as above, and save them in a nonoverlapping arrangement in a
single OBJ file. Call this the parametrization-space mesh. If two
boundaries are to be joined into a seam, care must be taken in this
step to have them discretized consistently, with both sides having the
same number of vertices and equal lengths of corresponding edges.

Second, we take the same mesh and move its vertices into the desired
initial positions in world space, say around a posed character. We
indicate seams and darts by placing two or more boundary vertices very
close to each other; in the next step, such vertices will be fused
together. Here, though, we only move vertices, but must not modify the
mesh topology. This is saved as the world-space mesh.

Finally, the parametrization-space and world-space meshes are combined
to form a mesh in which the seam vertices have been fused, but the
intrinsic flat shapes of the panels are still intact in texture
coordinates. This is done with the command

bin/arcsim merge <param-mesh> <world-mesh> <out-mesh> [<thresh>]

where the optional <thresh> (default 0.01) sets the maximum distance
threshold between vertices to be merged.

For an example of this procedure, see the meshes named tshirtm.obj,
tshirtw.obj, and tshirt.obj in the meshes/ direectory.

======================================================================
Output files
======================================================================

The output of the simulation consists of a number of files:

* conf.json is a copy of the scene file that was used to run the
simulation. This is useful for resuming, replaying, and general
future reference.

* <frame>.bin is the full simulation state of frame <frame>. To
generate obj files from the simulation state, a post-processing run
of bin/arcsim generate <outdir> has to be executed.

* <frame>_<i>.obj is the mesh for the <i>th cloth at the given frame
number. A simulation may have multiple articles of cloth, e.g. the
pants, t-shirt, and vest of the kicking character.

* obs_<j>.obj is a copy of the geometry of the <j>th obstacle in its
reference pose.

* <frame>obs<j>.txt is an XML fragment describing the transformation
of the <j>th obstacle at the given frame. It is only used to plug
into the Mitsuba scene file when rendering. The resume and replay
code ignores it, instead reconstructing the obstacle motion from the
specification in conf.json.

* timing is a dump of the wall-clock compute time spent per time step
in each routine of the simulation.
32 changes: 32 additions & 0 deletions conf/crumple-pnas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Aluminium foil disk crumpled in a shrinking sphere
// Narain et al. 2013, Figure 8
{
"frame_time": 0.01,
"frame_steps": 10,
"duration": 5,
"cloths": [{
"mesh": "meshes/disk.obj",
"transform": {"scale": 50e-3},
// "transform": {"translate": [0.5, 0, 0.5]},
"materials": [{
"data": "materials/aluminium.json",
"yield_curv": 150
}],
"remeshing": {
"refine_angle": 0.2,
"refine_compression": 10e-6,
"size": [1e-3, 20e-3],
"aspect_min": 0.2
}
}],
"motions": [[
{"time": 0, "transform": {"scale": 51e-3}},
{"time": 2.5, "transform": {"scale": 20e-3}},
{"time": 5, "transform": {"scale": 8.2e-3}}
]],
"obstacles": [{
"mesh": "meshes/sphere-inv.obj",
"motion": 0
}],
"magic": {"collision_stiffness": 1e10, "repulsion_thickness": 2.5e-4}
}
Loading

0 comments on commit e469f1c

Please sign in to comment.