Core Scene Graph Data Structures in C++


PixelTexture and ImageTexture

In the VRML’97 Standard the texture field of an Appearance node is allowed to contain pointers to several different texture nodes. In the DGP2023 implementation the texture field of an Appearance node is only allowed to contain a pointer to an ImageTexture node, which is implemented as a subclass of the PixelTexture node, or to directly to a PixelTexture node.

The TextureTransform node is not implemented as a class in the DGP2023 application, and the Appearance class does not contain a field to store a pointer to an instance of a TextureTransform node. Along the same lines, the DGP2023 application does not yet include a class to represent images. In the DGP2023 data structures the PixelTexture node is implemented as a separate class just because it make sense to make ImageTexture a subclass of PixelTexture, but the functionality needed to manipulate images and pixels is not implemented yet. This functionality will be added as the need arises later.

This is how the PixelTexture node and the ImageTexture node are defined in the VRML'97 Standard.

PixelTexture {
  // SFImage image   0 0 0
  SFBool     repeatS TRUE
  SFBool     repeatT TRUE
}
ImageTexture {
  MFString url     []
  SFBool   repeatS TRUE
  SFBool   repeatT TRUE
}

This are the public interfaces to the PixelTexture class and to the ImageTexture class, as defined in the DGP2023 implementation.

class PixelTexture : public Node {
  public:
                        PixelTexture();
    virtual            ~PixelTexture();
    bool                getRepeatS();
    bool                getRepeatT();
    void                setRepeatS(bool value);
    void                setRepeatT(bool value);
    virtual bool        isPixelTexture() const { return           true; }
    virtual string      getType()        const { return "PixelTexture"; }
};
class ImageTexture : public PixelTexture {
  public:
                        ImageTexture();
    virtual            ~ImageTexture();
    vector<string>&     getUrl();
    string              getUrl(int i);
    void                adToUrl(const string& str);
    virtual bool        isImageTexture() const { return           true; }
    virtual string      getType()        const { return "ImageTexture"; }
};