~ubuntu-branches/ubuntu/wily/opencollada/wily-proposed

« back to all changes in this revision

Viewing changes to COLLADASaxFrameworkLoader/include/COLLADASaxFWLMeshPrimitiveInputList.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
Import upstream version 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2008-2009 NetAllied Systems GmbH
 
3
 
 
4
        This file is part of COLLADASaxFrameworkLoader.
 
5
        
 
6
    Licensed under the MIT Open Source License, 
 
7
    for details please see LICENSE file or the website
 
8
    http://www.opensource.org/licenses/mit-license.php
 
9
*/
 
10
 
 
11
#ifndef __COLLADASAXFWL_INPUTLIST_H__
 
12
#define __COLLADASAXFWL_INPUTLIST_H__
 
13
 
 
14
#include "COLLADASaxFWLPrimitiveBase.h"
 
15
#include "COLLADASaxFWLInputShared.h"
 
16
 
 
17
#include "COLLADAFWMeshPrimitive.h"
 
18
 
 
19
 
 
20
namespace COLLADASaxFWL
 
21
{
 
22
 
 
23
    class MeshLoader;
 
24
        class Vertices;
 
25
 
 
26
 
 
27
    /**
 
28
    Geometric primitives, which assemble values from the inputs into vertex attribute data. 
 
29
    Can be any combination of any primitive types in any order. 
 
30
 
 
31
    To describe geometric primitives that are formed from the vertex data, the <mesh> element may 
 
32
    contain zero or more of the primitive elements <lines>, <linestrips>, <polygons>, <polylist>,
 
33
    <triangles>, <trifans>, and <tristrips>.
 
34
    The <vertices> element under <mesh> is used to describe mesh-vertices. Polygons, triangles, and 
 
35
    so forth index mesh-vertices, not positions directly. Mesh-vertices must have at least one 
 
36
    <input> (unshared) element with a semantic attribute whose value is POSITION.
 
37
    For texture coordinates, COLLADA�s right-handed coordinate system applies; therefore, an ST 
 
38
    texture coordinate of [0,0] maps to the lower-left texel of a texture image, when loaded in a 
 
39
    professional 2-D texture viewer/editor.
 
40
    */
 
41
    class MeshPrimitiveInputList 
 
42
    {
 
43
 
 
44
    private:
 
45
        /**
 
46
        * The input element may occur any number of times. This input is a local
 
47
        * input with the  offset and set attributes. 
 
48
        */
 
49
        InputSharedArray mInputArray;
 
50
 
 
51
        /**
 
52
         * The maximal offset value in the input element.
 
53
         */
 
54
        unsigned long long mInputArrayMaxOffset;
 
55
        
 
56
        /**
 
57
         * To convert the vertex input elements.
 
58
         */
 
59
                Vertices& mVertices;
 
60
 
 
61
    public:     
 
62
 
 
63
                /**
 
64
        * Constructor
 
65
        */
 
66
       MeshPrimitiveInputList ( Vertices& vertices ) 
 
67
            : mInputArray(InputSharedArray::OWNER)
 
68
            , mInputArrayMaxOffset (0)
 
69
                        , mVertices(vertices)
 
70
        {}
 
71
 
 
72
        /**
 
73
        * Destructor
 
74
        */
 
75
        virtual ~MeshPrimitiveInputList() 
 
76
                {
 
77
                        clearInputs();
 
78
                }
 
79
 
 
80
                /** Clears the inputs related contents but keeps the vertices.*/
 
81
                void clearInputs();
 
82
                
 
83
        /**
 
84
         * The input element may occur any number of times. This input is a 
 
85
         * local input with the  offset and set attributes.
 
86
         * @return const InputArray The array with the input elements.
 
87
         */
 
88
        const InputSharedArray& getInputArray () const 
 
89
        {
 
90
            return mInputArray; 
 
91
        }
 
92
 
 
93
        /**
 
94
         * Appends an input element in the list of input elements. 
 
95
         * Handle with care, new memory will be allocated!
 
96
         */
 
97
        const InputShared* appendInputElement ( InputShared* inputShared );
 
98
 
 
99
        /**
 
100
        * The input element may occur any number of times. This input is a 
 
101
        * local input with the  offset and set attributes.
 
102
        * @return const InputArray The array with the input elements.
 
103
        */
 
104
        const unsigned long long getInputArrayMaxOffset () const 
 
105
        {
 
106
            return mInputArrayMaxOffset;
 
107
        }
 
108
 
 
109
 
 
110
        /**
 
111
        * Returns the input element with the given semantic or 0 if it not exist.
 
112
        * @param semantic The semantic of the searched input element.
 
113
        * @param parent True, if the vertex element of the parent mesh should also searched.
 
114
        * @return InputShared* Pointer to the searched input element or 0 if it not exist.
 
115
        */
 
116
        const InputShared* getInputBySemantic ( const InputSemantic::Semantic& semantic ) const;
 
117
 
 
118
        /**
 
119
        * Returns the positions input element or 0 if it not exist.
 
120
        * @param parent True, if the vertex element of the parent mesh should also searched.
 
121
        * @return InputShared* Pointer to the searched input element or 0 if it not exist.
 
122
        */
 
123
        const InputShared* getPositionInput () const
 
124
        {
 
125
            return getInputBySemantic ( InputSemantic::POSITION );
 
126
        }
 
127
 
 
128
        /**
 
129
        * Returns the normals input element or 0 if it not exist.
 
130
        * @param parent True, if the vertex element of the parent mesh should also searched.
 
131
        * @return InputShared* Pointer to the searched input element or 0 if it not exist.
 
132
        */
 
133
        const InputShared* getNormalInput () const
 
134
        {
 
135
            return getInputBySemantic ( InputSemantic::NORMAL );
 
136
        }
 
137
 
 
138
        const InputShared* getTangentInput () const
 
139
        {
 
140
            return getInputBySemantic ( InputSemantic::TEXTANGENT );
 
141
        }
 
142
 
 
143
        const InputShared* getBinormalInput () const
 
144
        {
 
145
            return getInputBySemantic ( InputSemantic::TEXBINORMAL );
 
146
        }
 
147
 
 
148
    };
 
149
 
 
150
    
 
151
    typedef COLLADAFW::ArrayPrimitiveType<MeshPrimitiveInputList*> PolyBaseArray;
 
152
 
 
153
}
 
154
 
 
155
#endif // __COLLADASAXFWL_INPUTLIST_H__