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


C++ Plane类代码示例

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


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

示例1: offset

//----------------------------------------------------
void CRocketLauncher::UpdateTPLaser(float frameTime)
{
	m_lastUpdate -= frameTime;

	bool allowUpdate = true;
	if(m_lastUpdate<=0.0f)
		m_lastUpdate = m_Timeout;
	else
		allowUpdate = false;

	const CCamera& camera = gEnv->pRenderer->GetCamera();

	//If character not visible, laser is not correctly updated
	if(CActor* pOwner = GetOwnerActor())
	{
		ICharacterInstance* pCharacter = pOwner->GetEntity()->GetCharacter(0);
		if(pCharacter && !pCharacter->IsCharacterVisible())
			return;
	}

	Vec3   offset(-0.06f,0.28f,0.115f); //To match scope position in TP LAW model
	Vec3   pos = GetEntity()->GetWorldTM().TransformPoint(offset);
	Vec3   dir = GetEntity()->GetWorldRotation().GetColumn1();

	Vec3 hitPos(0,0,0);
	float laserLength = 0.0f;

	if(allowUpdate)
	{
		IPhysicalEntity* pSkipEntity = NULL;
		if(GetOwner())
			pSkipEntity = GetOwner()->GetPhysics();

		const float range = m_LaserRangeTP;

		// Use the same flags as the AI system uses for visibility.
		const int objects = ent_terrain|ent_static|ent_rigid|ent_sleeping_rigid|ent_independent; //ent_living;
		const int flags = (geom_colltype_ray << rwi_colltype_bit) | rwi_colltype_any | (10 & rwi_pierceability_mask) | (geom_colltype14 << rwi_colltype_bit);

		ray_hit hit;
		if (gEnv->pPhysicalWorld->RayWorldIntersection(pos, dir*range, objects, flags,
			&hit, 1, &pSkipEntity, pSkipEntity ? 1 : 0))
		{
			laserLength = hit.dist;
			m_lastLaserHitPt = hit.pt;
			m_lastLaserHitSolid = true;
		}
		else
		{
			m_lastLaserHitSolid = false;
			m_lastLaserHitPt = pos + dir * range;
			laserLength = range + 0.1f;
		}

		// Hit near plane
		if (dir.Dot(camera.GetViewdir()) < 0.0f)
		{
			Plane nearPlane;
			nearPlane.SetPlane(camera.GetViewdir(), camera.GetPosition());
			nearPlane.d -= camera.GetNearPlane()+0.15f;
			Ray ray(pos, dir);
			Vec3 out;
			m_lastLaserHitViewPlane = false;
			if (Intersect::Ray_Plane(ray, nearPlane, out))
			{
				float dist = Distance::Point_Point(pos, out);
				if (dist < laserLength)
				{
					laserLength = dist;
					m_lastLaserHitPt = out;
					m_lastLaserHitSolid = true;
					m_lastLaserHitViewPlane = true;
				}
			}
		}

		hitPos = m_lastLaserHitPt;
	}
	else
	{
		laserLength = Distance::Point_Point(m_lastLaserHitPt, pos);
		hitPos = pos + dir * laserLength;
	}

	if (m_smoothLaserLength < 0.0f)
		m_smoothLaserLength = laserLength;
	else
	{
		if (laserLength < m_smoothLaserLength)
			m_smoothLaserLength = laserLength;
		else
			m_smoothLaserLength += (laserLength - m_smoothLaserLength) * min(1.0f, 10.0f * frameTime);
	}

	const float assetLength = 2.0f;
	m_smoothLaserLength = CLAMP(m_smoothLaserLength,0.01f,m_LaserRangeTP);
	float scale = m_smoothLaserLength / assetLength; 

	// Scale the laser based on the distance.
//.........这里部分代码省略.........
开发者ID:kitnet,项目名称:crynegine,代码行数:101,代码来源:RocketLauncher.cpp

示例2:

// line perpendicular to a plane at a specific point
Line::Line(const Plane& _plane, const Point& _point)
{
	Line(_plane.getNormalVector(), _point);
}
开发者ID:Boris-Petrov261,项目名称:geometry-3d-space,代码行数:5,代码来源:Line.cpp

示例3: setupSBA

void setupSBA(SysSBA &sys)
{
    // Create camera parameters.
    frame_common::CamParams cam_params;
    cam_params.fx = 430; // Focal length in x
    cam_params.fy = 430; // Focal length in y
    cam_params.cx = 320; // X position of principal point
    cam_params.cy = 240; // Y position of principal point
    cam_params.tx = 0.3; // Baseline 

    // Define dimensions of the image.
    int maxx = 640;
    int maxy = 480;

    // Create a plane containing a wall of points.
    Plane middleplane;
    middleplane.resize(3, 2, 10, 5);
    //middleplane.rotate(PI/4.0, PI/6.0, 1, 0);
    middleplane.rotate(PI/4.0, 1, 0, 1);
    middleplane.translate(0.0, 0.0, 5.0);
    
    // Create another plane containing a wall of points.
    Plane mp2;
    mp2.resize(3, 2, 10, 5);
    mp2.rotate(0, 0, 0, 1);
    mp2.translate(0.0, 0.0, 4.0);


    // Create another plane containing a wall of points.
    Plane mp3;
    mp3.resize(3, 2, 10, 5);
    mp3.rotate(-PI/4.0, 1, 0, 1);
    mp3.translate(0.0, 0.0, 4.5);



    // Vector containing the true point positions.
    vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > normals;
    
    points.insert(points.end(), middleplane.points.begin(), middleplane.points.end());
    normals.insert(normals.end(), middleplane.points.size(), middleplane.normal);
    points.insert(points.end(), mp2.points.begin(), mp2.points.end());
    normals.insert(normals.end(), mp2.points.size(), mp2.normal);
    points.insert(points.end(), mp3.points.begin(), mp3.points.end());
    normals.insert(normals.end(), mp3.points.size(), mp3.normal);
    
    // Create nodes and add them to the system.
    unsigned int nnodes = 2; // Number of nodes.
    double path_length = 1.0; // Length of the path the nodes traverse.

    // Set the random seed.
    unsigned short seed = (unsigned short)time(NULL);
    seed48(&seed);
    
    unsigned int i = 0;
    
    Vector3d inormal0 = middleplane.normal;
    Vector3d inormal1 = middleplane.normal;
    Vector3d inormal20 = mp2.normal;
    Vector3d inormal21 = mp2.normal;
    Vector3d inormal30 = mp3.normal;
    Vector3d inormal31 = mp3.normal;
    
    for (i = 0; i < nnodes; i++)
    { 
      // Translate in the x direction over the node path.
      Vector4d trans(i/(nnodes-1.0)*path_length, 0, 0, 1);
            
#if 1
      if (i >= 2)
	    {
	      // perturb a little
	      double tnoise = 0.5;	// meters
	      trans.x() += tnoise*(drand48()-0.5);
	      trans.y() += tnoise*(drand48()-0.5);
	      trans.z() += tnoise*(drand48()-0.5);
	    }
#endif

      // Don't rotate.
      Quaterniond rot(1, 0, 0, 0);
#if 1
      if (i >= 2)
	    {
	      // perturb a little
	      double qnoise = 0.1;	// meters
	      rot.x() += qnoise*(drand48()-0.5);
	      rot.y() += qnoise*(drand48()-0.5);
	      rot.z() += qnoise*(drand48()-0.5);
	    }
#endif
      rot.normalize();
      
      // Add a new node to the system.
      sys.addNode(trans, rot, cam_params, false);
      
      // set normal
      if (i == 0)
	{
	  inormal0 = rot.toRotationMatrix().transpose() * inormal0;
//.........这里部分代码省略.........
开发者ID:IDSCETHZurich,项目名称:gajanLocal,代码行数:101,代码来源:point_plane2_vis.cpp

示例4: ExtractPlanes

void Frustum::ExtractPlanes(glm::mat4 &clip)
{
	
        Plane *pPlane = 0;
		pPlane = &planes[FRUSTUM_PLANE_NEAR];
		pPlane->set(clip[0].w + clip[0].z, clip[1].w + clip[1].z, clip[2].w + clip[2].z, clip[3].w + clip[3].z);
        pPlane->normalize();

        // Left clipping plane.
        pPlane = &planes[FRUSTUM_PLANE_FAR];
        pPlane->set(clip[0].w - clip[0].z, clip[1].w - clip[1].z,clip[2].w - clip[2].z,clip[3].w - clip[3].z);
        pPlane->normalize();

        // Left clipping plane.
        pPlane = &planes[FRUSTUM_PLANE_LEFT];
        pPlane->set(clip[0].w + clip[0].x,clip[1].w + clip[1].x,clip[2].w + clip[2].x,clip[3].w + clip[3].x);
        pPlane->normalize();

        pPlane = &planes[FRUSTUM_PLANE_RIGHT];
        pPlane->set(clip[0].w - clip[0].x, clip[1].w - clip[1].x, clip[2].w - clip[2].x, clip[3].w - clip[3].x);
        pPlane->normalize();

        pPlane = &planes[FRUSTUM_PLANE_BOTTOM];
        pPlane->set(clip[0].w + clip[0].y,clip[1].w + clip[1].y,clip[2].w + clip[2].y,clip[3].w + clip[3].y);
        pPlane->normalize();

        pPlane = &planes[FRUSTUM_PLANE_TOP];
        pPlane->set(clip[0].w - clip[0].y, clip[1].w - clip[1].y, clip[2].w - clip[2].y, clip[3].w- clip[3].y);
        pPlane->normalize();
}
开发者ID:valentin-bas,项目名称:MineClient,代码行数:30,代码来源:Frustum.cpp

示例5: Intersects

bool Ray::Intersects(const Plane &plane) const
{
	return plane.Intersects(*this, 0);
}
开发者ID:360degrees-fi,项目名称:tundra,代码行数:4,代码来源:Ray.cpp

示例6: ExtractPlanes

		void Frustum::ExtractPlanes(ScePspFMatrix4 &clip)
		{
			Plane *pPlane = 0;

			// Left clipping plane.
			/*pPlane = &planes[FRUSTUM_PLANE_NEAR];
			pPlane->set(clip.w.x + clip.z.x,clip.w.y + clip.z.y,clip.w.z + clip.z.z,clip.w.w + clip.z.w);
			pPlane->normalize();

			// Left clipping plane.
			pPlane = &planes[FRUSTUM_PLANE_FAR];
			pPlane->set(clip.w.x - clip.z.x,clip.w.y - clip.z.y,clip.w.z - clip.z.z,clip.w.w - clip.z.w);
			pPlane->normalize();

			// Left clipping plane.
			pPlane = &planes[FRUSTUM_PLANE_LEFT];
			pPlane->set(clip.w.x + clip.x.x,clip.w.y + clip.x.y,clip.w.z + clip.x.z,clip.w.w + clip.x.w);
			pPlane->normalize();

			pPlane = &planes[FRUSTUM_PLANE_RIGHT];
			pPlane->set(clip.w.x - clip.x.x,clip.w.y - clip.x.y,clip.w.z - clip.x.z,clip.w.w - clip.x.w);
			pPlane->normalize();

			pPlane = &planes[FRUSTUM_PLANE_BOTTOM];
			pPlane->set(clip.w.x + clip.y.x,clip.w.y + clip.y.y,clip.w.z + clip.y.z,clip.w.w + clip.y.w);
			pPlane->normalize();

			pPlane = &planes[FRUSTUM_PLANE_TOP];
			pPlane->set(clip.w.x - clip.y.x,clip.w.y - clip.y.y,clip.w.z - clip.y.z,clip.w.w - clip.y.w);
			pPlane->normalize();*/

			// Left clipping plane.
			pPlane = &planes[FRUSTUM_PLANE_NEAR];
			pPlane->set(clip.x.w + clip.x.z,clip.y.w + clip.y.z,clip.z.w + clip.z.z,clip.w.w + clip.w.z);
			pPlane->normalize();

			// Left clipping plane.
			pPlane = &planes[FRUSTUM_PLANE_FAR];
			pPlane->set(clip.x.w - clip.x.z,clip.y.w - clip.y.z,clip.z.w - clip.z.z,clip.w.w - clip.w.z);
			pPlane->normalize();

			// Left clipping plane.
			pPlane = &planes[FRUSTUM_PLANE_LEFT];
			pPlane->set(clip.x.w + clip.x.x,clip.y.w + clip.y.x,clip.z.w + clip.z.x,clip.w.w + clip.w.x);
			pPlane->normalize();

			pPlane = &planes[FRUSTUM_PLANE_RIGHT];
			pPlane->set(clip.x.w - clip.x.x,clip.y.w - clip.y.x,clip.z.w - clip.z.x,clip.w.w - clip.w.x);
			pPlane->normalize();

			pPlane = &planes[FRUSTUM_PLANE_BOTTOM];
			pPlane->set(clip.x.w + clip.x.y,clip.y.w + clip.y.y,clip.z.w + clip.z.y,clip.w.w + clip.w.y);
			pPlane->normalize();

			pPlane = &planes[FRUSTUM_PLANE_TOP];
			pPlane->set(clip.x.w - clip.x.y,clip.y.w - clip.y.y,clip.z.w - clip.z.y,clip.w.w - clip.w.y);
			pPlane->normalize();


		}
开发者ID:BeYkeRYkt,项目名称:Minecraft-LCMod-J16-woolio,代码行数:60,代码来源:Frustum.cpp

示例7: loadSFM

int loadSFM(char* fileName, Mesh &mesh) {
	fstream file(fileName);
	string buffer;

	vector<point3> vertices;
	vector<vec3>   normals;
	vector<point3> faces;


	// if not opened
	if (!file.is_open())
	{
		cout << "Unable to open file" << endl;
		return 0;
	}

	// read file line by line
	while (getline(file, buffer, '\n'))
	{
		//if (buffer[0] == 'v') {
		//	fprintf(stdout, "Got v\n");
		//}

		if (buffer[0] != 'v' && buffer[0] != 'f') {
			continue;
		}

		// read each element in this line
		stringstream currentLine(buffer);
		string currentColumn;
		vector<double> triangleElement;
		while (getline(currentLine, currentColumn, '\ '))
		{
			if (currentColumn[0] != 'v' && currentColumn[0] != 'f') {
				triangleElement.push_back(stod(currentColumn)); //! stod converts string to double
			}
		}

		if (triangleElement.size() != 3) {
			fprintf(stdout, "Only read %llu elements from current line \n", triangleElement.size());
			return 0;
		}


		if (buffer[0] == 'v') {
			vertices.push_back(point3(triangleElement[0], triangleElement[1], triangleElement[2]));
			normals.push_back(vec3(0.0));
		}
		else if (buffer[0] == 'f') {
			faces.push_back(point3(triangleElement[0], triangleElement[1], triangleElement[2]));
		}
		else {
			fprintf(stdout, "buffer[0] is not either 'v' or 'f' \n");
			return 0;
		}
		
		
	}


	averageNormals(vertices, faces, normals);


	Plane temp;

	// store data in mesh
	for (int i = 0; i < faces.size(); i++) {
		//! smf index starts from 1 instead of 0, so need to -1
		Triangle3D facet;

		facet.faces[0] = int(faces[i][0]) - 1;
		facet.faces[1] = int(faces[i][1]) - 1;
		facet.faces[2] = int(faces[i][2]) - 1;

		facet.vertices[0] = vertices[facet.faces[0]];
		facet.vertices[1] = vertices[facet.faces[1]];
		facet.vertices[2] = vertices[facet.faces[2]];

		facet.normals[0] = normals[facet.faces[0]];
		facet.normals[1] = normals[facet.faces[1]];
		facet.normals[2] = normals[facet.faces[2]];
	
		
		temp.set3Points(facet.vertices[0], facet.vertices[2], facet.vertices[1]); // in this case clock wise is normal direction

		facet.triangleNormal = temp.normal;
		facet.centerOfMass = (facet.vertices[0] + facet.vertices[1] + facet.vertices[2]) / 3;
		mesh.push_back(facet);
	}

	return 1;
}
开发者ID:hby001,项目名称:InteractiveComputerGraphicsHW,代码行数:92,代码来源:loadSMF.cpp

示例8: FUNCTION_PROFILER


//.........这里部分代码省略.........

	if (m_allowUpdate)
	{
		m_allowUpdate = false;

		IPhysicalEntity* pSkipEntity = NULL;
		if(parent->GetOwner())
			pSkipEntity = parent->GetOwner()->GetPhysics();

		const float range = m_lamparams.laser_range[eIGS_ThirdPerson]*dsg1Scale;

		// Use the same flags as the AI system uses for visbility.
		const int objects = ent_terrain|ent_static|ent_rigid|ent_sleeping_rigid|ent_independent; //ent_living;
		const int flags = (geom_colltype_ray << rwi_colltype_bit) | rwi_colltype_any | (10 & rwi_pierceability_mask) | (geom_colltype14 << rwi_colltype_bit);

		ray_hit hit;
		if (gEnv->pPhysicalWorld->RayWorldIntersection(lamPos, dir*range, objects, flags,
			&hit, 1, &pSkipEntity, pSkipEntity ? 1 : 0))
		{
			laserLength = hit.dist;
			m_lastLaserHitPt = hit.pt;
			m_lastLaserHitSolid = true;
		}
		else
		{
			m_lastLaserHitSolid = false;
			m_lastLaserHitPt = lamPos + dir * range;
			laserLength = range + 0.1f;
		}

		// Hit near plane
		if (dir.Dot(camera.GetViewdir()) < 0.0f)
		{
			Plane nearPlane;
			nearPlane.SetPlane(camera.GetViewdir(), camera.GetPosition());
			nearPlane.d -= camera.GetNearPlane()+0.15f;
			Ray ray(lamPos, dir);
			Vec3 out;
			m_lastLaserHitViewPlane = false;
			if (Intersect::Ray_Plane(ray, nearPlane, out))
			{
				float dist = Distance::Point_Point(lamPos, out);
				if (dist < laserLength)
				{
					laserLength = dist;
					m_lastLaserHitPt = out;
					m_lastLaserHitSolid = true;
					m_lastLaserHitViewPlane = true;
				}
			}
		}

		hitPos = m_lastLaserHitPt;
	}
	else
	{
		laserLength = Distance::Point_Point(m_lastLaserHitPt, lamPos);
		hitPos = lamPos + dir * laserLength;
	}

	if (m_smoothLaserLength < 0.0f)
		m_smoothLaserLength = laserLength;
	else
	{
		if (laserLength < m_smoothLaserLength)
			m_smoothLaserLength = laserLength;
开发者ID:xxxAEKxxx,项目名称:Seasons,代码行数:67,代码来源:Lam.cpp

示例9:

float V3d::distAbove(Plane p) { // -ve if below in terms of plane's normal
  return p.distto(*this);
}
开发者ID:10crimes,项目名称:code,代码行数:3,代码来源:plane.c

示例10: main


//.........这里部分代码省略.........
  sh_texture.build();
  sh_texture.load_tex(NULL, buf_width, buf_height, N_COEFFS/4,
      GL_RGBA32F, GL_RGBA, GL_FLOAT);
  Framebuffer sh_buffer(buf_width,buf_height);
  sh_buffer.build();
  for (int i = 0; i < N_COEFFS/4; i++)
  {
    sh_buffer.bind_to_texture_layer(GL_COLOR_ATTACHMENT0+i,
        sh_texture.handle(), i);
  }

  glActiveTexture(GL_TEXTURE0+36);
  Texture2d shexp_texture;
  shexp_texture.build();
  shexp_texture.load_tex(NULL, buf_width, buf_height,
      GL_R32F, GL_RED, GL_FLOAT);
  Framebuffer shexp_buffer(buf_width,buf_height);
  shexp_buffer.build();
  shexp_buffer.bind_to_texture(GL_COLOR_ATTACHMENT0,
      shexp_texture.handle());

  Sphere sph;
  sph.build();

  glActiveTexture(GL_TEXTURE0+42);
  CubeMap skymap = gen_cube_map(256, sky_function, GL_R32F, GL_RED, GL_FLOAT);

  NDCQuad all_the_pixels;
  all_the_pixels.build();

  int num_spheres = load_spheres("Humanoid_0000.vsp", positions_data,
      radiuses_data);

  Plane pln;
  pln.build();
  Transform plane_transform(vec3(0,0,0),quat(1,0,0,0),vec3(2000));
  WorldObject pln_obj(&pln, &plane_transform);

  WavefrontMesh dude("Humanoid_0000.obj");
  dude.build();
  Transform dude_transform(vec3(0,0,0), quat(1,0,0,0), vec3(1));
  WorldObject dude_obj(&dude, &dude_transform);

  GLsizei n_objects = 2;
  WorldObject** objects = new WorldObject*[n_objects];
  objects[0] = &pln_obj;
  objects[1] = &dude_obj;

  float oracle_factor = 15;
  float far = 2000.0f;
  int width, height;
  float aspect;
  mat4 projection;

  sh_shader->use();
  sh_shader->updateInt("screen_width", buf_width);
  sh_shader->updateInt("screen_height", buf_height);
  sh_shader->updateInt("position", 33);
  sh_shader->updateInt("normal", 34);
  sh_shader->updateFloat("oracle_factor", oracle_factor);
  sh_shader->updateInt("sh_lut", 0);

  shexp_shader->use();
  shexp_shader->updateInt("screen_width", buf_width);
  shexp_shader->updateInt("screen_height", buf_height);
  shexp_shader->updateInt("a_lut", 1);
开发者ID:jellymann,项目名称:shexp,代码行数:67,代码来源:main.cpp

示例11: thrust_HiForest


//.........这里部分代码省略.........
	
      }//end axis loop
      
      if (debug) cout << "FINAL THRUST VALUE: " << thrust_max << endl; 
      
      // FILL BAD THRUST VALUES TO DEBUG =============================
      if(thrust_max < 0.47) {
	
	//h_TBadpT->Fill(pt[naxis], pThat_weight);
	h_TBad[cBin]->Fill(thrust_max);
	h_etaBad[cBin]->Fill(eta_v[max_nref]);
	h_phiBad[cBin]->Fill(phi_v[max_nref]);
	h_nrefBad[cBin]->Fill(max_nref);
	h_jetCountBad[cBin]->Fill(NJets_Sel);
	//h_weightBad->Fill(pThat_weight);
	//h_pthatBad->Fill(pThat);
	h_fileNum->Fill(ifile);

	if (debug) cout << "______________________________" << endl; 
	if (debug) cout << "| X0X : THRUST LESS THAN 0.5 |" << endl;
	if (debug) cout << "|  Max Thrust: " << thrust_max << endl;
	//cout << "|  Max Thrust: " << thrust_max << endl;
	if (debug) cout << "______________________________" << endl; 
      }

      // fill thrust vs Aj plot
      hThrust_vs_Aj[cBin]->Fill(Aj, thrust_max);

    
      //PART 3 ====================================================
      //Begin code to select the Thrust Major and Minor axes
      
      //define the plane perpendicular to this axis in order to calculate Tmaj and Tmin
      Plane* perp = new Plane(max_thrust_axis);
      
      //reset maximum values for new axis test
      thrust_maj_max = 0;   thrust_min_max = 0; 
      
      //Thrust maj axis loop
      for(Long64_t naxis = 0; naxis < NJets_Sel; ++naxis){

	// if((pt[naxis] < pT_cut)||(TMath::Abs(eta[naxis]) > 2)){ continue;}
	if(debug) cout<< " \n --------- New Test Axis (Min/Maj)--------- " << endl; 
	
	//define the jet axis for this iteration
	//calculate px, py, pz
	// px[naxis] = pt[naxis]*TMath::Cos(phi[naxis]);
	// py[naxis] = pt[naxis]*TMath::Sin(phi[naxis]); 
	// pz[naxis] = pt[naxis]*TMath::SinH(eta[naxis]);
	
	//define momentum three vector
	TVector3 p3 (px[naxis], py[naxis], pz[naxis]);
	if(debug) cout<<"Jet Axis UnNormed = {" << p3(0) << ", " << p3(1) << ", " << p3(2)<< "}" << endl;
	p3 = Norm(p3);
	if(debug) cout<<"Jet Axis Normed = {" << p3(0) << ", " << p3(1) << ", " << p3(2)<< "}" << endl;
	
	//define maj_axis and min_axis 
	TVector3 maj_axis = perp->Projection((p3));
	if(debug) cout<<"Maj Axis UnNormed = {" << maj_axis(0) << ", " << maj_axis(1) << ", " << maj_axis(2)<< "}" << endl;
	maj_axis = Norm(maj_axis);
	TVector3 min_axis = max_thrust_axis.Cross(maj_axis);
	min_axis = Norm(min_axis); 
	
	if(debug) cout<<"Jet Axis = {" << p3(0) << ", " << p3(1) << ", " << p3(2)<< "}" << endl;
	if(debug) cout<<"Maj Axis = {" << maj_axis(0) << ", " << maj_axis(1) << ", " << maj_axis(2)<< "}" << endl;
	if(debug) cout<<"Min Axis = {" << min_axis(0) << ", " << min_axis(1) << ", " << min_axis(2)<< "}\n" << endl;
开发者ID:rkunnawa,项目名称:CMSRun2Analysis,代码行数:67,代码来源:thrust_HiForest.C

示例12: Produce

void GameManager::Collision(FlyObject* objectA, FlyObject* objectB)
{
	int type_ = 0;
	if (objectA->Name() == "Player" || objectB->Name() == "Player")
	{
		if (objectB->Name() == "Player"){
			std::swap(objectA, objectB);
		}
		Player* play = static_cast<Player*>(objectA);

		if (objectB->Name() == "EnemyBomb")
		{
			Weapon *bomb = static_cast<Weapon*>(objectB);
			Produce(_T("Explosion"), Point(objectB->X() + objectB->Width() / 2, objectB->Y() + objectB->Height() / 2));
			if (!God()){ play->SubHP(bomb->Power());}
			if (play->HP() <= 0){
				//play->Killed();
				OverGame();}
			bomb->Killed();
		}
		if (objectB->Name() == "Enemy")
		{
			Plane *enemy = static_cast<Plane *>(objectB);
			if (enemy->DetailedName() == "Box" || enemy->DetailedName() == "BossLeft" || enemy->DetailedName() == "BossMid" || enemy->DetailedName() == "BossRight") return;
			Produce(_T("Explosion"), Point(objectB->X() + objectB->Width() / 2, objectB->Y() + objectB->Height() / 2));

			if (!God()) play->SubHP(1);
			if (play->HP() <= 0) {
				//play->Killed();
				OverGame();
			}

			if (enemy->DetailedName() == "EnemyPrimaryPlane")
			{
				factory_.ProduceTool(5, *(enemy->Position()), enemy->DetailedName());
			}
			else if (enemy->DetailedName() == "PropellerPlane")
			{
				factory_.ProduceTool(6, *(enemy->Position()), enemy->DetailedName());
			}
			else if (enemy->DetailedName() == "Tank")
			{
				factory_.ProduceTool(7, *(enemy->Position()), enemy->DetailedName());
			}
			else if (enemy->DetailedName() == "Box")
			{
				factory_.ProduceTool(Rand(5, 7), *(enemy->Position()), enemy->DetailedName());
			}

			enemy->Killed();

		}
		if (objectB->Name() == "Tool")
		{
			Tool *tool = static_cast<Tool *>(objectB);
			play->AddTool(tool->DetailedName(),tool->EnemyName(),tool->AddMark());
			tool->DestroyTool();
		}
	}
	else if (objectA->Name() == "PlayerBomb" || objectB->Name() == "PlayerBomb")
	{
		if (objectB->Name() == "PlayerBomb")
		{
			std::swap(objectA,objectB);
		}
		Weapon* bomb = static_cast<Weapon*>(objectA);
		
		if (objectB->Name() == "Enemy")
		{
			Plane* enemy = static_cast<Plane*>(objectB);
			bomb->Killed();
			enemy->SubHP(bomb->Power());
			if (enemy->HP() <= 0)
			{
				Produce(_T("Explosion"),Point(objectB->X() + objectB->Width()/2, objectB->Y() + objectB->Height() / 2));
				if (enemy->DetailedName() == "EnemyPrimaryPlane")
				{
					factory_.ProduceTool(5, *(enemy->Position()),enemy->DetailedName());
				}
				else if (enemy->DetailedName() == "PropellerPlane")				
				{
					factory_.ProduceTool(6, *(enemy->Position()), enemy->DetailedName());
				}
				else if (enemy->DetailedName() == "Tank")
				{
					factory_.ProduceTool(7, *(enemy->Position()), enemy->DetailedName());
				}
				else if (enemy->DetailedName() == "Box")
				{
					factory_.ProduceTool(Rand(5,7), *(enemy->Position()), enemy->DetailedName());
				}
				enemy->Killed();
			}

		}
	}
}
开发者ID:VivienCheng,项目名称:SkyPlane,代码行数:97,代码来源:GameManager.cpp

示例13: CCLOG

void GameWorld::updategame(float dt){
    //CCLOG("update game");
    
    Vector<Plane*> targets2Delete;
    //CCLOG("111, _targets: %zd.", _targets.size());
    Vector<Plane*>::iterator iter;//;
    for (iter = _targets.begin(); iter != _targets.end(); iter++) {
        // target的碰撞体积
        Plane* target = dynamic_cast<Plane*>(*iter);
        Rect targetRect = target->boundingBox();
        // plane的碰撞矩形
        Rect planeRect = _myPlane->boundingBox();
        // plane与target的碰撞检测
        if(targetRect.intersectsRect(planeRect)){
            if(target->getTag() == 4){
                CCLOG("package\n");
                // if package and plane collide
                //doubleBulletFlag = true;
                this->scheduleOnce(schedule_selector(GameWorld::setDoubleBulletFlagF), 5);
                targets2Delete.pushBack(target);
            } else {
                CCLOG("game end.");
                // if enemy and plane collide
                auto gameOverScene = GameOverScene::create();
                gameOverScene->getLayer()->getLabel()->setString(" ");
                gameOverScene->getLayer()->setCurrentScore(score);
                // converts 'int' to 'string'
                std::stringstream ss;
                std::string str;
                ss<<score;
                ss>>str;
                const char *pHighScore = str.c_str();
                // converts 'const char *' to 'int'
                const char *highScore = localStorageGetItem("high_score").c_str();
                if(highScore != NULL ){
                    int highScoreInt = std::atoi(highScore);
                    // If higher than the highest score ,your score will replace it;
                    if(highScoreInt<score)
                        CCLOG("high_score: %s.", pHighScore);
                        localStorageSetItem("high_score", pHighScore);
                }else{
                    localStorageSetItem("high_score", pHighScore);
                    CCLOG("high_score: %s.", pHighScore);
                }
                gameOverScene->getLayer()->getScore()->setString(pHighScore);
                Director::getInstance()->replaceScene(gameOverScene);
            }
        }
        
        //CCLOG("222, bullet: %zd.", _bullets.size());
        Vector<Sprite*> bullets2Delete;
        Vector<Sprite*>::iterator iterB;
        //bullet与target的碰撞
        for (iterB = _bullets.begin(); iterB != _bullets.end(); iterB++) {
        //CCARRAY_FOREACH(_bullets, bulletsIterator){
            auto bullet = dynamic_cast<Sprite*>(*iterB);
            Rect bulletRect = bullet->boundingBox();
            if(targetRect.intersectsRect(bulletRect)){
                target->attacked++;
                //CCLOG("target attacked: %d.", target->attacked);
                bullets2Delete.pushBack(bullet);
            }
        }
        
        /*
         CCLOG("333");
        for (iterB = bullets2Delete.begin(); iterB != bullets2Delete.end(); iter++) {
        //CCARRAY_FOREACH(bullets2Delete, bulletsIterator){
            auto bullet = dynamic_cast<Sprite*>(*iterB);
            _bullets.eraseObject(bullet);
            this->removeChild(bullet);
        }*/
        
        if(target->attacked >= target->attackedCount){
            targets2Delete.pushBack(target);
        }
        bullets2Delete.clear();
    }
    
    //CCLOG("444, targets2Delete: %zd.", targets2Delete.size());
    for (iter = targets2Delete.begin(); iter != targets2Delete.end(); iter++) {
    //CCARRAY_FOREACH(targets2Delete, targetIterator){
        auto target = dynamic_cast<Plane*>(*iter);
        _targets.eraseObject(target);
        if(target->getTag() == 1){
            score+=10;
        }else if(target->getTag() == 2){
            score+=20;
        }else if(target->getTag() == 3){
            score+=50;
            //CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("explosion.mp3");
        }else if(target->getTag() == 4){
            CCLOG("target is the package");
            this->scheduleOnce(schedule_selector(GameWorld::setDoubleBulletFlagF), 5);
            doubleBulletFlag = true;
        }
        this->removeChild(target);
        std::stringstream ss;
        std::string str;
        ss<<score;
//.........这里部分代码省略.........
开发者ID:shujunqiao,项目名称:cocos-samples,代码行数:101,代码来源:GameWorld.cpp

示例14: setUpResult

/*!
 * \brief BestFitPlane::setUpResult
 * \param plane
 * \return
 */
bool BestFitPlane::setUpResult(Plane &plane){

    //get and check input observations
    if(!this->inputElements.contains(0) || this->inputElements[0].size() < 3){
        emit this->sendMessage(QString("Not enough valid observations to fit the plane %1").arg(plane.getFeatureName()), eWarningMessage);
        return false;
    }
    QList<QPointer<Observation> > inputObservations;
    foreach(const InputElement &element, this->inputElements[0]){
        if(!element.observation.isNull() && element.observation->getIsSolved() && element.observation->getIsValid()
                && element.shouldBeUsed){
            inputObservations.append(element.observation);
            this->setIsUsed(0, element.id, true);
            continue;
        }
        this->setIsUsed(0, element.id, false);
    }
    if(inputObservations.size() < 3){
        emit this->sendMessage(QString("Not enough valid observations to fit the plane %1").arg(plane.getFeatureName()), eWarningMessage);
        return false;
    }

    //centroid
    OiVec centroid(4);
    foreach(const QPointer<Observation> &obs, inputObservations){
        centroid = centroid + obs->getXYZ();
    }
开发者ID:OpenIndy,项目名称:OpenIndy-DefaultPlugin,代码行数:32,代码来源:p_bestfitplane.cpp

示例15: AddPlane

void Frustum::CalculateFrustum(float angle, float ratio, float near, float far,
                               Vector3D &camPos, Vector3D &lookAt, Vector3D &up)
{
   Vector3D xVec, yVec, zVec;
	Vector3D vecN, vecF;
	Vector3D nearTopLeft, nearTopRight,
	         nearBottomLeft, nearBottomRight;
   Vector3D farTopLeft, farTopRight,
            farBottomLeft, farBottomRight;

	float radians = (float)tan((DEG_TO_RAD(angle)) * 0.5);
	float nearH = near  * radians;
	float nearW = nearH * ratio;
	float farH = far    * radians;
	float farW = farH   * ratio;

	zVec = camPos - lookAt;
	zVec.Normalize();

	xVec = up.CrossProduct(zVec);
	xVec.Normalize();

	yVec = zVec.CrossProduct(xVec);

	vecN = camPos - zVec * near;
	vecF = camPos - zVec * far;

	nearTopLeft     = vecN + yVec * nearH - xVec * nearW;
	nearTopRight    = vecN + yVec * nearH + xVec * nearW;
	nearBottomLeft  = vecN - yVec * nearH - xVec * nearW;
	nearBottomRight = vecN - yVec * nearH + xVec * nearW;

	farTopLeft      = vecF + yVec * farH - xVec * farW;
	farTopRight     = vecF + yVec * farH + xVec * farW;
	farBottomLeft   = vecF - yVec * farH - xVec * farW;
	farBottomRight  = vecF - yVec * farH + xVec * farW;

   m_frustum.clear();

   Plane plane;

   plane.CreatePlaneFromTri(nearTopRight, nearTopLeft,
                            farTopLeft);
   AddPlane(plane);

   plane.CreatePlaneFromTri(nearBottomLeft, nearBottomRight,
                            farBottomRight);
   AddPlane(plane);

   plane.CreatePlaneFromTri(nearTopLeft, nearBottomLeft,
                            farBottomLeft);
   AddPlane(plane);

   plane.CreatePlaneFromTri(nearBottomRight, nearTopRight,
                            farBottomRight);
   AddPlane(plane);

   plane.CreatePlaneFromTri(nearTopLeft, nearTopRight,
                            nearBottomRight);
   AddPlane(plane);

   plane.CreatePlaneFromTri(farTopRight, farTopLeft,
                            farBottomLeft);
   AddPlane(plane);
}
开发者ID:undisputed-seraphim,项目名称:rin.ai,代码行数:65,代码来源:Frustum.cpp


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