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

« back to all changes in this revision

Viewing changes to COLLADASaxFrameworkLoader/include/COLLADASaxFWLKinematicsSceneCreator.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_KINEMATICSSCENECREATOR_H__
 
12
#define __COLLADASAXFWL_KINEMATICSSCENECREATOR_H__
 
13
 
 
14
#include "COLLADASaxFWLPrerequisites.h"
 
15
#include "COLLADAFWKinematicsModel.h"
 
16
#include "COLLADAFWKinematicsController.h"
 
17
 
 
18
#include <map>
 
19
#include <stack>
 
20
 
 
21
namespace COLLADAFW
 
22
{
 
23
        class KinematicsScene;
 
24
        class KinematicsModel;
 
25
}
 
26
 
 
27
 
 
28
namespace COLLADASaxFWL
 
29
{
 
30
        class DocumentProcessor;
 
31
        class KinematicsIntermediateData;
 
32
        class KinematicsModel;
 
33
        class KinematicLink;
 
34
        class KinematicAttachment;
 
35
        class KinematicsController;
 
36
        class KinematicsInstanceKinematicsModel;
 
37
        class KinematicsInstanceKinematicsScene;
 
38
        class KinematicsScene;
 
39
        class KinematicsBindJointAxis;
 
40
        class AxisInfo;
 
41
 
 
42
    /** Creates a kinematics scene from an intermediate kinematics data */
 
43
        class KinematicsSceneCreator    
 
44
        {
 
45
        public:
 
46
                typedef std::map<COLLADAFW::Joint*, size_t> JointIndexMap;
 
47
 
 
48
                typedef std::stack<size_t> NumberStack;
 
49
 
 
50
                typedef std::map<COLLADAFW::JointPrimitive*, COLLADAFW::JointPrimitive*> JointPrimitiveJointPrimitiveMap;
 
51
 
 
52
                typedef COLLADABU::hash_map<KinematicsModel*, COLLADAFW::KinematicsModel*> KinematicsModelFWKinematicsModelMap;
 
53
 
 
54
                typedef std::set<COLLADAFW::InstanceKinematicsScene::NodeLinkBinding> NodeLinkBindingSet;
 
55
 
 
56
        private:
 
57
                /** The kinematics scene we are about to create.*/
 
58
                COLLADAFW::KinematicsScene* mKinematicsScene;
 
59
 
 
60
                /** The file loader that has all the information about the kinematics scene.*/
 
61
                DocumentProcessor* mDocumentProcessor;
 
62
 
 
63
                /** The kinematics intermediate data th kinematics scene will be created from. It is 
 
64
                provided by mFileLoader.*/
 
65
                const KinematicsIntermediateData& mKinematicsIntermediateData;
 
66
 
 
67
                /** Link number of the current link.*/
 
68
                size_t mLargestLinkNumber;
 
69
 
 
70
                /** Holds the link numbers of the current link and all of its parents.*/
 
71
                NumberStack mLinkNumberStack;
 
72
 
 
73
                /** Index of the next joint to be added to the current kinematics model.*/
 
74
                size_t mLargestJointIndex;
 
75
        
 
76
                /** Maps the joints in the intermediate data to their index in the current framework 
 
77
                kinematics model.*/
 
78
                JointIndexMap mJointIndexMap;
 
79
 
 
80
                /** We use this to map the joints created during the parse proces to the final nodes in the kinematics model,
 
81
                to point to the correct joint in the axis infos.
 
82
                TODO: This solution is to simple for the general case. Requires a much better algo
 
83
                */
 
84
                JointPrimitiveJointPrimitiveMap mOriginalClonedJointPrimitiveMap;
 
85
 
 
86
                /** Maps the intermediate kinematics model to the fw kinematics model.*/
 
87
                KinematicsModelFWKinematicsModelMap mKinematicsModelFWKinematicsModelMap;
 
88
 
 
89
                /** Set of all node link bindings. */
 
90
                NodeLinkBindingSet mNodeLinkBindingSet;
 
91
        public:
 
92
 
 
93
        /** Constructor. */
 
94
                KinematicsSceneCreator( DocumentProcessor* documentProcessor);
 
95
 
 
96
        /** Destructor. */
 
97
                virtual ~KinematicsSceneCreator();
 
98
 
 
99
                COLLADAFW::KinematicsScene* createAndGetKinematicsScene();
 
100
 
 
101
        private:
 
102
 
 
103
        /** Disable default copy ctor. */
 
104
                KinematicsSceneCreator( const KinematicsSceneCreator& pre );
 
105
 
 
106
        /** Disable default assignment operator. */
 
107
                const KinematicsSceneCreator& operator= ( const KinematicsSceneCreator& pre );
 
108
 
 
109
                COLLADAFW::KinematicsModel* createFWKinematicsModel(KinematicsModel* kinematicsModel);
 
110
        
 
111
                void createJointLinkConnections(const KinematicLink* link, COLLADAFW::KinematicsModel* fwKinematicsModel);
 
112
                void createJointLinkConnections(const KinematicAttachment* attachment, size_t jointIndex, COLLADAFW::KinematicsModel* fwKinematicsModel);
 
113
        
 
114
                COLLADAFW::KinematicsController* createFWKinematicsController(KinematicsController* kinematicsController);
 
115
 
 
116
                COLLADAFW::InstanceKinematicsScene* createFWInstanceKinematicsScene(KinematicsInstanceKinematicsScene* instanceKinematicsScene);
 
117
 
 
118
                COLLADAFW::AxisInfo createFWAxisInfo( const AxisInfo& axisInfo, bool& success );
 
119
 
 
120
                COLLADAFW::UniqueId processInstanceKinematicsModel(const KinematicsInstanceKinematicsModel& instanceKinematicsModel);
 
121
 
 
122
                bool resolveLink(KinematicsScene* kinematicsScene, 
 
123
                                     KinematicsBindJointAxis* kinematicsBindJointAxis,
 
124
                                                 size_t* linkNumber,
 
125
                                                 COLLADAFW::KinematicsModel** kinModel);
 
126
 
 
127
                size_t findLinkByJOintPrimitive(const COLLADAFW::KinematicsModel* fwKinModel, const COLLADAFW::JointPrimitive* jointPrimitive);
 
128
        };
 
129
 
 
130
} // namespace COLLADASAXFWL
 
131
 
 
132
#endif // __COLLADASAXFWL_KINEMATICSSCENECREATOR_H__