您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ vector3函数代码示例

51自学网 2021-06-03 09:36:53
  C++
这篇教程C++ vector3函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中vector3函数的典型用法代码示例。如果您正苦于以下问题:C++ vector3函数的具体用法?C++ vector3怎么用?C++ vector3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了vector3函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(){	//**************//	//** jVector2 **//	//**************//	// Create an "empty" jVector2:  (0,0)	jVector2 vector1;	// Create "partial" jVector2: (5,0)	jVector2 vector2(5.0f);	// Create "full" jVector2: (1,2)	jVector2 vector3(1.0f, 2.0f);	// print the vectors out	std::cout << vector1.toString() << std::endl;	std::cout << vector2.toString() << std::endl;	std::cout << vector3.toString() << std::endl;	// add two vectors together	jVector2 sum23 = vector2 + vector3;	std::cout << sum23.toString() << std::endl;	// subtract two vectors	jVector2 diff = jVector2(6.0f, 4.0f) - jVector2(10.0f, 2.0f);	std::cout << diff.toString() << std::endl;	// multiply vector by scalar	std::cout << (vector3 * 1.25f).toString() << std::endl;	// divide vector by scalar	std::cout << (sum23 / 10.0f).toString() << std::endl;	// test equality	std::cout << (sum23 == diff) << std::endl;	// test inequality	std::cout << (diff != vector1) << std::endl;	// get magnitude	std::cout << vector3.magnitude_sqr() << std::endl;	// normalize vector	std::cout << (vector3.normalized()).toString() << std::endl;	////////////////////////////////////////////////////	// jVector3	jVector3 vector_1;	jVector3 vector_2(5.0f);	jVector3 vector_3(1.0f, 2.0f, 3.0f);	std::cout << vector_1.toString() << std::endl;	std::cout << vector_2.toString() << std::endl;	std::cout << vector_3.toString() << std::endl;	// This will be put into the jDebug namespace/class./*	#ifdef linux	#else		// And this is why programming for Windows sucks...		HANDLE h_stdout = GetStdHandle( STD_OUTPUT_HANDLE );		CONSOLE_SCREEN_BUFFER_INFO csbi;		GetConsoleScreenBufferInfo( h_stdout, &csbi );		// Foreground B G R I		// Colors     0 0 1 1		// Background B G R I		// Colors     0 0 0 1		// All together, 00110001 is like this:		SetConsoleTextAttribute( h_stdout, 0x31 );		std::cout << vector_1 << std::endl;		SetConsoleTextAttribute( h_stdout, csbi.wAttributes );	#endif */	jDebug::LogError("An error has occurred!");	jDebug::LogWarning("A warning has occurred!");	jDebug::Log("A notification has appeared.");	jDebug::AddLogger("main", "logs/main.log");	jDebug::LogError("main", "A test error to be found in main.log");	jDebug::Log("main", "A test notification to be found in main.log");	// Don't forget your cleanup!	jDebug::DestructLoggers();	return 0;}
开发者ID:RengaJ,项目名称:jtech,代码行数:78,


示例2: normalize

 vector3 normalize() {     float norm = sqrt(x*x + y*y + z*z);     return vector3(x / norm, y / norm, z / norm); }
开发者ID:glurbi,项目名称:cglcore,代码行数:4,


示例3: normalize3

 Vector4T&	normalize3   (double len = 1.0)		       { vector3().normalize(len); return *this; }
开发者ID:enuuros,项目名称:multitude,代码行数:1,


示例4: while

//------------------------------------------------------------------------------bool OBOpenDXCubeFormat::ReadMolecule( OBBase* pOb, OBConversion* pConv ){    OBMol* pmol = pOb->CastAndClear<OBMol>();    if(pmol == 0)      return false;    istream& ifs = *pConv->GetInStream();    const char* title = pConv->GetTitle();    char buffer[BUFF_SIZE];    stringstream errorMsg;    if (!ifs)      return false; // We are attempting to read past the end of the file    pmol->SetTitle(title);    while (ifs.good() && ifs.getline(buffer,BUFF_SIZE)) {      if (buffer[0] == '#')        continue; // comment line      if (EQn(buffer, "object", 6))        break;    }    if (!ifs)      return false; // ran out of lines    vector<string> vs;    tokenize(vs, buffer);    // Number of grid points (voxels)    vector<int> voxels(3);    if (!EQn(buffer, "object", 6) || vs.size() != 8)      return false;    else {      voxels[0] = atoi(vs[5].c_str());      voxels[1] = atoi(vs[6].c_str());      voxels[2] = atoi(vs[7].c_str());    }    double x, y, z;    if (!ifs.getline(buffer, BUFF_SIZE) || !EQn(buffer, "origin", 6))      return false;    else {      tokenize(vs, buffer);      if (vs.size() != 4)        return false;      x = atof(vs[1].c_str());      y = atof(vs[2].c_str());      z = atof(vs[3].c_str());    }    vector3 origin(x, y, z);    // now three lines with the x, y, and z axes    vector<vector3> axes;    for (unsigned int i = 0; i < 3; ++i) {      if (!ifs.getline(buffer, BUFF_SIZE) || !EQn(buffer, "delta", 5))        return false;      else {        tokenize(vs, buffer);        if (vs.size() != 4)          return false;        x = atof(vs[1].c_str());        y = atof(vs[2].c_str());        z = atof(vs[3].c_str());        axes.push_back(vector3(x, y, z));      }    }    // Two remaining header lines before the data:    /*      object 2 class gridconnections counts nx ny nz      object 3 class array type double rank 0 times n data follows    */    if (!ifs.getline(buffer, BUFF_SIZE) || !EQn(buffer, "object", 6))      return false;    if (!ifs.getline(buffer, BUFF_SIZE) || !EQn(buffer, "object", 6))      return false;    pmol->BeginModify();    pmol->SetDimension(3);    OBGridData *gd = new OBGridData;    gd->SetAttribute("OpenDX");    // get all values as one vector<double>    char *endptr;    vector<double> values;    int n = voxels[0]*voxels[1]*voxels[2];    int line = 0;    values.reserve(n);    while (ifs.getline(buffer, BUFF_SIZE))    {      ++line;      if (EQn(buffer, "attribute", 9))        break; // we're finished with reading data -- although we should probably have a voxel check in here too      tokenize(vs, buffer);      if (vs.size() == 0)//.........这里部分代码省略.........
开发者ID:Reinis,项目名称:openbabel,代码行数:101,


示例5: Plane

Tmpl8::Frustum::Frustum(){////////////////////////////////// Viewspace frustum ////////////////////////////////////////// didn't quit finish it. 	float top = -(SCRHEIGHT / 2) + 1; 	float left = -(SCRWIDTH / 2) + 1; 	float bottom = (SCRHEIGHT / 2) - 1; 	float right = (SCRWIDTH / 2) - 1; 	float nearp = 1.0f; 	float farp = 50; 	float FoV = 0.003;  	for(unsigned int i = 0; i < 6; ++i) 	{ 		m_Plane[i] = new Plane(); 	}  	vector3 nv1, nv2, nv3, nv4; 	vector3 fv1, fv2, fv3, fv4;  	nv1.x = left * nearp / FoV; 	nv1.y = top * nearp / FoV; 	nv1.z = nearp;  	nv2.x = left * nearp / FoV; 	nv2.y = bottom * nearp / FoV; 	nv2.z = nearp;  	nv3.x = right * nearp / FoV; 	nv3.y = top * nearp / FoV; 	nv3.z = nearp;  	nv4.x = right * nearp / FoV; 	nv4.y = bottom * nearp / FoV; 	nv4.z = nearp;  	fv1.x = left * farp / FoV; 	fv1.y = top * farp / FoV; 	fv1.z = farp;  	fv2.x = left * farp / FoV; 	fv2.y = bottom * farp / FoV; 	fv2.z = farp;  	fv3.x = right * farp / FoV; 	fv3.y = top * farp / FoV; 	fv3.z = farp;  	fv4.x = right * farp / FoV; 	fv4.y = bottom * farp / FoV; 	fv4.z = farp;  	//Left 	vector3 edge1 = nv1 - nv2; 	vector3 edge2 = nv1 - fv1; 	vector3 normal = edge1.Cross(edge2); 	float length = normal.Length(); 	normal.Normalize(); 	m_Plane[Frustum::PLANE_LEFT]->SetNormal(normal); 	m_Plane[Frustum::PLANE_LEFT]->SetDistance(0);   	//Right 	edge1 = nv4 - nv3; 	edge2 = nv3 - fv3; 	normal = edge1.Cross(edge2); 	normal.Normalize(); 	m_Plane[Frustum::PLANE_RIGHT]->SetNormal(normal); 	m_Plane[Frustum::PLANE_RIGHT]->SetDistance(0);  	//Top 	edge1 = nv4 - nv2; 	edge2 = nv2 - fv2; 	normal = edge2.Cross(edge1); 	normal.Normalize(); 	m_Plane[Frustum::PLANE_TOP]->SetNormal(normal); 	m_Plane[Frustum::PLANE_TOP]->SetDistance(0);  	//bottom 	edge1 = nv3 - nv1; 	edge2 = nv1 - fv1; 	normal = edge1.Cross(edge2); 	normal.Normalize(); 	m_Plane[Frustum::PLANE_BOTTOM]->SetNormal(normal); 	m_Plane[Frustum::PLANE_BOTTOM]->SetDistance(0);  	m_Plane[Frustum::PLANE_NEAR]->SetNormal(vector3(0, 0, 1)); 	m_Plane[Frustum::PLANE_NEAR]->SetDistance(nearp); 	m_Plane[Frustum::PLANE_FAR]->SetNormal(vector3(0, 0, -1)); 	m_Plane[Frustum::PLANE_FAR]->SetDistance(-farp);}
开发者ID:JoeyFladderak,项目名称:Software-Rasterizer,代码行数:92,


示例6: AxisParams

CUniversalJoint::CUniversalJoint(): AxisParams(2){	AxisParams[0].Axis = vector3(0.0f, 0.0f, 1.0f);	AxisParams[1].Axis = vector3(0.0f, 1.0f, 0.0f);}
开发者ID:moltenguy1,项目名称:deusexmachina,代码行数:5,


示例7: vector3

void AppClass::InitVariables(void){	//Set the camera position	m_pCameraMngr->SetPositionTargetAndView(		vector3(0.0f, 2.5f, 15.0f),//Camera position		vector3(0.0f, 2.5f, 0.0f),//What Im looking at		REAXISY);//What is up	m_pCameraMngr->SetCameraMode(CAMERAMODE::CAMROTHOZ);	//Instance objects to display the game elements	m_pMeshMngr->InstanceSphere(0.3f, 5, RERED, "Ball");	m_pMeshMngr->InstanceCuboid(vector3(20, 1, 1), REPURPLE, "BoxT");	m_pMeshMngr->InstanceCuboid(vector3(20, 1, 1), REPURPLE, "BoxB");	m_pMeshMngr->InstanceCuboid(vector3(1, 11, 1), REGREEN, "BoxL");	m_pMeshMngr->InstanceCuboid(vector3(1, 11, 1), REGREEN, "BoxR");		m_pMeshMngr->InstanceCuboid(vector3(0.5, 3, 0.5), REBLUE, "PalletL");	m_pMeshMngr->InstanceCuboid(vector3(0.5, 3, 0.5), REBLUE, "PalletR");	//Create game objects based on the loaded objects	m_pBall = new MyEntityClass("Ball");		m_pBoxT = new MyEntityClass("BoxT");	m_pBoxB = new MyEntityClass("BoxB");	m_pBoxL = new MyEntityClass("BoxL");	m_pBoxR = new MyEntityClass("BoxR");	m_pPalletL = new MyEntityClass("PalletL");	m_pPalletR = new MyEntityClass("PalletR");	//Set properties of the objects	m_pBall->SetVelocity(vector3(0.11f, 0.11f, 0.0f));	m_pBoxT->SetModelMatrix(glm::translate(vector3(0, 5, 0)));	m_pBoxB->SetModelMatrix(glm::translate(vector3(0, -5, 0)));	m_pBoxR->SetModelMatrix(glm::translate(vector3(10.5, 0, 0)));}
开发者ID:icicle-tricycle,项目名称:Lab_Rat,代码行数:38,


示例8: ON_KEY_PRESS_RELEASE

void AppClass::ProcessKeyboard(void){	bool bModifier = false;	float fSpeed = 0.01f;#pragma region ON PRESS/RELEASE DEFINITION	static bool	bLastF1 = false, bLastF2 = false, bLastF3 = false, bLastF4 = false, bLastF5 = false,				bLastF6 = false, bLastF7 = false, bLastF8 = false, bLastF9 = false, bLastF10 = false,				bLastEscape = false;#define ON_KEY_PRESS_RELEASE(key, pressed_action, released_action){  /			bool pressed = sf::Keyboard::isKeyPressed(sf::Keyboard::key);			/			if(pressed){											/				if(!bLast##key) pressed_action;}/*Just pressed? *//			else if(bLast##key) released_action;/*Just released?*//			bLast##key = pressed; } //remember the state#pragma endregion#pragma region Modifiers	if(sf::Keyboard::isKeyPressed(sf::Keyboard::LShift) || sf::Keyboard::isKeyPressed(sf::Keyboard::RShift))		bModifier = true;#pragma endregion	if (sf::Keyboard::isKeyPressed(sf::Keyboard::R))	{		m_v3Orientation = vector3(0.0f);		something = quaternion(vector3(0.0f, 0.0f, 0.0f));	}	if (sf::Keyboard::isKeyPressed(sf::Keyboard::X))	{		if (!bModifier) {			m_v3Orientation.x += 1.0f;			something = something * quaternion(vector3(PI * 0.01f, 0, 0));		}		else {			m_v3Orientation.x -= 1.0f;			something = something * quaternion(-vector3(PI * 0.01f, 0, 0));		}	}	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Y))	{		if (!bModifier) {			m_v3Orientation.y += 1.0f;			something = something * quaternion(vector3(PI * 0.01f, 0, 0));		}		else {			m_v3Orientation.y -= 1.0f;			something = something * quaternion(-vector3(0.0f, -PI * 0.01f, 0));		}	}	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Z))	{		if (!bModifier) {			m_v3Orientation.z += 1.0f;			something = something * quaternion(vector3(PI * 0.01f, 0, 0));		}		else {			m_v3Orientation.z -= 1.0f;			something = something * quaternion(-vector3(0, 0, -PI * 0.01f));		}	}#pragma region Camera Positioning	if(bModifier)		fSpeed *= 10.0f;	if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))		m_pCameraMngr->MoveForward(fSpeed);	if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))		m_pCameraMngr->MoveForward(-fSpeed);		if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))		m_pCameraMngr->MoveSideways(-fSpeed);	if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))		m_pCameraMngr->MoveSideways(fSpeed);	m_pCameraMngr->CalculateView();#pragma endregion#pragma region Other Actions	ON_KEY_PRESS_RELEASE(Escape, NULL, PostMessage(m_pWindow->GetHandler(), WM_QUIT, NULL, NULL))#pragma endregion}
开发者ID:VLesnar,项目名称:ReEngineApp_2015s,代码行数:83,


示例9: vector3

vector3 vector3::sym(vector3 v1)//V关于N的对称就是2(N*V)*N-V{	double k=2*(this->x*v1.x+this->y*v1.y+this->z*v1.z)/(v1.x*v1.x+v1.y*v1.y+v1.z*v1.z);	return vector3(v1.x*k-this->x,v1.y*k-this->y,v1.z*k-this->z);}
开发者ID:perypery,项目名称:perypery,代码行数:5,


示例10: while

  bool XSFFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)  {    OBMol* pmol = pOb->CastAndClear<OBMol>();    if(pmol==NULL)      return false;    //Define some references so we can use the old parameter names    istream &ifs = *pConv->GetInStream();    OBMol &mol = *pmol;    const char* title = pConv->GetTitle();    char buffer[BUFF_SIZE];    string str;    double x,y,z;    OBAtom *atom;    vector3 translationVectors[3];    int numTranslationVectors = 0;    vector<string> vs;    vector<vector3> atomPositions;    bool createdAtoms = false;    int atomicNum;    mol.BeginModify();    while (ifs.getline(buffer, BUFF_SIZE))      {        if (buffer[0] == '#')          continue; // comment        if (strstr(buffer, "ATOMS") != NULL) {          // Minimum of 4 columns -- AtNum, x, y, z (forces)          // where AtNum stands for atomic number (or symbol), while X Y Z are          ifs.getline(buffer, BUFF_SIZE);          tokenize(vs, buffer);          while (vs.size() >= 4) {            if (!createdAtoms) {              atom = mol.NewAtom();              //set atomic number              atomicNum = OBElements::GetAtomicNum(vs[0].c_str());              if (atomicNum == 0) {                atomicNum = atoi(vs[0].c_str());              }              atom->SetAtomicNum(atomicNum);            }            x = atof((char*)vs[1].c_str());            y = atof((char*)vs[2].c_str());            z = atof((char*)vs[3].c_str());            atomPositions.push_back(vector3(x, y, z)); // we may have a movie or animation            ifs.getline(buffer, BUFF_SIZE);            tokenize(vs, buffer);          }          createdAtoms = true; // don't run NewAtom() anymore        }        else if ( strstr(buffer, "PRIMVEC")                 || strstr(buffer, "CONVVEC") ) {          // translation vectors          numTranslationVectors = 0; // if we have an animation          while (numTranslationVectors < 3 && ifs.getline(buffer,BUFF_SIZE)) {            tokenize(vs,buffer); // we really need to check that it's 3 entries only            if (vs.size() < 3) return false; // timvdm 18/06/2008            x = atof((char*)vs[0].c_str());            y = atof((char*)vs[1].c_str());            z = atof((char*)vs[2].c_str());            translationVectors[numTranslationVectors++].Set(x, y, z);          }        }        else if (strstr(buffer, "PRIMCOORD") != NULL) {          // read the coordinates          ifs.getline(buffer, BUFF_SIZE);          tokenize(vs, buffer);          if (vs.size() < 2) return false;          int numAtoms = atoi(vs[0].c_str());          for (int a = 0; a < numAtoms; ++a) {            if (!ifs.getline(buffer,BUFF_SIZE))              break;            tokenize(vs,buffer);            if (vs.size() < 4)              break;            if (!createdAtoms) {              atom = mol.NewAtom();              //set atomic number              atomicNum = OBElements::GetAtomicNum(vs[0].c_str());              if (atomicNum == 0) {                atomicNum = atoi(vs[0].c_str());              }              atom->SetAtomicNum(atomicNum);            }            x = atof((char*)vs[1].c_str());            y = atof((char*)vs[2].c_str());            z = atof((char*)vs[3].c_str());            atomPositions.push_back(vector3(x, y, z));          }        }      }    mol.EndModify();    int natom = mol.NumAtoms();//.........这里部分代码省略.........
开发者ID:Reinis,项目名称:openbabel,代码行数:101,


示例11: rotate_vector

	vector3 rotate_vector( vector3 const& v, quat const& q )	{		quat p = quat(v.x(), v.y(), v.z(), 0);		quat tp = q * p * q.inverse();		return vector3(tp.qx(), tp.qy(), tp.qz());	}
开发者ID:yozhijk,项目名称:test,代码行数:6,


示例12: vector3

void AppClass::Update(void){	//Sets the camera	m_pCameraMngr->SetPositionTargetAndView(vector3(0.0f, 25.0f, 0.0f), vector3(0.0f, 0.0f, 0.0f), -REAXISZ);	//Update the system's time	m_pSystem->UpdateTime();	//Update the mesh manager's time without updating for collision detection	m_pMeshMngr->Update();	//First person camera movement	if (m_bFPC == true)		CameraRotation();	//Call the arcball method	ArcBall();	//Adds all loaded instance to the render list	m_pMeshMngr->AddInstanceToRenderList("ALL");	//This matrices will just orient the objects to the camera	matrix4 rotateX = glm::rotate(IDENTITY_M4, 90.0f, vector3(1.0f, 0.0f, 0.0f));	matrix4 rotateY = glm::rotate(IDENTITY_M4, 90.0f, vector3(0.0f, 1.0f, 0.0f));	//This matrices will hold the relative transformation of the Moon and the Earth	matrix4 distanceEarth = glm::translate(11.0f, 0.0f, 0.0f);	matrix4 distanceMoon = glm::translate(2.0f, 0.0f, 0.0f);	//Earth's orbit around the Sun	matrix4 orbitEarth = glm::rotate(IDENTITY_M4, m_fEarthTimer, vector3(0.0f, 1.0f, 0.0f));	//Earth's rotation on its own axis	matrix4 rotationEarth = glm::rotate(IDENTITY_M4, m_fEarthTimer * 28.0f, vector3(0.0f, 1.0f, 0.0f));	//Moon's orbit around the Earth	matrix4 orbitMoon = glm::rotate(IDENTITY_M4, m_fMoonTimer, vector3(0.0f, -1.0f, 0.0f));	//Moon's rotation around its own axis	matrix4 rotationMoon = glm::rotate(IDENTITY_M4, m_fMoonTimer, vector3(0.0f, 1.0f, 0.0f));	//I will calculate the Earth position in space relative to the Sun (which is in global space)	matrix4 earthsSpace = orbitEarth * distanceEarth;//the translation depends on the orientation of the space (Earths orbit)	m_m4Earth = earthsSpace * rotationEarth;//the rotation of the Earth will depend on the new space	m_m4Earth = m_m4Earth * rotateX;//Will orient the Earth to the camera now	//I will calculate the moon's position in space relative to the Earth (earthsSpace)	matrix4 moonsSpace = orbitMoon * distanceMoon;//the moon's translation depends on its orientation (Moons orbit)	m_m4Moon = earthsSpace * moonsSpace;//Then we place the moons space in therms of the earth space	m_m4Moon = m_m4Moon * rotateY * rotateX;//Then we orient the Moon to the camera)	printf("Earth Day: %.3f, Moon Day: %.3f/r", m_fEarthTimer, m_fMoonTimer);//print the Frames per Second	//Indicate the FPS	int nFPS = m_pSystem->GetFPS();	//Print info on the screen	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);	m_pMeshMngr->Print("Earth Day: ", REWHITE);	m_pMeshMngr->PrintLine(std::to_string(m_fEarthTimer), REBLUE);	m_pMeshMngr->Print("Moon Day: ", REWHITE);	m_pMeshMngr->PrintLine(std::to_string(m_fMoonTimer), REBLUE);	m_pMeshMngr->Print("FPS:");	m_pMeshMngr->Print(std::to_string(nFPS), RERED);	m_fMoonTimer++;//Increase moon timer	m_fEarthTimer = m_fMoonTimer / 28.0f; //divide by the moon's day}
开发者ID:kxk9106,项目名称:ReEngineApp_2015s,代码行数:65,


示例13: vector3

glm::mat4 Camera::GetView(){    return glm::lookAt(vector3(position.x, position.y, position.z),        vector3(target.x, target.y, target.z),        vector3(up.x, up.y, up.z));}
开发者ID:twixthehero,项目名称:ReEngineApp_2015s,代码行数:6,


示例14: dirWCStoLCS

//	dir3D conversions to/from different RHCoordSyst3'svector3	dirWCStoLCS(vector3 vDir1, RHCoordSys3 LCS){	normalize(vDir1);	return vector3(dot(vDir1,LCS[0]),dot(vDir1,LCS[1]),dot(vDir1,LCS[2]));}
开发者ID:Chandangsharma,项目名称:EnergyPlus,代码行数:6,


示例15: v3Max

void ApplicationClass::GenerateBoundingBox(matrix4 a_mModelToWorld, String a_sInstanceName){	if(m_pMeshMngr->IsInstanceCreated(a_sInstanceName))	{		static bool bInitialized = false;		static vector3 vCenterPoint;		static float fDistance;		if(!bInitialized)		{			std::vector<vector3> lVertices = m_pMeshMngr->m_pModelMngr->GetVertices(a_sInstanceName);			unsigned int nVertices = lVertices.size();			vCenterPoint = lVertices[0];			vector3 v3Max(lVertices[0]);			vector3 v3Min(lVertices[0]);			for(unsigned int nVertex = 1; nVertex < nVertices; nVertex++)			{				//m_v3Centroid += lVertices[nVertex];				if(v3Min.x > lVertices[nVertex].x)					v3Min.x = lVertices[nVertex].x;				else if(v3Max.x < lVertices[nVertex].x)					v3Max.x = lVertices[nVertex].x;							if(v3Min.y > lVertices[nVertex].y)					v3Min.y = lVertices[nVertex].y;				else if(v3Max.y < lVertices[nVertex].y)					v3Max.y = lVertices[nVertex].y;				if(v3Min.z > lVertices[nVertex].z)					v3Min.z = lVertices[nVertex].z;				else if(v3Max.z < lVertices[nVertex].z)					v3Max.z = lVertices[nVertex].z;			}			vCenterPoint = (v3Min + v3Max) / 2.0f;			m_pMeshMngr->AddAxisToQueue(a_mModelToWorld * glm::translate(vCenterPoint));			fDistance = glm::distance(vCenterPoint, lVertices[0]);			for(unsigned int nVertex = 1; nVertex < nVertices; nVertex++)			{				float fDistanceNew = glm::distance(vCenterPoint, lVertices[nVertex]);				if(fDistance < fDistanceNew)					fDistance = fDistanceNew;			}			bInitialized = true;		}		m_pMeshMngr->AddCubeToQueue(a_mModelToWorld * glm::translate(vCenterPoint) * glm::scale(vector3(fDistance * 2.0f)), MERED, MERENDER::WIRE);	}}
开发者ID:eric-fonseca,项目名称:HomeworkA8,代码行数:49,


示例16: Update

void ApplicationClass::Update (void){	m_pSystem->UpdateTime(); //Update the system	m_pMeshMngr->Update(); //Updates the mesh information	float fTimeSpan = m_pSystem->StopClock(); //Check the time difference between this method calls	static float fRunTime = 0.0f;	fRunTime += fTimeSpan; //update the run time count	//matrix4 m4Steve = glm::rotate(matrix4(IDENTITY), fRunTime * 15, vector3( 0.0f,-1.0f, 0.0f));	matrix4 m4Steve = glm::translate(vector3( 0.0f,0.0f, 0.0f));	matrix4 m4Zombie = glm::translate(vector3(-6.0f, 0.0f, 0.0f));	matrix4 m4Cow = glm::translate(vector3(-3.0f, 0.0f, 0.0f));	matrix4 m4Pig = glm::translate(vector3(6.0f, 0.0f, 0.0f));		m_pMeshMngr->SetModelMatrix(m4Steve, "Steve");	m_pMeshMngr->SetModelMatrix(m_m4Creeper, "Creeper");	m_pMeshMngr->SetModelMatrix(m4Pig, "Pig");	m_pMeshMngr->SetModelMatrix(m4Zombie, "Zombie");	m_pMeshMngr->SetModelMatrix(m4Cow, "Cow");#pragma region Method	//GenerateBoundingBox(mA,"A");#pragma endregion#pragma region Bounding Box Class	//pBoundingBox1->GenerateBoundingBox("Steve");	//pBoundingBox2->GenerateBoundingBox("Creeper");		//pBoundingBox1->AddBoxToRenderList(m4Steve, MEYELLOW, true);	//pBoundingBox2->AddBoxToRenderList(m_m4Creeper, MEYELLOW, true);#pragma endregion#pragma region Bounding Box Manager	m_pBSMngr->GenerateBoundingBox("Steve");	m_pBSMngr->GenerateBoundingBox("Creeper");	m_pBSMngr->GenerateBoundingBox("Cow");	m_pBSMngr->GenerateBoundingBox("Zombie");	m_pBSMngr->GenerateBoundingBox("Pig");	m_pBSMngr->SetBoundingBoxSpace(m4Steve, "Steve");	m_pBSMngr->SetBoundingBoxSpace(m_m4Creeper, "Creeper");	m_pBSMngr->SetBoundingBoxSpace(m4Cow, "Cow");	m_pBSMngr->SetBoundingBoxSpace(m4Pig, "Pig");	m_pBSMngr->SetBoundingBoxSpace(m4Zombie, "Zombie");	m_pBSMngr->CalculateCollision();	m_pBSMngr->AddBoxToRenderList("ALL");#pragma endregion	m_pMeshMngr->AddInstanceToRenderList();		//First person camera movement	if(m_bFPC == true)		CameraRotation();	m_pCamera->PrintInfo();	printf("FPS: %d/r", m_pSystem->FPS);//print the Frames per Second}
开发者ID:eric-fonseca,项目名称:HomeworkA8,代码行数:62,


示例17: pow

	Intersection Cylindre::intersect(Rayon* r){	Intersection inter;	double a;	double b;	double c;	double delta;	double t, t1, t2;	/* equation du Cylindre y
C++ vector3d函数代码示例
C++ vector2f函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。