Graphics API JSDoc stubs

This commit is contained in:
David Rowe 2018-05-12 12:53:43 +12:00
parent 6d000f3362
commit a2bb9de441
8 changed files with 88 additions and 11 deletions

View file

@ -36,6 +36,30 @@ namespace scriptable {
using ModelProviderPointer = std::shared_ptr<scriptable::ModelProvider>;
using WeakModelProviderPointer = std::weak_ptr<scriptable::ModelProvider>;
/**jsdoc
* @typedef {object} Graphics.Material
* @property {string} name
* @property {string} model
* @property {number} opacity
* @property {number} roughness
* @property {number} metallic
* @property {number} scattering
* @property {boolean} unlit
* @propety {Vec3} emissive
* @propety {Vec3} albedo
* @property {string} emissiveMap
* @property {string} albedoMap
* @property {string} opacityMap
* @property {string} metallicMap
* @property {string} specularMap
* @property {string} roughnessMap
* @property {string} glossMap
* @property {string} normalMap
* @property {string} bumpMap
* @property {string} occlusionMap
* @property {string} lightmapMap
* @property {string} scatteringMap
*/
class ScriptableMaterial {
public:
ScriptableMaterial() {}
@ -68,7 +92,7 @@ namespace scriptable {
/**jsdoc
* @typedef {object} Graphics.MaterialLayer
* @property {Material} material - This layer's material.
* @property {Graphics.Material} material - This layer's material.
* @property {number} priority - The priority of this layer. If multiple materials are applied to a mesh part, only the highest priority layer is used.
*/
class ScriptableMaterialLayer {

View file

@ -166,6 +166,17 @@ bool GraphicsScriptingInterface::updateMeshPart(scriptable::ScriptableMeshPointe
scriptable::ScriptableMeshPointer GraphicsScriptingInterface::newMesh(const QVariantMap& ifsMeshData) {
// TODO: this is bare-bones way for now to improvise a new mesh from the scripting side
// in the future we want to support a formal C++ structure data type here instead
/**jsdoc
* @typedef {object} Graphics.IFSData
* @property {string} [name=""] - mesh name (useful for debugging / debug prints).
* @property {string} [topology=""]
* @property {number[]} indices - vertex indices to use for the mesh faces.
* @property {Vec3[]} vertices - vertex positions (model space)
* @property {Vec3[]} [normals=[]] - vertex normals (normalized)
* @property {Vec3[]} [colors=[]] - vertex colors (normalized)
* @property {Vec2[]} [texCoords0=[]] - vertex texture coordinates (normalized)
*/
QString meshName = ifsMeshData.value("name").toString();
QString topologyName = ifsMeshData.value("topology").toString();
QVector<glm::uint32> indices = buffer_helpers::variantToVector<glm::uint32>(ifsMeshData.value("indices"));

View file

@ -46,10 +46,28 @@ public slots:
*/
scriptable::ScriptableModelPointer getModel(QUuid uuid);
/**jsdoc
* @function Graphics.updateModel
* @param {Uuid} id
* @param {Graphics.Model} model
* @returns {boolean}
*/
bool updateModel(QUuid uuid, const scriptable::ScriptableModelPointer& model);
/**jsdoc
* @function Graphics.canUpdateModel
* @param {Uuid} id
* @param {number} [meshIndex=-1]
* @param {number} [partNumber=-1]
* @returns {boolean}
*/
bool canUpdateModel(QUuid uuid, int meshIndex = -1, int partNumber = -1);
/**jsdoc
* @function Graphics.newModel
* @param {Graphics.Mesh[]} meshes
* @returns {Graphics.Model}
*/
scriptable::ScriptableModelPointer newModel(const scriptable::ScriptableMeshes& meshes);
/**jsdoc
@ -59,15 +77,6 @@ public slots:
* @param {Graphics.IFSData} ifsMeshData Index-Faced Set (IFS) arrays used to create the new mesh.
* @returns {Graphics.Mesh} the resulting Mesh / Mesh Part object
*/
/**jsdoc
* @typedef {object} Graphics.IFSData
* @property {string} [name] - mesh name (useful for debugging / debug prints).
* @property {number[]} indices - vertex indices to use for the mesh faces.
* @property {Vec3[]} vertices - vertex positions (model space)
* @property {Vec3[]} [normals] - vertex normals (normalized)
* @property {Vec3[]} [colors] - vertex colors (normalized)
* @property {Vec2[]} [texCoords0] - vertex texture coordinates (normalized)
*/
scriptable::ScriptableMeshPointer newMesh(const QVariantMap& ifsMeshData);
#ifdef SCRIPTABLE_MESH_TODO
@ -77,6 +86,11 @@ public slots:
bool updateMeshPart(scriptable::ScriptableMeshPointer mesh, scriptable::ScriptableMeshPartPointer part);
#endif
/**jsdoc
* @function Graphics.exportModelToOBJ
* @param {Graphics.Model} model
* @returns {string}
*/
QString exportModelToOBJ(const scriptable::ScriptableModel& in);
private:

View file

@ -36,6 +36,10 @@ namespace scriptable {
* @property {number} numIndices - Total number of vertex indices in the mesh.
* @property {number} numVertices - Total number of vertices in the Mesh.
* @property {number} numAttributes - Number of currently defined vertex attributes.
* @property {boolean} valid
* @property {boolean} strong
* @property {object} extents
* @property {object} bufferFormats
*/
class ScriptableMesh : public ScriptableMeshBase, QScriptable {
Q_OBJECT

View file

@ -12,7 +12,11 @@
namespace scriptable {
/**jsdoc
* @typedef {object} Graphics.MeshPart
* @property {boolean} valid
* @property {number} partIndex - The part index (within the containing Mesh).
* @property {number} firstVertexIndex
* @property {number} baseVertexIndex
* @property {number} lastVertexIndex
* @property {Graphics.Topology} topology - element interpretation (currently only 'triangles' is supported).
* @property {string[]} attributeNames - Vertex attribute names (color, normal, etc.)
* @property {number} numIndices - Number of vertex indices that this mesh part refers to.
@ -20,6 +24,8 @@ namespace scriptable {
* @property {number} numFaces - Number of faces represented by the mesh part (numIndices / numVerticesPerFace).
* @property {number} numVertices - Total number of vertices in the containing Mesh.
* @property {number} numAttributes - Number of currently defined vertex attributes.
* @property {object} extents
* @property {object} bufferFormats
*/
class ScriptableMeshPart : public QObject, QScriptable {

View file

@ -21,7 +21,7 @@ namespace scriptable {
* @property {Uuid} objectID - UUID of corresponding inworld object (if model is associated)
* @property {number} numMeshes - The number of submeshes contained in the model.
* @property {Graphics.Mesh[]} meshes - Array of submesh references.
* @property {Object.<string, Graphics.MaterialLayer[]>} materialLayers - Map of materials layer lists. You can look up a material layer list by mesh part number or by material name.
* @property {Object.<string,Graphics.MaterialLayer[]>} materialLayers - Map of materials layer lists. You can look up a material layer list by mesh part number or by material name.
* @property {string[]} materialNames - Array of all the material names used by the mesh parts of this model, in order (e.g. materialNames[0] is the name of the first mesh part's material).
*/

View file

@ -76,6 +76,23 @@ public:
// Access vertex position value
const Vec3& getPos(Index index) const { return _vertexBuffer.get<Vec3>(index); }
/**jsdoc
* <table>
* <thead>
* <tr><th>Value</th><th>Description</th></tr>
* </thead>
* <tbody>
* <tr><td><code>0</code></td><td>Points.</td></tr>
* <tr><td><code>1</code></td><td>Lines.</td></tr>
* <tr><td><code>2</code></td><td>Line strip.</td></tr>
* <tr><td><code>3</code></td><td>Triangles.</td></tr>
* <tr><td><code>4</code></td><td>Triangle strip.</td></tr>
* <tr><td><code>5</code></td><td>Quads.</td></tr>
* <tr><td><code>6</code></td><td>Quad strip.</td></tr>
* </tbody>
* </table>
* @typedef {number} Graphics.Topology
*/
enum Topology {
POINTS = 0,
LINES,

View file

@ -44,6 +44,7 @@ exports.handlers = {
'../../libraries/controllers/src/controllers/impl/',
'../../libraries/display-plugins/src/display-plugins/',
'../../libraries/entities/src',
'../../libraries/graphics/src/graphics/',
'../../libraries/graphics-scripting/src/graphics-scripting/',
'../../libraries/input-plugins/src/input-plugins',
'../../libraries/model-networking/src/model-networking/',