├── .gitignore
├── .project
├── .vscode
├── launch.json
├── settings.json
└── tasks.json
├── Assets
└── animation.gif
├── AttachWeights
├── AttachWeights.cpp
├── AttachWeights.vcproj
├── AttachWeights.vcxproj
├── AttachWeights.vcxproj.filters
├── Makefile
├── ReadMe.txt
├── stdafx.cpp
└── stdafx.h
├── Makefile
├── Pinocchio.sln
├── Pinocchio.slnenv
├── Pinocchio
├── COPYING
├── Makefile
├── Pinocchio.cpp
├── Pinocchio.h
├── Pinocchio.vcproj
├── Pinocchio.vcxproj
├── Pinocchio.vcxproj.filters
├── attachment.cpp
├── attachment.h
├── debugging.h
├── deriv.h
├── discretization.cpp
├── dtree.h
├── embedding.cpp
├── graphutils.cpp
├── graphutils.h
├── hashutils.h
├── indexer.cpp
├── indexer.h
├── intersector.cpp
├── intersector.h
├── lsqSolver.cpp
├── lsqSolver.h
├── mathutils.h
├── matrix.cpp
├── matrix.h
├── mesh.cpp
├── mesh.h
├── mesh
│ └── fbx.h
├── multilinear.h
├── pinocchioApi.cpp
├── pinocchioApi.h
├── pointprojector.h
├── quaddisttree.h
├── rect.h
├── refinement.cpp
├── skeleton.cpp
├── skeleton.h
├── transform.h
├── utils.h
├── vector.h
└── vecutils.h
├── PinocchioStatic
├── PinocchioStatic.vcproj
├── PinocchioStatic.vcxproj
└── PinocchioStatic.vcxproj.filters
├── Project
├── CMakeLists.txt
├── Makefile
├── Project.vcproj
├── Project.vcxproj
├── Project.vcxproj.filters
├── Shaders
│ └── skeleton
│ │ ├── skeleton_fs.glsl
│ │ └── skeleton_vs.glsl
├── data
│ ├── human.obj
│ ├── joints.out
│ └── skeleton.out
├── defmesh.cpp
├── defmesh.h
├── device.h
├── main.cpp
├── motion.cpp
├── motion.h
├── program.h
├── renderer.h
├── tools.h
├── window.cpp
└── window.h
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | ._*
3 | *.ali
4 | *.o
5 | *.db
6 | *.out
7 | *.log.*
8 | *log.200*
9 | *.orig
10 | *.patch
11 | **b~*
12 | bin/
13 | obj/
14 | Debug/
15 | debug/
16 | Release/
17 | release/
18 | *.obj
19 | \#*
20 | .\#*
21 | *.log
22 | *.pdb
23 | *.ncb
24 | *.user
25 | *.idb
26 | *.dep
27 | *.suo
28 | !**/data/*
29 | **/misc
30 | **/.vs/
31 | **/out/
32 | **/Libs/
33 | **/output/
34 | BuildLog.htm
35 | /debug/
36 | /fltk-1.1.9/
37 | Pinocchio/libpinocchio.a
38 | /cmake-build-debug
39 | .idea
40 | AttachWeights/attachWeights
41 | AttachWeights/AttachWeights
42 | AttachWeights/AttachWeights.exe
43 | AttachWeights/AttachWeightsMac
44 | AttachWeights/AttachWeightsLinux
45 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Pinocchio
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 | ?name?
14 |
15 |
16 |
17 | org.eclipse.cdt.make.core.append_environment
18 | true
19 |
20 |
21 | org.eclipse.cdt.make.core.autoBuildTarget
22 | all
23 |
24 |
25 | org.eclipse.cdt.make.core.buildArguments
26 |
27 |
28 |
29 | org.eclipse.cdt.make.core.buildCommand
30 | make
31 |
32 |
33 | org.eclipse.cdt.make.core.buildLocation
34 | ${workspace_loc:/Pinocchio/Debug}
35 |
36 |
37 | org.eclipse.cdt.make.core.cleanBuildTarget
38 | clean
39 |
40 |
41 | org.eclipse.cdt.make.core.contents
42 | org.eclipse.cdt.make.core.activeConfigSettings
43 |
44 |
45 | org.eclipse.cdt.make.core.enableAutoBuild
46 | false
47 |
48 |
49 | org.eclipse.cdt.make.core.enableCleanBuild
50 | true
51 |
52 |
53 | org.eclipse.cdt.make.core.enableFullBuild
54 | true
55 |
56 |
57 | org.eclipse.cdt.make.core.fullBuildTarget
58 | all
59 |
60 |
61 | org.eclipse.cdt.make.core.stopOnError
62 | true
63 |
64 |
65 | org.eclipse.cdt.make.core.useDefaultBuildCmd
66 | true
67 |
68 |
69 |
70 |
71 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
72 |
73 |
74 |
75 |
76 |
77 | org.eclipse.cdt.core.ccnature
78 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
79 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
80 | org.eclipse.cdt.core.cnature
81 |
82 |
83 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "g++ build and debug active file",
9 | "type": "cppdbg",
10 | "request": "launch",
11 | "program": "${workspaceFolder}/Project/Project",
12 | "args": [ "/home/mansoor/Downloads/human_mesh.obj" ,"-motion", "${workspaceFolder}/Project/data/walk.txt"],
13 | "stopAtEntry": false,
14 | "cwd": "${workspaceFolder}",
15 | "environment": [],
16 | "externalConsole": false,
17 | "MIMode": "gdb",
18 | "setupCommands": [
19 | {
20 | "description": "Enable pretty-printing for gdb",
21 | "text": "-enable-pretty-printing",
22 | "ignoreFailures": true
23 | }
24 | ],
25 | "preLaunchTask": "build",
26 | "miDebuggerPath": "/usr/bin/gdb"
27 | }
28 | ]
29 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.associations": {
3 | "new": "cpp",
4 | "iosfwd": "cpp",
5 | "iostream": "cpp",
6 | "ostream": "cpp",
7 | "array": "cpp",
8 | "string": "cpp",
9 | "string_view": "cpp",
10 | "memory": "cpp",
11 | "istream": "cpp",
12 | "functional": "cpp",
13 | "hash_map": "cpp",
14 | "hash_set": "cpp",
15 | "initializer_list": "cpp",
16 | "utility": "cpp",
17 | "map": "cpp",
18 | "dense": "cpp",
19 | "geometry": "cpp",
20 | "complex": "cpp",
21 | "atomic": "cpp",
22 | "*.tcc": "cpp",
23 | "deque": "cpp",
24 | "unordered_map": "cpp",
25 | "vector": "cpp",
26 | "iterator": "cpp",
27 | "memory_resource": "cpp",
28 | "optional": "cpp",
29 | "fstream": "cpp",
30 | "sstream": "cpp",
31 | "streambuf": "cpp",
32 | "system_error": "cpp",
33 | "tuple": "cpp",
34 | "typeinfo": "cpp",
35 | "algorithm": "cpp",
36 | "cctype": "cpp",
37 | "clocale": "cpp",
38 | "cmath": "cpp",
39 | "cstdarg": "cpp",
40 | "cstddef": "cpp",
41 | "cstdint": "cpp",
42 | "cstdio": "cpp",
43 | "cstdlib": "cpp",
44 | "cstring": "cpp",
45 | "cwchar": "cpp",
46 | "cwctype": "cpp",
47 | "exception": "cpp",
48 | "numeric": "cpp",
49 | "set": "cpp",
50 | "type_traits": "cpp",
51 | "limits": "cpp",
52 | "stdexcept": "cpp",
53 | "cinttypes": "cpp"
54 | }
55 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the tasks.json format
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "label": "build",
8 | "type": "shell",
9 | "command": "cd Project && make && make cleanobj"
10 | },
11 |
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/Assets/animation.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DomainFlag/automatic-rigging-animation/81db10d35da885efe2613c64347d50d4b34bd7c9/Assets/animation.gif
--------------------------------------------------------------------------------
/AttachWeights/AttachWeights.cpp:
--------------------------------------------------------------------------------
1 | // AttachWeights.cpp : Defines the entry point for the console application.
2 | //
3 |
4 | #include "stdafx.h"
5 |
6 | #include
7 |
8 | #include "../Pinocchio/skeleton.h"
9 | #include "../Pinocchio/utils.h"
10 | #include "../Pinocchio/debugging.h"
11 | #include "../Pinocchio/attachment.h"
12 | #include "../Pinocchio/pinocchioApi.h"
13 |
14 | struct ArgData
15 | {
16 | ArgData() :
17 | stopAtMesh(false), stopAfterCircles(false), skelScale(1.), noFit(true),
18 | skeleton(HumanSkeleton()), stiffness(1.),
19 | skelOutName("skeleton.out"), weightOutName("attachment.out")
20 | {
21 | }
22 |
23 | bool stopAtMesh;
24 | bool stopAfterCircles;
25 | string filename;
26 | Quaternion<> meshTransform;
27 | double skelScale;
28 | bool noFit;
29 | Skeleton skeleton;
30 | string skeletonname;
31 | double stiffness;
32 | string skelOutName;
33 | string weightOutName;
34 | };
35 |
36 |
37 | void printUsageAndExit()
38 | {
39 | cout << "Usage: attachWeights filename.{obj | ply | off | gts | stl}" << endl;
40 | cout << " [-skel skelname] [-rot x y z deg]* [-scale s]" << endl;
41 | cout << " [-meshonly | -mo] [-circlesonly | -co]" << endl;
42 | cout << " [-fit] [-stiffness s]" << endl;
43 | cout << " [-skelOut skelOutFile] [-weightOut weightOutFile]" << endl;
44 |
45 | exit(0);
46 | }
47 |
48 | ArgData processArgs(const vector &args)
49 | {
50 | ArgData out;
51 | int cur = 2;
52 | int num = args.size();
53 | if(num < 2)
54 | printUsageAndExit();
55 |
56 | out.filename = args[1];
57 |
58 | while(cur < num) {
59 | string curStr = args[cur++];
60 | if(curStr == string("-skel")) {
61 | if(cur == num) {
62 | cout << "No skeleton specified; ignoring." << endl;
63 | continue;
64 | }
65 | curStr = args[cur++];
66 | if(curStr == string("human"))
67 | out.skeleton = HumanSkeleton();
68 | else if(curStr == string("horse"))
69 | out.skeleton = HorseSkeleton();
70 | else if(curStr == string("kinect"))
71 | out.skeleton = HorseSkeleton();
72 | else if(curStr == string("quad"))
73 | out.skeleton = QuadSkeleton();
74 | else if(curStr == string("centaur"))
75 | out.skeleton = CentaurSkeleton();
76 | else
77 | out.skeleton = FileSkeleton(curStr);
78 | out.skeletonname = curStr;
79 | continue;
80 | }
81 | if(curStr == string("-rot")) {
82 | if(cur + 3 >= num) {
83 | cout << "Too few rotation arguments; exiting." << endl;
84 | printUsageAndExit();
85 | }
86 | double x, y, z, deg;
87 | sscanf(args[cur++].c_str(), "%lf", &x);
88 | sscanf(args[cur++].c_str(), "%lf", &y);
89 | sscanf(args[cur++].c_str(), "%lf", &z);
90 | sscanf(args[cur++].c_str(), "%lf", °);
91 |
92 | out.meshTransform = Quaternion<>(Pinocchio::Vector3(x, y, z), deg * M_PI / 180.) * out.meshTransform;
93 | continue;
94 | }
95 | if(curStr == string("-scale")) {
96 | if(cur >= num) {
97 | cout << "No scale provided; exiting." << endl;
98 | printUsageAndExit();
99 | }
100 | sscanf(args[cur++].c_str(), "%lf", &out.skelScale);
101 | continue;
102 | }
103 | if(curStr == string("-meshonly") || curStr == string("-mo")) {
104 | out.stopAtMesh = true;
105 | continue;
106 | }
107 | if(curStr == string("-circlesonly") || curStr == string("-co")) {
108 | out.stopAfterCircles = true;
109 | continue;
110 | }
111 | if(curStr == string("-fit")) {
112 | out.noFit = false;
113 | continue;
114 | }
115 | if(curStr == string("-stiffness")) {
116 | if(cur >= num) {
117 | cout << "No stiffness provided; exiting." << endl;
118 | printUsageAndExit();
119 | }
120 | sscanf(args[cur++].c_str(), "%lf", &out.stiffness);
121 | continue;
122 | }
123 | if(curStr == string("-skelOut")) {
124 | if(cur == num) {
125 | cout << "No skeleton output specified; ignoring." << endl;
126 | continue;
127 | }
128 | curStr = args[cur++];
129 | out.skelOutName = curStr;
130 | continue;
131 | }
132 | if(curStr == string("-weightOut")) {
133 | if(cur == num) {
134 | cout << "No weight output specified; ignoring." << endl;
135 | continue;
136 | }
137 | curStr = args[cur++];
138 | out.weightOutName = curStr;
139 | continue;
140 | }
141 | cout << "Unrecognized option: " << curStr << endl;
142 | printUsageAndExit();
143 | }
144 |
145 | return out;
146 | }
147 |
148 | void process(const vector &args)
149 | {
150 | int i;
151 | ArgData a = processArgs(args);
152 |
153 | Debugging::setOutStream(cout);
154 |
155 | Mesh m(a.filename);
156 | if(m.vertices.size() == 0) {
157 | cout << "Error reading file. Aborting." << endl;
158 | exit(0);
159 | return;
160 | }
161 |
162 | for(i = 0; i < (int)m.vertices.size(); ++i)
163 | m.vertices[i].pos = a.meshTransform * m.vertices[i].pos;
164 | m.normalizeBoundingBox();
165 | m.computeVertexNormals();
166 |
167 | Skeleton given = a.skeleton;
168 | given.scale(a.skelScale * 0.7);
169 |
170 | if(a.stopAtMesh) { //if early bailout
171 | return;
172 | }
173 |
174 | PinocchioOutput o;
175 | if(!a.noFit) { //do everything
176 | o = autorig(given, m);
177 | }
178 | else { //skip the fitting step--assume the skeleton is already correct for the mesh
179 | TreeType *distanceField = constructDistanceField(m);
180 | VisTester *tester = new VisTester(distanceField);
181 |
182 | o.embedding = a.skeleton.fGraph().verts;
183 | for(i = 0; i < (int)o.embedding.size(); ++i)
184 | o.embedding[i] = m.toAdd + o.embedding[i] * m.scale;
185 |
186 | o.attachment = new Attachment(m, a.skeleton, o.embedding, tester, a.stiffness);
187 |
188 | delete tester;
189 | delete distanceField;
190 | }
191 |
192 | if(o.embedding.size() == 0) {
193 | cout << "Error embedding" << endl;
194 | exit(0);
195 | }
196 |
197 | //output skeleton embedding
198 | for(i = 0; i < (int)o.embedding.size(); ++i)
199 | o.embedding[i] = (o.embedding[i] - m.toAdd) / m.scale;
200 | ofstream os(a.skelOutName.c_str());
201 | for(i = 0; i < (int)o.embedding.size(); ++i) {
202 | os << i << " " << o.embedding[i][0] << " " << o.embedding[i][1] <<
203 | " " << o.embedding[i][2] << " " << a.skeleton.fPrev()[i] << endl;
204 | }
205 |
206 | //output attachment
207 | std::ofstream astrm(a.weightOutName.c_str());
208 | for(i = 0; i < (int)m.vertices.size(); ++i) {
209 | Vector v = o.attachment->getWeights(i);
210 | for(int j = 0; j < v.size(); ++j) {
211 | double d = floor(0.5 + v[j] * 10000.) / 10000.;
212 | astrm << d << " ";
213 | }
214 | astrm << endl;
215 | }
216 |
217 | delete o.attachment;
218 | }
219 |
220 |
221 | int main(int argc, char **argv)
222 | {
223 |
224 | vector args;
225 | for(int i = 0; i < argc; ++i)
226 | args.push_back(argv[i]);
227 | process(args);
228 |
229 | return 0;
230 | }
231 |
--------------------------------------------------------------------------------
/AttachWeights/AttachWeights.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
25 |
28 |
31 |
34 |
37 |
40 |
52 |
55 |
58 |
61 |
68 |
71 |
74 |
77 |
80 |
83 |
86 |
89 |
92 |
93 |
101 |
104 |
107 |
110 |
113 |
116 |
129 |
132 |
135 |
138 |
148 |
151 |
154 |
157 |
160 |
163 |
166 |
169 |
172 |
173 |
174 |
175 |
176 |
177 |
182 |
185 |
186 |
189 |
190 |
191 |
196 |
199 |
200 |
201 |
206 |
207 |
210 |
211 |
212 |
213 |
214 |
215 |
--------------------------------------------------------------------------------
/AttachWeights/AttachWeights.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {09E0B2DD-ABD8-4202-A4E7-047CC86BA355}
15 | AttachWeights
16 | Win32Proj
17 |
18 |
19 |
20 | Application
21 | v142
22 | Unicode
23 | true
24 |
25 |
26 | Application
27 | v142
28 | Unicode
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | <_ProjectFileVersion>16.0.29511.113
42 |
43 |
44 | $(SolutionDir)$(Configuration)\
45 | $(Configuration)\
46 | true
47 | MinimumRecommendedRules.ruleset
48 |
49 |
50 |
51 |
52 | $(SolutionDir)$(Configuration)\
53 | $(Configuration)\
54 | false
55 | MinimumRecommendedRules.ruleset
56 |
57 |
58 |
59 |
60 |
61 | Disabled
62 | WIN32;_DEBUG;_CONSOLE;PINOCCHIO_STATIC;%(PreprocessorDefinitions)
63 | true
64 | EnableFastChecks
65 | MultiThreadedDebug
66 |
67 | Level3
68 | EditAndContinue
69 |
70 |
71 | true
72 | Console
73 | MachineX86
74 | $(FBX_DIR)/lib/vs2015/x86/debug
75 | libfbxsdk-mt.lib;%(AdditionalDependencies)
76 |
77 |
78 |
79 |
80 | Full
81 | AnySuitable
82 | true
83 | Speed
84 | WIN32;NDEBUG;_CONSOLE;PINOCCHIO_STATIC;%(PreprocessorDefinitions)
85 | MultiThreaded
86 |
87 | Level3
88 | ProgramDatabase
89 |
90 |
91 | $(OutDir)$(ProjectName)Win.exe
92 | true
93 | Console
94 | true
95 | true
96 | MachineX86
97 | $(FBX_DIR)/lib/vs2015/x86/release
98 | libfbxsdk-mt.lib;%(AdditionalDependencies)
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 | {f66ad322-abb4-4992-8fef-bb9cb6bdd9d7}
114 | false
115 |
116 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/AttachWeights/AttachWeights.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 |
26 |
27 | Header Files
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/AttachWeights/Makefile:
--------------------------------------------------------------------------------
1 | # OS-Specfic Stuff
2 | ifeq ($(OSTYPE),darwin)
3 | OS_COMPILE_FLAGS = -DOSX
4 | TARGET_EXT = Mac
5 | else
6 | # LINUX stuff
7 | OS_COMPILE_FLAGS = -DLINUX
8 | TARGET_EXT = Linux
9 | endif
10 |
11 | LIBS = -lm -pthread -I./../fbx/include -lfbxsdk -I/usr/include/libxml2/libxml -lxml2 -ldl -lrt -luuid -lz
12 |
13 | CC = g++
14 | # CCFLAGS = -c -O3 -Wall -fPIC $(OS_COMPILE_FLAGS)
15 | # Uncomment this to use a debug version
16 | CCFLAGS = -c -g3 -O0 -Wall $(LIBS) -fPIC $(OS_COMPILE_FLAGS)
17 |
18 | TARGETBASE = AttachWeights
19 | TARGET = $(TARGETBASE)$(TARGET_EXT)
20 |
21 | $(TARGET) : stdfx.o $(TARGETBASE).o
22 | gcc -O3 -Wall -fPIC -o $(TARGET) stdafx.o $(TARGETBASE).o ../Pinocchio/libpinocchio.a -lstdc++ -lm $(LIBS)
23 |
24 | stdfx.o : stdafx.cpp stdafx.h
25 | $(CC) $(CCFLAGS) stdafx.cpp
26 |
27 | $(TARGET).o : stdafx.h
28 | $(CC) $(CCFLAGS) $(TARGET).cpp
29 |
30 | clean :
31 | rm -f *.o
32 | rm -f $(TARGET)
33 |
--------------------------------------------------------------------------------
/AttachWeights/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | CONSOLE APPLICATION : AttachWeights Project Overview
3 | ========================================================================
4 |
5 | AppWizard has created this AttachWeights application for you.
6 |
7 | This file contains a summary of what you will find in each of the files that
8 | make up your AttachWeights application.
9 |
10 |
11 | AttachWeights.vcproj
12 | This is the main project file for VC++ projects generated using an Application Wizard.
13 | It contains information about the version of Visual C++ that generated the file, and
14 | information about the platforms, configurations, and project features selected with the
15 | Application Wizard.
16 |
17 | AttachWeights.cpp
18 | This is the main application source file.
19 |
20 | /////////////////////////////////////////////////////////////////////////////
21 | Other standard files:
22 |
23 | StdAfx.h, StdAfx.cpp
24 | These files are used to build a precompiled header (PCH) file
25 | named AttachWeights.pch and a precompiled types file named StdAfx.obj.
26 |
27 | /////////////////////////////////////////////////////////////////////////////
28 | Other notes:
29 |
30 | AppWizard uses "TODO:" comments to indicate parts of the source code you
31 | should add to or customize.
32 |
33 | /////////////////////////////////////////////////////////////////////////////
34 |
--------------------------------------------------------------------------------
/AttachWeights/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // AttachWeights.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/AttachWeights/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 |
9 | #include
10 | #ifdef WIN32 // Windows defs
11 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
12 | #include
13 |
14 | #else // linux / OSX defs
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | #ifdef LINUX
32 | #include
33 | #endif
34 |
35 | #include
36 | #include
37 |
38 | // these are needed for Win32/Linux string comparisons
39 | #define stricmp strcasecmp
40 | #define strnicmp strncasecmp
41 |
42 | typedef int BOOL;
43 | typedef long int LONG;
44 | typedef short int SHORT;
45 | typedef char CHAR;
46 |
47 | typedef unsigned long int DWORD;
48 | typedef unsigned short WORD;
49 | typedef unsigned char BYTE;
50 | typedef unsigned int UINT;
51 |
52 | typedef long long INT64;
53 | typedef unsigned long long UINT64;
54 |
55 | typedef int PT_FILEHANDLE;
56 | typedef void * DLL_HANDLE;
57 |
58 | typedef unsigned long DWORD;
59 | typedef unsigned long* LPDWORD;
60 | typedef void* LPOVERLAPPED;
61 | typedef void* OVERLAPPED;
62 | typedef void* LPVOID;
63 | typedef void* PVOID;
64 | typedef void VOID;
65 | typedef int HANDLE; // note that handle here is assumed to be
66 | // a pointer to a file decriptor
67 | typedef int* PHANDLE;
68 | typedef int BOOL;
69 |
70 | typedef unsigned long UINT32;
71 | typedef unsigned long ULONG;
72 | typedef unsigned short USHORT;
73 | typedef unsigned char UCHAR;
74 | typedef long long INT64;
75 | typedef long long LARGE_INTEGER;
76 | typedef unsigned char BYTE;
77 |
78 | /* These are defined so we can use TCHAR compatible string calls */
79 | #define _T(arg) arg
80 | #define TCHAR char
81 | #define tstrcpy strcpy
82 | #define tstrncpy strncpy
83 | #define _tcscat strcat
84 | #define _tcscpy(str1, str2) strcpy(str1, str2)
85 | #define _tcslen(str1) strlen(str1)
86 | #define _tfopen(filename, access) fopen(filename, access)
87 | #define _gettc getc
88 | #define _puttc putc
89 | #define _stscanf sscanf
90 | #define _stprintf sprintf
91 | #define _tprintf printf
92 |
93 |
94 |
95 | /* common constants */
96 | #define SUCCESS 0
97 | #define FAILURE -1
98 |
99 | #define IOCTL_FAIL(status) (status < 0)
100 |
101 | /** unusual return codes */
102 | #define UNIMPLEMENTED -1001
103 |
104 | // create some equivalent constants in linux that windows have
105 | #define STATIC static
106 |
107 | #ifndef TRUE
108 | #define TRUE 1
109 | #endif
110 |
111 | #ifndef FALSE
112 | #define FALSE 0
113 | #endif
114 |
115 | #ifndef INVALID_HANDLE_VALUE
116 | #define INVALID_HANDLE_VALUE -1
117 | #endif
118 |
119 | /** sleep for x milliseconds */
120 | inline void nap(unsigned long msec) { usleep(msec*1000); }
121 |
122 | #define Sleep sleep
123 |
124 | typedef double VWTIME;
125 | /** returns the amount of time in seconds since some arbitrary moment. */
126 | inline VWTIME VWGetTime() { return 0.0; }
127 |
128 | #endif // end linux defs
129 |
130 | // TODO: reference additional headers your program requires here
131 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile for Pinocchio
2 |
3 | dirs = Pinocchio AttachWeights
4 | # DemoUI is a windows prog, and on windows, VisualC++ is used,
5 | # so we can ignore it here
6 | # dirs = Pinocchio AttachWeights DemoUI
7 |
8 | # Define a standard makePerDir command, which goes into
9 | # each dir, and runs make $(makerule)
10 | define makePerDir
11 | for dir in $(dirs); \
12 | do \
13 | cd $$dir && { $(MAKE) $(makerule); cd ..; }; \
14 | done
15 | endef
16 |
17 | nullstring :=
18 |
19 | all: makerule = $(nullstring)
20 | depend: makerule = depend
21 | clean: makerule = clean
22 |
23 | all depend clean:
24 | $(makePerDir)
25 |
26 |
27 | #all:
28 | # cd Pinocchio && $(MAKE)
29 | # cd DemoUI && $(MAKE)
30 | #
31 | #depend:
32 | # cd Pinocchio && $(MAKE) depend
33 | # cd DemoUI && $(MAKE) depend
34 | #
35 | #clean:
36 | # cd Pinocchio && $(MAKE) clean
37 | # cd DemoUI && $(MAKE) clean
38 |
39 |
40 | # DO NOT DELETE
41 |
--------------------------------------------------------------------------------
/Pinocchio.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29613.14
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project", "Project\Project.vcxproj", "{D512EF05-3826-4CE9-A527-EF75DF68FE26}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Pinocchio", "Pinocchio\Pinocchio.vcxproj", "{835E35C4-9AB1-4CB3-A8A9-A0B89171280D}"
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AttachWeights", "AttachWeights\AttachWeights.vcxproj", "{09E0B2DD-ABD8-4202-A4E7-047CC86BA355}"
11 | EndProject
12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PinocchioStatic", "PinocchioStatic\PinocchioStatic.vcxproj", "{F66AD322-ABB4-4992-8FEF-BB9CB6BDD9D7}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Win32 = Debug|Win32
17 | Release|Win32 = Release|Win32
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {D512EF05-3826-4CE9-A527-EF75DF68FE26}.Debug|Win32.ActiveCfg = Debug|Win32
21 | {D512EF05-3826-4CE9-A527-EF75DF68FE26}.Debug|Win32.Build.0 = Debug|Win32
22 | {D512EF05-3826-4CE9-A527-EF75DF68FE26}.Release|Win32.ActiveCfg = Release|Win32
23 | {D512EF05-3826-4CE9-A527-EF75DF68FE26}.Release|Win32.Build.0 = Release|Win32
24 | {835E35C4-9AB1-4CB3-A8A9-A0B89171280D}.Debug|Win32.ActiveCfg = Debug|Win32
25 | {835E35C4-9AB1-4CB3-A8A9-A0B89171280D}.Debug|Win32.Build.0 = Debug|Win32
26 | {835E35C4-9AB1-4CB3-A8A9-A0B89171280D}.Release|Win32.ActiveCfg = Release|Win32
27 | {835E35C4-9AB1-4CB3-A8A9-A0B89171280D}.Release|Win32.Build.0 = Release|Win32
28 | {09E0B2DD-ABD8-4202-A4E7-047CC86BA355}.Debug|Win32.ActiveCfg = Debug|Win32
29 | {09E0B2DD-ABD8-4202-A4E7-047CC86BA355}.Debug|Win32.Build.0 = Debug|Win32
30 | {09E0B2DD-ABD8-4202-A4E7-047CC86BA355}.Release|Win32.ActiveCfg = Release|Win32
31 | {09E0B2DD-ABD8-4202-A4E7-047CC86BA355}.Release|Win32.Build.0 = Release|Win32
32 | {F66AD322-ABB4-4992-8FEF-BB9CB6BDD9D7}.Debug|Win32.ActiveCfg = Debug|Win32
33 | {F66AD322-ABB4-4992-8FEF-BB9CB6BDD9D7}.Debug|Win32.Build.0 = Debug|Win32
34 | {F66AD322-ABB4-4992-8FEF-BB9CB6BDD9D7}.Release|Win32.ActiveCfg = Release|Win32
35 | {F66AD322-ABB4-4992-8FEF-BB9CB6BDD9D7}.Release|Win32.Build.0 = Release|Win32
36 | EndGlobalSection
37 | GlobalSection(SolutionProperties) = preSolution
38 | HideSolutionNode = FALSE
39 | EndGlobalSection
40 | GlobalSection(ExtensibilityGlobals) = postSolution
41 | SolutionGuid = {BEEC3BB2-CE3D-4AC0-AEF5-B1A15849DF2F}
42 | EndGlobalSection
43 | EndGlobal
44 |
--------------------------------------------------------------------------------
/Pinocchio.slnenv:
--------------------------------------------------------------------------------
1 | FLTKDIR=$(SolutionDir)\fltk-1.1.9
--------------------------------------------------------------------------------
/Pinocchio/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile for Pinocchio
2 | CC = g++
3 | # CCFLAGS = -c -O3 -Wall -fPIC -lm -DDEBUG -g
4 | CCFLAGS = -c -g3 -O0 -Wall -fPIC
5 | LIBS = -lm -pthread -I./../fbx/include -I/usr/include/libxml2/libxml -lxml2 -ldl -lrt -luuid -lz
6 |
7 | OBJECTS := attachment.o discretization.o indexer.o lsqSolver.o mesh.o \
8 | graphutils.o intersector.o matrix.o skeleton.o embedding.o \
9 | pinocchioApi.o refinement.o
10 |
11 | BUILD_DIR = ./`uname -s`-`uname -m`
12 |
13 | TARGET = libpinocchio.a
14 |
15 | $(TARGET): $(OBJECTS)
16 | ar rcs $@ $^
17 |
18 | .cpp.o:
19 | $(CC) $(CCFLAGS) $(LIBS) $<
20 |
21 |
22 | #do a makedepend and remove all the external dependencies from the makefile
23 | #works on my system, no one else should need to do it.
24 | depend:
25 | makedepend *.cpp > /dev/null >& 1
26 | perl -pi -e 's/\.c\.o/\.o/' Makefile
27 | perl -pi -e 's/\/u[Ss]r[a-zA-Z0-9\+\-\/\.\_]*//' Makefile
28 | perl -pi -e 's/\/u[Ss]r[a-zA-Z0-9\+\-\/\.\_]*//' Makefile
29 | perl -pi -e 's/\/u[Ss]r[a-zA-Z0-9\+\-\/\.\_]*//' Makefile
30 | perl -pi -e 's/\/u[Ss]r[a-zA-Z0-9\+\-\/\.\_]*//' Makefile
31 | perl -pi -e 's/\/u[Ss]r[a-zA-Z0-9\+\-\/\.\_]*//' Makefile
32 | perl -pi -e 's/\/u[Ss]r[a-zA-Z0-9\+\-\/\.\_]*//' Makefile
33 | perl -pi -e 's/\/u[Ss]r[a-zA-Z0-9\+\-\/\.\_]*//' Makefile
34 | perl -pi -e 's/\/u[Ss]r[a-zA-Z0-9\+\-\/\.\_]*//' Makefile
35 | perl -pi -e 's/^[a-zA-Z].*\.o\:\s*$$//' Makefile
36 |
37 | clean:
38 | rm -f $(OBJECTS) libpinocchio.a *~ core gmon.out *.bak
39 |
40 |
41 | # DO NOT DELETE
42 |
43 | Pinocchio.o: Pinocchio.h
44 | attachment.o: attachment.h mesh.h vector.h hashutils.h mathutils.h
45 | attachment.o: Pinocchio.h rect.h skeleton.h
46 | attachment.o: graphutils.h transform.h vecutils.h lsqSolver.h
47 | discretization.o: pinocchioApi.h mesh.h vector.h hashutils.h mathutils.h
48 | discretization.o: Pinocchio.h rect.h
49 | discretization.o: quaddisttree.h dtree.h indexer.h multilinear.h
50 | discretization.o: intersector.h vecutils.h pointprojector.h debugging.h
51 | discretization.o: attachment.h skeleton.h graphutils.h transform.h deriv.h
52 | embedding.o: pinocchioApi.h mesh.h vector.h hashutils.h mathutils.h
53 | embedding.o: Pinocchio.h rect.h quaddisttree.h
54 | embedding.o: dtree.h indexer.h multilinear.h intersector.h vecutils.h
55 | embedding.o: pointprojector.h debugging.h attachment.h skeleton.h
56 | embedding.o: graphutils.h transform.h
57 | graphutils.o: graphutils.h vector.h hashutils.h mathutils.h
58 | graphutils.o: Pinocchio.h debugging.h
59 | indexer.o: indexer.h hashutils.h mathutils.h
60 | indexer.o: Pinocchio.h vector.h
61 | intersector.o: intersector.h mesh.h vector.h hashutils.h mathutils.h
62 | intersector.o: Pinocchio.h rect.h vecutils.h
63 | lsqSolver.o: lsqSolver.h
64 | lsqSolver.o: mathutils.h
65 | lsqSolver.o: Pinocchio.h hashutils.h debugging.h
66 | matrix.o: matrix.h mathutils.h
67 | matrix.o: Pinocchio.h debugging.h
68 | mesh.o: mesh.h mesh/fbx.h vector.h hashutils.h mathutils.h
69 | mesh.o: Pinocchio.h
70 | mesh.o: rect.h utils.h debugging.h
71 | fbx.o: mesh/fbx.h mesh.h
72 | pinocchioApi.o: pinocchioApi.h mesh.h vector.h hashutils.h mathutils.h
73 | pinocchioApi.o: Pinocchio.h rect.h
74 | pinocchioApi.o: quaddisttree.h dtree.h indexer.h multilinear.h intersector.h
75 | pinocchioApi.o: vecutils.h pointprojector.h debugging.h attachment.h
76 | pinocchioApi.o: skeleton.h graphutils.h transform.h
77 | refinement.o: pinocchioApi.h mesh.h vector.h hashutils.h mathutils.h
78 | refinement.o: Pinocchio.h rect.h quaddisttree.h
79 | refinement.o: dtree.h indexer.h multilinear.h intersector.h vecutils.h
80 | refinement.o: pointprojector.h debugging.h attachment.h skeleton.h
81 | refinement.o: graphutils.h transform.h deriv.h
82 | skeleton.o: skeleton.h graphutils.h vector.h hashutils.h mathutils.h
83 | skeleton.o: Pinocchio.h utils.h debugging.h
84 |
--------------------------------------------------------------------------------
/Pinocchio/Pinocchio.cpp:
--------------------------------------------------------------------------------
1 | /* This file is part of the Pinocchio automatic rigging library.
2 | Copyright (C) 2007 Ilya Baran (ibaran@mit.edu)
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | // Pinocchio.cpp : Defines the entry point for the DLL application.
20 | #include "windows.h"
21 | #include "Pinocchio.h"
22 |
23 | #ifdef _MANAGED
24 | #pragma managed(push, off)
25 | #endif
26 |
27 | BOOL APIENTRY DllMain( HMODULE hModule,
28 | DWORD ul_reason_for_call,
29 | LPVOID lpReserved
30 | )
31 | {
32 | switch (ul_reason_for_call)
33 | {
34 | case DLL_PROCESS_ATTACH:
35 | case DLL_THREAD_ATTACH:
36 | case DLL_THREAD_DETACH:
37 | case DLL_PROCESS_DETACH:
38 | break;
39 | }
40 | return TRUE;
41 | }
42 |
43 | #ifdef _MANAGED
44 | #pragma managed(pop)
45 | #endif
46 |
47 |
--------------------------------------------------------------------------------
/Pinocchio/Pinocchio.h:
--------------------------------------------------------------------------------
1 | /* This file is part of the Pinocchio automatic rigging library.
2 | Copyright (C) 2007 Ilya Baran (ibaran@mit.edu)
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | // The following ifdef block is the standard way of creating macros which make exporting
20 | // from a DLL simpler. All files within this DLL are compiled with the PINOCCHIO_EXPORTS
21 | // symbol defined on the command line. this symbol should not be defined on any project
22 | // that uses this DLL. This way any other project whose source files include this file see
23 | // PINOCCHIO_API functions as being imported from a DLL, whereas this DLL sees symbols
24 | // defined with this macro as being exported.
25 | #ifdef _WIN32
26 | #ifdef PINOCCHIO_EXPORTS
27 | #define PINOCCHIO_API __declspec(dllexport)
28 | #else //PINOCCHIO_EXPORTS
29 | #ifdef PINOCCHIO_STATIC
30 | #define PINOCCHIO_API
31 | #else //PINOCCHIO_STATIC
32 | #define PINOCCHIO_API __declspec(dllimport)
33 | #endif //PINOCCHIO_STATIC
34 | #endif //PINOCCHIO_EXPORTS
35 | #else //_WIN32
36 | #define PINOCCHIO_API
37 | #endif //_WIN32
38 |
--------------------------------------------------------------------------------
/Pinocchio/Pinocchio.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
25 |
28 |
31 |
34 |
37 |
40 |
52 |
55 |
58 |
61 |
65 |
68 |
71 |
74 |
77 |
80 |
83 |
86 |
89 |
90 |
98 |
101 |
104 |
107 |
110 |
113 |
126 |
129 |
132 |
135 |
138 |
141 |
144 |
147 |
150 |
153 |
156 |
159 |
162 |
163 |
164 |
165 |
166 |
167 |
172 |
175 |
176 |
179 |
180 |
183 |
184 |
187 |
188 |
191 |
192 |
195 |
196 |
199 |
200 |
203 |
204 |
207 |
208 |
211 |
212 |
215 |
216 |
219 |
220 |
223 |
224 |
225 |
230 |
233 |
234 |
237 |
238 |
241 |
242 |
245 |
246 |
249 |
250 |
253 |
254 |
257 |
258 |
261 |
262 |
265 |
266 |
269 |
270 |
273 |
274 |
277 |
278 |
281 |
282 |
285 |
286 |
289 |
290 |
293 |
294 |
297 |
298 |
301 |
302 |
305 |
306 |
309 |
310 |
313 |
314 |
317 |
318 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
--------------------------------------------------------------------------------
/Pinocchio/Pinocchio.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {835E35C4-9AB1-4CB3-A8A9-A0B89171280D}
15 | Pinocchio
16 | Win32Proj
17 |
18 |
19 |
20 | DynamicLibrary
21 | v142
22 | Unicode
23 | true
24 |
25 |
26 | DynamicLibrary
27 | v142
28 | Unicode
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | <_ProjectFileVersion>16.0.29511.113
42 |
43 |
44 | $(SolutionDir)$(Configuration)\
45 | $(Configuration)\
46 | MinimumRecommendedRules.ruleset
47 |
48 |
49 | $(VC_IncludePath);$(WindowsSDK_IncludePath);$(FBX_DIR)\include
50 | $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(FBX_DIR)\lib
51 |
52 |
53 | $(SolutionDir)$(Configuration)\
54 | $(Configuration)\
55 | MinimumRecommendedRules.ruleset
56 |
57 |
58 | $(VC_IncludePath);$(WindowsSDK_IncludePath);$(FBX_DIR)\include
59 | $(FBX_DIR)\lib;$(LibraryPath)
60 |
61 |
62 |
63 | Disabled
64 | WIN32;_DEBUG;_WINDOWS;_USRDLL;PINOCCHIO_EXPORTS;%(PreprocessorDefinitions)
65 | true
66 | EnableFastChecks
67 | MultiThreadedDebugDLL
68 |
69 | Level3
70 | EditAndContinue
71 | stdcpp14
72 | $(FBX_DIR)/include
73 | true
74 |
75 |
76 | true
77 | $(FBX_DIR)/lib/vs2015/x86/debug
78 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;wininet.lib;libfbxsdk-md.lib;%(AdditionalDependencies)
79 |
80 |
81 |
82 |
83 | Full
84 | AnySuitable
85 | true
86 | Speed
87 | WIN32;NDEBUG;_WINDOWS;_USRDLL;PINOCCHIO_EXPORTS;%(PreprocessorDefinitions)
88 | MultiThreadedDLL
89 |
90 | Level3
91 | ProgramDatabase
92 | $(FBX_DIR)/include
93 |
94 |
95 | $(FBX_DIR)/lib/vs2015/x86/release
96 | wininet.lib;libfbxsdk-md.lib;%(AdditionalDependencies)
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/Pinocchio/Pinocchio.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 | Source Files
19 |
20 |
21 | Source Files
22 |
23 |
24 | Source Files
25 |
26 |
27 | Source Files
28 |
29 |
30 | Source Files
31 |
32 |
33 | Source Files
34 |
35 |
36 | Source Files
37 |
38 |
39 | Source Files
40 |
41 |
42 | Source Files
43 |
44 |
45 | Source Files
46 |
47 |
48 | Source Files
49 |
50 |
51 | Source Files
52 |
53 |
54 |
55 |
56 | Header Files
57 |
58 |
59 | Header Files
60 |
61 |
62 | Header Files
63 |
64 |
65 | Header Files
66 |
67 |
68 | Header Files
69 |
70 |
71 | Header Files
72 |
73 |
74 | Header Files
75 |
76 |
77 | Header Files
78 |
79 |
80 | Header Files
81 |
82 |
83 | Header Files
84 |
85 |
86 | Header Files
87 |
88 |
89 | Header Files
90 |
91 |
92 | Header Files
93 |
94 |
95 | Header Files
96 |
97 |
98 | Header Files
99 |
100 |
101 | Header Files
102 |
103 |
104 | Header Files
105 |
106 |
107 | Header Files
108 |
109 |
110 | Header Files
111 |
112 |
113 | Header Files
114 |
115 |
116 | Header Files
117 |
118 |
119 | Header Files
120 |
121 |
122 | Header Files
123 |
124 |
125 |
--------------------------------------------------------------------------------
/Pinocchio/attachment.h:
--------------------------------------------------------------------------------
1 | /* This file is part of the Pinocchio automatic rigging library.
2 | Copyright (C) 2007 Ilya Baran (ibaran@mit.edu)
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef ATTACHMENT_H
20 | #define ATTACHMENT_H
21 |
22 | #include "mesh.h"
23 | #include "skeleton.h"
24 | #include "transform.h"
25 |
26 | class VisibilityTester
27 | {
28 | public:
29 | virtual ~VisibilityTester() {}
30 | virtual bool canSee(const Pinocchio::Vector3 &v1, const Pinocchio::Vector3 &v2) const = 0;
31 | };
32 |
33 | template class VisTester : public VisibilityTester
34 | {
35 | public:
36 | VisTester(const T *t) : tree(t) {}
37 |
38 | virtual bool canSee(const Pinocchio::Vector3 &v1, const Pinocchio::Vector3 &v2) const //faster when v2 is farther inside than v1
39 | {
40 | const double maxVal = 0.002;
41 | double atV2 = tree->locate(v2)->evaluate(v2);
42 | double left = (v2 - v1).length();
43 | double leftInc = left / 100.;
44 | Pinocchio::Vector3 diff = (v2 - v1) / 100.;
45 | Pinocchio::Vector3 cur = v1 + diff;
46 | while(left >= 0.) {
47 | double curDist = tree->locate(cur)->evaluate(cur);
48 | if(curDist > maxVal)
49 | return false;
50 | //if curDist and atV2 are so negative that distance won't reach above maxVal, return true
51 | if(curDist + atV2 + left <= maxVal)
52 | return true;
53 | cur += diff;
54 | left -= leftInc;
55 | }
56 | return true;
57 | }
58 |
59 | private:
60 | const T *tree;
61 | };
62 | template VisibilityTester *makeVisibilityTester(const T *tree) { return new VisTester(tree); } //be sure to delete afterwards
63 |
64 | class AttachmentPrivate;
65 |
66 | class PINOCCHIO_API Attachment
67 | {
68 | public:
69 | Attachment() : a(NULL) {}
70 | Attachment(const Attachment &);
71 | Attachment(const Mesh &mesh, const Skeleton &skeleton, const vector &match, const VisibilityTester *tester, double initialHeatWeight=1.);
72 | virtual ~Attachment();
73 |
74 | Mesh deform(const Mesh &mesh, const vector > &transforms) const;
75 | Vector getWeights(int i) const;
76 | private:
77 | AttachmentPrivate * a = nullptr;
78 | };
79 |
80 | #endif
81 |
--------------------------------------------------------------------------------
/Pinocchio/debugging.h:
--------------------------------------------------------------------------------
1 | /* This file is part of the Pinocchio automatic rigging library.
2 | Copyright (C) 2007 Ilya Baran (ibaran@mit.edu)
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef DEBUGGING_H
20 | #define DEBUGGING_H
21 |
22 | #include "mathutils.h"
23 |
24 | class Debugging
25 | {
26 | public:
27 | static ostream &out() { return *outStream; }
28 | static void PINOCCHIO_API setOutStream(ostream &os) { outStream = &os; }
29 |
30 | private:
31 | static ostream *outStream;
32 | };
33 |
34 | #endif //DEBUGGING_H
35 |
--------------------------------------------------------------------------------
/Pinocchio/deriv.h:
--------------------------------------------------------------------------------
1 | /* This file is part of the Pinocchio automatic rigging library.
2 | Copyright (C) 2007 Ilya Baran (ibaran@mit.edu)
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef DERIV_H_INCLUDED
20 | #define DERIV_H_INCLUDED
21 |
22 | #include "vector.h"
23 |
24 | template
25 | class Deriv
26 | {
27 | public:
28 | typedef Deriv Self;
29 |
30 | Deriv() : x(Real()) {}
31 | Deriv(const Real &inX) : x(inX) {}
32 | Deriv(const Real &inX, int varNum) : x(inX) { d[varNum] = Real(1.); }
33 | Deriv(const Self &inD) : x(inD.x), d(inD.d) {}
34 | Deriv(const Real &inX, const Vector &inD) : x(inX), d(inD) {}
35 |
36 | Real getReal() const { return x; }
37 | Real getDeriv(int num = 0) const { return d[num]; }
38 |
39 | Self operator*(const Self &other) const { return Self(x * other.x, x * other.d + other.x * d); }
40 | Self operator+(const Self &other) const { return Self(x + other.x, d + other.d); }
41 | Self operator-(const Self &other) const { return Self(x - other.x, d - other.d); }
42 | Self operator/(const Self &other) const { return Self(x / other.x, (other.x * d - x * other.d) / SQR(other.x)); }
43 | Self operator-() const { return Self(-x, -d); }
44 | Self &operator+=(const Self &other) { x += other.x; d += other.d; return *this; }
45 | Self &operator-=(const Self &other) { x -= other.x; d -= other.d; return *this; }
46 | Self &operator*=(const Self &other) { (*this) = (*this) * other; return *this; }
47 | Self &operator/=(const Self &other) { (*this) = (*this) / other; return *this; }
48 |
49 | bool operator<(const Self &other) const { return x < other.x; }
50 | bool operator<=(const Self &other) const { return x <= other.x; }
51 | bool operator>(const Self &other) const { return x > other.x; }
52 | bool operator>=(const Self &other) const { return x >= other.x; }
53 | bool operator==(const Self &other) const { return x == other.x; }
54 | bool operator!=(const Self &other) const { return x != other.x; }
55 |
56 | operator Real() const { return x; }
57 |
58 | //for internal use
59 | const Real &_x() const { return x; }
60 | const Vector &_d() const { return d; }
61 |
62 | private:
63 |
64 | Real x;
65 | Vector d;
66 | };
67 |
68 | #define DerivRV Deriv
69 | #define ONEVAR(func, deriv) template \
70 | DerivRV func(const DerivRV &x) { return DerivRV(func(x._x()), x._d() * (deriv)); }
71 |
72 | ONEVAR(sqrt, Real(0.5) / sqrt(x._x()))
73 | ONEVAR(log, Real(1.) / x._x())
74 | ONEVAR(log10, Real(0.43429448190325182765) / x._x()) //the number is 1 / log(10)
75 | ONEVAR(exp, exp(x._x()))
76 | ONEVAR(sin, cos(x._x()))
77 | ONEVAR(cos, -sin(x._x()))
78 | ONEVAR(tan, Real(1.) / SQR(cos(x._x())))
79 | ONEVAR(acos, Real(-1.) / sqrt(Real(1. - SQR(x._x()))))
80 | ONEVAR(asin, Real(1.) / sqrt(Real(1. - SQR(x._x()))))
81 | ONEVAR(atan, Real(1.) / (Real(1.) + SQR(x._x())))
82 | ONEVAR(fabs, x._x() < Real(0.) ? Real(-1.) : Real(1.))
83 |
84 | #undef ONEVAR
85 | #define TWOVAR(func, derivx, derivy) template \
86 | DerivRV func(const DerivRV &x, const DerivRV &y) { return DerivRV(func(x._x(), y._x()), x._d() * (derivx) + y._d() * (derivy)); }
87 |
88 | TWOVAR(pow, y._x() * pow(x._x(), y._x() - Real(1.)), log(x._x()) * pow(x._x(), y._x()))
89 | TWOVAR(atan2, y._x() / (SQR(x._x()) + SQR(y._x())), -x._x() / (SQR(x._x()) + SQR(y._x())))
90 |
91 | #undef TWOVAR
92 | #undef DerivRV
93 |
94 | template
95 | basic_ostream& operator<<(basic_ostream& os, const Deriv &d)
96 | {
97 | os << "Deriv(" << d._x() << ", " << d._d() << ")";
98 | return os;
99 | }
100 |
101 | #endif //DERIV_H_INCLUDED
102 |
--------------------------------------------------------------------------------
/Pinocchio/dtree.h:
--------------------------------------------------------------------------------
1 | /* This file is part of the Pinocchio automatic rigging library.
2 | Copyright (C) 2007 Ilya Baran (ibaran@mit.edu)
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef DTREE_H
20 | #define DTREE_H
21 |
22 | #include "rect.h"
23 | #include "indexer.h"
24 |
25 | template
26 | class DNode : public Data
27 | {
28 | public:
29 | typedef DNode Self;
30 | typedef Vector Vec;
31 | typedef Rect MyRect;
32 |
33 | int countNodes() const
34 | {
35 | int nodes = 1;
36 | if(children[0] != NULL)
37 | for(int i = 0; i < numChildren; ++i)
38 | nodes += children[i]->countNodes();
39 | return nodes;
40 | }
41 |
42 | int maxLevel() const
43 | {
44 | if(children[0] == NULL)
45 | return 0;
46 | int ml = 0;
47 | for(int i = 0; i < numChildren; ++i)
48 | ml = max(ml, children[i]->maxLevel());
49 | return 1 + ml;
50 | }
51 |
52 | Self *getParent() const { return parent; }
53 | Self *getChild(int idx) const { return children[idx]; }
54 | const MyRect &getRect() const { return rect; }
55 | int getChildIndex() const { return childIndex; }
56 |
57 | static const int numChildren = 1 << Dim;
58 |
59 | private:
60 | DNode(MyRect r) : Data(this), parent(NULL), rect(r)
61 | {
62 | zeroChildren();
63 | Data::init();
64 | }
65 |
66 | DNode(Self *inParent, int inChildIndex) : Data(this), parent(inParent), childIndex(inChildIndex)
67 | {
68 | zeroChildren();
69 | rect = MyRect(inParent->rect.getCorner(childIndex)) | MyRect(inParent->rect.getCenter());
70 | Data::init();
71 | }
72 |
73 | ~DNode()
74 | {
75 | for(int i = 0; i < numChildren; ++i)
76 | if(children[i])
77 | delete children[i];
78 | }
79 |
80 | void split()
81 | {
82 | for(int i = 0; i < numChildren; ++i)
83 | children[i] = new Self(this, i);
84 | }
85 |
86 | template class IDX> friend class DRootNode;
87 |
88 | void zeroChildren() { for(int i = 0; i < numChildren; ++i) children[i] = NULL; }
89 |
90 | //data
91 | Self *parent;
92 | Self *children[numChildren];
93 | int childIndex;
94 |
95 | MyRect rect;
96 | };
97 |
98 | template class Indexer = DumbIndexer>
99 | class DRootNode : public DNode, public Indexer, Dim>
100 | {
101 | public:
102 | typedef DNode Node;
103 | typedef DRootNode Self;
104 | typedef Indexer MyIndexer;
105 | typedef Vector Vec;
106 | typedef Rect MyRect;
107 |
108 | DRootNode(MyRect r = MyRect(Vec(), Vec().apply(bind2nd(plus(), 1.)))) : Node(r)
109 | {
110 | MyIndexer::setRoot(this);
111 | }
112 |
113 | void split(Node *node)
114 | {
115 | node->split();
116 | }
117 | };
118 |
119 | #endif
120 |
--------------------------------------------------------------------------------
/Pinocchio/graphutils.cpp:
--------------------------------------------------------------------------------
1 | /* This file is part of the Pinocchio automatic rigging library.
2 | Copyright (C) 2007 Ilya Baran (ibaran@mit.edu)
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #include "graphutils.h"
20 | #include "debugging.h"
21 |
22 | #define CHECK(pred) { if(!(pred)) { Debugging::out() << "Graph integrity error: " #pred << " in line " << __LINE__ << endl; return false; } }
23 |
24 | bool PtGraph::integrityCheck() const
25 | {
26 | CHECK(verts.size() == edges.size());
27 |
28 | int i, j, k;
29 | for(i = 0; i < (int)edges.size(); ++i) {
30 | for(j = 0; j < (int)edges[i].size(); ++j) {
31 | int cur = edges[i][j];
32 | CHECK(cur >= 0);
33 | CHECK(cur < (int)edges.size());
34 | CHECK(cur != i); //no self edges
35 |
36 | vector::const_iterator it = find(edges[cur].begin(), edges[cur].end(), i);
37 | CHECK(it != edges[cur].end());
38 |
39 | for(k = 0; k < j; ++k) //duplicates
40 | CHECK(cur != edges[i][k]);
41 | }
42 | }
43 |
44 | return true;
45 | }
46 |
47 | ShortestPather::ShortestPather(const PtGraph &g, int root)
48 | {
49 | int sz = g.verts.size();
50 | priority_queue todo;
51 | vector done(sz, false);
52 | prev.resize(sz, -1);
53 | dist.resize(sz, -1);
54 |
55 | todo.push(Inf(0., root, -1));
56 | while(!todo.empty())
57 | {
58 | Inf cur = todo.top();
59 | todo.pop();
60 | if(done[cur.node])
61 | continue;
62 | done[cur.node] = true;
63 | prev[cur.node] = cur.prev;
64 | dist[cur.node] = cur.dist;
65 |
66 | const vector &e = g.edges[cur.node];
67 | for(int i = 0; i < (int)e.size(); ++i) {
68 | if(!done[e[i]]) {
69 | double dist = cur.dist + (g.verts[cur.node] - g.verts[e[i]]).length();
70 | todo.push(Inf(dist, e[i], cur.node));
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Pinocchio/graphutils.h:
--------------------------------------------------------------------------------
1 | /* This file is part of the Pinocchio automatic rigging library.
2 | Copyright (C) 2007 Ilya Baran (ibaran@mit.edu)
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef GRAPHUTILS_H
20 | #define GRAPHUTILS_H
21 |
22 | #include
23 | #include "vector.h"
24 |
25 | struct PtGraph
26 | {
27 | vector verts;
28 | vector > edges;
29 |
30 | bool integrityCheck() const;
31 | };
32 |
33 | class ShortestPather
34 | {
35 | public:
36 | ShortestPather(const PtGraph &g, int root);
37 |
38 | vector pathFrom(int vtx) const
39 | {
40 | vector out(1, vtx);
41 | while(prev[vtx] >= 0)
42 | out.push_back(vtx = prev[vtx]);
43 | return out;
44 | }
45 | double distFrom(int vtx) const { return dist[vtx]; }
46 |
47 | private:
48 | struct Inf
49 | {
50 | Inf(double inDist, int inNode, int inPrev) : dist(inDist), node(inNode), prev(inPrev) {}
51 | bool operator<(const Inf &inf) const { return dist > inf.dist; }
52 | double dist;
53 | int node, prev;
54 | };
55 |
56 | vector prev;
57 | vector dist;
58 | };
59 |
60 | class AllShortestPather
61 | {
62 | public:
63 | AllShortestPather() {}
64 |
65 | AllShortestPather(const PtGraph &g)
66 | {
67 | for(int i = 0; i < (int)g.verts.size(); ++i)
68 | paths.push_back(ShortestPather(g, i));
69 | }
70 |
71 | vector path(int from, int to) const { return paths[to].pathFrom(from); }
72 | double dist(int from, int to) const { return paths[to].distFrom(from); }
73 |
74 | private:
75 | vector paths;
76 | };
77 |
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/Pinocchio/hashutils.h:
--------------------------------------------------------------------------------
1 | /* This file is part of the Pinocchio automatic rigging library.
2 | Copyright (C) 2007 Ilya Baran (ibaran@mit.edu)
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef HASHUTILS_H
20 | #define HASHUTILS_H
21 |
22 | #include "mathutils.h"
23 |
24 | #ifndef _WIN32
25 | #include
26 | #include
27 |
28 | #define _HASH_NAMESPACE __gnu_cxx
29 |
30 | using namespace _HASH_NAMESPACE;
31 |
32 | namespace _HASH_NAMESPACE {
33 | template struct hash >
34 | {
35 | size_t operator()(const pair &p) const { return hash()(p.first) + 37 * hash()(p.second); }
36 | };
37 |
38 | template struct hash
39 | {
40 | size_t operator()(T *p) const { return (size_t)p; }
41 | };
42 | }
43 |
44 | #define MAKE_HASH(type, code) \
45 | namespace _HASH_NAMESPACE { \
46 | template<> struct hash \
47 | { \
48 | size_t operator()(const type &p) const { code } \
49 | }; \
50 | }
51 | #else //MICROSOFT VC 2005
52 | #include