-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
341 additions
and
487 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
|
||
// Control point of curve #0 | ||
-2.87181 1.84298 0.22415 | ||
-2.15362 0.72365 -0.290709 | ||
-0.781428 1.69175 0.865892 | ||
-0.569098 1.70164 1.77287 | ||
|
||
// Control point of curve #1 | ||
0.692288 0.970642 0.904679 | ||
0.799703 1.41361 1.88313 | ||
2.58704 1.45852 1.0763 | ||
0.75 0.25 0 | ||
-0.75 0 0 | ||
0.75 1.25 -1.70373 | ||
-0.75 1.48362 1.10581 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Copyright 2020 Nghia Truong <nghiatruong.vn@gmail.com> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
#include "DrawableObjects/Curves/Curve.h" | ||
|
||
/****************************************************************************************************/ | ||
class CubicBezier : public Curve { | ||
public: | ||
explicit CubicBezier(Scene3D* const scene, | ||
int subdivision = 128, | ||
const Color3& color = Color3(1.0f), | ||
float thickness = 1.0f, | ||
bool renderControlPoints = true, | ||
bool editableControlPoints = true, | ||
float controlPointRadius = 0.05f) : | ||
Curve(scene, subdivision, color, thickness, renderControlPoints, | ||
editableControlPoints, controlPointRadius) {} | ||
protected: | ||
virtual void computeLines() override { | ||
if(m_ControlPoints.size() != 4) { | ||
Fatal() << "Cubic Bezier requires 4 control points, currently has" | ||
<< m_ControlPoints.size(); | ||
} | ||
const auto B0 = m_ControlPoints[0]; | ||
const auto B1 = m_ControlPoints[1]; | ||
const auto B2 = m_ControlPoints[2]; | ||
const auto B3 = m_ControlPoints[3]; | ||
|
||
const auto step = 1.0f / static_cast<float>(m_Subdivision); | ||
for(int i = 0; i <= m_Subdivision; ++i) { | ||
const auto t = static_cast<float>(i) * step; | ||
const auto t_sqr = t * t; | ||
const auto one_m_t = 1.0f - t; | ||
const auto one_m_t_sqr = one_m_t * one_m_t; | ||
|
||
const auto position = one_m_t * one_m_t_sqr * B0 + | ||
3.0f * one_m_t_sqr * t * B1 + | ||
3.0f * one_m_t * t_sqr * B2 + | ||
t * t_sqr * B3; | ||
m_Points.push_back(position); | ||
|
||
if(i == 0 || i == m_Subdivision) { | ||
m_Points.push_back(position); | ||
} | ||
} | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.