1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/********************************************************************
*
*	Created:	22/6/2015   14:05
*
*	File:		fsITransformationComponent.h
*
*	Author:		Martin P. Kind
*	
*	Purpose:	Modify parent position / scale / rotation over time
*
*********************************************************************/

#ifndef fsITransformationComponenthdr
#define fsITransformationComponenthdr

#include <functional>
#include <fsCore/fsSColour.h>
#include <fsCore/src/fsCUniqueId.h>

#include <fsAppCore/src/components/fsIComponent.h>

class fsINode;
class fsITransformation;

class fsITransformationComponent : public fsIComponent
{
	friend class fsCComponentFactory;

public:

	fsBool reverseGet() const;
	void reverseSet(fsBool pState);
	fsBool completeGet() const;

	virtual void simpleTransformSet(fsSColour pStart, fsSColour pEnd, fsS32 pDuration, std::function<void ()> pCompletionAction = nullptr);
	virtual void simpleTransformSet(fsF32 pStart, fsF32 pEnd, fsS32 pDuration, std::function<void()> pCompletionAction = nullptr);

	static const fsStr mGraphKey;
	static const fsCUniqueId mTypeId;

protected:

	fsS32 elapsedTimeGet() const;

	virtual void updateTransform() = 0;
	virtual void transformationCreateDo(const fsCVariableTable& pVars);

	void resetDo() override;
	void updateDo(fsS32 pDeltaMs) override;
	void initialiseFromVariableTableDo(const fsCVariableTable& pVars) override;

	fsITransformationComponent(fsCEntity* pParent);
	virtual ~fsITransformationComponent();<--- Destructor in derived class

	fsCEntity* mTransformationTarget;
	fsITransformation* mTransformation;

private:

	void transformationCreate(const fsCVariableTable& pVars);

	fsBool childTransformationIncompleteGet() const;

	fsCEntity* transformationParentGet();
	fsBool entityHasTransformationComponentGet(const fsINode* pNode);

	fsS32 mElapsedTime;
	fsBool mReverse;

	std::function<void()> mOnCompletionAction;
};

#endif