Installation

This page explains how to install, build and run the Deform client, as well as how to integrate the Deform SDK in your own application. The instructions below assumes basic knowledge about Microsoft Visual Studio. The Deform SDK is developed and built using Microsoft Visual C++.

If your application is built using another development environment or requires bindings to other languages, feel free to contact support@deformdynamics.com, we will be happy to oblige.

System requirements

In order to build the Deform client and use the SDK, you will need the following:

  1. A computer running Microsoft Windows 10
  2. Visual Studio 2017
  3. CUDA 10.1

Dependencies

The client uses a number of external libraries. It is recommended that you use vcpkg to retrieve all of these external libraries. It can be found here: https://github.com/Microsoft/vcpkg

Once vcpkg is installed, you should copy install_externals.bat and update_externals.bat from the root folder to your vcpkg directory. These files contain scripts for acquiring the latest versions of the SDK dependencies. First, run install_externals.bat to install all externals. Once all dependencies are installed, it is recommended that you run update_externals.bat to update to the latest version of each installed dependency.

Building the Deform client

Open up the Visual Studio solution, located in build/deform_client.sln. Make sure you set the client to be the startup project, and that you use the Release-x64 configuration. Now you are able to build and run the project.

Verification

Once you run the project from within Visual Studio (CTRL+F5), you should see the following demo:




You can use the arrow keys to navigate back and forth between demos.

Adding the Deform SDK to an application

After installing the dependencies using vcpkg as detailed above, adding the Deform SDK to an application is done as follows:

  1. Copy the provided deform_sdk folder to your project.
  2. Make sure that you are using the Release configuration and the x64 platform.
  3. Add the necessary headers to your project by right-clicking your project in Visual Studio, selecting Properties and writing the path to the deform_sdk/include folder under Configuration Properties > C/C++ > Additional Include Directories.
  4. Add $(VcpkgRoot)..\x64-windows-static\include to the additional include directories too. This ensures that the dependencies installed using vcpkg earlier are seen by your project.
  5. Link deform.lib by writing its path (deform_sdk/lib/) to Configuration Properties > Linker > General > Additional Library Directories and adding deform.lib to Configuration Properties > Linker > Input > Additional Dependencies.
  6. Copy the contents of deform_sdk/bin to the working directory of your project. The working directory of the project is shown under Configuration Properties > Debugging > Working Directory.
  7. Create a file called main.cpp with the following contents:
#include "vivace_interface.h"

int main(int argc, char** argv)
{
    IVivace* pVivace = CreateVivace();
    pVivace->Reset();
    pVivace->Load("./deform_config.xml");

    float size = 2;
    int resolution = 51;

    size_t id = pVivace->add_obj_patch(size, size, resolution, resolution);
    pVivace->set_invmass_obj(id, 0, 0);
    pVivace->set_invmass_obj(id, resolution - 1, 0);

    pVivace->Init();

    for (int i = 0; i < 1000; i++)
    {
        pVivace->Update();

        /*
        For an example on how to render the deformable patch using OpenGL,
        see renderer.cpp in the Deform client. Pointers to vertices, normals
        and triangles can be retrieved in the following way:

        Vertices:   pVivace->get_render_pos_pointer();
        Normals:    pVivace->get_render_nor_pointer();
        Triangles:  pVivace->get_render_face_pointer();
        */
    }

    pVivace->Shutdown();
    DestroyVivace();
}

The above program is a minimal example of how to use the Deform SDK. A description of the individual parts of the program follows below. If the program runs without issues, the integration of the Deform SDK was successful.

Code overview

The first three lines create an instance of Vivace and loads a configuration file:

IVivace* pVivace = CreateVivace();
pVivace->Reset();
pVivace->Load("./deform_config.xml");

It then defines a squared patch of size 2x2 with 51x51 vertices:

float size = 2;
int resolution = 51;

size_t id = pVivace->add_obj_patch(size, size, resolution, resolution);

In order for the patch not to fall indefinitely, two vertices are fixed by setting their inverted mass to 0 (or their mass to infinity):

pVivace->set_invmass_obj(id, 0, 0);
pVivace->set_invmass_obj(id, resolution - 1, 0);

The simulation is initialized by calling pVivace->Init(). It is then updated for 1000 frames:

for (int i = 0; i < 1000; i++)
{
    pVivace->Update();
}

Once the loop has finished, the simulation is stopped and the Vivace instance is deallocated:

pVivace->Shutdown();
DestroyVivace();

For more examples of how to use the Deform SDK, see the tutorials.