Skip to content

Commit 6291058

Browse files
committed
- Initial release
1 parent f7e9a1f commit 6291058

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+66955
-2
lines changed

CMakeLists.txt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
cmake_minimum_required(VERSION 2.4)
2+
set(CMAKE_SUPPRESS_REGENERATION "1")
3+
4+
project(MayaPartioTools)
5+
6+
set(CMAKE_DEBUG_POSTFIX "_d")
7+
8+
include_directories(${PROJECT_SOURCE_DIR})
9+
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
10+
11+
if(WIN32)
12+
add_definitions(-DNT_PLUGIN -DGLEW_STATIC)
13+
endif()
14+
if(UNIX)
15+
add_definitions(-DREQUIRE_IOSTREAM)
16+
add_compile_options(-fPIC -m64)
17+
set(PLUGIN_SUFFIX ".so")
18+
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
19+
set(SUFFIX ".so")
20+
set(STD_INCLUDES "." ".." "/usr/X11R6/include" "/usr/include" "/usr/include/CC")
21+
include_directories(${STD_INCLUDES})
22+
add_definitions(-DLINUX)
23+
endif()
24+
25+
subdirs(
26+
extern/glew
27+
extern/partio
28+
extern/zlib
29+
)
30+
31+
add_library(MayaPartioTools SHARED
32+
src/colormap_jet.h
33+
src/colormap_plasma.h
34+
src/PluginMain.cpp
35+
src/PartioEmitter.cpp
36+
src/PartioEmitter.h
37+
src/PartioVisualizer.cpp
38+
src/PartioVisualizer.h
39+
src/PartioVisualizerDrawOverride.cpp
40+
src/PartioVisualizerDrawOverride.h
41+
src/Shader.cpp
42+
src/Shader.h
43+
)
44+
45+
find_package(Maya)
46+
if (MAYA_FOUND)
47+
include_directories(${MAYA_INCLUDE_DIR})
48+
target_link_libraries (MayaPartioTools ${MAYA_LIBRARIES})
49+
endif ()
50+
51+
if(WIN32)
52+
target_link_libraries(MayaPartioTools opengl32.lib glu32.lib glew partio zlib)
53+
else()
54+
target_link_libraries(MayaPartioTools GL GLU partio zlib)
55+
endif()
56+
add_dependencies(MayaPartioTools glew partio zlib)
57+
58+
include_directories(${CMAKE_SOURCE_DIR}/extern/glew/include)
59+
60+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
61+
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
62+
63+
MAYA_PLUGIN(MayaPartioTools)
64+
65+
add_custom_command(TARGET MayaPartioTools PRE_BUILD
66+
COMMAND ${CMAKE_COMMAND} -E copy_directory
67+
${CMAKE_SOURCE_DIR}/scripts $<TARGET_FILE_DIR:MayaPartioTools>/scripts)
68+
69+
70+
71+
72+

Changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1.0
2+
3+
- Initial release

LICENSE

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
MIT License
1+
The MIT License (MIT)
22

3-
Copyright (c) 2019 Interactive Computer Graphics
3+
Copyright (c) 2019 Jan Bender
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22+

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
MayaPartioTools is an open-source plugin to visualize and import particle data in Maya. The plugin can handle all file formats that are supported by the [Partio](https://www.disneyanimation.com/technology/partio.html) library.
2+
3+
This plugin can be used to import and render the particle data generated with our fluid simulation library:
4+
- [https://github.com/InteractiveComputerGraphics/SPlisHSPlasH](https://github.com/InteractiveComputerGraphics/SPlisHSPlasH)
5+
6+
**Author**: [Jan Bender](http://www.interactive-graphics.de), **License**: MIT
7+
8+
9+
## Features
10+
11+
* an open-source Maya plugin to import Partio data
12+
* adds a visualizer node which enables a quick preview using OpenGL rendering
13+
* imports particle data in the particle system of Maya (nParticles)
14+
15+
16+
## Build Instructions
17+
18+
This project is based on [CMake](https://cmake.org/). To build the plugin, the Maya devkit must be installed. If you tell CMake which Maya version you are using, CMake will search for the Maya headers and libraries in the usual Maya directories. CMake generates project files, Makefiles, etc. and then you can compile the project with a compiler of your choice that supports C++11.
19+
20+
The code was tested with the following configurations:
21+
- Windows 10 64-bit, CMake 3.11.2, Visual Studio 2017
22+
- Debian 9 64-bit, CMake 3.12.3, GCC 6.3.0.
23+
24+
25+
## Installation
26+
27+
Just load the plugin in Plug-in Manager of Maya.
28+
29+
Note: The plugin needs the scripts directory. So if you copy the plugin, also copy the scripts folder.
30+
31+
32+
## Usage
33+
34+
After loading the plugin a new menu appears which is called "Partio Tools". It allows you to create the node types:
35+
36+
* PartioVisualizerNode: This node allows you to visualize large sets of particles in the Maya UI using OpenGL. Typically this can be used to generate a quick preview.
37+
* PartioEmitterNode: This node reads particle data from any Partio format and generates Maya nParticles. In this way the particles can be rendered.
38+
39+
40+
### PartioVisualizerNode
41+
42+
<img src="images/visualizer_gui.jpg" height="347"> <img src="images/visualizer.jpg" height="347">
43+
44+
This node can visualize large sets of particles in Maya's viewport 2.0 using OpenGL and some shader programs. The PartioVisualizerNode can be used to get a quick preview of a particle file sequence.
45+
46+
* Particle File: Location of your particle files (e.g. c:/example/particle_data_#.bgeo), where # is a placeholder for the index
47+
* Radius: The particle radius
48+
* Frame Index: The index of the frame which should be loaded. By default a expression is used to set this index to the current time index but this expression can also be changed in Maya.
49+
* Attr. used for coloring: Attribute in the partio file which should be used for coloring the particles. Any float or vector field can be used.
50+
* Min val: The minimum value of the attribute used for coloring. Smaller values will be clamped.
51+
* Max val: The maximum value of the attribute used for coloring. Larger values will be clamped.
52+
* Color Map Type: Choice of a color map used for coloring. If this is set to none, then the base color is used for the minimum value and white for the maximum value.
53+
* Base Color: Color used if no color map is selected.
54+
55+
56+
57+
### PartioEmitterNode
58+
59+
<img src="images/emitter_gui.jpg" height="324"> <img src="images/emitter.jpg" height="324">
60+
61+
The PartioEmitterNode imports particles from partio files in Maya. If you create a new PartioEmitterNode, the plugin will also create an nParticle node and connect both. So your particles are imported in Maya's nParticle system.
62+
Moreover, an aiStandardSurface will be created and connected with a ramp that is used to color the particles. The color depends on the user-defined scalar or vector field (Attr. used for coloring).
63+
64+
* Particle File: Location of your particle files (e.g. c:/example/particle_data_#.bgeo), where # is a placeholder for the index
65+
* Frame Index: The index of the frame which should be loaded. By default a expression is used to set this index to the current time index but this expression can also be changed in Maya.
66+
* Attr. used for coloring: Attribute in the partio file which should be used for coloring the particles. Any float or vector field can be used.
67+
* Min val: The minimum value of the attribute used for coloring. Smaller values will be clamped.
68+
* Max val: The maximum value of the attribute used for coloring. Larger values will be clamped.
69+
* Remove particles: This attribute can be used to remove single particles by their index when loading the file. The indices of multiple particles must be separated by a semicolon (e.g. 1001;1005;1100).
70+
* Nucleus Fix: Maya sometimes crashed when removing particles (in scenarios where the particle count varies over time). This fix solved this problem. When enabled, particles are not removed, they are just moved to a place where the camera cannot see them.

cmake/FindMaya.cmake

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Copyright 2017 Chad Vernon
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4+
# associated documentation files (the "Software"), to deal in the Software without restriction,
5+
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
6+
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7+
# furnished to do so, subject to the following conditions:
8+
#
9+
# The above copyright notice and this permission notice shall be included in all copies or
10+
# substantial portions of the Software.
11+
#
12+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13+
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15+
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17+
18+
#.rst:
19+
# FindMaya
20+
# --------
21+
#
22+
# Find Maya headers and libraries.
23+
#
24+
# Imported targets
25+
# ^^^^^^^^^^^^^^^^
26+
#
27+
# This module defines the following :prop_tgt:`IMPORTED` target:
28+
#
29+
# ``Maya::Maya``
30+
# The Maya libraries, if found.
31+
#
32+
# Result variables
33+
# ^^^^^^^^^^^^^^^^
34+
#
35+
# This module will set the following variables in your project:
36+
#
37+
# ``Maya_FOUND``
38+
# Defined if a Maya installation has been detected
39+
# ``MAYA_INCLUDE_DIR``
40+
# Where to find the headers (maya/MFn.h)
41+
# ``MAYA_LIBRARIES``
42+
# All the Maya libraries.
43+
#
44+
45+
# Set a default Maya version if not specified
46+
if(NOT DEFINED MAYA_VERSION)
47+
set(MAYA_VERSION 2018 CACHE STRING "Maya version")
48+
endif()
49+
50+
# OS Specific environment setup
51+
set(MAYA_COMPILE_DEFINITIONS "REQUIRE_IOSTREAM;_BOOL")
52+
set(MAYA_INSTALL_BASE_SUFFIX "")
53+
set(MAYA_TARGET_TYPE LIBRARY)
54+
if(WIN32)
55+
# Windows
56+
set(MAYA_INSTALL_BASE_DEFAULT "C:/Program Files/Autodesk")
57+
set(MAYA_COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS};NT_PLUGIN")
58+
set(MAYA_PLUGIN_EXTENSION ".mll")
59+
set(MAYA_TARGET_TYPE RUNTIME)
60+
elseif(APPLE)
61+
# Apple
62+
set(MAYA_INSTALL_BASE_DEFAULT /Applications/Autodesk)
63+
set(MAYA_COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS};OSMac_")
64+
set(MAYA_PLUGIN_EXTENSION ".bundle")
65+
else()
66+
# Linux
67+
set(MAYA_COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS};LINUX")
68+
set(MAYA_INSTALL_BASE_DEFAULT /usr/autodesk)
69+
if(MAYA_VERSION LESS 2016)
70+
# Pre Maya 2016 on Linux
71+
set(MAYA_INSTALL_BASE_SUFFIX -x64)
72+
endif()
73+
set(MAYA_PLUGIN_EXTENSION ".so")
74+
endif()
75+
76+
set(MAYA_INSTALL_BASE_PATH ${MAYA_INSTALL_BASE_DEFAULT} CACHE STRING
77+
"Root path containing your maya installations, e.g. /usr/autodesk or /Applications/Autodesk/")
78+
79+
set(MAYA_LOCATION ${MAYA_INSTALL_BASE_PATH}/maya${MAYA_VERSION}${MAYA_INSTALL_BASE_SUFFIX})
80+
81+
# Maya include directory
82+
find_path(MAYA_INCLUDE_DIR maya/MFn.h
83+
PATHS
84+
${MAYA_LOCATION}
85+
$ENV{MAYA_LOCATION}
86+
PATH_SUFFIXES
87+
"include/"
88+
"devkit/include/"
89+
)
90+
91+
find_library(MAYA_LIBRARY
92+
NAMES
93+
OpenMaya
94+
PATHS
95+
${MAYA_LOCATION}
96+
$ENV{MAYA_LOCATION}
97+
PATH_SUFFIXES
98+
"lib/"
99+
"Maya.app/Contents/MacOS/"
100+
NO_DEFAULT_PATH
101+
)
102+
set(MAYA_LIBRARIES "${MAYA_LIBRARY}")
103+
104+
include(FindPackageHandleStandardArgs)
105+
find_package_handle_standard_args(Maya
106+
REQUIRED_VARS MAYA_INCLUDE_DIR MAYA_LIBRARY)
107+
mark_as_advanced(MAYA_INCLUDE_DIR MAYA_LIBRARY)
108+
109+
if (NOT TARGET Maya::Maya)
110+
add_library(Maya::Maya UNKNOWN IMPORTED)
111+
set_target_properties(Maya::Maya PROPERTIES
112+
INTERFACE_COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS}"
113+
INTERFACE_INCLUDE_DIRECTORIES "${MAYA_INCLUDE_DIR}"
114+
IMPORTED_LOCATION "${MAYA_LIBRARY}")
115+
116+
if (APPLE AND ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND MAYA_VERSION LESS 2017)
117+
# Clang and Maya 2016 and older needs to use libstdc++
118+
set_target_properties(Maya::Maya PROPERTIES
119+
INTERFACE_COMPILE_OPTIONS "-std=c++0x;-stdlib=libstdc++")
120+
endif ()
121+
endif()
122+
123+
# Add the other Maya libraries into the main Maya::Maya library
124+
set(_MAYA_LIBRARIES OpenMayaAnim OpenMayaFX OpenMayaRender OpenMayaUI Foundation clew)
125+
foreach(MAYA_LIB ${_MAYA_LIBRARIES})
126+
find_library(MAYA_${MAYA_LIB}_LIBRARY
127+
NAMES
128+
${MAYA_LIB}
129+
PATHS
130+
${MAYA_LOCATION}
131+
$ENV{MAYA_LOCATION}
132+
PATH_SUFFIXES
133+
"lib/"
134+
"Maya.app/Contents/MacOS/"
135+
NO_DEFAULT_PATH)
136+
mark_as_advanced(MAYA_${MAYA_LIB}_LIBRARY)
137+
if (MAYA_${MAYA_LIB}_LIBRARY)
138+
add_library(Maya::${MAYA_LIB} UNKNOWN IMPORTED)
139+
set_target_properties(Maya::${MAYA_LIB} PROPERTIES
140+
IMPORTED_LOCATION "${MAYA_${MAYA_LIB}_LIBRARY}")
141+
set_property(TARGET Maya::Maya APPEND PROPERTY
142+
INTERFACE_LINK_LIBRARIES Maya::${MAYA_LIB})
143+
set(MAYA_LIBRARIES ${MAYA_LIBRARIES} "${MAYA_${MAYA_LIB}_LIBRARY}")
144+
endif()
145+
endforeach()
146+
147+
function(MAYA_PLUGIN _target)
148+
if (WIN32)
149+
set_target_properties(${_target} PROPERTIES
150+
LINK_FLAGS "/export:initializePlugin /export:uninitializePlugin")
151+
endif()
152+
set_target_properties(${_target} PROPERTIES
153+
PREFIX ""
154+
SUFFIX ${MAYA_PLUGIN_EXTENSION})
155+
endfunction()

extern/glew/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
if (NOT BUILD_NO_DEMOS)
2+
include_directories(include)
3+
4+
add_library(glew
5+
src/glew.c
6+
include/GL/glew.h
7+
include/GL/glxew.h
8+
include/GL/wglew.h
9+
)
10+
11+
set_target_properties(glew PROPERTIES FOLDER "External Dependencies")
12+
add_definitions(-DGLEW_NO_GLU -DGLEW_STATIC)
13+
14+
if (WIN32)
15+
target_link_libraries(glew opengl32.lib)
16+
endif()
17+
18+
if(APPLE)
19+
include_directories ( /System/Library/Frameworks )
20+
find_library(COCOA_LIBRARY Cocoa)
21+
find_library(GLUT_LIBRARY GLUT )
22+
find_library(OpenGL_LIBRARY OpenGL )
23+
mark_as_advanced (COCOA_LIBRARY
24+
GLUT_LIBRARY
25+
OpenGL_LIBRARY)
26+
set(EXTRA_LIBS ${COCOA_LIBRARY} ${GLUT_LIBRARY} ${OpenGL_LIBRARY})
27+
target_link_libraries(glew ${EXTRA_LIBS})
28+
endif (APPLE)
29+
endif()

0 commit comments

Comments
 (0)