Browse Source

Added class Trade::MeshObjectData, specialized for mesh instance types.

vectorfields
Vladimír Vondruš 14 years ago
parent
commit
265da56976
  1. 58
      src/Trade/MeshObjectData.h
  2. 11
      src/Trade/ObjectData.h

58
src/Trade/MeshObjectData.h

@ -0,0 +1,58 @@
#ifndef Magnum_Trade_MeshObjectData_h
#define Magnum_Trade_MeshObjectData_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
This file is part of Magnum.
Magnum is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
only, as published by the Free Software Foundation.
Magnum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License version 3 for more details.
*/
/** @file
* @brief Class Magnum::Trade::MeshObjectData
*/
#include "ObjectData.h"
namespace Magnum { namespace Trade {
/**
@brief %Mesh object data
Provides access to material information for given mesh instance.
*/
class MAGNUM_EXPORT MeshObjectData: public ObjectData {
MeshObjectData(const MeshObjectData& other) = delete;
MeshObjectData(MeshObjectData&& other) = delete;
MeshObjectData& operator=(const MeshObjectData& other) = delete;
MeshObjectData& operator=(MeshObjectData&& other) = delete;
public:
/**
* @brief Constructor
* @param children Child objects
* @param transformation Transformation (relative to parent)
* @param instance Instance ID
* @param material Material ID
*
* Creates object with mesh instance type.
*/
inline MeshObjectData(std::vector<size_t> children, const Matrix4& transformation, size_t instance, size_t material): ObjectData(children, transformation, InstanceType::Mesh, instance), _material(material) {}
/** @brief Material ID */
inline size_t material() { return _material; }
private:
size_t _material;
};
}}
#endif

11
src/Trade/ObjectData.h

@ -26,7 +26,8 @@ namespace Magnum { namespace Trade {
/** /**
@brief %Object data @brief %Object data
Provides access to object transformation and hierarchy. Provides access to object transformation and hierarchy. See also
MeshObjectData, which is specialized for objects with mesh instance type.
*/ */
class MAGNUM_EXPORT ObjectData { class MAGNUM_EXPORT ObjectData {
ObjectData(const ObjectData& other) = delete; ObjectData(const ObjectData& other) = delete;
@ -51,6 +52,9 @@ class MAGNUM_EXPORT ObjectData {
*/ */
inline ObjectData(std::vector<size_t> children, const Matrix4& transformation, InstanceType instanceType, size_t instanceId): _children(children), _transformation(transformation), _instanceType(instanceType), _instanceId(instanceId) {} inline ObjectData(std::vector<size_t> children, const Matrix4& transformation, InstanceType instanceType, size_t instanceId): _children(children), _transformation(transformation), _instanceType(instanceType), _instanceId(instanceId) {}
/** @brief Destructor */
inline virtual ~ObjectData() {}
/** @brief Child objects */ /** @brief Child objects */
inline std::vector<size_t>& children() { return _children; } inline std::vector<size_t>& children() { return _children; }
@ -60,13 +64,16 @@ class MAGNUM_EXPORT ObjectData {
/** /**
* @brief Instance type * @brief Instance type
* @return Type of instance held by this object * @return Type of instance held by this object
*
* If the instance is of type InstanceType::Mesh, the instance can be
* casted to MeshObjectData and provide more information.
*/ */
inline InstanceType instanceType() const { return _instanceType; } inline InstanceType instanceType() const { return _instanceType; }
/** /**
* @brief Instance ID * @brief Instance ID
* @return ID of given camera / light / mesh etc., specified by * @return ID of given camera / light / mesh etc., specified by
* instance() * instanceType()
*/ */
inline size_t instanceId() const { return _instanceId; } inline size_t instanceId() const { return _instanceId; }

Loading…
Cancel
Save