Portfolios Introduction

In Visualize, a portfolio is a library where a scene’s materials and resources are stored. Although portfolios exist inside of the Database, they aren’t part of the segment hierarchy. Once a portfolio is created, a segment can use it as its active portfolio, gaining access to all of the its resources. Like other attributes, portfolios are inherited down the segment tree. Portfolios may also be shared among unrelated segments.

../_images/portfolios.png

Portfolios encapsulate resources and exist outside the segment tree

Developers are encouraged to employ reusability and modularity in the design of their scene graphs. An effective way to use portfolios is to associate a unique portfolio with a model segment hierarchy. This allows you to organize and manage your definitions by model. For instance, if you are modelling two similar, but slightly different objects, you might create a separate portfolio for each one. If one model needs resources from the other model’s portfolio, they can be easily imported. In this way, data is not duplicated. The code snippet below demonstrates how to create a portfolio and make it active on a segment:

    HPS::PortfolioKey myPortfolio = HPS::Database::CreatePortfolio();

    mySegmentKey.GetPortfolioControl().Push(myPortfolio);

For a discussion on how to define all the objects (textures, glyphs, style, etc.) that are contained inside a portfolio, please continue reading in the next section.