コード例 #1
0
 void stage_plot_callback(boost::shared_ptr<PointRobotBSPPlanner> planner, OSGViewerPtr viewer, OptProb* prob, DblVec& x) {
   vector<GraphHandlePtr> handles;
   handles.clear();
   OpenRAVEPlotterMixin<PointRobotBSPPlanner>::plot_opt_trajectory(planner, planner->rad, viewer, prob, x, &handles);
   vector<double> color_params;
   for (int i = 0; i <= planner->T; ++i) {
     color_params.push_back(((double)i)/((double)planner->T-1.0));
   }
   StateT state;
   VarianceT sigma;
   Vector3d mean;
   Matrix3d cov;
   for (int i = 0; i <= planner->T; ++i) {
     BeliefT b = getVec(x, planner->helper->belief_vars.row(i));
     planner->helper->belief_func->extract_state_and_sigma(b, &state, &sigma);
     belief_to_endeffector_noise(planner->rad, planner->link, state, sigma, &mean, &cov);
     handles.push_back(viewer->PlotEllipseXYContour(gaussian_as_transform(mean, cov), OR::Vector(0,color_params[i],1.0-color_params[i],1)));
   }
   BeliefT b = getVec(x, planner->helper->belief_vars.row(0));
   for (int i = 0; i <= planner->T; ++i) {
     planner->helper->belief_func->extract_state_and_sigma(b, &state, &sigma);
     belief_to_endeffector_noise(planner->rad, planner->link, state, sigma, &mean, &cov);
     handles.push_back(viewer->PlotEllipseXYContour(gaussian_as_transform(mean, cov), OR::Vector(0,color_params[i],1.0-color_params[i],1), true)); 
     if (i < planner->T) b = planner->helper->belief_func->call(b, getVec(x, planner->helper->control_vars.row(i)));
   }
   viewer->Idle();
 }
コード例 #2
0
ファイル: heu2826.cpp プロジェクト: hphp/Algorithm
int Similar(int s1,int s2,int flag)
{
    int cc = 0;
    while(cc <=  n)
    {
        Vec a1 = getVec(0,s1,next(s1+mv[0][0]));
        Vec b1 = getVec(0,s1,next(s1+mv[0][1]));
        Vec a2 = getVec(1,s2,next(s2+mv[flag][0]));
        Vec b2 = getVec(1,s2,next(s2+mv[flag][1]));
        //	printf("%d %d :: (%.2lf,%.2lf) (%.2lf,%.2lf) (%.2lf,%.2lf) (%.2lf,%.2lf)\n",s1,s2,a1.x,a1.y,b1.x,b1.y,a2.x,a2.y,b2.x,b2.y);

        double da1 = dis(a1);
        double db1 = dis(b1);
        double da2 = dis(a2);
        double db2 = dis(b2);

        if(! Nequal(DP(a1,b1)*da2*db2,DP(a2,b2)*db1*da1))
        {
            //	printf("hei %d %d %lf %lf\n",s1,s2,DP(a1,b1)*da2*db2,DP(a2,b2)*db1*da1);
            return 0;
        }
        if(! Nequal(da1*db2,db1*da2))
        {
            //	printf("hei2 %d %d %lf %lf\n",s1,s2,da1*db2,db1*da2);
            return 0;
        }
        cc ++;
        s1 = next(s1+mv[0][1]);
        s2 = next(s2+mv[flag][1]);
    }
//	printf("%d %d\n",s1,s2);
    return 1;
}
 virtual void CustomPlot(const DblVec& x, std::vector<OR::GraphHandlePtr>& handles) {
   typename BeliefFuncT::BeliefT belief0 = getVec(x, this->m_vars0);
   typename BeliefFuncT::BeliefT belief1 = getVec(x, this->m_vars1);
   vector<DblVec> dofvals0, dofvals1;
   this->belief_func->sigma_points(belief0, &dofvals0);
   this->belief_func->sigma_points(belief1, &dofvals1);
   this->m_cc->PlotSigmaHullCast(*this->m_rad, this->m_links, dofvals0, dofvals1, handles);
 }
 void CalcCollisions(const DblVec& x, vector<BeliefCollision>& collisions) {
   typename BeliefFuncT::BeliefT belief0 = getVec(x, this->m_vars0);
   typename BeliefFuncT::BeliefT belief1 = getVec(x, this->m_vars1);
   vector<DblVec> dofvals0, dofvals1;
   this->belief_func->sigma_points(belief0, &dofvals0);
   this->belief_func->sigma_points(belief1, &dofvals1);
   this->m_cc->SigmaHullCastVsAll(*this->m_rad, this->m_links, dofvals0, dofvals1, collisions);
 }
コード例 #5
0
void getAtomsSoa(HostAtomsSoa* hostAtoms, DevAtomsSoa* devAtoms)
{
    getVec(devAtoms->r, hostAtoms->r, hostAtoms->totalRealSize, 0);
    getVec(devAtoms->p, hostAtoms->p, hostAtoms->totalRealSize, 0);
    getVec(devAtoms->f, hostAtoms->f, hostAtoms->totalRealSize, 0);

    oclCopyToHost(devAtoms->gid, hostAtoms->gid, hostAtoms->totalIntSize, 0);
    oclCopyToHost(devAtoms->iSpecies, hostAtoms->iSpecies, hostAtoms->totalIntSize, 0);
}
コード例 #6
0
ファイル: modeling_utils.cpp プロジェクト: asbroad/trajopt
ConvexObjectivePtr CostFromErrFunc::convex(const vector<double>& xin, Model* model) {
    VectorXd x = getVec(xin, vars_);
    MatrixXd jac = (dfdx_) ? dfdx_->call(x) : calcForwardNumJac(*f_, x, epsilon_);
    ConvexObjectivePtr out(new ConvexObjective(model));
    VectorXd y = f_->call(x);
    for (int i=0; i < jac.rows(); ++i) {
        AffExpr aff = affFromValGrad(y[i], x, jac.row(i), vars_);
        if (coeffs_.size()>0) {
            exprScale(aff, coeffs_[i]);
            if (coeffs_[i] == 0) continue;
        }
        switch (pen_type_) {
        case SQUARED:
            out->addQuadExpr(exprSquare(aff));
            break;
        case ABS:
            out->addAbs(aff, 1);
            break;
        case HINGE:
            out->addHinge(aff, 1);
            break;
        default:
            assert(0 && "unreachable");
        }
    }
    return out;
}
コード例 #7
0
ConvexObjectivePtr CostFromFunc::convex(const vector<double>& xin) {
  VectorXd x = getVec(xin, vars_);

  ConvexObjectivePtr out(new ConvexObjective());
  QuadExpr quad;
  if (!full_hessian_) {
    double val;
    VectorXd grad,hess;
    calcGradAndDiagHess(*f_, x, epsilon_, val, grad, hess);
    hess = hess.cwiseMax(VectorXd::Zero(hess.size()));
    //QuadExpr& quad = out->quad_;
    quad.affexpr.constant = val - grad.dot(x) + .5*x.dot(hess.cwiseProduct(x));
    quad.affexpr.vars = vars_;
    quad.affexpr.coeffs = toDblVec(grad - hess.cwiseProduct(x));
    quad.vars1 = vars_;
    quad.vars2 = vars_;
    quad.coeffs = toDblVec(hess*.5);
  }
  else {
    double val;
    VectorXd grad;
    MatrixXd hess;
    calcGradHess(f_, x, epsilon_, val, grad, hess);

    MatrixXd pos_hess = MatrixXd::Zero(x.size(), x.size());
    Eigen::SelfAdjointEigenSolver<MatrixXd> es(hess);
    VectorXd eigvals = es.eigenvalues();
    MatrixXd eigvecs = es.eigenvectors();
    for (size_t i=0, end = x.size(); i != end; ++i) { //tricky --- eigen size() is signed
      if (eigvals(i) > 0) pos_hess += eigvals(i) * eigvecs.col(i) * eigvecs.col(i).transpose();
    }

    //QuadExpr& quad = out->quad_;
    quad.affexpr.constant = val - grad.dot(x) + .5*x.dot(pos_hess * x);
    quad.affexpr.vars = vars_;
    quad.affexpr.coeffs = toDblVec(grad - pos_hess * x);

    int nquadterms = (x.size() * (x.size()-1))/2;
    quad.coeffs.reserve(nquadterms);
    quad.vars1.reserve(nquadterms);
    quad.vars2.reserve(nquadterms);
    for (size_t i=0, end = x.size(); i != end; ++i) { //tricky --- eigen size() is signed
      quad.vars1.push_back(vars_[i]);
      quad.vars2.push_back(vars_[i]);
      quad.coeffs.push_back(pos_hess(i,i)/2);
      for (size_t j=i+1; j != end; ++j) {  //tricky --- eigen size() is signed
        quad.vars1.push_back(vars_[i]);
        quad.vars2.push_back(vars_[j]);
        quad.coeffs.push_back(pos_hess(i,j));
      }
    }
  }
  out->addQuadExpr(quad);

  return out;
}
コード例 #8
0
ファイル: costs.cpp プロジェクト: panjia1983/channel_backward
  double RotationContinuityL1Cost::value(const vector<double>& xvec, Model* model) {
    VectorXd vals = getVec(xvec, vars);
    double ret = 0;
    for (int i = 1; i < vars.size(); ++i)
    {
      ret += fabs(vals[i] - vals[i-1]);
    }

    return ret * coeff;
  }
コード例 #9
0
double CostFromErrFunc::value(const vector<double>& xin, Model* model) {
  VectorXd x = getVec(xin, vars_);
  VectorXd err = f_->call(x);
  if (coeffs_.size()>0) err.array() *= coeffs_.array();
  switch (pen_type_) {
    case SQUARED: return err.array().square().sum();
    case ABS: return err.array().abs().sum();
    case HINGE: return err.cwiseMax(VectorXd::Zero(err.size())).sum();
    default: assert(0 && "unreachable"); 
  }
  
  return 0; // avoid compiler warning
}
コード例 #10
0
GLuint subdivideIcosahedronDisplayList(int depth)
{
	int dispList = glGenLists(1);
	
	glNewList(dispList, GL_COMPILE);
		for(int i=0; i<5; i++){
			float vAng1 = -Pi;
			float vAng2 = -Pi+Pi/3;
			float vAngStep = Pi/3;
			float hAng1 = i*2*Pi/5+Pi/5;
			float hAng2 = i*2*Pi/5;
			float hAngStep = Pi/5;
			Vector v[6];
			for(int j=0; j<3; j++){
				v[j*2+0] = getVec(vAng1+j*vAngStep, hAng1+j*hAngStep);
				v[j*2+1] = getVec(vAng2+j*vAngStep, hAng2+j*hAngStep);
			}
			emitStrip(v, 0, 1, 1, 3, depth);
		}
	glEndList();
	return dispList;
}
コード例 #11
0
		float AngularMatrix::isComplete()
		{
			int maxElement = size*size*size;
			int uniqueElement = 0;
			for (int i=0; i<size; i++)
				for (int j=0; j<size; j++)
					for (int k=0; k<size; k++)
					{
						if (getVec(i,j,k)[2] != 0) uniqueElement++;
					}
				
			return (((float)uniqueElement)/((float)maxElement))*100.0f;
		}
コード例 #12
0
		bool AngularMatrix::getPosition(const gmtl::Vec3f& angle, gmtl::Point3f &position)
		{
			if (angle[0]>=minimum[0] && angle[0]<=maximum[0] && 
				angle[1]>=minimum[1] && angle[1]<=maximum[1] &&
				angle[2]>=minimum[2] && angle[2]<=maximum[2])
			{
				position = getVec((int)((angle[0]-minimum[0])/delta),
								  (int)((angle[1]-minimum[1])/delta),
								  (int)((angle[2]-minimum[2])/delta));
				return true;
			}
			return false;
		}
コード例 #13
0
ファイル: modeling_utils.cpp プロジェクト: asbroad/trajopt
ConvexConstraintsPtr ConstraintFromFunc::convex(const vector<double>& xin, Model* model) {
    VectorXd x = getVec(xin, vars_);
    MatrixXd jac = (dfdx_) ? dfdx_->call(x) : calcForwardNumJac(*f_, x, epsilon_);
    ConvexConstraintsPtr out(new ConvexConstraints(model));
    VectorXd y = f_->call(x);
    for (int i=0; i < jac.rows(); ++i) {
        AffExpr aff = affFromValGrad(y[i], x, jac.row(i), vars_);
        if (coeffs_.size()>0) {
            if (coeffs_[i] == 0) continue;
            exprScale(aff, coeffs_[i]);
        }
        if (type() == INEQ) out->addIneqCnt(aff);
        else out->addEqCnt(aff);
    }
    return out;
}
コード例 #14
0
ConvexConstraintsPtr ConstraintFromNumDiff::convex(const vector<double>& xin, Model* model) {
    VectorXd x = getVec(xin, vars_);
    MatrixXd jac = calcForwardNumJac(*f_, x, epsilon_);
    ConvexConstraintsPtr out(new ConvexConstraints(model));
    VectorXd y = f_->call(x);
    for (int i=0; i < jac.rows(); ++i) {
        if (enabled_.empty() || enabled_[i]) {
            AffExpr aff;
            aff.constant = y[i] - jac.row(i).dot(x);
            aff.coeffs = toDblVec(jac.row(i));
            aff.vars = vars_;
            aff = cleanupAff(aff);
            if (type() == INEQ) out->addIneqCnt(aff);
            else out->addEqCnt(aff);
        }
    }
    return out;
}
コード例 #15
0
ConvexObjectivePtr CostFromNumDiffErr::convex(const vector<double>& xin, Model* model) {
    VectorXd x = getVec(xin, vars_);
    MatrixXd jac = calcForwardNumJac(*f_, x, epsilon_);
    ConvexObjectivePtr out(new ConvexObjective(model));
    VectorXd y = f_->call(x);
    for (int i=0; i < jac.rows(); ++i) {
        if (coeffs_[i] > 0) {
            AffExpr aff;
            aff.constant = y[i] - jac.row(i).dot(x);
            aff.coeffs = toDblVec(jac.row(i));
            aff.vars = vars_;
            aff = cleanupAff(aff);
            if (pen_type_ == SQUARED) {
                out->addQuadExpr(exprMult(exprSquare(aff), coeffs_[i]));
            }
            else {
                out->addAbs(aff, coeffs_[i]);
            }
        }
    }
    return out;
}
コード例 #16
0
ファイル: Mouse.cpp プロジェクト: sweet4lorie/ThePicker
ray Mouse::getRay(const Camera & camera, float win_width, float win_height)
{
    ray myRay;
    
    float x = (2.0f * *mouseX) / win_width - 1.0f;
    float y = 1.0f - (2.0f * *mouseY) / win_height;
    float z = -1.0f;
    
    vec rayNds = getVec(x, y, z);
    float rayClip[] = {rayNds.x, rayNds.y, z, 1.0};
    
    float rayEye[4];
    float tempInverse[16];
    float rayWorld[4];
    
    matInverse(&tempInverse[0]);
    matMultVec4fUtil(rayEye, rayClip, &tempInverse[0]);
    
    rayEye[2] = z;
    rayEye[3] = 0.0;
    
    matMultVec4fUtil(rayWorld, rayEye, &tempInverse[0]);
    vec4 rayWor = getVec4(rayWorld[0], rayWorld[1], rayWorld[2], rayWorld[3]);
    
    // don't forget to normalise the vector at some point
    rayWor = vec4Normalize(rayWor);
    
    myRay.origin.x = camera.position.x;
    myRay.origin.y = camera.position.y;
    myRay.origin.z = camera.position.z;
    myRay.direction.x = rayWor.x;
    myRay.direction.y = rayWor.y;
    myRay.direction.z = rayWor.z;
    myRay.direction.w = rayWor.w;
    
    return myRay;
}
コード例 #17
0
ファイル: modeling_utils.cpp プロジェクト: asbroad/trajopt
vector<double> ConstraintFromFunc::value(const vector<double>& xin) {
    VectorXd x = getVec(xin, vars_);
    VectorXd err = f_->call(x);
    if (coeffs_.size()>0) err.array() *= coeffs_.array();
    return toDblVec(err);
}
コード例 #18
0
ファイル: costs.cpp プロジェクト: panjia1983/channel_backward
 double RotationL1Cost::value(const vector<double>& xvec, Model* model) {
   VectorXd vals = getVec(xvec, vars);
   return vals.array().abs().sum() * coeff;
 }
コード例 #19
0
ファイル: modeling_utils.cpp プロジェクト: asbroad/trajopt
double CostFromFunc::value(const vector<double>& xin) {
    VectorXd x = getVec(xin, vars_);
    return f_->call(x);
}
コード例 #20
0
double CostFromNumDiffErr::value(const vector<double>& xin) {
    VectorXd x = getVec(xin, vars_);
    VectorXd scaled_err = f_->call(x).cwiseProduct(coeffs_);
    return (pen_type_ == SQUARED) ? scaled_err.squaredNorm() : scaled_err.lpNorm<1>();
}
コード例 #21
0
// initialize opengl components event handler
void MyGLWidget::initializeGL() {
	displayClass = new DisplayClass();
	std::ifstream tracer;
	std::string ts;
	tracer.open(raytraceconfig);
	
	//output filename
	getline(tracer, ts);
	displayClass->rayOutputFile = new std::string(cut(ts));
	
	//resolution
	getline(tracer, ts);
	glm::vec3 v = getVec(cut(ts));
	displayClass->resoX = new float(v.x);
	displayClass->resoY = new float(v.y);

	displayClass->rayCamera = new Camera();
	//eye
	getline(tracer, ts);
	displayClass->rayCamera->eye = getVec(cut(ts));

	//view direction
	getline(tracer, ts);
	displayClass->rayCamera->center = getVec(cut(ts));

	//up vec
	getline(tracer, ts);
	displayClass->rayCamera->up = getVec(cut(ts));

	//fovy
	getline(tracer, ts);
	displayClass->rayCamera->fovy = getVec(cut(ts)).x;

	displayClass->rayLightPos = new std::vector<glm::vec3*>();
	displayClass->rayLightCol = new std::vector<glm::vec3*>();
	glm::vec3* lpos;
	glm::vec3* lcol;
	
	for (int lc = 0; lc < 3; lc++) {
		//lightpos
		getline(tracer, ts);
		lpos = new glm::vec3(getVec(cut(ts)));
		displayClass->rayLightPos->push_back(lpos);

		//lightcol
		getline(tracer, ts);
		lcol = new glm::vec3(getVec(cut(ts)));
		displayClass->rayLightCol->push_back(lcol);

	}
	//ambient color
	getline(tracer, ts);
	displayClass->rayAmbientCol = new glm::vec3(getVec(cut(ts)));
	*displayClass->rayAmbientCol = glm::clamp(*displayClass->rayAmbientCol, 0.0f, 1.0f);

	//mat1
	getline(tracer, ts);
	ts = cut(ts);
	std::istringstream myStream = static_cast<std::istringstream>(ts);
	float tem;
	displayClass->mtl1 = new float[8];
	int ml = 0;
	while (myStream >> tem) {
		displayClass->mtl1[ml] = tem;
		ml++;
	}

	//mat2
	getline(tracer, ts);
	ts = cut(ts);
	myStream = static_cast<std::istringstream>(ts);
	displayClass->mtl2 = new float[8];
	ml = 0;
	while (myStream >> tem) {
		displayClass->mtl2[ml] = tem;
		ml++;
	}

	//mat3
	getline(tracer, ts);
	ts = cut(ts);
	myStream = static_cast<std::istringstream>(ts);
	displayClass->mtl3 = new float[8];
	ml = 0;
	while (myStream >> tem) {
		displayClass->mtl3[ml] = tem;
		ml++;
	}

	displayClass->mtlf = new float[8];
	displayClass->mtlf[0] = 0.5f;
	displayClass->mtlf[1] = 0.5f;
	displayClass->mtlf[2] = 0.0f;
	displayClass->mtlf[3] = 5.0f;
	displayClass->mtlf[4] = 0.0f;
	displayClass->mtlf[5] = 0.0f;
	displayClass->mtlf[6] = 0.0f;
	displayClass->mtlf[7] = 0.0f;

	tracer.close();

	std::ifstream config;
	std::ifstream meshfile;
	config.open(filename);
	std::string reader;
	getline(config, reader);
	glm::vec3 vec = getVec(reader);
	int xSize = vec[0];
	int zSize = vec[1];
	int numItems = vec[2];
	std::vector<std::vector<Node*>> grid;
	for (int fn = 0; fn < xSize; fn++) {
		std::vector<Node*> col;
		for (int fx = 0; fx < zSize; fx++) {
			col.push_back(NULL);
		}
		grid.push_back(col);
	}
	int i = 0;
	glm::vec4 origin(((float) xSize)/-2.0f, -0.1f, ((float) zSize)/-2.0f, 1.0f);
	displayClass->graph = new SceneGraph();
	displayClass->floor = new Prism(1, xSize, 0.1f, -1 * zSize, origin);
	SceneGraph* sg = displayClass->graph;
	sg->rootNode = new Node(displayClass->floor, NULL, NULL, 0, 0);
	*sg->rootNode->mtl = 4;
	sg->rootNode->scale = new glm::mat4();//glm::scale(glm::mat4(), glm::vec3(xSize, 0.1f, zSize)));
	sg->rootNode->rotate = new glm::mat4();//glm::rotate(glm::mat4(), 0.1f, glm::vec3(0.0f, 1.0f, 0.0f)));
	sg->rootNode->translate = new glm::mat4();
	Furniture* currentPrimitive = NULL;
	Node* par;
	glm::mat4 transl;
	glm::mat4 rot;
	glm::mat4 scal;
	Node* thisNode;
	int xi;
	float* yi;
	int zi;
	int mtl;
	std::string myName;
	std::string meshparse;
	while (i < numItems) {
		currentPrimitive = NULL;
		Mesh* myMesh = NULL;
		getline(config, reader);
		getline(config, reader);
		myName = reader;
		if (myName == "table") {
			getline(config, reader);
			mtl = getVec(reader).x;
			currentPrimitive = new Table(mtl);
		} else if (myName == "chair") {
			getline(config, reader);
			mtl = getVec(reader).x;
			currentPrimitive = new Chair(mtl);
		} else if (myName == "cabinet") {
			getline(config, reader);
			mtl = getVec(reader).x;
			currentPrimitive = new Cabinet(mtl);
		} else if (myName == "lamp") {
			getline(config, reader);
			mtl = getVec(reader).x;
			currentPrimitive = new Lamp(mtl);
		} else if (myName == "multitable") {
			getline(config, reader);
			mtl = getVec(reader).x;
			currentPrimitive = new Table(mtl);
			*currentPrimitive->localTransforms->at(currentPrimitive->localTransforms->size() - 1) *= glm::scale(glm::mat4(), glm::vec3(2.0f, 1.0f, 1.0f));
			/*for (int n = 0; n < currentPrimitive->localTransforms->size(); n++) {
				*currentPrimitive->localTransforms->at(n) = glm::translate(glm::mat4(), glm::vec3(0.5f, 0.0f, 0.0f)) * *currentPrimitive->localTransforms->at(n);
			}*/
		} else if (myName == "mesh") {
			getline(config, reader);
			meshfile.open(reader);
			getline(config, reader);
			mtl = getVec(reader).x;
			getline(meshfile, meshparse);
			if (meshparse == "extrusion") {
				getline(meshfile, meshparse);
				vec = getVec(meshparse);
				float len = vec.x;
				getline(meshfile, meshparse);
				vec = getVec(meshparse);
				int numVerts = vec.x;
				std::vector<glm::vec3> verts;
				for (int w = 0; w < numVerts; w++) {
					getline(meshfile, meshparse);
					vec = getVec(meshparse);
					glm::vec3 myvec(vec.x, 0.0f, vec.y);
					verts.push_back(myvec);
				}
				myMesh = new Mesh(mtl, len, numVerts, verts);
			} else if (meshparse == "surfrev") {
				getline(meshfile, meshparse);
				vec = getVec(meshparse);
				int numSlices = vec.x;
				getline(meshfile, meshparse);
				vec = getVec(meshparse);
				int numVerts = vec.x;
				std::vector<glm::vec4> verts;
				for (int w = 0; w < numVerts; w++) {
					getline(meshfile, meshparse);
					vec = getVec(meshparse);
					if (vec.x < 0) {
						std::cerr << "Error: negative x value in surfrev" << std::endl;
						exit(1);
					}
					glm::vec4 myvec(vec.x, vec.y, 0.0f, 1.0f);
					verts.push_back(myvec);
				}
				myMesh = new Mesh(mtl, numSlices, numVerts, verts);
			}
			meshfile.close();
		}

		//colors
		//getline(config, reader);

		//translation
		getline(config, reader);
		vec = getVec(reader);
		xi = vec.x;
		yi = new float(0);
		zi = vec.y;

		//rotation
		getline(config, reader);
		vec = getVec(reader);
		rot = glm::rotate(glm::mat4(), vec.x, glm::vec3(0.0f, 1.0f, 0.0f));

		//scale
		getline(config, reader);
		vec = getVec(reader);
		scal = glm::scale(glm::mat4(), vec);
		
		thisNode = new Node(NULL, currentPrimitive, NULL, xi, zi);
		*thisNode->mtl = mtl;
		if (myName == "mesh") {
			thisNode->shape = myMesh;
			if (*myMesh->kind == 99) {
				//*yi = *myMesh->height/2.0f;
			} else if (*myMesh->kind == 100) {
				//*yi = *myMesh->height/2.0f;
			}
		}
		par = sg->rootNode;
		if (grid.at(xi).at(zi) != NULL) {
			par = grid.at(xi).at(zi);
			if (par->furniture == NULL) {
				if (par != sg->rootNode) {
					*yi += *par->shape->height;
				}
			} else {
				*yi += *par->furniture->height;
			}
		}
		thisNode->parent = par;
	    grid.at(xi).at(zi) = thisNode;
		if (myName == "multitable") {
			grid.at(xi + 1).at(zi) = thisNode;
		}

		//setPar(par, myPar, xi, yi, zi);
		transl = glm::translate(glm::mat4(), glm::vec3(xi + origin.x + 0.5, *yi, zi + origin.z + 0.5));
		if (myName == "multitable") {
			transl = glm::translate(glm::mat4(), glm::vec3(0.5f, 0.0f, 0.0f)) * transl;
		}
		if (thisNode->furniture != NULL) {
			*thisNode->furniture->height *= scal[1][1];
		} else {
			*thisNode->shape->height *= scal[1][1];
		}
		if (thisNode->parent != displayClass->graph->rootNode) {
			if (thisNode->furniture == NULL) {
				if (thisNode->parent->furniture == NULL) {
					*thisNode->shape->height += *thisNode->parent->shape->height;
				} else {
					*thisNode->shape->height += *thisNode->parent->furniture->height;
				}
			} else {
				if (thisNode->parent->furniture == NULL) {
					*thisNode->furniture->height += *thisNode->parent->shape->height;
				} else {
					*thisNode->furniture->height += *thisNode->parent->furniture->height;
				}
			}
		}
		thisNode->rotate = new glm::mat4(rot);// * *par->rotate);
		thisNode->translate = new glm::mat4(transl);
		thisNode->scale = new glm::mat4(scal);// * *par->scale);

		//add to parent's list of children
		par->children->push_back(thisNode);
		i++;
	}
	displayClass->selectedNode = displayClass->graph->rootNode;
}
コード例 #22
0
vector<double> ConstraintFromNumDiff::value(const vector<double>& xin) {
    VectorXd x = getVec(xin, vars_);
    return toDblVec(f_->call(x));
}