Coder Social home page Coder Social logo

tinyxpd's Introduction

TinyXPD, dependency-free and header-only C++11 XGen XPD cache I/O library.

TinyXPD is a simple library to read/write XGen XPD cache file.

Currently reading/writing spline XPD data is implemented.

Requirement

  • C++11 compiler

Supported platform

  • macOS
  • Linux
  • Windows(Visual Studio 2017 or later)
  • Android
  • iOS
  • Big endian machine(e.g. POWER)

Supported XPD version

  • XPD3(~Maya 2018)

Parsing XPD file

+-----------------------------+   |\
| XPD header                  |   |
+-----------------------------+   | XPD data
|                             |   |
| XPD prim data               |   |
|                             |   |
|                             |   |
+-----------------------------+   |/

XPDHeader contains header information and the list of data offset from the beginning of a XPD data.

Whole XPD data is supplied by the app user(ParseXPDHeaderFromMemory API), or read from a file(ParseXPDFromFile). ParseXPDFromFile API is handy but consumes memory. If you want to open large XPD file(e.g. 1GB or more), consider using ParseXPDHeaderFromMemory API(with mmap-ping a XPD data).

// Do this only in **one** .cc file.
#define TINY_XPD_IMPLEMENTATION
#include "tiny_xpd.h"

std::string filename = "sample.xpd";

XPDHeader xpd_header;
std::vector<uint8_t> xpd_data;
std::string err;

bool ret = ParseXPDFromFile(filename, &xpd_header, &xpd_data, &err);

// From memory(stream) version.
// Fill xpd_data by yourself in some way.
// xpd_data = ...
// bool ret = ParseXPDHeader(xpd_data.data(), xpd_data.size(), &xpd_header, &err);

if (!err.empty()) {
  std::cerr << err << std::endl;
}

if (!ret) {
  std::cerr << "Failed to parse XPD" << std::endl;
}

// See `xpd_reader_example.cc` for how to access primitive data.

Examples

Generating XPD file from Maya

You can use xgSplineDataToXpd sample plug-in(located in /usr/autodesk/maya/plug-ins/xgen/plug-ins/ or write your own XPD writer plugin.

Note on importing XPD in legacy XGen

It looks legaxy XGen's From XPD File feature expects that spline data layout is as defined in xgSplineDataToXpd sample code.

Per CV width

Data layout used in xgSplineDataToXpd example does not support exporting per-CV width. It can only support constant width over CVs(strand), and taper. width ramp is not support.

If you need a spline curve with varying width, you may need to write your own XGen loader(generator) plugin, or bake taper parameter to width ramp value and export/import it in other data format(e.g. python + JSON).

Supported types

  • Curve(XGen interactive grooming splines)
  • Point(xuv)

TODO

  • Support xuv format.

License

MIT license.

tinyxpd's People

Contributors

syoyo avatar

Watchers

James Cloos avatar

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.