Hello World

From The Foundry MODO SDK wiki
Revision as of 19:07, 31 January 2012 by Shf (Talk | contribs) (Created page with "So you've decided to write a plug-in. Good for you! This "Hello World!" tutorial will cover the absolute minimum steps required to create a plug-in and get feedback inside the ap...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

So you've decided to write a plug-in. Good for you! This "Hello World!" tutorial will cover the absolute minimum steps required to create a plug-in and get feedback inside the application.

Preparation

Build Environment Setup

You need to do three things to be ready to start coding a plug-in.

  1. Include headers. The lxsdk header directory needs to be on the compiler search path.
  2. Build common lib. The common code library archive needs to be built using your compiler and environment. You will link your plug-in to this library to get base implementations for the shared classes and objects.
  3. Empty .cpp file ready to compile and link.

You should be able to get started with this using the provided IDE projects for VC and XCode.

Decide on Your Server Type

A plug-in can't do anything unless it provides one of the proscribed server types for nexus to access. Is this a command, an item type, a tool? Perhaps the plug-in will have multiple servers that all work together. This is something for you to decide.

For the purpose of this tutorial we'll be making an image saver, which is one of the simplest types.

Writing Code

Headers

The first part of your plug-in source file will include the required headers. There are two types of headers you will typically want to use:

  • lx_<system>.hpp -- the user header for any given nexus system will have an L-X-underscore prefix and be of the hpp type. Check the documentation to see which interfaces are defined as part of a given system.
  • lxu_<name>.hpp -- utility headers have an L-X-U-underscore prefix, and contain helper classes of various kinds.

In this case we want the io system and image system headers. I/O gives us the definitions for savers and loaders, and Image defines the interfaces for image objects.

#include <lxsdk/lx_io.hpp>
#include <lxsdk/lx_image.hpp>

The Server Class