• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ pos2函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: pos2

void TrillSegment::symbolLine(SymId start, SymId fill, SymId end)
      {
      qreal x1 = 0;
      qreal x2 = pos2().x();
      qreal w   = x2 - x1;
      qreal mag = magS();
      ScoreFont* f = score()->scoreFont();

      _symbols.clear();
      _symbols.push_back(start);
      qreal w1 = f->advance(start, mag);
      qreal w2 = f->advance(fill, mag);
      qreal w3 = f->advance(end, mag);
      int n    = lrint((w - w1 - w3) / w2);
      for (int i = 0; i < n; ++i)
           _symbols.push_back(fill);
      _symbols.push_back(end);
      QRectF r(f->bbox(_symbols, mag));
      setbbox(r);
      }
开发者ID:Jojo-Schmitz,项目名称:MuseScore,代码行数:20,代码来源:trill.cpp


示例2: b1

void TrillSegment::layout()
      {
      QRectF b1(symBbox(SymId::ornamentTrill));
      QRectF rr(b1.translated(-b1.x(), 0.0));
      rr |= QRectF(0.0, rr.y(), pos2().x(), rr.height());
      setbbox(rr);
      if (parent())
            rypos() += score()->styleS(ST_trillY).val() * spatium();
      if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) {
            Accidental* a = trill()->accidental();
            if (a) {
                  a->layout();
                  a->setMag(a->mag() * .6);
                  qreal _spatium = spatium();
                  a->setPos(_spatium*1.3, -2.2*_spatium);
                  a->adjustReadPos();
                  }
            }
      adjustReadPos();
      }
开发者ID:Isensee,项目名称:MuseScore,代码行数:20,代码来源:trill.cpp


示例3: Vector2D

//===========================================================================
void ftSurfaceSetPoint::resetPosition(Vector3D pos, int bnd)
//
//===========================================================================
{
    xyz_ = pos;
    uv_ = Vector2D(0.0, 0.0);
    dist_ = -1.0;
    at_boundary_ = bnd;

    // Iterate to find parameter values
    Point pos2(pos.begin(), pos.end());
    Point close_pt;
    double par_u, par_v, dist;
    double eps = 1.0e-12;  // A small number
    for (size_t ki=0; ki<par_pts_.size(); ++ki)
    {
	par_pts_[ki].first->closestPoint(pos2, par_u, par_v, close_pt, dist, eps);
	Vector2D param(par_u, par_v);
	par_pts_[ki].second = param;
    }
}
开发者ID:99731,项目名称:GoTools,代码行数:22,代码来源:ftSurfaceSetPoint.C


示例4: simpleCase

bool simpleCase()
{
  XcMatrix cell1 ( 3.0, 0.0, 0.0, 2.0, 4.0, 0.0, 2.0, 5.0, 3.0 );
  XcMatrix cell2 (cell1);

  std::vector<XcVector> pos1;
  pos1.reserve(4);

  pos1.push_back(XcVector(0.0, 0.25, 0.25));
  pos1.push_back(XcVector(0.25, 0.25, 0.25));
  pos1.push_back(XcVector(0.0, 0.5, 0.25));
  pos1.push_back(XcVector(0.0, 0.25, 0.75));
  std::vector<XcVector> pos2 (pos1);

  std::vector<unsigned int> types1;
  types1.reserve(4);

  types1.push_back(1);
  types1.push_back(2);
  types1.push_back(2);
  types1.push_back(1);
  std::vector<unsigned int> types2 (types1);

  bool match = XtalComp::compare(cell1, types1, pos1,
                                 cell2, types2, pos2,
                                 NULL, 0.05, 0.25);

  if (!match)
    return false;

  // Displace an atom, ensure that comparison fails.
  pos2[0] += XcVector(0.5,0,0);
  match = XtalComp::compare(cell1, types1, pos1,
                            cell2, types2, pos2,
                            NULL, 0.05, 0.25);
  if (match)
    return false;

  return true;
}
开发者ID:ajshamp,项目名称:XtalOpt-ajs,代码行数:40,代码来源:test.cpp


示例5: pos

void RddcEvlDisplay::drawHopOver(){
    if(this->m_dimClust==NULL)
        return;
    RddtClust* clust = this->m_dimClust->m_currentSelection;
    if(clust==NULL)
        return;
    if(clust->m_nRddtDims.size()<1){
        return;
    }
    int which = this->whichGlyph(m_x,m_y);
    if(which<0 || which>=m_profileRects.size())
        return;
    QRect tmp = this->m_profileRects[which];
    int size = clust->m_partitionPerVariable.size();
    if(size<2)
        return;
    int numCols = (int)(sqrt((double)size))+1;
    int numRows = (int)ceil((double)size/(double)numCols);

    double glyphWidthData = (double)1/(double)numCols;
    double glyphHeightData = (double)1/(double)numRows;

    Vec2 pos(tmp.left(),tmp.bottom());
    Vec2 pos2(tmp.left()+tmp.width(),tmp.bottom()-tmp.height());

    Vec2 topCorner = this->m_canvas->mapScreenToData(pos);
    Vec2 bottomRightCorner =
            this->m_canvas->mapScreenToData(pos2);

    glyphWidthData = bottomRightCorner.X - topCorner.X;
    glyphHeightData = (topCorner.Y - bottomRightCorner.Y);

    unsigned long c = this->cm->getColor(ColorManager::BRUSH_SELECTED1);
    this->m_canvas->setForeground(c);
    this->m_canvas->drawRectangle(topCorner.X,(double)1-topCorner.Y,
                                  glyphWidthData,glyphHeightData);

}
开发者ID:kaiyuzhao,项目名称:XmdvFeaVis,代码行数:38,代码来源:RddcEvlDisplay.cpp


示例6: exit

void Node::computeDistance(){

  if(getNode(1) == NULL || getNode(2) == NULL){
    std::cout << "undefined link" << std::endl;
    exit(-1);
  }
  
  sf::Vector2f pos0(getPos());
  sf::Vector2f pos1(getNode(1)->getPos());
  sf::Vector2f pos2(getNode(2)->getPos());

  float dis1x = pos0.x - pos1.x;
  float dis1y = pos0.y - pos1.y;

  float dis2x = pos0.x - pos2.x;
  float dis2y = pos0.y - pos2.y;

  _n1_distance = sqrt((dis1x*dis1x) + (dis1y*dis1y));

  _n2_distance = sqrt((dis2x*dis2x) + (dis2y*dis2y));
  

}
开发者ID:ProjectTB2D,项目名称:First-Try-Duo,代码行数:23,代码来源:Node.cpp


示例7: lineName

 bool WindowsManager::addLine (const char* lineNameCorba,
         const value_type* posCorba1,
         const value_type* posCorba2,
         const value_type* colorCorba)
 {
     std::string lineName (lineNameCorba);
     if (nodes_.find (lineName) != nodes_.end ()) {
         std::cout << "You need to chose an other name, \"" << lineName
             << "\" already exist." << std::endl;
         return false;
     }
     else {
         mtx_.lock();
         osgVector3 pos1 (posCorba1[0], posCorba1[1], posCorba1[2]);
         osgVector3 pos2 (posCorba2[0], posCorba2[1], posCorba2[2]);
         LeafNodeLinePtr_t line = LeafNodeLine::create
             (lineName, pos1, pos2, getColor (colorCorba));
         WindowsManager::initParent (lineName, line);
         addNode (lineName, line);
         mtx_.unlock();
         return true;
     }
 }
开发者ID:stonneau,项目名称:gepetto-viewer-corba,代码行数:23,代码来源:windows-manager.cpp


示例8: pos

void Plane::addBullet(float dt)
{
	if (m_bulletType == BULLET) {
        auto pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("bullet1.png");
        Point pos(getPositionX(), getPositionY() + getContentSize().height * 0.5);
        float distance = Director::getInstance()->getWinSize().height + 100;
        Sprite *bullet = createBullet(pFrame, pos, distance);
		m_bullets->addChild(bullet);
	} else if (m_bulletType == DOUBLE_BULLET) {
        auto pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("bullet2.png");
        float sx = getPositionX(); float sy = getPositionY();
        Size content = getContentSize();

        Point pos(sx - content.width * 0.25, sy + content.height * 0.5);
        float distance = Director::getInstance()->getWinSize().height + 100;
        Sprite *bullet1 = createBullet(pFrame, pos, distance);
        m_bullets->addChild(bullet1);

        Point pos2(sx + content.width * 0.25, sy + content.height * 0.5);
        Sprite *bullet2 = createBullet(pFrame, pos2, distance);
        m_bullets->addChild(bullet2);
	}
}
开发者ID:sydnash,项目名称:wexin_planefight,代码行数:23,代码来源:plane.cpp


示例9: pos1

    void NodeLink::NodeCallback::operator()(::osg::Node* node, ::osg::NodeVisitor* nv)
    {
        osg::ref_ptr<osg::Node> f1 = node1.get();
        osg::ref_ptr<osg::Node> f2 = node2.get();
        if(!f1.get() || !f2.get())
            return;

        //transform local view2 to local view1
        ::osg::Matrix world2local = ::osg::computeWorldToLocal(nv->getNodePath());

        ::osg::Vec3 pos1(0,0,0);
        ::osg::MatrixList list1 = f1->getWorldMatrices();
        assert(!list1.empty());
        pos1 = pos1*list1.front();
        pos1 = pos1*world2local;

        ::osg::Vec3 pos2(0,0,0);
        ::osg::MatrixList list2 = f2->getWorldMatrices();
        assert(!list2.empty());
        pos2 = pos2*list2.front();
        pos2 = pos2*world2local;

        ::osg::Geode *geode = node->asGeode();
        assert(geode);
        assert(1 == geode->getNumDrawables());
        ::osg::Geometry* geometry = geode->getDrawable(0)->asGeometry();
        assert(geometry);
        assert(geometry->getVertexArray());
        assert(geometry->getVertexArray()->getType() == ::osg::Array::Vec3ArrayType);
        ::osg::Vec3Array *osg_vertex= dynamic_cast< ::osg::Vec3Array*>(geometry->getVertexArray());
        assert(osg_vertex);
        (*osg_vertex)[0] = pos1;
        (*osg_vertex)[1] = pos2;

        geometry->dirtyBound();
        traverse(node, nv);
    }
开发者ID:Brazilian-Institute-of-Robotics,项目名称:gui-vizkit3d,代码行数:37,代码来源:NodeLink.cpp


示例10: pos

bool
url_type::read(const std::string& line)
{
	// XXXXX:YYYYYYY/ZZZZZZZ
	std::string::size_type pos(line.find(char(':')));
	if ( pos == std::string::npos ) return false;

	host.assign(line, 0, pos);
	++pos;

	std::string::size_type pos2(line.find(char('/'), pos));
	if ( pos2 == std::string::npos )
	{
		service.assign(line, pos, std::string::npos);
		page.clear();
	}
	else
	{
		service.assign(line, pos, pos2-pos);
		page.assign(line, pos2, std::string::npos);
	}

	return true;
}
开发者ID:ArtisticCoding,项目名称:libpw,代码行数:24,代码来源:pw_common.cpp


示例11: score

  // s1 should be the original spectrum
  DoubleReal CompNovoIdentificationBase::compareSpectra_(const PeakSpectrum & s1, const PeakSpectrum & s2)
  {
    DoubleReal score(0.0);

    PeakSpectrum::ConstIterator it1 = s1.begin();
    PeakSpectrum::ConstIterator it2 = s2.begin();

    Size num_matches(0);
    while (it1 != s1.end() && it2 != s2.end())
    {
      DoubleReal pos1(it1->getPosition()[0]), pos2(it2->getPosition()[0]);
      if (fabs(pos1 - pos2) < fragment_mass_tolerance_)
      {
        score += it1->getIntensity();
        ++num_matches;
      }

      if (pos1 <= pos2)
      {
        ++it1;
      }
      else
      {
        ++it2;
      }
    }

    if (num_matches == 0)
    {
      return 0;
    }

    score /= sqrt((DoubleReal)num_matches);

    return score;
  }
开发者ID:aiche,项目名称:open-ms-mirror,代码行数:37,代码来源:CompNovoIdentificationBase.C


示例12: switch

void CInMapDraw::GotNetMsg(const unsigned char* msg)
{
	const int playerID = msg[2];

	switch (msg[3]) {
		case NET_POINT: {
			float3 pos(*(short*) &msg[4], 0, *(short*) &msg[6]);
			const string label = (char*) &msg[8];
			LocalPoint(pos, label, playerID);
			break;
		}
		case NET_LINE: {
			float3 pos1(*(short*) &msg[4], 0, *(short*) &msg[6]);
			float3 pos2(*(short*) &msg[8], 0, *(short*) &msg[10]);
			LocalLine(pos1, pos2, playerID);
			break;
		}
		case NET_ERASE: {
			float3 pos(*(short*) &msg[4], 0, *(short*) &msg[6]);
			LocalErase(pos, playerID);
			break;
		}
	}
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:24,代码来源:InMapDraw.cpp


示例13: pos1

QRectF Dynamic::drag(EditData* ed)
      {
      QRectF f = Element::drag(ed);

      //
      // move anchor
      //
      Qt::KeyboardModifiers km = qApp->keyboardModifiers();
      if (km != (Qt::ShiftModifier | Qt::ControlModifier)) {
            int si;
            Segment* seg = 0;
            _score->pos2measure(ed->pos, &si, 0, &seg, 0);
            if (seg && (seg != segment() || staffIdx() != si)) {
                  QPointF pos1(pagePos());
                  score()->undo(new ChangeParent(this, seg, si));
                  setUserOff(QPointF());
                  layout();
                  QPointF pos2(pagePos());
                  setUserOff(pos1 - pos2);
                  ed->startMove = pos2;
                  }
            }
      return f;
      }
开发者ID:Didistreu,项目名称:MuseScore,代码行数:24,代码来源:dynamic.cpp


示例14: magS

void TrillSegment::draw(QPainter* painter) const
      {
      qreal mag  = magS();
      int idx    = score()->symIdx();
      QRectF b2(symbols[idx][trillelementSym].bbox(mag));
      qreal w2   = symbols[idx][trillelementSym].width(mag);

      qreal x2   = pos2().x();

      painter->setPen(curColor());
      if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) {
            int sym = 0;
            qreal x0 = 0.0, x1 = 0.0, y = 0.0;
            int n = 0;
            QRectF b1;

            switch(trill()->trillType()) {
                  case Trill::TRILL_LINE:
                        sym  = trillSym;
                        b1   = symbols[idx][sym].bbox(mag);
                        x0   = -b1.x();
                        x1   = x0 + b1.width();
                        n    = int(floor((x2-x1) / w2));
                        y    = 0.0;
                        break;

                  case Trill::UPPRALL_LINE:
                        sym  = upprallSym;
                        b1   = symbols[idx][sym].bbox(mag);
                        x0   = -b1.x();
                        x1   = b1.width();
                        n    = int(floor((x2-x1) / w2));
                        y    = -b1.height();
                        break;
                  case Trill::DOWNPRALL_LINE:
                        sym  = downprallSym;
                        b1   = symbols[idx][sym].bbox(mag);
                        x0   = -b1.x();
                        x1   = b1.width();
                        n    = int(floor((x2-x1) / w2));
                        y    = -b1.height();
                        break;
                  case Trill::PRALLPRALL_LINE:
                        sym  = prallprallSym;
                        b1   = symbols[idx][sym].bbox(mag);
                        x0   = -b1.x();
                        x1   = b1.width();
                        n    = int(floor((x2-x1) / w2));
                        y    = -b1.height();
                        break;
                  case Trill::PURE_LINE:
                        sym = noSym;
                        x0 = 0;
                        x1 = 0;
                        n    = int(floor((x2-x1) / w2));
                        y = 0.0;
                  }
            if (n <= 0)
                  n = 1;
            if (sym != noSym)
                  symbols[idx][sym].draw(painter, mag, QPointF(x0, y));
            symbols[idx][trillelementSym].draw(painter, mag,  QPointF(x1, b2.y() * .9), n);
            }
      else {
            qreal x1 = 0.0;
            int n = int(floor((x2-x1) / w2));
            symbols[idx][trillelementSym].draw(painter, mag,  QPointF(x1, b2.y() * .9), n);
            }
      }
开发者ID:bojan88,项目名称:MuseScore,代码行数:69,代码来源:trill.cpp


示例15: spatium

void HairpinSegment::layout()
      {
      Dynamic* sd = 0;
      Dynamic* ed = 0;
      qreal _spatium = spatium();

      if (autoplace()) {
            setUserOff(QPointF());
            setUserOff2(QPointF());
            }
      if (isSingleType() || isBeginType()) {
            sd = lookupDynamic(hairpin()->startElement());
            if (sd) {
                  if (autoplace()) {
                        qreal dx        = sd->bbox().right() + sd->pos().x()
                                             + sd->segment()->pos().x() + sd->measure()->pos().x();
                        // hardcoded distance between Dynamic and Hairpin: 0.5sp
                        qreal dist      = dx - pos().x() + score()->styleP(StyleIdx::autoplaceHairpinDynamicsDistance);
                        rUserXoffset()  = dist;
                        rUserXoffset2() = -dist;
                        }
                  else
                        sd->doAutoplace();
                  }
            }
      if (isSingleType() || isEndType()) {
            ed = lookupDynamic(hairpin()->endElement());
            if (ed) {
                  if (autoplace()) {
                        rUserXoffset2() -= ed->bbox().width();
                        qreal dx         = ed->bbox().left() + ed->pos().x()
                                           + ed->segment()->pos().x() + ed->measure()->pos().x();
                        // hardcoded distance between Hairpin and Dynamic: 0.5sp
                        ed->rUserXoffset() = pos2().x() + pos().x() - dx + score()->styleP(StyleIdx::autoplaceHairpinDynamicsDistance);
                        }
                  else
                        ed->doAutoplace();
                  }
            }

      Hairpin::Type type = hairpin()->hairpinType();
      if (type == Hairpin::Type::DECRESC_LINE || type == Hairpin::Type::CRESC_LINE) {
            twoLines = false;
            TextLineSegment::layout();
            drawCircledTip = false;
            if (parent())
                  rypos() += score()->styleP(StyleIdx::hairpinY);
            }
      else {
            delete _text;
            delete _endText;
            _text    = 0;
            _endText = 0;

            QTransform t;
            qreal h1 = hairpin()->hairpinHeight().val()     * spatium() * .5;
            qreal h2 = hairpin()->hairpinContHeight().val() * spatium() * .5;

            qreal len;
            qreal x = pos2().x();
            if (x < _spatium)             // minimum size of hairpin
                  x = _spatium;
            qreal y = pos2().y();
            len     = sqrt(x * x + y * y);
            t.rotateRadians(asin(y/len));

            drawCircledTip   =  hairpin()->hairpinCircledTip();
            circledTipRadius = drawCircledTip ? 0.6 * _spatium * .5 : 0.0;

            QLine l1, l2;
            twoLines  = true;

            switch (type) {
                  case Hairpin::Type::CRESC_HAIRPIN: {
                        switch (spannerSegmentType()) {
                              case SpannerSegmentType::SINGLE:
                              case SpannerSegmentType::BEGIN:
                                    l1.setLine(circledTipRadius * 2.0, 0.0, len, h1);
                                    l2.setLine(circledTipRadius * 2.0, 0.0, len, -h1);
                                    circledTip.setX(circledTipRadius );
                                    circledTip.setY(0.0);
                                    break;

                              case SpannerSegmentType::MIDDLE:
                              case SpannerSegmentType::END:
                                    drawCircledTip = false;
                                    l1.setLine(.0,  h2, len, h1);
                                    l2.setLine(.0, -h2, len, -h1);
                                    break;
                              }
                        }
                        break;
                  case Hairpin::Type::DECRESC_HAIRPIN: {
                        switch(spannerSegmentType()) {
                              case SpannerSegmentType::SINGLE:
                              case SpannerSegmentType::END:
                                    l1.setLine(0.0,  h1, len - circledTipRadius * 2, 0.0);
                                    l2.setLine(0.0, -h1, len - circledTipRadius * 2, 0.0);
                                    circledTip.setX(len - circledTipRadius);
                                    circledTip.setY(0.0);
//.........这里部分代码省略.........
开发者ID:shredpub,项目名称:MuseScore,代码行数:101,代码来源:hairpin.cpp


示例16: main

int main(int argc, char **argv){
   vector pos1( 1, 2 ), pos2( 12, 33 );
   std::cout << pos1 << "  " << pos2 << "\n";
}
开发者ID:1611714,项目名称:TCTI-V1OOPC-15-BASE,代码行数:4,代码来源:main.cpp


示例17: glPushMatrix

void CStartPosSelecter::Draw()
{
	if(gu->spectating){
		delete this;
		return;
	}

	glPushMatrix();
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glMatrixMode(GL_MODELVIEW);

	glColor4f(0.2f,0.8f,0.2f,0.5f);
	glDisable(GL_TEXTURE_2D);
	glEnable(GL_DEPTH_TEST);
	glBegin(GL_QUADS);
	float by= gameSetup->allyStartingData[gu->myAllyTeam].startRectTop *gs->mapy*8;
	float bx= gameSetup->allyStartingData[gu->myAllyTeam].startRectLeft *gs->mapx*8;

	float dy = (gameSetup->allyStartingData[gu->myAllyTeam].startRectBottom - gameSetup->allyStartingData[gu->myAllyTeam].startRectTop) *gs->mapy*8/10;
	float dx = (gameSetup->allyStartingData[gu->myAllyTeam].startRectRight - gameSetup->allyStartingData[gu->myAllyTeam].startRectLeft) *gs->mapx*8/10;

	for(int a=0;a<10;++a){	//draw start rect restrictions
		float3 pos1(bx+a*dx,0,by);
		pos1.y=ground->GetHeight(pos1.x,pos1.z);
		float3 pos2(bx+(a+1)*dx,0,by);
		pos2.y=ground->GetHeight(pos2.x,pos2.z);

		glVertexf3(pos1);
		glVertexf3(pos2);
		glVertexf3(pos2+UpVector*100);
		glVertexf3(pos1+UpVector*100);

		pos1=float3(bx+a*dx,0,by+dy*10);
		pos1.y=ground->GetHeight(pos1.x,pos1.z);
		pos2=float3(bx+(a+1)*dx,0,by+dy*10);
		pos2.y=ground->GetHeight(pos2.x,pos2.z);

		glVertexf3(pos1);
		glVertexf3(pos2);
		glVertexf3(pos2+UpVector*100);
		glVertexf3(pos1+UpVector*100);

		pos1=float3(bx,0,by+dy*a);
		pos1.y=ground->GetHeight(pos1.x,pos1.z);
		pos2=float3(bx,0,by+dy*(a+1));
		pos2.y=ground->GetHeight(pos2.x,pos2.z);

		glVertexf3(pos1);
		glVertexf3(pos2);
		glVertexf3(pos2+UpVector*100);
		glVertexf3(pos1+UpVector*100);

		pos1=float3(bx+dx*10,0,by+dy*a);
		pos1.y=ground->GetHeight(pos1.x,pos1.z);
		pos2=float3(bx+dx*10,0,by+dy*(a+1));
		pos2.y=ground->GetHeight(pos2.x,pos2.z);

		glVertexf3(pos1);
		glVertexf3(pos2);
		glVertexf3(pos2+UpVector*100);
		glVertexf3(pos1+UpVector*100);
	}
	glEnd();

	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glDisable(GL_DEPTH_TEST);

	float mx=float(mouse->lastx)/gu->viewSizeX;
	float my=(gu->viewSizeY-float(mouse->lasty))/gu->viewSizeY;

	glDisable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	glDisable(GL_ALPHA_TEST);

	if (!showReady) {
		return;
	}

	if (InBox(mx, my, readyBox)) {
		glColor4f(0.7f, 0.2f, 0.2f, guiAlpha);
	} else {
		glColor4f(0.7f, 0.7f, 0.2f, guiAlpha);
	}
	DrawBox(readyBox);

	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
	if (InBox(mx, my, readyBox)) {
		glColor4f(0.7f, 0.2f, 0.2f, guiAlpha);
	} else {
		glColor4f(0.7f, 0.7f, 0.2f, guiAlpha);
	}
	DrawBox(readyBox);
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

//.........这里部分代码省略.........
开发者ID:DeadnightWarrior,项目名称:spring,代码行数:101,代码来源:StartPosSelecter.cpp


示例18: fprintf


//.........这里部分代码省略.........
	{
		fprintf(stderr, "failed to reserve samples!\n");
		return false;
	}

	//should probably be done in the InputSystem!
	if( !al_install_keyboard() )
	{
		printf( "Keyboard not installed!\n" ); 
		return false;
	}

	//should probably be done in the InputSystem!
	if( !al_install_mouse() )
	{
		printf( "Mouse not installed!\n" ); 
		return false;
	}

	//should be somewhere else!
	al_init_font_addon();
	if( !al_init_ttf_addon() )
	{
		printf( "ttf font addon not initted properly!\n" ); 
		return false;
	}

	//actually load the font
	mpFont = al_load_ttf_font( "cour.ttf", 20, 0 );
	if( mpFont == NULL )
	{
		printf( "ttf font file not loaded properly!\n" ); 
		return false;
	}

	//show the mouse
	if( !al_hide_mouse_cursor( mpGraphicsSystem->getDisplay() ) )
	{
		printf( "Mouse cursor not able to be hidden!\n" ); 
		return false;
	}

	if( !al_init_primitives_addon() )
	{
		printf( "Primitives addon not added!\n" ); 
		return false;
	}

	//load the sample
	mpSample = al_load_sample( "clapping.wav" );
	if (!mpSample)
	{
		printf( "Audio clip sample not loaded!\n" ); 
		return false;
	}

	mpMessageManager = new GameMessageManager();

	//load buffers
	mBackgroundBufferID = mpGraphicsBufferManager->loadBuffer("wallpaper.bmp");
	mPlayerIconBufferID = mpGraphicsBufferManager->loadBuffer("arrow.bmp");
	mEnemyIconBufferID = mpGraphicsBufferManager->loadBuffer("enemy-arrow.bmp");
	
	//setup sprites
	GraphicsBuffer* pBackGroundBuffer = mpGraphicsBufferManager->getBuffer( mBackgroundBufferID );
	if( pBackGroundBuffer != NULL )
	{
		mpSpriteManager->createAndManageSprite( BACKGROUND_SPRITE_ID, pBackGroundBuffer, 0, 0, pBackGroundBuffer->getWidth(), pBackGroundBuffer->getHeight() );
	}
	GraphicsBuffer* pPlayerBuffer = mpGraphicsBufferManager->getBuffer( mPlayerIconBufferID );
	Sprite* pArrowSprite = NULL;
	if( pPlayerBuffer != NULL )
	{
		pArrowSprite = mpSpriteManager->createAndManageSprite( PLAYER_ICON_SPRITE_ID, pPlayerBuffer, 0, 0, pPlayerBuffer->getWidth(), pPlayerBuffer->getHeight() );
	}
	GraphicsBuffer* pAIBuffer = mpGraphicsBufferManager->getBuffer( mEnemyIconBufferID );
	Sprite* pEnemyArrow = NULL;
	if( pAIBuffer != NULL )
	{
		pEnemyArrow = mpSpriteManager->createAndManageSprite( AI_ICON_SPRITE_ID, pAIBuffer, 0, 0, pAIBuffer->getWidth(), pAIBuffer->getHeight() );
	}

	//setup units
	Vector2D pos( 0.0f, 0.0f );
	Vector2D vel( 0.0f, 0.0f );
	mpUnit = new KinematicUnit( pArrowSprite, pos, 1, vel, 0.0f, 200.0f, 10.0f );
	
	Vector2D pos2( 1000.0f, 500.0f );
	Vector2D vel2( 0.0f, 0.0f );
	mpAIUnit = new KinematicUnit( pEnemyArrow, pos2, 1, vel2, 0.0f, 180.0f, 100.0f );
	//give steering behavior
	mpAIUnit->dynamicArrive( mpUnit ); 

	Vector2D pos3( 500.0f, 500.0f );
	mpAIUnit2 = new KinematicUnit( pEnemyArrow, pos3, 1, vel2, 0.0f, 180.0f, 100.0f );
	//give steering behavior
	mpAIUnit2->dynamicSeek( mpUnit );  

	return true;
}
开发者ID:JackOfDawn,项目名称:AI,代码行数:101,代码来源:Game.cpp


示例19: FillPathVector


//.........这里部分代码省略.........
    m_WayPoints[0] = pos;
    t += keyFrames[0].delay * 1000;

    int cM = keyFrames[0].mapid;
    for (size_t i = 0; i < keyFrames.size() - 1; i++)        //
    {
        float d = 0;
        float tFrom = keyFrames[i].tFrom;
        float tTo = keyFrames[i].tTo;

        // keep the generation of all these points; we use only a few now, but may need the others later
        if (((d < keyFrames[i + 1].distFromPrev) && (tTo > 0)))
        {
            while ((d < keyFrames[i + 1].distFromPrev) && (tTo > 0))
            {
                tFrom += 100;
                tTo -= 100;

                if (d > 0)
                {
                    float newX, newY, newZ;
                    newX = keyFrames[i].x + (keyFrames[i + 1].x - keyFrames[i].x) * d / keyFrames[i + 1].distFromPrev;
                    newY = keyFrames[i].y + (keyFrames[i + 1].y - keyFrames[i].y) * d / keyFrames[i + 1].distFromPrev;
                    newZ = keyFrames[i].z + (keyFrames[i + 1].z - keyFrames[i].z) * d / keyFrames[i + 1].distFromPrev;

                    teleport = false;
                    if ((int)keyFrames[i].mapid != cM)
                    {
                        teleport = true;
                        cM = keyFrames[i].mapid;
                    }

                    //                    sLog.outString("T: %d, D: %f, x: %f, y: %f, z: %f", t, d, newX, newY, newZ);
                    TWayPoint pos2(keyFrames[i].mapid, newX, newY, newZ, teleport);
                    if (teleport || ((t - last_t) >= 1000))
                    {
                        m_WayPoints[t] = pos2;
                        last_t = t;
                    }
                }

                if (tFrom < tTo)                            // caught in tFrom dock's "gravitational pull"
                {
                    if (tFrom <= 30000)
                    {
                        d = 0.5f * (tFrom / 1000) * (tFrom / 1000);
                    }
                    else
                    {
                        d = 0.5f * 30 * 30 + 30 * ((tFrom - 30000) / 1000);
                    }
                    d = d - keyFrames[i].distSinceStop;
                }
                else
                {
                    if (tTo <= 30000)
                    {
                        d = 0.5f * (tTo / 1000) * (tTo / 1000);
                    }
                    else
                    {
                        d = 0.5f * 30 * 30 + 30 * ((tTo - 30000) / 1000);
                    }
                    d = keyFrames[i].distUntilStop - d;
                }
                t += 100;
开发者ID:TheGhostGroup,项目名称:AscEmu,代码行数:67,代码来源:TransporterHandler.cpp


示例20: pos0

void MeshFusion::intoMesh(Matrix4f invm, MyTri *scanned)
{

	int nnode[2048];

	int ocase = -1;
	int	nface = scanned->totalFace / 3;
	for (int i = 0; i < nface; i++)
	{
		int n0 = scanned->meshTri[3 * i];
		int n1 = scanned->meshTri[3 * i + 1];
		int n2 = scanned->meshTri[3 * i + 2];
		Point2  first_vertex = scanned->meshProj[n0];
		Point2  second_vertex = scanned->meshProj[n1];
		Point2  third_vertex = scanned->meshProj[n2];

		bool s0 = scanned->stat[n0];
		bool s1 = scanned->stat[n1];
		bool s2 = scanned->stat[n2];

		if (!s0 && !s1 && !s2)
		{
			Vector3f pos0(scanned->meshVertex[n0].x, scanned->meshVertex[n0].y, scanned->meshVertex[n0].z);
			Vector3f pos1(scanned->meshVertex[n1].x, scanned->meshVertex[n1].y, scanned->meshVertex[n1].z);
			Vector3f pos2(scanned->meshVertex[n2].x, scanned->meshVertex[n2].y, scanned->meshVertex[n2].z);

			Vector3f ipos0 = invm *pos0;
			Vector3f ipos1 = invm *pos1;
			Vector3f ipos2 = invm *pos2;

			// if (nnode[n0] <= 0)
			{
				mytriData.meshVertex[mytriData.totalVertex].x = ipos0.x;
				mytriData.meshVertex[mytriData.totalVertex].y = ipos0.y;
				mytriData.meshVertex[mytriData.totalVertex].z = ipos0.z;
				nnode[n0] = mytriData.totalVertex;
				mytriData.totalVertex++;
			}

			//if (nnode[n1] <= 0)
			{
				mytriData.meshVertex[mytriData.totalVertex].x = ipos1.x;
				mytriData.meshVertex[mytriData.totalVertex].y = ipos1.y;
				mytriData.meshVertex[mytriData.totalVertex].z = ipos1.z;
				nnode[n1] = mytriData.totalVertex;
				mytriData.totalVertex++;
			}

			//if (nnode[n2] <= 0)
			{
				mytriData.meshVertex[mytriData.totalVertex].x = ipos2.x;
				mytriData.meshVertex[mytriData.totalVertex].y = ipos2.y;
				mytriData.meshVertex[mytriData.totalVertex].z = ipos2.z;
				nnode[n2] = mytriData.totalVertex;
				mytriData.totalVertex++;
			}

			mytriData.meshTri[mytriData.totalFace++] = nnode[n0];
			mytriData.meshTri[mytriData.totalFace++] = nnode[n1];
			mytriData.meshTri[mytriData.totalFace++] = nnode[n2];

		}


	}

}
开发者ID:toreal,项目名称:InfiniTAM,代码行数:67,代码来源:meshMerge.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ position函数代码示例发布时间:2022-05-31
下一篇:
C++ pos1函数代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap