亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cvector.cpp

?? 一個DXD制作的讀取QUAKE的BSP結構的Demo可以參考
?? CPP
字號:
/*
   Class Name:

      CVector4.

   Created by:

      Allen Sherrod (Programming Ace of www.UltimateGameProgramming.com).

   Description:

      This class represents a 3D (well 4D) point for a vertex's x, y, z, and w axis.
*/


#include"CVector.h"        // CVector4 class.

#define M_PI 3.141592654


CVector4::CVector4()
{
   // Initialize the variables to 0.
   x = y = z = 0.0;
}


CVector4::CVector4(float X, float Y, float Z)
{
   // Initialize the varibles to the data in X, Y, and Z.
   x = X;
   y = Y;
   z = Z;
}


CVector4::CVector4(float X, float Y, float Z, float W)
{
   // Initialize the varibles to the data in X, Y, and Z.
   x = X;
   y = Y;
   z = Z;
   w = W;
}


CVector4::CVector4(const CVector4 &v)
{
   // Initialize this object to v.
   x = v.x;
   y = v.y;
   z = v.z;
   w = v.w;
}


void CVector4::operator =(CVector4 v)
{
   // Make this objects x, y, and z equal to the object on the right of the = sign.
   x = v.x;
   y = v.y;
   z = v.z;
   w = v.w;
}


CVector4 CVector4::operator -(CVector4 v)
{
   // Return the value of this vector - v.
   return CVector4(x - v.x, y - v.y, z - v.z);
}


CVector4 CVector4::operator +(CVector4 v)
{
   // Return the value of this vector + v.
   return CVector4(x + v.x, y + v.y, z + v.z);
}


CVector4 CVector4::operator *(CVector4 v)
{
   // Return the value of this vector * v.
   return CVector4(x * v.x, y * v.y, z * v.z);
}


CVector4 CVector4::operator /(CVector4 v)
{
   // Return the value of this vector / v.
   return CVector4(x / v.x, y / v.y, z / v.z);
}


CVector4 CVector4::operator +(float f)
{
   // Return the value of this vector + f.
   return CVector4(x + f, y + f, z + f);
}


CVector4 CVector4::operator -(float f)
{
   // Return the value of this vector - f.
   return CVector4(x - f, y - f, z - f);
}


CVector4 CVector4::operator *(float f)
{
   // Return the value of this vector * f.
   return CVector4(x * f, y * f, z * f);
}


CVector4 CVector4::operator /(float f)
{
   // Return the value of this vector / f.  We do this by multiplying the recip.
   f = 1/f;

   return CVector4(x * f, y * f, z * f);
}


void CVector4::operator +=(CVector4 v)
{
   // Add this by object v and store results here.
   x += v.x;
   y += v.y;
   z += v.z;
}


void CVector4::operator -=(CVector4 v)
{
   // Subtract this by object v and store results here.
   x -= v.x;
   y -= v.y;
   z -= v.z;
}


void CVector4::operator *=(CVector4 v)
{
   // Mul this by object v and store results here.
   x *= v.x;
   y *= v.y;
   z *= v.z;
}


void CVector4::operator /=(CVector4 v)
{
   // Divide this by object v and store results here.
   x /= v.x;
   y /= v.y;
   z /= v.z;
}


void CVector4::operator +=(float f)
{
   // Add this by object f and store results here.
   x += f;
   y += f;
   z += f;
}


void CVector4::operator -=(float f)
{
   // Subract this by object f and store results here.
   x -= f;
   y -= f;
   z -= f;
}


void CVector4::operator *=(float f)
{
   // Multiply this by object f and store results here.
   x *= f;
   y *= f;
   z *= f;
}


void CVector4::operator /=(float f)
{
   // Divide this by object f and store results here by multiplying by the recip.
   f = 1/f;

   x *= f;
   y *= f;
   z *= f;
}


bool CVector4::operator ==(CVector4 v)
{
   // Return true if all equal each other, false if one or more don't.
   return ((x == v.x) && (y== v.y) && (z == v.z));
}


bool CVector4::operator !=(CVector4 v)
{
   // Return true if one or all don't equal each other, false if they equal.
   return !((x == v.x) && (y== v.y) && (z == v.z));
}


void CVector4::CrossProduct(CVector4 v1, CVector4 v2)
{
   // Get the cross product of v1 and v2 and store it in this vector.
   x = ((v1.y * v2.z) - (v1.z * v2.y));
   y = ((v1.z * v2.x) - (v1.x * v2.z));
   z = ((v1.x * v2.y) - (v1.y * v2.x));
}


void CVector4::CrossProduct3(CVector4 v1, CVector4 v2, CVector4 v3)
{
   // Get the cross product of v1, v2, and v3.
   x = v1.y * v2.z * v3.w +
       v1.z * v2.w * v3.y +
       v1.w * v2.y * v3.z - 
       v1.y * v2.w * v3.z -
       v1.z * v2.y * v3.w -
       v1.w * v2.z * v3.y;

   y = v1.x * v2.w * v3.z +
       v1.z * v2.x * v3.w +
       v1.w * v2.z * v3.x -
       v1.x * v2.z * v3.w -
       v1.z * v2.w * v3.x -
       v1.w * v2.x * v3.z;

   z = v1.x * v2.y * v3.w +
       v1.y * v2.w * v3.x +
       v1.w * v2.x * v3.y -
       v1.x * v2.w * v3.y -
       v1.y * v2.x * v3.w -
       v1.w * v2.y * v3.x;

   w = v1.x * v2.z * v3.y +
       v1.y * v2.x * v3.z +
       v1.z * v2.y * v3.x -
       v1.x * v2.y * v3.z -
       v1.y * v2.z * v3.x -
       v1.z * v2.x * v3.y;
}


float CVector4::DotProduct3(CVector4 v1)
{
   // Get the dot product of v1 and this object and return it.
   return x * v1.x + y * v1.y + z * v1.z;
}


float CVector4::DotProduct4(CVector4 v1)
{
   // Get the dot product of v1 and this object and return it.
   return x * v1.x + y * v1.y + z * v1.z + w * v1.w;
}


float CVector4::GetLength()
{
   // Return the length for this object.
   return (float)sqrt((x * x + y * y + z * z));
}


void CVector4::Normal()
{
   // Reduce this object to a unit vector.
   float lenght = GetLength();

   if(lenght == 0.0f)
      lenght = 1.0f;

   x = x/lenght;
   y = y/lenght;
   z = z/lenght;
   w = w/lenght;
}


void CVector4::Normalize(CVector4 Triangle[])
{
   // Normalize a triangle and store results in this object.
   CVector4 v1, v2;

   v1.x = Triangle[0].x - Triangle[1].x;
   v1.y = Triangle[0].y - Triangle[1].y;
   v1.z = Triangle[0].z - Triangle[1].z;
   v1.w = Triangle[0].w - Triangle[1].w;

   v2.x = Triangle[1].x - Triangle[2].x;
   v2.y = Triangle[1].y - Triangle[2].y;
   v2.z = Triangle[1].z - Triangle[2].z;
   v2.w = Triangle[1].w - Triangle[2].w;

   CrossProduct(v1, v2);
   Normal();
}


void CVector4::CalculateTangentVector(CVector4 Point1, CVector4 Point2, CVector4 Point3,
                                      CVector4 NormalOfA, CTexCoord P1Tex, CTexCoord P2Tex,
                                      CTexCoord P3Tex)
{
   // Get the vector between point 1 and point 2.
   CVector4 VectorAB = Point2 - Point1;

   // Get the vector between point 1 and point 3.
	CVector4 VectorAC = Point3 - Point1;

   // Compute the components of the vectors to the vertex normal of the first point.
   CVector4 ProjAB = VectorAB - (NormalOfA * NormalOfA.DotProduct4(VectorAB));
   CVector4 ProjAC = VectorAC - (NormalOfA * NormalOfA.DotProduct4(VectorAC));

   // Calculate the tu difference of point 2 and 1 then of point 3 and 1.
   float TexCoorUAB = P2Tex.tu - P1Tex.tu;
   float TexCoorUAC = P3Tex.tu - P1Tex.tu;

	// Calculate the tv difference of point 2 and 1 then of point 3 and 1.
   float TexCoorVAB = P2Tex.tv - P1Tex.tv;
   float TexCoorVAC = P3Tex.tv - P1Tex.tv;

   // Switch the sign if the u of point 1 and 3 * v of 1 and 2 is greater than u of 1 and 2 *
   // v of point 1 and 3.
   if((TexCoorUAC * TexCoorVAB) > (TexCoorUAB * TexCoorVAC))
      {
         TexCoorUAC = -TexCoorUAC;
         TexCoorUAB = -TexCoorUAB;
      }

   // Calculate the tangent vector, normalize it, then return it (the normal values).
   CVector4 Tangent = (ProjAB * TexCoorUAC) - (ProjAC * TexCoorUAB);
   Tangent.Normal();

   *this += Tangent;
}


void CVector4::ExtendVertexPos(CVector4 currentVertex, CVector4 lightPos, float Extend)
{
    CVector4 lightDir;  // Direction of the light to the vertex position.
    CVector4 newPos;    // New extended vertex position to make up the shadow volume.

    // Get the light direction from the vertex position and the light position.
    lightDir = currentVertex - lightPos;

    // Now that we know where its going we add it to the position of the light so
    // we get the correct, new position.  We multiply it by a passed it value to
    // give the volume some distance or things won't come out quite as we want.
    newPos = lightPos + lightDir * Extend;

    x = newPos.x;
    y = newPos.y;
    z = newPos.z;
    w = newPos.w;
}


void CVector4::ExtendVertexPos(CVector4 lightPos, float Extend)
{
    CVector4 lightDir;  // Direction of the light to the vertex position.
    CVector4 newPos;    // New extended vertex position to make up the shadow volume.

    // Get the light direction from the vertex position and the light position.
    lightDir = CVector4(x, y, z, w) - lightPos;

    // Now that we know where its going we add it to the position of the light so
    // we get the correct, new position.  We multiply it by a passed it value to
    // give the volume some distance or things won't come out quite as we want.
    newPos = lightPos + lightDir * Extend;

    x = newPos.x;
    y = newPos.y;
    z = newPos.z;
    w = newPos.w;
}


CVector4 CVector4::GetRotatedX(double angle)
{
   float sinAngle = (float)sin(M_PI * angle / 180);
	float cosAngle = (float)cos(M_PI * angle / 180);

	return CVector4(x, y * cosAngle - z * sinAngle, y * sinAngle + z * cosAngle, w);
}


CVector4 CVector4::GetRotatedY(double angle)
{
   float sinAngle = (float)sin(M_PI * angle / 180);
	float cosAngle = (float)cos(M_PI * angle / 180);

	return CVector4(x * cosAngle + z * sinAngle, y, -x * sinAngle + z * cosAngle, w);
}


CVector4 CVector4::GetRotatedZ(double angle)
{
   float sinAngle = (float)sin(M_PI * angle / 180);
	float cosAngle = (float)cos(M_PI * angle / 180);

	return CVector4(x * cosAngle - y * sinAngle, x * sinAngle + y * cosAngle, z, w);

}


CVector4 CVector4::GetRotatedAxis(double angle, CVector4 axis)
{
	if(angle == 0.0) return(*this);

   axis.Normal();

	CVector4 RotationRow1, RotationRow2, RotationRow3;

   double newAngle = M_PI * angle / 180;
	float sinAngle = (float)sin(newAngle);
	float cosAngle = (float)cos(newAngle);
	float oneSubCos = 1.0f - cosAngle;

	RotationRow1.x = (axis.x) * (axis.x) + cosAngle * (1 - (axis.x) * (axis.x));
	RotationRow1.y = (axis.x) * (axis.y) * (oneSubCos) - sinAngle * axis.z;
	RotationRow1.z = (axis.x) * (axis.z) * (oneSubCos) + sinAngle * axis.y;

	RotationRow2.x = (axis.x) * (axis.y) * (oneSubCos) + sinAngle * axis.z;
	RotationRow2.y = (axis.y) * (axis.y) + cosAngle * (1 - (axis.y) * (axis.y));
	RotationRow2.z = (axis.y) * (axis.z) * (oneSubCos) - sinAngle * axis.x;
	
	RotationRow3.x = (axis.x) * (axis.z) * (oneSubCos) - sinAngle * axis.y;
	RotationRow3.y = (axis.y) * (axis.z) * (oneSubCos) + sinAngle * axis.x;
	RotationRow3.z = (axis.z) * (axis.z) + cosAngle * (1 - (axis.z) * (axis.z));

	return CVector4(this->DotProduct3(RotationRow1),
                   this->DotProduct3(RotationRow2),
                   this->DotProduct3(RotationRow3));
}


void CVector4::CalculateBinormalVector(CVector4 tangent, CVector4 normal)
{
   this->CrossProduct(tangent, normal);
}


void CVector4::ClampTo01()
{
   CVector4 temp(x, y, z, w);
   temp.Normal();
   temp = temp * 0.5f + CVector4(0.5f, 0.5f, 0.5f);

   x = temp.x;
   y = temp.y;
   z = temp.z;
}


// Copyright September 2003
// All Rights Reserved!
// Allen Sherrod
// ProgrammingAce@UltimateGameProgramming.com
// www.UltimateGameProgramming.com

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品毛片大码女人| 一区二区在线看| 久久精品视频免费| 中文字幕一区免费在线观看 | 日韩一区二区电影在线| 欧美久久久久久蜜桃| 欧美撒尿777hd撒尿| 久久亚洲精品小早川怜子| 国产精品传媒在线| 日本视频一区二区三区| 成人激情文学综合网| 911精品国产一区二区在线| 国产日韩精品一区二区浪潮av| 亚洲精品成人a在线观看| 激情综合网av| 欧美自拍偷拍一区| 国产欧美一区二区精品忘忧草| 一卡二卡欧美日韩| 国产老妇另类xxxxx| 欧美日韩中字一区| 中文欧美字幕免费| 久久99久久精品欧美| 成人a级免费电影| 日韩免费成人网| 亚洲一二三四在线观看| 国产白丝精品91爽爽久久| 91精品欧美一区二区三区综合在| 中文字幕欧美区| 久久狠狠亚洲综合| 91精品国产综合久久福利| 亚洲人成网站色在线观看 | 亚洲精品美国一| 国产乱子伦视频一区二区三区| 欧美唯美清纯偷拍| 亚洲日本在线观看| 成人精品视频网站| 久久女同精品一区二区| 久久精品国产一区二区三| 欧美亚洲一区二区在线| 亚洲欧美日韩一区二区三区在线观看| 国产伦精品一区二区三区免费迷| 欧美成va人片在线观看| 男男gaygay亚洲| 欧美美女黄视频| 视频在线在亚洲| 91精品综合久久久久久| 婷婷中文字幕综合| 99国产精品99久久久久久| 欧美不卡一区二区三区四区| 一区二区三区日本| 老司机免费视频一区二区| 欧美系列一区二区| 一区二区三区中文字幕| 在线免费视频一区二区| 亚洲一区在线观看免费| 精品视频在线免费| 亚洲成a人v欧美综合天堂 | 99re成人在线| 国产日韩综合av| 久久成人免费网| 久久麻豆一区二区| 成人激情校园春色| 亚洲激情五月婷婷| 欧美日韩国产经典色站一区二区三区 | 色域天天综合网| 亚洲线精品一区二区三区八戒| 欧美日韩国产天堂| 韩国视频一区二区| 亚洲国产成人一区二区三区| 91免费观看在线| 亚洲日穴在线视频| 欧美日韩国产精品成人| 青青草成人在线观看| 国产欧美精品一区二区三区四区 | 日韩天堂在线观看| 韩国成人福利片在线播放| 国产欧美精品一区| 欧美写真视频网站| 国产一区二区三区电影在线观看| 久久精品在线免费观看| 色哟哟欧美精品| 麻豆免费看一区二区三区| 中文一区一区三区高中清不卡| 欧洲一区二区三区免费视频| 美女国产一区二区三区| 欧美国产日韩在线观看| 欧美日韩久久久一区| 国产91精品一区二区麻豆网站| 亚洲精品国产精品乱码不99| 欧美一区二区三区电影| 99re这里只有精品视频首页| 日韩精品每日更新| 中文字幕在线不卡国产视频| 欧美久久免费观看| av在线播放成人| 精品在线免费观看| 亚洲午夜精品一区二区三区他趣| 精品国产一区二区三区久久影院 | 欧美人牲a欧美精品| 国产成人精品亚洲午夜麻豆| 日韩电影免费在线| 亚洲欧美日韩精品久久久久| 欧美电影免费观看完整版| 91免费观看在线| 国产精品一区2区| 日本欧美肥老太交大片| 久久综合狠狠综合| 欧美亚洲尤物久久| 99r精品视频| 国产精品亚洲专一区二区三区 | 精品亚洲成a人在线观看| 亚洲精品久久久蜜桃| 欧美一区二区三区在线观看| 99久久婷婷国产精品综合| 国产成人超碰人人澡人人澡| 蜜臀91精品一区二区三区| 一区二区三区日本| 一区二区三区美女视频| 综合欧美亚洲日本| 国产精品毛片a∨一区二区三区| 日韩精品一区二区三区老鸭窝| 欧美久久久久免费| 欧美日韩性生活| 91福利资源站| 国产精品夜夜爽| 国产精品18久久久久久久久| 五月婷婷激情综合网| 成人免费在线播放视频| 日韩一区二区免费高清| 51精品久久久久久久蜜臀| 欧美三级电影在线看| 欧美色综合影院| 欧美日韩国产片| 日韩视频不卡中文| 日韩欧美久久久| 久久一区二区视频| 国产日韩精品一区二区三区| 欧美国产精品一区二区三区| 亚洲国产精品99久久久久久久久| 久久精品亚洲国产奇米99| 久久精品欧美日韩精品 | 国产精品无人区| 久久精品在这里| 国产精品久久久久精k8| 亚洲美女免费视频| 亚洲国产乱码最新视频| 蜜臀精品久久久久久蜜臀| 国内偷窥港台综合视频在线播放| 高清国产午夜精品久久久久久| 成人免费观看男女羞羞视频| 97se亚洲国产综合自在线不卡 | 一区二区三区中文免费| 一区二区三区四区在线| 一二三区精品视频| 麻豆精品视频在线| 福利一区二区在线观看| 在线视频欧美区| 91精品国产一区二区人妖| 久久久国产精品不卡| 一区二区中文视频| 亚洲国产精品视频| 国产裸体歌舞团一区二区| 91小视频在线| 精品裸体舞一区二区三区| 国产精品久久久久久久久动漫| 性做久久久久久| 韩国av一区二区| 91极品视觉盛宴| 欧美视频三区在线播放| 欧美精品一区二区蜜臀亚洲| 亚洲手机成人高清视频| 日韩不卡手机在线v区| 精品一区二区免费在线观看| 91小视频免费看| 337p日本欧洲亚洲大胆精品| 亚洲欧洲韩国日本视频| 欧美a级理论片| 色香蕉久久蜜桃| 久久久av毛片精品| 性做久久久久久免费观看 | 中文一区在线播放| 韩国视频一区二区| 日韩一级欧美一级| 亚洲午夜私人影院| 91蜜桃婷婷狠狠久久综合9色| 久久精品一区蜜桃臀影院| 韩国成人精品a∨在线观看| 91麻豆精品国产91久久久更新时间 | 色成年激情久久综合| 亚洲国产精品黑人久久久| 国产一区二区不卡在线| 日韩午夜小视频| 久久狠狠亚洲综合| 欧美一级久久久久久久大片| 青青草原综合久久大伊人精品 | 国产精品成人一区二区三区夜夜夜 | 国产精品久久久久久久第一福利| 国产精品香蕉一区二区三区| 久久理论电影网| 国产黄色精品视频|