当前位置: 首页>>代码示例>>C++>>正文


C++ MakeVector函数代码示例

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


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

示例1: Str_Vector3N

TVector3 Str_Vector3N (const string &s) {
	float x, y, z;
	istringstream is(s);
	is >> x >> y >> z;
	if (is.fail()) return MakeVector (0, 0, 0);
	else return MakeVector (x, y, z);
}
开发者ID:gyeben,项目名称:extremetuxracer,代码行数:7,代码来源:spx.cpp

示例2: MFCollision_RayBoxTest

bool MFCollision_RayBoxTest(const MFVector& rayPos, const MFVector& rayDir, const MFVector& boxPos, const MFVector& boxRadius, MFRayIntersectionResult *pResult)
{
	MFVector plane[6];
	plane[0] = MakeVector(MFVector::up, boxPos.x + boxRadius.x);
	plane[1] = MakeVector(-MFVector::up, boxPos.x - boxRadius.x);
	return false;
}
开发者ID:RemedyGameJam,项目名称:fuji,代码行数:7,代码来源:MFCollision.cpp

示例3: IntersectPolygon

bool IntersectPolygon (TPolygon p, TVector3 *v) {
    TRay ray; 
    TVector3 nml, edge_nml, edge_vec;
    TVector3 pt;
    double d, s, nuDotProd, wec;
    double edge_len, t, distsq;
    int i;

    nml = MakeNormal (p, v);
    ray.pt = MakeVector (0., 0., 0.);
    ray.vec = nml;

    nuDotProd = DotProduct (nml, ray.vec);
    if  (fabs(nuDotProd) < EPS)
        return false;

    d = - (nml.x * v[p.vertices[0]].x + 
           nml.y * v[p.vertices[0]].y + 
           nml.z * v[p.vertices[0]].z);

    if  (fabs (d) > 1) return false;

    for  (i=0; i < p.num_vertices; i++) {
		TVector3 *v0, *v1;

		v0 = &v[p.vertices[i]];
		v1 = &v[p.vertices[ (i+1) % p.num_vertices ]]; 

		edge_vec = SubtractVectors (*v1, *v0);
		edge_len = NormVector (&edge_vec);

		t = - DotProduct (*((TVector3 *) v0), edge_vec);

		if  (t < 0) {
			distsq = MAG_SQD2 (*v0);
		} else if  (t > edge_len) {
			distsq = MAG_SQD2 (*v1);
		} else {
			*v0 = AddVectors (*v0, ScaleVector (t, edge_vec));
			distsq = MAG_SQD2 (*v0);
		}

		if  (distsq <= 1) return true;
    }

    s = - (d + DotProduct (nml, MakeVector (ray.pt.x, ray.pt.y, ray.pt.z))) / nuDotProd;
    pt = AddVectors (ray.pt, ScaleVector (s, ray.vec));

    for  (i=0; i < p.num_vertices; i++) {
        edge_nml = CrossProduct (nml, 
            SubtractVectors (v[p.vertices[ (i+1) % p.num_vertices ]], v[p.vertices[i]]));

        wec = DotProduct (SubtractVectors (pt, v[p.vertices[i]]), edge_nml);
        if (wec < 0) return false;
    } 
    return true;
} 
开发者ID:cdlewis,项目名称:extremetuxracer,代码行数:57,代码来源:mathlib.cpp

示例4: make_view_matrix

void make_view_matrix(Vec p1, Vec p2, Matrix m)
{
	Flt d, len, l1;
	Vec up, out, left;
	Vec upv={0,1,0};

	//Log( "make_view_matrix()...\n");
	//Line between p1 and p2 form a LOS Line-of-sight.
	//A rotation matrix is built to transform objects to this LOS.
	//
	//Diana Gruber
	//http://www.makegames.com/3Drotation/
	//
	m[0][0]=1.0; m[0][1]=0.0; m[0][2] =0.0;
	m[1][0]=0.0; m[1][1]=1.0; m[1][2] =0.0;
	m[2][0]=0.0; m[2][1]=0.0; m[2][2] =1.0;
	VecSub(p2, p1, out);
	//
	len = out[0]*out[0] + out[1]*out[1] + out[2]*out[2];
	if (len == 0.0) {
		MakeVector(0.0,0.0,1.0,out);
	}
	else {
		l1 = 1.0 / sqrt(len);
		out[0] *= l1;
		out[1] *= l1;
		out[2] *= l1;
	}
	//
	m[2][0] = out[0];
	m[2][1] = out[1];
	m[2][2] = out[2];
	//
	d = out[0] * upv[0] + out[1] * upv[1] + out[2] * upv[2]; 
	up[0] = upv[0] - d * out[0];
	up[1] = upv[1] - d * out[1];
	up[2] = upv[2] - d * out[2];
	len = up[0]*up[0] + up[1]*up[1] + up[2]*up[2];
	if (len == 0.0) {
		MakeVector(0, 0, 1, up);
	} else {
		l1 = 1.0 / sqrt(len);
		up[0] *= l1;
		up[1] *= l1;
		up[2] *= l1;
	}
	m[1][0] = up[0];
	m[1][1] = up[1];
	m[1][2] = up[2];
	//make left vector.
	VecCross(up, out, left);
	m[0][0] = left[0];
	m[0][1] = left[1];
	m[0][2] = left[2];
}
开发者ID:wanderlast,项目名称:cs335-heistgame,代码行数:55,代码来源:matrix.c

示例5: MFFont_DrawText

float MenuItemColour::ListDraw(bool selected, const MFVector &_pos, float maxWidth)
{
	MFVector pos = _pos;

	MFFont_DrawText(MFFont_GetDebugFont(), pos+MakeVector(0.0f, MENU_FONT_HEIGHT*0.25f, 0.0f), MENU_FONT_HEIGHT, selected ? MakeVector(1,1,0,1) : MFVector::one, MFStr("%s: 0x%08X", name, pData->ToPackedColour()));

	pos += MakeVector(maxWidth - 55.0f, 2.0f, 0.0f);

	MFPrimitive(PT_TriStrip|PT_Untextured);

	MFBegin(4);
	MFSetColourV(MFVector::white);
	MFSetPositionV(pos);
	MFSetPositionV(pos + MakeVector(45.0f, 0.0f, 0.0f));
	MFSetPositionV(pos + MakeVector(0.0f, MENU_FONT_HEIGHT*1.5f-4.0f, 0.0f));
	MFSetPositionV(pos + MakeVector(45.0f, MENU_FONT_HEIGHT*1.5f-4.0f, 0.0f));
	MFEnd();

	pos += MakeVector(2.0f, 2.0f, 0.0f);

	MFBegin(4);
	MFSetColourV(*pData);
	MFSetPositionV(pos);
	MFSetPositionV(pos + MakeVector(41.0f, 0.0f, 0.0f));
	MFSetPositionV(pos + MakeVector(0.0f, MENU_FONT_HEIGHT*1.5f-8.0f, 0.0f));
	MFSetPositionV(pos + MakeVector(41.0f, MENU_FONT_HEIGHT*1.5f-8.0f, 0.0f));
	MFEnd();

	return MENU_FONT_HEIGHT*1.5f;
}
开发者ID:TurkeyMan,项目名称:fuji,代码行数:30,代码来源:DebugMenu.cpp

示例6: MFRenderer_ClearScreen

void EditorScreen::Draw()
{
	GHScreen::DrawScreens();	

	MFRenderer_ClearScreen(MFRCF_Depth);

	MFMatrix mat;
	mat.LookAt(MakeVector(2.0,1.5,-1.0), MakeVector(1.0,0.3f,1.0f));
	MFView_SetCameraMatrix(mat);
//	pScene->Draw();
}
开发者ID:KingDwag,项目名称:feedback-editor,代码行数:11,代码来源:Editor.cpp

示例7: if

void CCharShape::AdjustOrientation (CControl *ctrl, double dtime,
		 double dist_from_surface, TVector3 surf_nml) {
    TVector3 new_x, new_y, new_z; 
    TMatrix cob_mat, inv_cob_mat;
    TMatrix rot_mat;
    TQuaternion new_orient;
    double time_constant;
    static TVector3 minus_z_vec = { 0, 0, -1};
    static TVector3 y_vec = { 0, 1, 0 };

    if  (dist_from_surface > 0) {
		new_y = ScaleVector (1, ctrl->cvel);
		NormVector (&new_y);
		new_z = ProjectToPlane (new_y, MakeVector(0, -1, 0));
		NormVector (&new_z);
		new_z = AdjustRollvector (ctrl, ctrl->cvel, new_z);
    } else { 
		new_z = ScaleVector (-1, surf_nml);
		new_z = AdjustRollvector (ctrl, ctrl->cvel, new_z);
		new_y = ProjectToPlane (surf_nml, ScaleVector (1, ctrl->cvel));
		NormVector(&new_y);
    }

    new_x = CrossProduct (new_y, new_z);
    MakeBasismatrix_Inv (cob_mat, inv_cob_mat, new_x, new_y, new_z);
    new_orient = MakeQuaternionFromMatrix (cob_mat);

    if (!ctrl->orientation_initialized) {
		ctrl->orientation_initialized = true;
		ctrl->corientation = new_orient;
    }

    time_constant = dist_from_surface > 0 ? TO_AIR_TIME : TO_TIME;

    ctrl->corientation = InterpolateQuaternions (
			ctrl->corientation, new_orient, 
			min (dtime / time_constant, 1.0));

    ctrl->plane_nml = RotateVector (ctrl->corientation, minus_z_vec);
    ctrl->cdirection = RotateVector (ctrl->corientation, y_vec);
    MakeMatrixFromQuaternion (cob_mat, ctrl->corientation);

    // Trick rotations 
    new_y = MakeVector (cob_mat[1][0], cob_mat[1][1], cob_mat[1][2]); 
    RotateAboutVectorMatrix (rot_mat, new_y, (ctrl->roll_factor * 360));
    MultiplyMatrices (cob_mat, rot_mat, cob_mat);
    new_x = MakeVector (cob_mat[0][0], cob_mat[0][1], cob_mat[0][2]); 
    RotateAboutVectorMatrix (rot_mat, new_x, ctrl->flip_factor * 360);
    MultiplyMatrices (cob_mat, rot_mat, cob_mat);

    TransposeMatrix (cob_mat, inv_cob_mat);
    TransformNode (0, cob_mat, inv_cob_mat); 
}
开发者ID:RKSimon,项目名称:extremetuxracer,代码行数:53,代码来源:tux.cpp

示例8: ReInitBaseSize

void ReInitBaseSize(int NewDimBase,int NewOverSampling)
  {
    const int OldPrn=prn;                    /* Ustalenie nowego rozmiaru bazy */
    register int i,AllDim;

    prn=OFF;
    if(AllocStatus==ON)
      {
        CloseRand2D();                       /* Zwolnienie poprzednich zasobow */
        free((void *)sygnal);
        free((void *)OrgSygnal);
        CloseTune();
      }

    DimBase=NewDimBase;
    OverSampling=NewOverSampling;
    SetTuneScale();                         /* Alokcja nowych zasobow */
    if(MallatDiction==ON)
      {
        DictionSize=MakeMallatDictionary(DimBase,OverSampling,OFF);
        if(Heuristic==ON)                       /* Poprawnosc konfiguracji */
          {
            if(StartDictionSize>=DictionSize)
              Heuristic=OFF;
            else if(FastMode==OFF)
              Heuristic=OFF;
            else if(DiadicStructure==OFF)
              Heuristic=OFF;
          }
      }

    if(Heuristic==OFF)
      StartDictionSize=DictionSize;

    if(InicRandom(OFF)==-1)
      {
        fprintf(stderr,"Problems opening randomized dictionary !\n");
        exit(EXIT_FAILURE);
      }

    if((sygnal=MakeVector(AllDim=3*DimBase))==NULL ||
       (OrgSygnal=MakeVector(DimBase))==NULL)
      {
        fprintf(stderr,"Memory allocation error (main) !\n");
        exit(EXIT_FAILURE);
      }

    for(i=0 ; i<AllDim ; i++)
      sygnal[i]=0.0F;
    for(i=0 ; i<DimBase ; i++)
      OrgSygnal[i]=0.0F;
    prn=OldPrn;
  }
开发者ID:dellagustin,项目名称:mp31,代码行数:53,代码来源:main.c

示例9: init

void init() {
	#ifdef USE_UMBRELLA
	umbrella.pos[0] = 220.0;
	umbrella.pos[1] = (double)(yres-200);
	VecCopy(umbrella.pos, umbrella.lastpos);
	umbrella.width = 200.0;
	umbrella.width2 = umbrella.width * 0.5;
	umbrella.radius = (float)umbrella.width2;
	umbrella.shape = UMBRELLA_FLAT;
	#endif //USE_UMBRELLA
	MakeVector(-150.0,180.0,0.0, bigfoot.pos);
	MakeVector(6.0,0.0,0.0, bigfoot.vel);
}
开发者ID:DrewLane24,项目名称:Project,代码行数:13,代码来源:rainforest.c

示例10: init

void init() {
    kangaroo.pos[0] = 60.0;
    kangaroo.pos[1] = 60.0;
    VecCopy(kangaroo.pos, kangaroo.lastpos);
    kangaroo.width = 200.0;
    kangaroo.width2 = kangaroo.width * 0.5;
    kangaroo.height = 100.0;
    kangaroo.height2 = kangaroo.height * 0.5;
    kangaroo.shape = 1;

    MakeVector(150.0,180.0,0.0, rhino.pos);
    MakeVector(-6.0,0.0,0.0, rhino.vel);
    rhino.height = 200.0;
    rhino.height2 = rhino.height * 0.5;

    MakeVector(150.0,180.0,0.0, animal.pos);
    MakeVector(-6.0,0.0,0.0, animal.vel);
    animal.height = 200.0;
    animal.height2 = animal.height * 0.5;

    MakeVector(150.0,180.0,0.0, apple.pos);//#########################4lin
    MakeVector(-6.0,0.0,0.0, apple.vel);
    apple.height = 200.0;
    apple.height2 = apple.height * 0.5;
//############################################

    MakeVector(300.0,600.0,0.0, ufo.pos);
    MakeVector(0.0,-6.0,0.0, ufo.vel);
}
开发者ID:KangarooInc,项目名称:KangarooKO,代码行数:29,代码来源:AngelKangarooKO.c

示例11: PolygonCenter

vector3d PolygonCenter(pcs_polygon &polygon)
{

	float TotalArea=0, triarea;
	vector3d Centroid = MakeVector(0,0,0), midpoint;

	for (unsigned int i = 0; i < polygon.verts.size()-2; i++)
	{
		midpoint = polygon.verts[i].point + polygon.verts[i+1].point + polygon.verts[i+2].point;
		midpoint = midpoint/3;

		// Area of Triangle defined by P1, P2, P3 = vector3d(crossProduct(p2-p1, p3-p1)).magnitude()/2

		triarea = Magnitude(CrossProduct(polygon.verts[i+1].point-polygon.verts[i].point, 
										 polygon.verts[i+2].point-polygon.verts[i].point)); // this needs to be area * 2
		if (triarea == 0)
		{
			return PolygonCenterFallback(polygon);
			//exit(1); //panic
		}
		midpoint = triarea*midpoint;
		TotalArea += triarea;
		Centroid += midpoint;

	}

	Centroid = float(1.0 / TotalArea) * Centroid;
	return Centroid;

}
开发者ID:z64555,项目名称:PCS2,代码行数:30,代码来源:pcs_pof_bspfuncs.cpp

示例12: MD3DecodeNormal

MFVector MD3DecodeNormal(unsigned short code)
{
	float latitude = ((float)(code & 0xFF)) * (2 * MFPI) / ((float)255);
	float longtitude = ((float)((code >> 8) & 0xFF)) * (2 * MFPI) / ((float)255);

	return MakeVector(-(float)(MFCos(latitude) * MFSin(longtitude)), -(float)(MFSin(latitude) * MFSin(longtitude)), -(float)(MFCos(longtitude)));
}
开发者ID:FujiGameJam,项目名称:fuji,代码行数:7,代码来源:ReadMD3.cpp

示例13: Game_Update

void Game_Update()
{
	// calculate a spinning world matrix
	MFMatrix world;
	world.SetTranslation(MakeVector(0, -5, 50));

	static float rotation = 0.0f;
	rotation += MFSystem_TimeDelta();
	world.RotateY(rotation);

	// set world matrix to the model
	MFModel_SetWorldMatrix(pModel, world);

	// advance the animation
	MFAnimation *pAnim = MFModel_GetAnimation(pModel);
	if(pAnim)
	{
		float start, end;
		MFAnimation_GetFrameRange(pAnim, &start, &end);
	
		static float time = 0.f;
		time += MFSystem_TimeDelta();// * 500;
		while(time >= end)
			time -= end;
		MFAnimation_SetFrame(pAnim, time);
	}
}
开发者ID:FujiGameJam,项目名称:fuji,代码行数:27,代码来源:main.cpp

示例14: if

void CKeyframe::Update (double timestep, CControl *ctrl) {
	if (!loaded) return;
    double frac;
    TVector3 pos;
	CCharShape *shape = Char.GetShape (g_game.char_id);

	if (!active) return;
    keytime += timestep;
	if (keytime >= frames[keyidx]->val[0]) {
		keyidx++;
		keytime = 0;
	}

    if  (keyidx >= numFrames-1 || numFrames < 2) {
		active = false;
        return;
    } 

    if  (fabs (frames[keyidx]->val[0]) < 0.0001) frac = 1.0;
	else frac = (frames[keyidx]->val[0] - keytime) / frames[keyidx]->val[0];

    pos.x = interp (frac, frames[keyidx]->val[1], frames[keyidx+1]->val[1]) + refpos.x;
    pos.z = interp (frac, frames[keyidx]->val[3], frames[keyidx+1]->val[3]) + refpos.z;
    pos.y = interp (frac, frames[keyidx]->val[2], frames[keyidx+1]->val[2]);
    pos.y += Course.FindYCoord (pos.x, pos.z);

	shape->ResetRoot ();
	shape->ResetJoints ();

    Players.GetCtrl (g_game.player_id)->cpos = pos;
    double disp_y = pos.y + TUX_Y_CORR + heightcorr; 
    shape->ResetNode (0);
    shape->TranslateNode (0, MakeVector (pos.x, disp_y, pos.z));
	InterpolateKeyframe (keyidx, frac, shape);
}
开发者ID:RKSimon,项目名称:extremetuxracer,代码行数:35,代码来源:keyframe.cpp

示例15: TEST_P

TEST_P(OpModuleProcessedTest, AnyString) {
  const std::string input =
      std::string("OpModuleProcessed \"") + GetParam() + "\"";
  EXPECT_THAT(
      CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_1),
      Eq(MakeInstruction(SpvOpModuleProcessed, MakeVector(GetParam()))));
}
开发者ID:Dagarman,项目名称:mame,代码行数:7,代码来源:text_to_binary.debug_test.cpp


注:本文中的MakeVector函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。