Esempio n. 1
0
void Player::addRandomPlane(std::string strSrc, bool isVisible) {
	int i = 0;
	bool isAdded = false;
	while(i<10 && !isAdded) {
		Plane* plane = genRandomPlane();
		if(!isPlaneConflicts(plane)) {
			//添加飞机
			addPlane(plane->direction, plane->pos, strSrc, isVisible);
			isAdded = true;
			CCLog("addRandomPlane_isAdded x=%f,y=%f", plane->pos.x, plane->pos.y);
		}
		i++;
	}
	//遍历的方式来保证可以顺利添加
	if(!isAdded) {	//TODO 写死的数字修改
		Direction direction = getRandomDirection();
		float posX=0.0f, posY=0.0f;
		if(direction == NORTH || direction == SOUTH) {
			posX = 6;
			posY = 7;
		} else {
			posX = 7;
			posY = 6;
		}
		for(int i=0; i<posX; i++) {
			for(int j=0; j<posY; j++) {
				if(!isPlaneConflicts(new Plane(ccp(i,j), direction))) {
					addPlane(direction, ccp(i,j), strSrc, isVisible);	//bugfix 在右侧添加了盟军飞机
					CCLog("addRandomPlane_isAdded_false x=%f,y=%f", i, j);
					return;
				}
			}
		}
	}
}
bool SceneParser::addElement(struct basicxmlnode * elementNode, Scene * scene){
	if (!elementNode) {
		std::cout << "SceneParser::addElement: empty element node \n";
		return false;
	}

	// find out element type
	if (std::string(elementNode->tag) == "Plane") {
		return addPlane(elementNode, scene);
	}
  else if (std::string(elementNode->tag) == "CirclePlane") {
		return addCirclePlane(elementNode, scene);
	}
	else if (std::string(elementNode->tag) == "Sphere") {
		return addSphere(elementNode, scene);
	}
	else if (std::string(elementNode->tag) == "Triangle") {
		return addTriangle(elementNode, scene);
	}
	else if (std::string(elementNode->tag) == "Quadric") {
		return addQuadric(elementNode, scene);
	}
	else if (std::string(elementNode->tag) == "Torus") {
		return addTorus(elementNode, scene);
	}
	else if (std::string(elementNode->tag) == "TriangleMesh") {
		return addTriangleMesh(elementNode, scene);
	}
	else {
		std::cout << "SceneParser::addElement: do not know how to generate \"" << elementNode->tag << "\"\n";
		return false;
	}
}
Esempio n. 3
0
void OgreBuilding::renderObliqueShape(MaterialDefinition const& material, Polygon const& bottomBase, Polygon const& topBase,
                                                                          Point const& beginingHeight, Point const& endHeight)
{
  assert(bottomBase.numberOfVertices() == topBase.numberOfVertices());
  assert(bottomBase.isClosed());

  Vector floorOffset = Vector(0, 0, beginingHeight.z());
  Vector ceilingOffset = Vector(0, 0, endHeight.z());

  Vector normal;
  unsigned int current, next;
  for (unsigned int number = 0; number < bottomBase.numberOfVertices(); number++)
  {
    current = number;
    next = (number + 1) % bottomBase.numberOfVertices();

    normal = bottomBase.edgeNormal(current)*(-1);

    Polygon plane;
    plane.addVertex(bottomBase.vertex(current) + floorOffset);
    plane.addVertex(bottomBase.vertex(next) + floorOffset);
    plane.addVertex(topBase.vertex(next) + ceilingOffset);
    plane.addVertex(topBase.vertex(current) + ceilingOffset);

    addPlane(plane, normal, material);
  }
}
Esempio n. 4
0
Q_matrix::Q_matrix(Vertex *v)
{
 a2=ab=ac=ad=b2=bc=bd=c2=cd=d2=0;
 Triangle *t;
 Node *n;
 List *vt = v->VT();
 FOREACHVTTRIANGLE(vt, t, n) addPlane(t);
 delete(vt);
}
void OptimizedPolyList::plane(U32 v1, U32 v2, U32 v3)
{
   /*
   AssertFatal(v1 < mPoints.size() && v2 < mPoints.size() && v3 < mPoints.size(),
      "OptimizedPolyList::plane(): Vertex indices are larger than vertex list size");

   mPolyList.last().plane = addPlane(PlaneF(mPoints[v1], mPoints[v2], mPoints[v3]));
   */

   mPolyList.last().plane = addPlane( PlaneF( mPoints[mVertexList[v1].vertIdx], mPoints[mVertexList[v2].vertIdx], mPoints[mVertexList[v3].vertIdx] ) );
}
Esempio n. 6
0
//TODO 崩溃 未重现
bool Player::rotate(Plane *plane) {
	Direction direct = getRotateDirection(plane->direction);
	Plane * newPlane = new Plane(plane->pos, direct);
	if(!isPlaneConflicts(newPlane, plane) && isPlaneInBoard(plane->pos, direct)) {
		newPlane->release();
		CCLog("plane rotate");
		CCPoint pos = plane->pos;
		deletePlane(plane);
		addPlane(direct, pos);
		return true;
	}
	newPlane->release();
	return false;
}
Esempio n. 7
0
//TODO 崩溃 未重现
bool Player::move(Plane *plane, int x, int y) {
	CCLog("************plane move:%f",plane->pos.x);
	CCPoint pos = ccp(plane->pos.x+x,plane->pos.y+y);
	Direction direct = plane->direction;
	Plane * newPlane = new Plane(pos, direct);
	if(!isPlaneConflicts(newPlane, plane) && isPlaneInBoard(pos, direct)) {
		CCLog("**************delete plane");
		deletePlane(plane);
		addPlane(direct, pos);
		newPlane->release();
		CCLog("**************newPlane release true");
		return true;
	}
	newPlane->release();
	CCLog("***************newPlane release false");
	return false;
}
Esempio n. 8
0
bool Plane::init(){
    CCSprite::initWithFile(getPlaneRes());
    
    addPlane(this);
    
    speed = CCRANDOM_0_1()*4+1;
    
    if(rand()%100<50){
        setScaleX(1);
        setPosition(ccp(570, 370));
        speed = -speed;
    }else{
        setScaleX(-1);
        setPosition(ccp(-20, 370));
    }
    
    scheduleUpdate();
    return true;
}
Esempio n. 9
0
vector<PxActor*> World::addWorldBox(const ofVec3f &leftTopFar, const ofVec3f& rightBottomNear)
{
	vector<PxActor*> result;

	result.push_back(addPlane(ofVec3f(leftTopFar.x, 0, 0)));
	result.push_back(addPlane(ofVec3f(rightBottomNear.x, 0, 0), ofQuaternion(180, ofVec3f(0, 1, 0))));

	result.push_back(addPlane(ofVec3f(0, rightBottomNear.y, 0), ofQuaternion(90, ofVec3f(0, 0, -1))));
	result.push_back(addPlane(ofVec3f(0, leftTopFar.y, 0), ofQuaternion(90, ofVec3f(0, 0, 1))));

	result.push_back(addPlane(ofVec3f(0, 0, rightBottomNear.z), ofQuaternion(90, ofVec3f(0, 1, 0))));
	result.push_back(addPlane(ofVec3f(0, 0, leftTopFar.z), ofQuaternion(90, ofVec3f(0, -1, 0))));

	return result;
}
void visualization::DetectionVisualizer::visualizeSampledGrasps()
{
  if (obj().draw_sampled_grasps_)
  {
    Point middle;
    middle.getVector3fMap() = obj().obj_bounding_box_->position_base_kinect_frame_;

    removeShape(SUPPORT_PLANE);
    addPlane(*(obj().table_plane_), middle.x, middle.y, middle.z, SUPPORT_PLANE);

    CloudPtr side_grasps = obj().getSampledSideGrasps();
    const pcl::PCLHeader &header = obj().world_obj_->header;
    transformPointCloud(FOOTPRINT_FRAME, header.frame_id, side_grasps, side_grasps,header.stamp,tf_listener_);
    visualizeCloud(SIDE_GRASPS, side_grasps, 255, 0, 0);
    CloudPtr top_grasps = obj().getSampledTopGrasps();
    transformPointCloud(FOOTPRINT_FRAME, header.frame_id, top_grasps, top_grasps,header.stamp,tf_listener_);
    visualizeCloud(TOP_GRASPS, top_grasps, 255, 0, 0);
    //visualizePoint(middle, 0, 0, 255, CENTROID);

    obj().draw_sampled_grasps_ = false;
  }
}
Esempio n. 11
0
void OgreBuilding::renderStorey(MaterialDefinition const& material, Point const& bottom, Point const& top)
{
  Polygon base = boundingBox->base();
  Polygon wall;
  Vector normal;
  Vector floorOffset = Vector(0, 0, bottom.z());
  Vector ceilingOffset = Vector(0, 0, top.z());
  int current, next;
  for (int i = 0; i < base.numberOfVertices(); i++)
  {
    current = i;
    next = (i+1) % base.numberOfVertices();

    normal = base.edgeNormal(current)*(-1);

    wall.clear();
    wall.addVertex(base.vertex(current) + floorOffset);
    wall.addVertex(base.vertex(next) + floorOffset);
    wall.addVertex(base.vertex(next) + ceilingOffset);
    wall.addVertex(base.vertex(current) + ceilingOffset);

    addPlane(wall, normal, material);
  }
}
Esempio n. 12
0
void Model::addBox(const glm::vec3 &size, const glm::vec3 &center, const glm::vec4 &texRect) {
    glm::vec3 mx = center + size;
    glm::vec3 mn = center - size;

    glm::vec2 t0(texRect.x, texRect.y);
    glm::vec2 t1(texRect.x + texRect.z, texRect.y + texRect.w);

    glm::vec3 a(mn.x, mn.y, mn.z);
    glm::vec3 b(mx.x, mn.y, mn.z);
    glm::vec3 c(mn.x, mx.y, mn.z);
    glm::vec3 d(mx.x, mx.y, mn.z);
    glm::vec3 e(mn.x, mn.y, mx.z);
    glm::vec3 f(mx.x, mn.y, mx.z);
    glm::vec3 g(mn.x, mx.y, mx.z);
    glm::vec3 h(mx.x, mx.y, mx.z);

    addPlane(h, f, b, texRect);
    addPlane(c, a, e, texRect);
    addPlane(c, g, h, texRect);
    addPlane(e, a, b, texRect);
    addPlane(g, e, f, texRect);
    addPlane(d, b, a, texRect);
}
Esempio n. 13
0
void Model::makePlane(const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c, const glm::vec4 &texRect) {
    clearVertices();
    clearIndices();
    setPrimitive(GLTriangles);
    addPlane(a, b, c, texRect);
}
Esempio n. 14
0
void Model::addPlane(const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c) {
    addPlane(a, b, c, glm::vec4(0, 0, 1, 1));
}
Esempio n. 15
0
void OptimizedPolyList::plane(const PlaneF& p)
{
   mPolyList.last().plane = addPlane(p);
}