本文整理汇总了C++中pos1函数的典型用法代码示例。如果您正苦于以下问题:C++ pos1函数的具体用法?C++ pos1怎么用?C++ pos1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pos1函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkLabel
Local void checkLabel(Char *w)
{
voice_index j, FORLIM;
Char STR1[256], STR2[256];
FORLIM = nvoices;
for (j = 0; j <= FORLIM - 1; j++) {
if (!strcmp(w, voice_label[j])) {
sprintf(STR2, "Voice label %s not unique", w);
warning(STR2, print);
return;
}
}
if (strlen(w) > 2)
return;
if (pos1(w[0], "CLU") > 0) {
if (strlen(w) > 1) {
if (pos1(w[1], "123456789") == 0)
return;
}
} else if (pos1(w[0], "123456789") == 0)
return;
sprintf(STR1, "Voice label %s conflicts with reserved label", w);
error(STR1, print);
}
示例2: textTranslate
Static void textTranslate(Char *uptext, Char *font)
{
short k;
Char STR1[256], STR2[256], STR3[256], STR4[256];
short FORLIM;
if (*uptext == '\0')
return;
do {
k = pos1('%', uptext);
if (k > 0) {
sprintf(STR4, "%s{\\mtxFlat}%s",
substr_(STR1, uptext, 1, k - 1),
substr_(STR3, uptext, k + 1, strlen(uptext) - k));
strcpy(uptext, STR4);
}
} while (k != 0);
do {
k = pos1('#', uptext);
if (k > 0) {
sprintf(STR2, "%s{\\mtxSharp}%s",
substr_(STR1, uptext, 1, k - 1),
substr_(STR4, uptext, k + 1, strlen(uptext) - k));
strcpy(uptext, STR2);
}
} while (k != 0);
switch (uptext[0]) {
case '<':
if (!strcmp(uptext, "<"))
strcpy(uptext, "\\mtxIcresc");
else if (!strcmp(uptext, "<."))
strcpy(uptext, "\\mtxTcresc");
else {
predelete(uptext, 1);
sprintf(uptext, "\\mtxCresc{%s}", strcpy(STR4, uptext));
}
break;
case '>':
if (!strcmp(uptext, ">"))
strcpy(uptext, "\\mtxIdecresc");
else if (!strcmp(uptext, ">."))
strcpy(uptext, "\\mtxTdecresc");
else {
predelete(uptext, 1);
sprintf(uptext, "\\mtxDecresc{%s}", strcpy(STR1, uptext));
}
break;
default:
FORLIM = strlen(uptext);
for (k = 0; k <= FORLIM - 1; k++) {
if (pos1(uptext[k], "mpfzrs~") == 0)
return;
}
break;
}
strcpy(font, "\\mtxPF");
}
示例3: getKeyframePositionAndRotation
bool DemoKeeper::demoLoop( const Ogre::FrameEvent& evt )
{
mWorld->markForWrite();
//
//running demo loop accordingly
//
if (Keyframe_demoRunning)
{
hkVector4 pos;
hkQuaternion rot;
getKeyframePositionAndRotation(m_time + evt.timeSinceLastFrame, pos, rot);
hkpKeyFrameUtility::applyHardKeyFrame(pos, rot, 1.0f /evt.timeSinceLastFrame, m_keyframedBody);
m_time += evt.timeSinceLastFrame;
}
else if (binaryaction_demoRunning)
{
hkVector4 pos1 = m_boxRigidBody1->getPosition();
hkVector4 pos2 = m_boxRigidBody2->getPosition();
hkVector4 lenVec;
lenVec.setSub4(pos1, pos2);
manual_spring = mSceneMgr->createManualObject();
manual_spring->setQueryFlags(0);
manual_spring->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
manual_spring->position(pos1(0),pos1(1),pos1(2));
if (lenVec.length3() > m_springAction->getRestLength())
{
// Line is red if the spring is stretched.
manual_spring->colour(1,0,0);
}
else
{
// Line is blue is spring is at rest or compressed.
manual_spring->colour(0,0,1);
}
manual_spring->position(pos2(0),pos2(1),pos2(2));
manual_spring->end();
springNode->detachAllObjects();
springNode->attachObject(manual_spring);
}
mWorld->unmarkForWrite();
return true;
}
示例4: setOnly
void setOnly(Char *line_)
{
Char line[256];
short num, num1, num2, l;
Char s[256];
Char STR1[256];
strcpy(line, line_);
if (*line == '\0')
return;
if (startsWithIgnoreCase(line, "only"))
GetNextWord(STR1, line, colon_, dummy);
for (l = 0; l <= lines_in_paragraph - 1; l++)
omit_line[l] = true;
do {
GetNextWord(s, line, blank_, comma_);
if (*s == '\0')
return;
curtail(s, comma_);
if (pos1('-', s) == 0) {
getNum(s, &num);
if (num > 0 && num <= lines_in_paragraph)
omit_line[num-1] = false;
else
warning("Invalid line number in Only: is skipped", print);
} else {
getTwoNums(s, &num1, &num2);
if (num1 > 0 && num2 <= lines_in_paragraph) {
for (num = num1 - 1; num <= num2 - 1; num++)
omit_line[num] = false;
} else
warning("Invalid line range in Only: is skipped", print);
}
} while (true);
}
示例5: pos0
void
AirController::doWork()
{
std::list<Flight*> flights = Airport::getInstance()->getFlights();
std::list<Flight*>::iterator it;
Position pos0(3500.0, 0.0, 100.0);
Position pos1(1500.0, 0.0, 50.0);
Position pos2(200.0, 0.0, 25.0);
Position pos3(-750.0, 0.0, 25.0);
Route r0, r1, r2, r3;
r0.pos = pos0;
r0.speed = 500.0;
r1.pos = pos1;
r1.speed = 100.0;
r2.pos = pos2;
r2.speed = 19.0;
r3.pos = pos3;
r3.speed = 15.0;
for(it = flights.begin(); it!=flights.end(); ++it)
{
if((*it)->getRoute()->empty())
{
(*it)->getRoute()->push_back(r3);
(*it)->getRoute()->push_front(r2);
(*it)->getRoute()->push_front(r1);
(*it)->getRoute()->push_front(r0);
}
}
}
示例6: Position
/**
* Whether going from one tile to another blocks movement.
* @param startTile
* @param endTile
* @param direction
* @return true/false
*/
bool Pathfinding::isBlocked(Tile *startTile, Tile *endTile, const int direction)
{
// check if the difference in height between start and destination is not too high
// so we can not jump to the highest part of the stairs from the floor
// stairs terrainlevel goes typically -8 -16 (2 steps) or -4 -12 -20 (3 steps)
// this "maximum jump height" is therefore set to 8
static const Position oneTileNorth = Position(0, -1, 0);
static const Position oneTileEast = Position(1, 0, 0);
static const Position oneTileSouth = Position(0, 1, 0);
static const Position oneTileWest = Position(-1, 0, 0);
Position pos1 (startTile->getPosition());
switch(direction)
{
case 0: // north
if (isBlocked(startTile, MapData::O_NORTHWALL)) return true;
break;
case 1: // north east
if (isBlocked(startTile,MapData::O_NORTHWALL)) return true;
if (isBlocked(endTile,MapData::O_WESTWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileEast),MapData::O_WESTWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileEast),MapData::O_NORTHWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileNorth),O_BIGWALL) && isBlocked(_save->getTile(pos1 + oneTileNorth),O_BIGWALL)) return true;
break;
case 2: // east
if (isBlocked(endTile,MapData::O_WESTWALL)) return true;
break;
case 3: // south east
if (isBlocked(endTile,MapData::O_WESTWALL)) return true;
if (isBlocked(endTile,MapData::O_NORTHWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileEast),MapData::O_WESTWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileSouth),MapData::O_NORTHWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileSouth),O_BIGWALL) && isBlocked(_save->getTile(pos1 + oneTileEast),O_BIGWALL)) return true;
break;
case 4: // south
if (isBlocked(endTile,MapData::O_NORTHWALL)) return true;
break;
case 5: // south west
if (isBlocked(endTile,MapData::O_NORTHWALL)) return true;
if (isBlocked(startTile,MapData::O_WESTWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileSouth),MapData::O_WESTWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileSouth),MapData::O_NORTHWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileSouth),O_BIGWALL) && isBlocked(_save->getTile(pos1 + oneTileWest),O_BIGWALL)) return true;
break;
case 6: // west
if (isBlocked(startTile,MapData::O_WESTWALL)) return true;
break;
case 7: // north west
if (isBlocked(startTile,MapData::O_WESTWALL)) return true;
if (isBlocked(startTile,MapData::O_NORTHWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileNorth),MapData::O_WESTWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileWest),MapData::O_NORTHWALL)) return true;
if (isBlocked(_save->getTile(pos1 + oneTileNorth),O_BIGWALL) && isBlocked(_save->getTile(pos1 + oneTileWest),O_BIGWALL)) return true;
break;
}
return false;
}
示例7: faceName
bool WindowsManager::addSquareFace (const char* faceNameCorba,
const value_type* posCorba1,
const value_type* posCorba2,
const value_type* posCorba3,
const value_type* posCorba4,
const value_type* colorCorba)
{
std::string faceName (faceNameCorba);
if (nodes_.find (faceName) != nodes_.end ()) {
std::cout << "You need to chose an other name, \"" << faceName
<< "\" 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]);
osgVector3 pos3 (posCorba3[0], posCorba3[1], posCorba3[2]);
osgVector3 pos4 (posCorba4[0], posCorba4[1], posCorba4[2]);
LeafNodeFacePtr_t face = LeafNodeFace::create
(faceName, pos1, pos2, pos3, pos3, getColor (colorCorba));
WindowsManager::initParent (faceName, face);
addNode (faceName, face);
mtx_.unlock();
return true;
}
}
示例8: getPositionInGrid
float CRole::getDistanceSqInGrid(IGridRole* role)
{
Point p1 = getPositionInGrid();
Point p2 = role->getPositionInGrid();
int i,j,m,n;
float smallest = FLT_MAX;
for (i = 0; i < getGridWidth(); ++i)
{
for (j = 0; j < getGridHeight(); ++j)
{
Point pos1(p1.x + i, p1.y + j);
for (m = 0; m < role->getGridWidth(); ++m)
{
for (n = 0; n < role->getGridHeight(); ++n)
{
Point pos2(p2.x + m, p2.y + n);
float dist = pos1.getDistanceSq(pos2);
if (dist < smallest)
{
// CCLOG("(%f,%f --> %f, %f) %f", pos1.x, pos1.y, pos2.x, pos2.y, dist);
smallest = dist;
}
}
}
}
}
return smallest;
}
示例9: pos1
void CollisionSystem::ResolveCollision(Actor* actor1, Actor* actor2)
{
const float PUSH_AMOUNT = 0.65f;
float radius1 = actor1->GetRadius();
float radius2 = actor2->GetRadius();
Vector2Df pos1(actor1->Get2DPos());
Vector2Df pos2(actor2->Get2DPos());
Vector2Df dir(pos1 - pos2);
float sqrdDist = dir.SquaredLength();
float radiusSqrd = radius1 + radius2;
radiusSqrd *= radiusSqrd;
if(sqrdDist < radiusSqrd)
{
float length = dir.Length();
float mult = abs(1.0f - length / (radius1 + radius2));
pos1 += dir * PUSH_AMOUNT * mult;
if(actor1->CanBeMoved())
actor1->SetPosition(Vector3Df(pos1.x_, 0.0f, pos1.y_));
pos2 += dir * -PUSH_AMOUNT * mult;
if(actor2->CanBeMoved())
actor2->SetPosition(Vector3Df(pos2.x_, 0.0f, pos2.y_));
actor1->Collided(actor2);
actor2->Collided(actor1);
}
}
示例10: drawRectangle
// ---
void Entity_4::drawOn (QGAMES::Screen* s, const QGAMES::Position& p)
{
QGAMES::ArtistInATiledMap::drawOn (s, p);
#ifndef NDEBUG
s -> drawRectangle (collisionZone (), QGAMES::Color (120,120,120,255));
int ePosX, ePosY, ntW, ntH;
QGAMES::bdata m = (QGAMES::bdata) 0.0;
QGAMES::Vector pv (__BD 0, __BD 0, __BD 0);
adjustRelevants (m, pv);
tilesOcuppied (ePosX, ePosY, ntW, ntH, m, pv);
int tWidth = (__TM map ()) -> tileWidth ();
int tHeight = (__TM map ()) -> tileHeight ();
int mWidth = map () -> width () / tWidth;
int mHeight = map () -> height () / tHeight;
int nE = ePosY * mWidth + ePosX;
for (int i = 0; i < ntH; i++)
{
for (int j = 0; j < ntW; j++)
{
int iPos = nE + (i * mWidth + j);
QGAMES::Position pos1 (__BD ((iPos % mWidth) * tWidth), __BD ((iPos / mWidth) * tHeight), __BD 0);
QGAMES::Position pos2 = pos1 + QGAMES::Vector (__BD tWidth, __BD tHeight, __BD 0);
s -> drawRectangle (QGAMES::Rectangle (pos1, pos2), QGAMES::Color (255,255,0,255));
}
}
#endif
}
示例11: processUsual
Local void processUsual(struct LOC_processLine *LINK)
{
if (hasVerseNumber(LINK->voice))
strcat(LINK->pretex, "\\mtxVerse");
LINK->l = pos1(multi_group, LINK->note);
if (LINK->l > 0)
scan1(LINK->note, LINK->l + 1, &LINK->nmulti);
activateBeamsAndSlurs(LINK->voice);
LINK->in_group = false;
if (LINK->ngrace > 0) {
LINK->in_group = true;
LINK->ngrace--;
} else {
if (LINK->nmulti > 0) {
LINK->in_group = true;
LINK->nmulti--;
}
}
checkOctave(LINK->voice, LINK->note);
renewPitch(LINK->voice, LINK->note);
if (!LINK->in_group) {
resetDuration(LINK->voice, durationCode(LINK->note));
markDebeamed(LINK->voice, LINK->note);
}
lookahead(LINK);
getSyllable(LINK->voice, LINK->pretex);
addUptext(LINK->voice, &LINK->no_uptext, LINK->pretex);
addChords(LINK);
}
示例12: torque1
dReal ServoMotor::getTorque() {
// code from Jeff Shim
osg::Vec3 torque1(fback_.t1[0], fback_.t1[1], fback_.t1[2] );
osg::Vec3 torque2(fback_.t2[0], fback_.t2[1], fback_.t2[2] );
osg::Vec3 force1(fback_.f1[0], fback_.f1[1], fback_.f1[2] );
osg::Vec3 force2(fback_.f2[0], fback_.f2[1], fback_.f2[2] );
const double* p1 = dBodyGetPosition( dJointGetBody(joint_->getJoint(),0) );
const double* p2 = dBodyGetPosition( dJointGetBody(joint_->getJoint(),1) );
osg::Vec3 pos1(p1[0], p1[1], p1[2]);
osg::Vec3 pos2(p2[0], p2[1], p2[2]);
dVector3 odeAnchor;
dJointGetHingeAnchor ( joint_->getJoint(), odeAnchor );
osg::Vec3 anchor(odeAnchor[0], odeAnchor[1], odeAnchor[2]);
osg::Vec3 ftorque1 = torque1 - (force1^(pos1-anchor));// torq by motor = total torq - constraint torq
osg::Vec3 ftorque2 = torque2 - (force2^(pos2-anchor));// opposite direction - use if this is necessary
dVector3 odeAxis;
dJointGetHingeAxis ( joint_->getJoint(), odeAxis);
osg::Vec3 axis(odeAxis[0], odeAxis[1], odeAxis[2] );
axis.normalize();
double torque = ftorque1 * axis;
//printf ("torque: % 1.10f\n", torque);
return torque;
}
示例13: countIt
Local void countIt(struct LOC_scanMusic *LINK)
{
struct LOC_countIt V;
V.LINK = LINK;
if (LINK->ngrace > 0) {
LINK->ngrace--;
return;
}
if (LINK->nmulti > 0) {
decmulti(LINK);
return;
}
if (LINK->count % 3 != 0 &&
(LINK->note[0] != rest && note_attrib[LINK->voice-1]['d' - 'a'] ||
LINK->note[0] == rest && rest_attrib[LINK->voice-1]['d' - 'a']))
LINK->count += LINK->count / 2;
/* p2c: mtx.pas, line 150:
* Note: Using % for possibly-negative arguments [317] */
incbar(LINK->count, &V);
LINK->l = pos1(multi_group, LINK->note);
if (LINK->l <= 0)
return;
predelete(LINK->note, LINK->l);
getNum(LINK->note, &LINK->nmulti);
decmulti(LINK);
}
示例14: checkSticky
Static void checkSticky(Char *note, boolean *attrib)
{
short i = 2;
short l;
Char c;
Char a[256];
if (*note == '\0')
return;
l = strlen(note);
while (i <= l) {
c = note[i-1];
if (islower(c)) {
if (i < l && note[i] == ':') {
delete1(note, i + 1);
l--;
attrib[c - 'a'] = !attrib[c - 'a'];
} else
attrib[c - 'a'] = false;
}
i++;
}
attribs(a, note);
for (c = 'z'; c >= 'a'; c--) {
if (attrib[c - 'a'] && pos1(c, a) == 0)
insertChar(c, note, 3);
}
}
示例15: DrawVertexList
void DrawVertexList(const VertexBuffer& vertexBuffer)
{
std::vector<VertexList*>::const_iterator bufferIt = vertexBuffer.lists.begin();
std::vector<VertexList*>::const_iterator bufferItEnd = vertexBuffer.lists.end();
for(; bufferIt != bufferItEnd; bufferIt++) {
const VertexList& vertexList = **bufferIt;
Graphic& graphic = Graphic::Instance();
int indexCount = (int)vertexList.indices.size();
for(int i = 0; ((i + 1) * 3) <= indexCount; i++) {
int idx0 = vertexList.indices[i * 3];
int idx1 = vertexList.indices[(i * 3) + 1];
int idx2 = vertexList.indices[(i * 3) + 2];
Vector2 pos0(vertexList.vertices[idx0].xyz.x, vertexList.vertices[idx0].xyz.y);
Vector2 pos1(vertexList.vertices[idx1].xyz.x, vertexList.vertices[idx1].xyz.y);
Vector2 pos2(vertexList.vertices[idx2].xyz.x, vertexList.vertices[idx2].xyz.y);
graphic.DrawLine(pos0, pos1, 0xFF0000FF);
graphic.DrawLine(pos1, pos2, 0xFF0000FF);
graphic.DrawLine(pos2, pos0, 0xFF0000FF);
}
}
}