GithubHelp home page GithubHelp logo

david-cattermole / vcglib-maya Goto Github PK

View Code? Open in Web Editor NEW
13.0 4.0 2.0 98 KB

VCG wrapper nodes for Autodesk Maya

License: GNU Lesser General Public License v3.0

CMake 2.59% C++ 90.74% Python 5.54% Shell 0.93% C 0.20%
mesh-data conversion computer-graphics maya maya-plugin c-plus-plus

vcglib-maya's Introduction

VCG Library for command line and Maya

VCG wrapper nodes for Autodesk Maya and standalone command line mesh processing utilities.

This set of nodes and commands for Autodesk Maya are designed to integrate vcglib into the Maya workflow and allow batch mesh processing.

Features

  • Standalone command line utilities for decimation and mesh statistics.
  • Conversion from Maya mesh data to VCG mesh.
  • Conversion from VCG mesh data to Maya mesh.
  • Reading of common mesh formats (OBJ, PLY, etc) files as a Maya node (without storing data into the Maya file).
  • Writing of common mesh formats (OBJ, PLY, etc) using a Maya node.
  • Fine-tuned decimation of mesh data, for optimal quality and speed.
  • Calculation of mesh statistics (area, volume, etc).
  • Cuts mesh faces based on volumetric objects (not 'booleans').

Usage

Example 1

Use the decimator command line utility to decimate Mesh files by a percentage of total faces.

$ decimator /path/to/input.obj /path/to/output.obj 10

Example 2

Create a polygon sphere and decimate it with VCG's triangle decimation algorithm.

import maya.cmds
maya.cmds.loadPlugin('vcgNodes')
sphere = maya.cmds.polySphere()
node = maya.cmds.vcgDecimate(sphere[0], percent=20)

Example 3

A more elaborate node network which performs the following steps.

  1. Read an .OBJ file from disk
  2. Compute the mesh statistics
  3. Decimate the mesh
  4. Write it out to disk
import maya.cmds

# Load the plugin.
maya.cmds.loadPlugin('vcgNodes')

# Create nodes
stubNode = maya.cmds.createNode('polyCube')
readFileNode = maya.cmds.createNode('vcgReadFileNode')
decimateNode = maya.cmds.createNode('vcgDecimateNode')
meshStatsNode = maya.cmds.createNode('vcgMeshStatsNode')
writeFileNode = maya.cmds.createNode('vcgWriteFileNode')
meshNode = maya.cmds.createNode('mesh')
maya.cmds.sets(edit=True, forceElement='initialShadingGroup')

# Connect nodes together
maya.cmds.connectAttr(stubNode + '.output', readFileNode + '.inMesh')
maya.cmds.connectAttr(readFileNode + '.outMesh', meshStatsNode + '.inMesh')
maya.cmds.connectAttr(meshStatsNode + '.outMesh', decimateNode + '.inMesh')
maya.cmds.connectAttr(decimateNode + '.outMesh', meshNode + '.inMesh')
maya.cmds.connectAttr(meshNode + '.outMesh', writeFileNode + '.inMesh')

# Set Input Path
nodeAttr = readFileNode + '.filePath'
inputPath = '/path/to/input_file.obj'
maya.cmds.setAttr(nodeAttr, inputPath, type='string')

# Set Output Path
nodeAttr = writeFileNode + '.filePath'
outputPath = '/path/to/output_file.obj'
maya.cmds.setAttr(nodeAttr, outputPath, type='string')

print 'centre of mass:', maya.cmds.getAttr(meshStatsNode + '.outCentreOfMass')
print 'mass:', maya.cmds.getAttr(meshStatsNode + '.outMass')

# Trigger the write the node
outNodeAttr = writeFileNode + '.outMesh'
maya.cmds.dgeval(outNodeAttr, verbose=True)

Building and Install

Dependencies

Ensure you have the following installed

Build & Install

Run the following commands in a Bash-like shell. Note the following build instructions have been tested on a CentOS 6.x installation.

Download vcglib

Download the stable version of vcglib from github and untar it into the current working directory.

$ wget https://github.com/cnr-isti-vclab/vcglib/archive/v1.0.1.tar.gz
$ tar -xf v1.0.1.tar.gz

If everything worked, you'll have a new directory in your current working directory named 'vcglib-1.0.1', this is the root of the VCG library headers. Everything is related to VCG is contained in this directory.

Optionally you may use any version of VCG, including the latest development branch, however results may be unstable.

Compile VCG Maya Plugin

Now we have our dependencies, we can now compile the Maya plugin. To build with Maya support make sure to set WANT_MAYA=1. You may also turn off building the standalone utilities decimator and meshStats by setting WANT_STANDALONE=0, it is enabled by default.

$ cd <project root>
$ mkdir build
$ cd build
$ cmake \
  -DVCG_INCLUDE_PATH=/path/to/vcglib \
  -DWANT_MAYA=1 \
  -DMAYA_INCLUDE_PATH=/path/to/maya/include \
  -DMAYA_LIB_PATH=/path/to/maya/lib ..
$ make -j 4

Do not forget to add the '..' at the end of the cmake command. For debug you may add the flag '-DCMAKE_BUILD_TYPE=Debug' to cmake.

Install VCG Maya Plugin

Now lets install into our home directory maya 'plug-ins' directory.

$ mkdir ~/maya/<maya version>/plug-ins
$ cd <project root>/build
$ cp vcgNodes.so ~/maya/<maya version>/plug-ins

Testing VCG

To run the test suite that comes with Maya VCG Nodes, cd into the ./test directory and run test.sh. By default only the standalone utilities are tested. To test the Maya nodes edit test.sh.

$ cd <project root>/test
$ ./test.sh

Limitations and Known Bugs

  • Maya Read / Write support is buggy and should not be used in production.
  • Maya / VCG mesh conversion only supports vertex position and triangular faces.
    • UVs are not supported
    • Colour Sets are not supported.

vcglib-maya's People

Contributors

david-cattermole avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

matrixworld

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.