Cumulia Illustrator Rendering Engine v2.1.0
A Rendering engine for industrial CAD/CAE model and optimized for greatest performance
 
Loading...
Searching...
No Matches
viewcube.h
1//##################################################################################################
2//
3// Copyright (c) 2024 Beijing Qiongqi Tech Co.,Ltd. All rights reserved.
4
5// This source code is confidential and proprietary to Beijing Qiongqi Tech Co.,Ltd(The Holder).
6// Any unauthorized use, copying, modification, or distribution of the code is strictly prohibited.
7// Any user shall obtain authorizaition from the Holder before modifying the source code. And the user shall not
8// sublicense, sell, distribute, or transfer the source code, whether in original or modified form, to any third party
9// without the prior written consent of the Holder.
10
11// This copyright notice and permission grant shall be included in all copies or substantial portions of the source code.
12
13// Author Cumulia Illustrator
14// Date 2025-08-05
15// Version V1.1.0
16//##################################################################################################
17
18#pragma once
19
20#include <cilcore.h>
21#include <cilselector.h>
22
23#include <functional>
24#include <string>
25
26namespace cil
27{
28 class Block
29 {
30 public:
33 };
34
35 /*enum class ViewCubeType
36 {
37 None,
38 Full,
39 Mini,
40 Corner
41 };*/
42
43 class ViewCube : public Pass
44 {
45 public:
46 ViewCube(const std::shared_ptr<Renderer>& renderer, const std::shared_ptr<Image2D>& image,
47 const std::shared_ptr<Vector2i>& coordinate, const std::shared_ptr<Vector2i>& backgroundSize, const std::shared_ptr<Vector2i>& windowSize);
48 virtual ~ViewCube();
49
50 int hilited() const;
52 void align(const std::shared_ptr<Camera>& camera, const std::shared_ptr<BoundingBox>& boundingBox, bool animate = false);
53 int hit(int x, int y);
54 void sync(const std::shared_ptr<Camera>& camera);
55 void bind(const std::string& name, std::function<void()> callback);
56 void unbind(const std::string& name);
57 void send(const std::string& name);
58
59 void setImage(const std::shared_ptr<Image2D>& image);
60 std::shared_ptr<Image2D> image() const;
61 void setBackgroundColor(const Color3f& color);
63 void setTextColor(const Color3f& color);
65 void setHilitedColor(const Color3f& color);
67 void setBorderColor(const Color3f& color);
69 void setHilitedBorderColor(const Color3f& color);
71
72 // setLocation
73 // updatelocation
74
75 private:
76 std::shared_ptr<Node> buildCube();
77 std::shared_ptr<Node> buildEdge();
78 std::shared_ptr<Node> buildAxis();
79 std::shared_ptr<Node> buildHilite();
80 std::shared_ptr<Primitive> buildFace(const Vector3f& p0, const Vector3f& p1, const Vector3f& p2, const Vector3f& p3, const std::string& text, float texCoordOffset);
81 std::shared_ptr<Material> buildFaceMaterial();
82 void onTimeout();
83 Vector3f slerp(const Vector3f& start, const Vector3f& end, float t);
84 Quaternion slerp(const Quaternion& start, const Quaternion& end, float t);
85
86 protected:
87 std::shared_ptr<Node> m_hilite;
88 std::shared_ptr<std::vector<std::shared_ptr<Block>>> m_blocks;
91 std::shared_ptr<Geometry> m_blockCube;
92 std::shared_ptr<Material> m_faceMaterial;
93 std::shared_ptr<FaceSelector<Block>> m_selector;
94 std::shared_ptr<Image2D> m_image;
95
96 private:
97 std::shared_ptr<Renderer> m_renderer;
98 std::shared_ptr<Color3f> m_backgroundColor;
99 std::shared_ptr<Color3f> m_borderColor;
100 std::shared_ptr<Color3f> m_textColor;
101 std::shared_ptr<Color3f> m_hilitedBorderColor;
102 std::shared_ptr<Color3f> m_hilitedColor;
103 std::function<void()> m_onHilited;
104 std::function<void()> m_onUpdated;
105 std::function<void()> m_onAnimationStarted;
106 std::function<void()> m_onAnimationEnded;
107 std::shared_ptr<Timer> m_timer;
108 int m_duration;
109 int m_elapsedTime;
110 std::shared_ptr<Camera> m_camera;
111 Matrix4f m_viewMatrix;
112 Vector3f m_startTrans;
113 Vector3f m_endTrans;
114 Quaternion m_startRot;
115 Quaternion m_endRot;
116 };
117
118 class FullViewCube : public ViewCube
119 {
120 public:
121 FullViewCube(const std::shared_ptr<Renderer>& renderer, const std::shared_ptr<Image2D>& image,
122 const std::shared_ptr<Vector2i>& coordinate, const std::shared_ptr<Vector2i>& backgroundSize, const std::shared_ptr<Vector2i>& windowSize);
123 virtual ~FullViewCube();
124
125 private:
126 void initialize();
127 };
128
129 class MiniViewCube : public ViewCube
130 {
131 public:
132 MiniViewCube(const std::shared_ptr<Renderer>& renderer, const std::shared_ptr<Image2D>& image,
133 const std::shared_ptr<Vector2i>& coordinate, const std::shared_ptr<Vector2i>& backgroundSize, const std::shared_ptr<Vector2i>& windowSize);
134 virtual ~MiniViewCube();
135
136 private:
137 void initialize();
138 };
139
141 {
142 public:
143 CornerViewCube(const std::shared_ptr<Renderer>& renderer, const std::shared_ptr<Image2D>& image,
144 const std::shared_ptr<Vector2i>& coordinate, const std::shared_ptr<Vector2i>& backgroundSize, const std::shared_ptr<Vector2i>& windowSize);
146
147 private:
148 void initialize();
149 };
150
151 std::shared_ptr<FullViewCube> _fullViewCube(const std::shared_ptr<Renderer>& renderer, const std::shared_ptr<Image2D>& image,
152 const std::shared_ptr<Vector2i>& coordinate, const std::shared_ptr<Vector2i>& backgroundSize, const std::shared_ptr<Vector2i>& windowSize);
153
154 std::shared_ptr<MiniViewCube> _miniViewCube(const std::shared_ptr<Renderer>& renderer, const std::shared_ptr<Image2D>& image,
155 const std::shared_ptr<Vector2i>& coordinate, const std::shared_ptr<Vector2i>& backgroundSize, const std::shared_ptr<Vector2i>& windowSize);
156
157 std::shared_ptr<CornerViewCube> _cornerViewCube(const std::shared_ptr<Renderer>& renderer, const std::shared_ptr<Image2D>& image,
158 const std::shared_ptr<Vector2i>& coordinate, const std::shared_ptr<Vector2i>& backgroundSize, const std::shared_ptr<Vector2i>& windowSize);
159}
Definition viewcube.h:29
Vector3f dir
Definition viewcube.h:32
Box3f box
Definition viewcube.h:31
The Box3f class inherits from Box3, specilizing the template parameters to float for element type and...
Definition box.h:214
The Color3f class inherits from Color3, specilizing the template parameters to float for element type...
Definition color.h:105
Definition viewcube.h:141
virtual ~CornerViewCube()
CornerViewCube(const std::shared_ptr< Renderer > &renderer, const std::shared_ptr< Image2D > &image, const std::shared_ptr< Vector2i > &coordinate, const std::shared_ptr< Vector2i > &backgroundSize, const std::shared_ptr< Vector2i > &windowSize)
Definition viewcube.h:119
virtual ~FullViewCube()
FullViewCube(const std::shared_ptr< Renderer > &renderer, const std::shared_ptr< Image2D > &image, const std::shared_ptr< Vector2i > &coordinate, const std::shared_ptr< Vector2i > &backgroundSize, const std::shared_ptr< Vector2i > &windowSize)
The Matrix4f class is 4 X 4 matrix.
Definition matrix.h:226
Definition viewcube.h:130
virtual ~MiniViewCube()
MiniViewCube(const std::shared_ptr< Renderer > &renderer, const std::shared_ptr< Image2D > &image, const std::shared_ptr< Vector2i > &coordinate, const std::shared_ptr< Vector2i > &backgroundSize, const std::shared_ptr< Vector2i > &windowSize)
The Pass class represents a rendering pass within a graphics pipeline.
Definition pass.h:32
CameraPtr camera
This member holds a shared pointer to a Camera object which the current pass uses for rendering.
Definition pass.h:37
std::string name
This memeber stores the name of the pass.
Definition pass.h:34
The Quaternion class inherits from the Tuple class, specilizing the templated parameter to float for ...
Definition quaternion.h:28
The class Vector3f inherits from the templated class of Vector3, and the template parameters are spec...
Definition vector.h:322
Definition viewcube.h:44
std::shared_ptr< Geometry > m_blockCube
Definition viewcube.h:91
void bind(const std::string &name, std::function< void()> callback)
void setImage(const std::shared_ptr< Image2D > &image)
void align(const std::shared_ptr< Camera > &camera, const std::shared_ptr< BoundingBox > &boundingBox, bool animate=false)
void send(const std::string &name)
std::shared_ptr< Image2D > image() const
Color3f borderColor() const
Color3f hilitedColor() const
void setBackgroundColor(const Color3f &color)
void setHilited(int hilited)
std::shared_ptr< Node > m_hilite
Definition viewcube.h:87
void setHilitedColor(const Color3f &color)
void sync(const std::shared_ptr< Camera > &camera)
Color3f hilitedBorderColor() const
int m_hilited
Definition viewcube.h:89
ViewCube(const std::shared_ptr< Renderer > &renderer, const std::shared_ptr< Image2D > &image, const std::shared_ptr< Vector2i > &coordinate, const std::shared_ptr< Vector2i > &backgroundSize, const std::shared_ptr< Vector2i > &windowSize)
void setTextColor(const Color3f &color)
int hit(int x, int y)
std::shared_ptr< FaceSelector< Block > > m_selector
Definition viewcube.h:93
int hilited() const
void unbind(const std::string &name)
std::shared_ptr< Image2D > m_image
Definition viewcube.h:94
Color3f textColor() const
void setBorderColor(const Color3f &color)
virtual ~ViewCube()
int m_unhilited
Definition viewcube.h:90
std::shared_ptr< std::vector< std::shared_ptr< Block > > > m_blocks
Definition viewcube.h:88
Color3f backgroundColor() const
void setHilitedBorderColor(const Color3f &color)
std::shared_ptr< Material > m_faceMaterial
Definition viewcube.h:92
Definition decal.h:23
std::shared_ptr< CornerViewCube > _cornerViewCube(const std::shared_ptr< Renderer > &renderer, const std::shared_ptr< Image2D > &image, const std::shared_ptr< Vector2i > &coordinate, const std::shared_ptr< Vector2i > &backgroundSize, const std::shared_ptr< Vector2i > &windowSize)
std::shared_ptr< MiniViewCube > _miniViewCube(const std::shared_ptr< Renderer > &renderer, const std::shared_ptr< Image2D > &image, const std::shared_ptr< Vector2i > &coordinate, const std::shared_ptr< Vector2i > &backgroundSize, const std::shared_ptr< Vector2i > &windowSize)
std::shared_ptr< FullViewCube > _fullViewCube(const std::shared_ptr< Renderer > &renderer, const std::shared_ptr< Image2D > &image, const std::shared_ptr< Vector2i > &coordinate, const std::shared_ptr< Vector2i > &backgroundSize, const std::shared_ptr< Vector2i > &windowSize)