File: EclassModelNode.h

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (112 lines) | stat: -rw-r--r-- 2,731 bytes parent folder | download | duplicates (3)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#pragma once

#include "inamespace.h"
#include "modelskin.h"
#include "ientity.h"
#include "iselection.h"
#include "editable.h"

#include "scene/TraversableNodeSet.h"
#include "transformlib.h"
#include "selectionlib.h"
#include "render/RenderablePivot.h"
#include "../target/TargetableNode.h"
#include "../EntityNode.h"
#include "../KeyObserverDelegate.h"
#include "../RotationKey.h"
#include "../OriginKey.h"

namespace entity
{

class EclassModelNode;
typedef std::shared_ptr<EclassModelNode> EclassModelNodePtr;

/**
 * @brief Entity node displaying a model defined in an entityDef.
 *
 * This is used for entities whose model is defined in the entity class, e.g.
 * guards, interactable objects etc.
 */
class EclassModelNode :
	public EntityNode,
	public Snappable
{
private:
    OriginKey _originKey;
    Vector3 _origin;

    RotationKey _rotationKey;
	RotationMatrix _rotation;

    AngleKey _angleKey;
	float _angle;

    render::RenderablePivot _renderOrigin;
    ShaderPtr _pivotShader;

	AABB _localAABB;

    bool _noShadowsLit;

private:
	// Constructor
	EclassModelNode(const IEntityClassPtr& eclass);
	// Copy Constructor
	EclassModelNode(const EclassModelNode& other);

public:
	static EclassModelNodePtr Create(const IEntityClassPtr& eclass);

    virtual ~EclassModelNode();

	// Snappable implementation
	virtual void snapto(float snap) override;

	// Bounded implementation
	virtual const AABB& localAABB() const override;

	scene::INodePtr clone() const override;

	// Renderable implementation
    void onPreRender(const VolumeTest& volume) override;
	void setRenderSystem(const RenderSystemPtr& renderSystem) override;

    // Returns the original "origin" value
    const Vector3& getUntransformedOrigin() override;
    
    const Vector3& getWorldPosition() const override;

    virtual bool isShadowCasting() const override;

protected:
	// Gets called by the Transformable implementation whenever
	// scale, rotation or translation is changed.
    void _onTransformationChanged() override;

	// Called by the Transformable implementation before freezing
	// or when reverting transformations.
    void _applyTransformation() override;

	// Override EntityNode::construct()
	void construct() override;

    void onSelectionStatusChange(bool changeGroupStatus) override;

private:
    void translate(const Vector3& translation);
	void rotate(const Quaternion& rotation);

    // Thes two should not be confused with the methods inherited from the Transformable class
	void _revertTransform();
	void _freezeTransform();

    void updateTransform();

    void originChanged();
    void rotationChanged();
    void angleChanged();
    void onNoshadowsLitChanged(const std::string& value);
};

} // namespace