예제 #1
0
void GetROIBounds(const ROI& roi,
									vector<Vec3F>& bounds) {
	bounds.push_back(Vec3F(1.0, 0.0, -roi.Left())); // left
	bounds.push_back(Vec3F(0.0, 1.0, -roi.Top())); // top
	bounds.push_back(Vec3F(-1.0, 0.0, roi.Right()-1)); // right
	bounds.push_back(Vec3F(0.0, -1.0, roi.Bottom()-1)); // bottom
}
예제 #2
0
void GetImageBounds(const ImageRef& size,
										vector<Vec3F>& bounds) {
	bounds.push_back(Vec3F(1.0, 0.0, 0.0)); // left
	bounds.push_back(Vec3F(0.0, 1.0, 0.0)); // top
	bounds.push_back(Vec3F(-1.0, 0.0, size.x-1)); // right
	bounds.push_back(Vec3F(0.0, -1.0, size.y-1)); // bottom
}
예제 #3
0
Cam::Cam(Vec3F p_pos, Vec3F p_look, float p_zNear, float p_zFar) {
    m_zNear = p_zNear;
    m_zFar = p_zFar;

    m_pos = p_pos;
    m_look = p_look;

    m_fov = -1.0f;
    m_aspect = -1.0f;

    m_right = Vec3F(1.0f, 0.0f, 0.0f);
    m_up = Vec3F(0.0f, 1.0f, 0.0f);
 }
예제 #4
0
Vec3F Vec3F::cross(const Vec3F& p_r) const {
    const float _x = y * p_r.z - z * p_r.y;
    const float _y = z * p_r.x - x * p_r.z;
    const float _z = x * p_r.y - y * p_r.x;
    return Vec3F(_x, _y, _z);

}
예제 #5
0
파일: GlutApp.cpp 프로젝트: mr-mo/oplo
	void GlutApp::update()
	{
		if (m_translating)
		{
			m_cameraController.moveForward(m_reversing ? m_motionSpeed * -1 : m_motionSpeed);
		}

		m_cameraController.updateCamera();

		const oplo::Matrix4<float>& proj = m_camera.GetProjectionMatrix();
		const oplo::Matrix4<float>& cam = m_camera.GetViewMatrix();

		Matrix4<float> mvp = proj * cam;

		m_uniforms.setUniform("modelview", cam.begin(), 16);
		m_uniforms.setUniform("modelviewProjection", mvp.begin(), 16);

		mvp.invert();
		m_uniforms.setUniform("inverseModelviewProjection", mvp.begin(), 16);


		//elevationPage.beginFrame(camera);
		//cameraController.UpdateCamera();
		float cosLight = cos(m_globalLightDirection.getRadians());
		float sinLight = sin(m_globalLightDirection.getRadians());

		Vec3F lightDir = Vec3F(cosLight, sinLight, 0.15f);
		lightDir.normalize();
		m_uniforms.setUniform("lightDirection", lightDir);

		//float maxTan = camera.GetTangentFOV();
		//const float tangentAxisDivisor = static_cast<float>(std::max(camera.GetViewingWidth(), camera.GetViewingHeight()));

		//maxTan = std::max(maxTan * camera.GetAspect(), maxTan) * 2;

		//Math::AffineMatrix< float > mModelview = camera.GetViewMatrix();
		//Math::AffineMatrix< float > mProjection = camera.GetProjectionMatrix();
		//Math::AffineMatrix< float > mModelviewProjection = mProjection * mModelview;


		//mModelviewProjection.Invert();

		//Engine::staticGet<UniformHandler>().SetUniform("sunDir", vLightDirDowncast[0], vLightDirDowncast[1], vLightDirDowncast[2]);
		//Engine::staticGet<UniformHandler>().SetUniform("cameraPos", camera.GetWorldPosition()[0], camera.GetWorldPosition()[1], camera.GetWorldPosition()[2]);
		//Engine::staticGet<UniformHandler>().SetUniform("maximumFrustumTangentAxis", tangentAxisDivisor * (1.f / (lodAggressiveness * maxTan)));
		//Engine::staticGet<UniformHandler>().SetUniform("inverseScreenWidthHeight", 1.f / camera.GetViewingWidth(), 1.f / camera.GetViewingHeight());
		//Engine::staticGet<UniformHandler>().SetUniform("inverseModelviewProjection", mModelviewProjection.Begin(), 16, true);
		//Engine::staticGet<UniformHandler>().SetUniform("hg", hg_[0], hg_[1], hg_[2]);
		//Engine::staticGet<UniformHandler>().SetUniform("hgHalf", hgHalf_[0], hgHalf_[1], hgHalf_[2]);

	}
예제 #6
0
namespace FunctionLibrary
{
  std::pair<Region, voxel_function> makeBox(
        const Vec3F & center,
        const Vec3F & size,
        const Vec3F & color = Vec3F(1,1,1),
        const float & steep = 10);

  
  std::pair<Region, voxel_function> clearAll(const float & density = -30);
 
  std::pair<Region, voxel_function> makeEllipsoid(
        const Vec3F & position,
        const Vec3F & radius,
        const Vec3F & color = Vec3F(1,1,1),
        const float & steep = 10);

  //Noise related functions
  
  std::pair<Region, voxel_function> addPerlinDensity(
      const float & amplitude,
      const Vec3F & frequency,
      const float & lacunarity = 2.0f,
      const float & persistence = 0.5f,
      const int & octaveCount = 6);
  
  std::pair<Region, voxel_function> addPerlinColor(
      const float & amplitude,
      const Vec3F & frequency,
      const float & lacunarity = 2.0f,
      const float & persistence = 0.5f,
      const int & octaveCount = 6);

  std::pair<Region, voxel_function> clampColor();

};
예제 #7
0
void PlaySpace::drawHUD()
{
	LineShape movementPrediction;
	float sizeMult = 1.f / Renderer.Context.Camera.Zoom.length();
	movementPrediction.TexImage = gAssets.DottedLine;
	float step = 1/60.f * sizeMult;
	float maxLength = 5.0 + 5.0 * sizeMult;
	Ship playerCopy = *Player;
	for(float t = 0; t < maxLength; t += step)
	{
		movementPrediction.insert(playerCopy.Position, 3 * sizeMult, Vec4F(Vec3F(1), Min((1.0f - (t / maxLength)) * sizeMult, 1.0f)));
		movementPrediction.Points.back().TexCoord = t * 16 / sizeMult;
		playerCopy.updateControls(step, this);
		applyPhysics(&playerCopy, step);
		for(GravitySource& src : GravitySources)
			src.influence(&playerCopy, step);
	}
	Renderer.draw(movementPrediction, Align2D(0, 0));
}
예제 #8
0
Vec3F Vec3F::max(const Vec3F& p_r) const {
    return Vec3F(
        std::max(x, p_r.x),
        std::max(y, p_r.y),
        std::max(z, p_r.z));
}
예제 #9
0
void Cam::yaw(const float p_angle) {
    Vec3F axisY = Vec3F(0.0f, 1.0f, 0.0f);
    m_right.rotate(p_angle, axisY);
    m_up.rotate(p_angle, axisY);
    m_look.rotate(p_angle, axisY);
}
예제 #10
0
파일: main.cpp 프로젝트: jagoly/sqee
#include "catch.hpp"

#include <sqee/misc/StringCast.hpp>
#include <sqee/maths/Volumes.hpp>


namespace sq {
std::ostream& operator<<(std::ostream& _os, const Vec2F& _value) { _os << sq::chai_string(_value); return _os; }
std::ostream& operator<<(std::ostream& _os, const Vec3F& _value) { _os << sq::chai_string(_value); return _os; }
std::ostream& operator<<(std::ostream& _os, const Vec4F& _value) { _os << sq::chai_string(_value); return _os; }
}


TEST_CASE("volume intersection tests", "[volumes]") {

    SECTION("unit BoundBox with no transform") {
        auto bbox = sq::make_BoundBox(Mat4F(), {0.f, 0.f, 0.f}, 1.0f, {1.f, 1.f, 1.f});

        REQUIRE(bbox.radius == 1.f);
        REQUIRE(bbox.origin == Vec3F(0.f, 0.0f, 0.f));
        REQUIRE(bbox.points[0] == Vec3F(-1.f, -1.f, -1.f));
        REQUIRE(bbox.points[1] == Vec3F(-1.f, -1.f, +1.f));
        REQUIRE(bbox.points[2] == Vec3F(-1.f, +1.f, -1.f));
        REQUIRE(bbox.points[3] == Vec3F(-1.f, +1.f, +1.f));
        REQUIRE(bbox.points[4] == Vec3F(+1.f, -1.f, -1.f));
        REQUIRE(bbox.points[5] == Vec3F(+1.f, -1.f, +1.f));
        REQUIRE(bbox.points[6] == Vec3F(+1.f, +1.f, -1.f));
        REQUIRE(bbox.points[7] == Vec3F(+1.f, +1.f, +1.f));
    }
}