예제 #1
0
	Vec1 hermite(const Vec1& value1, const Vec1& tangent1, const Vec1& value2,
				 const Vec1& tangent2, const float& amount)
	{
		return Vec1(hermite(value1.x, tangent1.x, value2.x, tangent2.x, amount));
	}
예제 #2
0
	Vec1 Vec1::operator*(const float &a) const
	{
		return Vec1(x * a);
	}
예제 #3
0
	Vec1 catmullRom(const Vec1& value1, const Vec1& value2, const Vec1& value3,
					const Vec1& value4, const float& amount)
	{
		return Vec1(catmullRom(value1.x, value2.x, value3.x, value4.x, amount));
	}
예제 #4
0
	Vec1 Vec1::operator-() const
	{
		return Vec1(-x);
	}
예제 #5
0
	Vec1 barycentric(const Vec1& value1, const Vec1& value2, const Vec1& value3,
					 const float& amount1, const float& amount2)
	{
		return Vec1(barycentric(value1.x, value2.x, value3.x, amount1, amount2));
	}
예제 #6
0
	Vec1 Vec1::operator+(const Vec1 &a) const
	{
		return Vec1(x + a.x);
	}
예제 #7
0
//
//  Vector.cpp
//  Camaleao
//
//  Created by Narendra Umate on 10/4/12.
//  Copyright (c) 2012 Narendra Umate. All rights reserved.
//

#include "Vector.h"

const Vec1 Vec1::zero = Vec1(0.0f);
const Vec1 Vec1::one = Vec1(1.0f);
const Vec1 Vec1::min = Vec1(FLT_MIN);
const Vec1 Vec1::max = Vec1(FLT_MAX);
const Vec1 Vec1::xxx = Vec1(1.0f);

const Vec2 Vec2::zero = Vec2(0.0f, 0.0f);
const Vec2 Vec2::one = Vec2(1.0f, 1.0f);
const Vec2 Vec2::min = Vec2(FLT_MIN, FLT_MIN);
const Vec2 Vec2::max = Vec2(FLT_MAX, FLT_MAX);
const Vec2 Vec2::xxx = Vec2(1.0f, 0.0f);
const Vec2 Vec2::yyy = Vec2(0.0f, 1.0f);

const Vec3 Vec3::zero = Vec3(0.0f, 0.0f, 0.0f);
const Vec3 Vec3::one = Vec3(1.0f, 1.0f, 1.0f);
const Vec3 Vec3::min = Vec3(FLT_MIN, FLT_MIN, FLT_MIN);
const Vec3 Vec3::max = Vec3(FLT_MAX, FLT_MAX, FLT_MAX);
const Vec3 Vec3::xxx = Vec3(1.0f, 0.0f, 0.0f);
const Vec3 Vec3::yyy = Vec3(0.0f, 1.0f, 0.0f);
const Vec3 Vec3::zzz = Vec3(0.0f, 0.0f, 1.0f);
예제 #8
0
void ROTOR_DISK::CalculateRotorGeometry(void)
{
 
    int i;
    double DTheta, Theta, s[3], t[3], r[3], mag, XYZo[3], XYZp[3];
    QUAT Quat, InvQuat, Vec1, Vec2, Vec3;
    
    // Random vector
    
    t[0] = 1.;
    t[1] = 2.;
    t[2] = 3.;
    
    // Cross into rotor normal to get a radius vector
    
    vector_cross(RotorNormal_, t, r);
    
    mag = sqrt(vector_dot(r,r));
    
    r[0] /= mag;
    r[1] /= mag;
    r[2] /= mag;
    
    // Scale it by the rotor radius
    
    r[0] *= RotorRadius_;
    r[1] *= RotorRadius_;
    r[2] *= RotorRadius_;
    
    // Now rotate this vector around the center of the rotor

    DTheta = 2.*PI / ( NUM_ROTOR_NODES - 1 );
    
    for ( i = 1 ; i <= NUM_ROTOR_NODES ; i++ ) {

       // Build quaternion about this hinge vector
     
       Theta = (i-1)*DTheta;
       
       Quat.FormRotationQuat(RotorNormal_,Theta);
 
       InvQuat = Quat;

       InvQuat.FormInverse();

       // Rotate about the normal vector

       Vec1(0) = r[0];
       Vec1(1) = r[1];
       Vec1(2) = r[2];

       Vec1 = Quat * Vec1 * InvQuat;
       
       // Shift by center of rotor
       
       RotorRadiusXYZ_[i][0] = Vec1(0) + RotorXYZ_[0];
       RotorRadiusXYZ_[i][1] = Vec1(1) + RotorXYZ_[1];
       RotorRadiusXYZ_[i][2] = Vec1(2) + RotorXYZ_[2];
       
    }

    // Vector along direction of rotor travel
    
    if ( RotorRPM_ >= 0. ) {
     
       s[0] = RotorRadiusXYZ_[2][0] - RotorRadiusXYZ_[1][0];
       s[1] = RotorRadiusXYZ_[2][1] - RotorRadiusXYZ_[1][1];
       s[2] = RotorRadiusXYZ_[2][2] - RotorRadiusXYZ_[1][2];
       
       XYZo[0] = RotorRadiusXYZ_[1][0];
       XYZo[1] = RotorRadiusXYZ_[1][1];
       XYZo[2] = RotorRadiusXYZ_[1][2];

       XYZp[0] = RotorRadiusXYZ_[2][0];
       XYZp[1] = RotorRadiusXYZ_[2][1];
       XYZp[2] = RotorRadiusXYZ_[2][2];
       
    }
    
    else {
     
       s[0] = RotorRadiusXYZ_[1][0] - RotorRadiusXYZ_[2][0];
       s[1] = RotorRadiusXYZ_[1][1] - RotorRadiusXYZ_[2][1];
       s[2] = RotorRadiusXYZ_[1][2] - RotorRadiusXYZ_[2][2];
       
       XYZo[0] = RotorRadiusXYZ_[2][0];
       XYZo[1] = RotorRadiusXYZ_[2][1];
       XYZo[2] = RotorRadiusXYZ_[2][2];       

       XYZp[0] = RotorRadiusXYZ_[1][0];
       XYZp[1] = RotorRadiusXYZ_[1][1];
       XYZp[2] = RotorRadiusXYZ_[1][2];
       
    }

    // Random vector
    
    t[0] = 1.;
    t[1] = 2.;
    t[2] = 3.;
    
    // Cross into rotor normal to get a radius vector
    
    vector_cross(RotorNormal_, t, r);

    mag = sqrt(vector_dot(r,r));
    
    r[0] /= mag;
    r[1] /= mag;
    r[2] /= mag;
    
    // Scale it by the rotor radius
    
    r[0] *= 0.050*RotorRadius_;
    r[1] *= 0.050*RotorRadius_;
    r[2] *= 0.050*RotorRadius_;
    
    DTheta = 2.*PI / ( 3 );
    
    for ( i = 1 ; i <= 3 ; i++ ) {

       // Build quaternion about this hinge vector
     
       Theta = (i-1)*DTheta;
       
       Quat.FormRotationQuat(s,Theta);
 
       InvQuat = Quat;

       InvQuat.FormInverse();

       // Rotate about the normal vector

       Vec1(0) = r[0];
       Vec1(1) = r[1];
       Vec1(2) = r[2];

       Vec1 = Quat * Vec1 * InvQuat;
       
       // Shift by center of rotor
       
       RotorDirectionVectorXYZ_[i][0] = Vec1(0) + XYZo[0];
       RotorDirectionVectorXYZ_[i][1] = Vec1(1) + XYZo[1];
       RotorDirectionVectorXYZ_[i][2] = Vec1(2) + XYZo[2];
       
    }
 
    RotorDirectionVectorXYZ_[4][0] = XYZp[0];
    RotorDirectionVectorXYZ_[4][1] = XYZp[1];
    RotorDirectionVectorXYZ_[4][2] = XYZp[2];
    
    // Calculate normals for each side of the arrow head
    
    // Tri 1
    
       s[0] = RotorDirectionVectorXYZ_[2][0] - RotorDirectionVectorXYZ_[1][0];
       s[1] = RotorDirectionVectorXYZ_[2][1] - RotorDirectionVectorXYZ_[1][1];
       s[2] = RotorDirectionVectorXYZ_[2][2] - RotorDirectionVectorXYZ_[1][2];
       
       t[0] = RotorDirectionVectorXYZ_[3][0] - RotorDirectionVectorXYZ_[1][0];
       t[1] = RotorDirectionVectorXYZ_[3][1] - RotorDirectionVectorXYZ_[1][1];
       t[2] = RotorDirectionVectorXYZ_[3][2] - RotorDirectionVectorXYZ_[1][2];
       
       vector_cross(s,t,r);
       
       mag = sqrt(vector_dot(r,r));
    
       r[0] /= mag;
       r[1] /= mag;
       r[2] /= mag;
       
       RotorDirectionVectorNormal_[1][0] = -r[0];
       RotorDirectionVectorNormal_[1][1] = -r[1];
       RotorDirectionVectorNormal_[1][2] = -r[2];
       
    // Tri 2
    
       s[0] = RotorDirectionVectorXYZ_[4][0] - RotorDirectionVectorXYZ_[2][0];
       s[1] = RotorDirectionVectorXYZ_[4][1] - RotorDirectionVectorXYZ_[2][1];
       s[2] = RotorDirectionVectorXYZ_[4][2] - RotorDirectionVectorXYZ_[2][2];
       
       t[0] = RotorDirectionVectorXYZ_[3][0] - RotorDirectionVectorXYZ_[2][0];
       t[1] = RotorDirectionVectorXYZ_[3][1] - RotorDirectionVectorXYZ_[2][1];
       t[2] = RotorDirectionVectorXYZ_[3][2] - RotorDirectionVectorXYZ_[2][2];
       
       vector_cross(s,t,r);
       
       mag = sqrt(vector_dot(r,r));
    
       r[0] /= mag;
       r[1] /= mag;
       r[2] /= mag;
       
       RotorDirectionVectorNormal_[2][0] = -r[0];
       RotorDirectionVectorNormal_[2][1] = -r[1];
       RotorDirectionVectorNormal_[2][2] = -r[2];       
 
    // Tri 3
    
       s[0] = RotorDirectionVectorXYZ_[4][0] - RotorDirectionVectorXYZ_[1][0];
       s[1] = RotorDirectionVectorXYZ_[4][1] - RotorDirectionVectorXYZ_[1][1];
       s[2] = RotorDirectionVectorXYZ_[4][2] - RotorDirectionVectorXYZ_[1][2];
       
       t[0] = RotorDirectionVectorXYZ_[2][0] - RotorDirectionVectorXYZ_[1][0];
       t[1] = RotorDirectionVectorXYZ_[2][1] - RotorDirectionVectorXYZ_[1][1];
       t[2] = RotorDirectionVectorXYZ_[2][2] - RotorDirectionVectorXYZ_[1][2];
       
       vector_cross(s,t,r);
       
       mag = sqrt(vector_dot(r,r));
    
       r[0] /= mag;
       r[1] /= mag;
       r[2] /= mag;
       
       RotorDirectionVectorNormal_[3][0] = -r[0];
       RotorDirectionVectorNormal_[3][1] = -r[1];
       RotorDirectionVectorNormal_[3][2] = -r[2];              

    // Tri 4
    
       s[0] = RotorDirectionVectorXYZ_[3][0] - RotorDirectionVectorXYZ_[1][0];
       s[1] = RotorDirectionVectorXYZ_[3][1] - RotorDirectionVectorXYZ_[1][1];
       s[2] = RotorDirectionVectorXYZ_[3][2] - RotorDirectionVectorXYZ_[1][2];
       
       t[0] = RotorDirectionVectorXYZ_[4][0] - RotorDirectionVectorXYZ_[1][0];
       t[1] = RotorDirectionVectorXYZ_[4][1] - RotorDirectionVectorXYZ_[1][1];
       t[2] = RotorDirectionVectorXYZ_[4][2] - RotorDirectionVectorXYZ_[1][2];
       
       vector_cross(s,t,r);
       
       mag = sqrt(vector_dot(r,r));
    
       r[0] /= mag;
       r[1] /= mag;
       r[2] /= mag;
       
       RotorDirectionVectorNormal_[4][0] = -r[0];
       RotorDirectionVectorNormal_[4][1] = -r[1];
       RotorDirectionVectorNormal_[4][2] = -r[2];    
       
}
예제 #9
0
	Vec1 Vec1::operator*(const Mat4 &m) const
	{
		return Vec1(x * m.d00 + m.d30);
	}
예제 #10
0
Vec1 Vec1::operator*(const Vec1& a) const {
    return Vec1(x * a.x);
}
예제 #11
0
Mat GetAlignTransform (const SHAPE &Shape,          // io
                       const SHAPE &AnchorShape)    // in
{
CheckSameNbrRows(Shape, AnchorShape, "GetAlignTransform");

double Sx = 0, Sy = 0, Sxx = 0, Syy = 0, Sxy = 0;
double SAx = 0, SAy = 0, SAxx = 0, SAyy = 0, SAxy = 0, SAyx = 0;

const int nPoints = Shape.nrows();

for (int i = 0; i < nPoints; i++)
    {
    double x1 = AnchorShape(i, VX);
    double y1 = AnchorShape(i, VY);
    double x2 = Shape(i, VX);
    double y2 = Shape(i, VY);

    if (x1 == 0 && y1 == 0)      // is anchor landmark unused?
        ;
    else if (x2 == 0 && y2 == 0) // is landmark unused?
        ;
    else
        {
        Sx += x2;
        Sy += y2;
        Sxx += x2 * x2;
        Syy += y2 * y2;
        Sxy += x2 * y2;

        SAx += x1;
        SAy += y1;
        SAxx += x2 * x1;
        SAyy += y2 * y1;
        SAxy += x2 * y1;
        SAyx += y2 * x1;
        }
    }
double AData[] = { Sxx, Sxy, Sx,
                   Sxy, Syy, Sy,
                   Sx,  Sy,  Shape.nrows() };

MatView A(AData, 3, 3, 0);  // 3x3, tda=0

// equation 1

double  VecData1[] = { SAxx, SAyx, SAx };
VecView Vec1(VecData1, 3);
Vec Soln1(SolveWithLU(A, Vec1));        // a b tx

// equation 2

double  VecData2[] = { SAxy, SAyy, SAy };
VecView Vec2(VecData2, 3);

Vec Soln2(SolveWithLU(A, Vec2));        // c y ty

// combine the solutions

double TransformData[] = { Soln1(0), Soln1(1), Soln1(2),    // a b tx
                           Soln2(0), Soln2(1), Soln2(2)};   // c d ty

Mat Transform(TransformData, 2, 3);

return Transform;
}
예제 #12
0
Vec1 entrywiseProduct(const Vec1& u, const Vec1& v) {
	return Vec1(u.x * v.x);
}
예제 #13
0
Vec1 maxVec(const Vec1& u, const Vec1& v) {
    return Vec1(u.x > v.x ? u.x : v.x);
}
예제 #14
0
Vec1 minVec(const Vec1& u, const Vec1& v) {
    return Vec1(u.x < v.x ? u.x : v.x);
}
예제 #15
0
	Vec1 Vec1::operator/(const float &a) const
	{
		return Vec1(x / a);
	}
예제 #16
0
	Vec1 Vec1::operator*(const Quat &q) const
	{
		return Vec1();	//TODO
	}
예제 #17
0
	Vec1 smoothStep(const Vec1& value1, const Vec1& value2, const float& amount)
	{
		return Vec1(smoothStep(value1.x, value2.x, amount));
	}
예제 #18
0
	Vec1 maxVec(const Vec1 &u, const Vec1 &v)
	{
		return Vec1(maxVec(u.x, v.x));
	}
예제 #19
0
	Vec1 Vec1::operator-(const Vec1 &a) const
	{
		return Vec1(x - a.x);
	}
void CGameWorld::Init()
{
	Vector3f Vec1({ 1, 0, 0 });
	Vector3f Vec2({ -1, 0, 0 });
	//std::cout << "Angle in rad: " << Vec1.Angle(Vec2) << std::endl;
	//std::cout << "Angle in degrees: " << (Vec1.Angle(Vec2) * (180.0f / 3.14159265359f)) << std::endl;

	std::string name = "";
	unsigned char timer = myTimerManager.CreateTimer();
	myTimerManager.UpdateTimers();

	myJson.Load("root.json", myRooms, this, name);

	myTimerManager.UpdateTimers();
	double delta = myTimerManager.GetTimer(timer).GetTimeElapsed().GetMiliseconds();
	std::cout << "Loading root.json and levels took " << delta << " milliseconds" << std::endl;

	myTimerManager.UpdateTimers();
	myJson.LoadMusic("JSON/Music.json");
	myTimerManager.UpdateTimers();
	delta = myTimerManager.GetTimer(timer).GetTimeElapsed().GetMiliseconds();
	std::cout << "Loading music took " << delta << " milliseconds" << std::endl;
	//myJson.LoadItems("JSON/items.json", myPlayer.GetInventory());

	std::cout << "Level: " << CGame::myTestLevel << std::endl;
	if (CGame::myTestLevel.size() > 0)
	{
		DL_PRINT(CGame::myTestLevel.c_str());
		ChangeLevel(CGame::myTestLevel);
	}
	else
	{
		ChangeLevel(name);
	}


	myDoQuit = false;
	myTalkIsOn = false;
	myPlayerCanMove = true;

	myTextFPS = new DX2D::CText("Text/PassionOne-Regular.ttf_sdf");
	myTextFPS->myPosition = { 0.5f, 0.05f };
	myTextFPS->myText = "FPS: ";
	myTextFPS->mySize = 0.8f;

	myRenderPasses.Init(32);

	myPlayer.Init(DX2D::Vector2f(0.5f, 0.8f), this);

	myFadeIn = 1.0f;
	myDoFadeIn = false;

	myShouldRenderDebug = false;
	myShouldRenderFPS = false;
	myShouldRenderNavPoints = false;
#ifdef _DEBUG
	myShouldRenderFPS = true;
	myShouldRenderNavPoints = true;
#endif

	myCurrentWaypoint = 0;
	myHasPath = false;
	myHasNewTargetPosition = false;
	myTargetPosition = { 0.0f, 0.0f };
	myNewTargetPosition = myTargetPosition;
	
#ifdef _DEBUG
	myDotSprites.Init(12000);
	for (int i = 0; i < 12000; ++i)
	{
		DX2D::CSprite* sprite = new DX2D::CSprite("Sprites/Dot.dds");
		myDotSprites.Add(sprite);
	}
#endif
	
	myOptionsMenu.Initialize();
}