本文整理汇总了C++中position函数的典型用法代码示例。如果您正苦于以下问题:C++ position函数的具体用法?C++ position怎么用?C++ position使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了position函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createHUD
osg::Node* createHUD(osgText::Text* updateText)
{
// create the hud. derived from osgHud.cpp
// adds a set of quads, each in a separate Geode - which can be picked individually
// eg to be used as a menuing/help system!
// Can pick texts too!
osg::Camera* hudCamera = new osg::Camera;
hudCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
hudCamera->setProjectionMatrixAsOrtho2D(0,1280,0,1024);
hudCamera->setViewMatrix(osg::Matrix::identity());
hudCamera->setRenderOrder(osg::Camera::POST_RENDER);
hudCamera->setClearMask(GL_DEPTH_BUFFER_BIT);
std::string timesFont("fonts/times.ttf");
// turn lighting off for the text and disable depth test to ensure its always ontop.
osg::Vec3 position(150.0f,800.0f,0.0f);
osg::Vec3 delta(0.0f,-60.0f,0.0f);
{
osg::Geode* geode = new osg::Geode();
osg::StateSet* stateset = geode->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
geode->setName("simple");
hudCamera->addChild(geode);
osgText::Text* text = new osgText::Text;
geode->addDrawable( text );
text->setFont(timesFont);
text->setText("Picking in Head Up Displays is simple!");
text->setPosition(position);
position += delta;
}
for (int i=0; i<5; i++) {
osg::Vec3 dy(0.0f,-30.0f,0.0f);
osg::Vec3 dx(120.0f,0.0f,0.0f);
osg::Geode* geode = new osg::Geode();
osg::StateSet* stateset = geode->getOrCreateStateSet();
const char *opts[]={"One", "Two", "Three", "January", "Feb", "2003"};
osg::Geometry *quad=new osg::Geometry;
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
std::string name="subOption";
name += " ";
name += std::string(opts[i]);
geode->setName(name);
osg::Vec3Array* vertices = new osg::Vec3Array(4); // 1 quad
osg::Vec4Array* colors = new osg::Vec4Array;
colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(0.8-0.1*i,0.1*i,0.2*i, 1.0));
quad->setColorArray(colors);
quad->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
(*vertices)[0]=position;
(*vertices)[1]=position+dx;
(*vertices)[2]=position+dx+dy;
(*vertices)[3]=position+dy;
quad->setVertexArray(vertices);
quad->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
geode->addDrawable(quad);
hudCamera->addChild(geode);
position += delta;
}
{ // this displays what has been selected
osg::Geode* geode = new osg::Geode();
osg::StateSet* stateset = geode->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
geode->setName("The text label");
geode->addDrawable( updateText );
hudCamera->addChild(geode);
updateText->setCharacterSize(20.0f);
updateText->setFont(timesFont);
updateText->setColor(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
updateText->setText("");
updateText->setPosition(position);
updateText->setDataVariance(osg::Object::DYNAMIC);
position += delta;
}
return hudCamera;
}
示例2: position
position operator/(const position &a, double n)
{
return position(a.x/n, a.y/n);
}
示例3: destroy
void Shield::shot() {
if (--m_health <= 0) {
destroy();
publish(ExplosionMessage(position()));
}
}
示例4: position
void LCD_Display::selectLineOne(){ //puts the cursor at line 0 char 0.
position(1,0); //position
}
示例5: init_sizes
void ChannelChatTab::setSplitPos(int x)
{
init_sizes();
position(userList_->x(), 0, x, 0);
}
示例6: height
void Weights::calculateWeights()
{
mCoefficientNumber = (mTwoDim ? ((size_t)mPolynomeOrder + 1) * ((size_t)mPolynomeOrder + 1)
: (size_t)mPolynomeOrder + 1);
size_t ix, iy, i, j;
int x, y;
// Determine coordinates of pixels to be sampled
if (mTwoDim)
{
int iPolynomeOrder = (int) mPolynomeOrder; //lets avoid signed/unsigned comparison warnings
int iHeight = (int) height();
int iWidth = (int) width();
for (y = -iPolynomeOrder; y < iHeight + iPolynomeOrder; ++y)
{
for (x = -iPolynomeOrder; x < iWidth + iPolynomeOrder; ++x)
{
if ((x < 0 && y < 0 && -x - y < iPolynomeOrder + 2) ||
(x < 0 && y >= iHeight && -x + y - iHeight < iPolynomeOrder + 1) ||
(x >= iWidth && y < 0 && x - y - iWidth < iPolynomeOrder + 1) ||
(x >= iWidth && y >= iHeight && x + y - iWidth - iHeight < iPolynomeOrder) ||
(x < 0 && y >= 0 && y < iHeight) || (x >= iWidth && y >= 0 && y < iHeight) ||
(y < 0 && x >= 0 && x < iWidth ) || (y >= iHeight && x >= 0 && x < iWidth))
{
QPoint position(x,y);
mPositions.append(position);
}
}
}
}
else
{
// In the one-dimensional case, only the y coordinate and y size is used. */
for (y = (-1)*mPolynomeOrder; y < 0; ++y)
{
QPoint position(0,y);
mPositions.append(position);
}
for (y = (int) height(); y < (int) height() + (int) mPolynomeOrder; ++y)
{
QPoint position(0,y);
mPositions.append(position);
}
}
// Allocate memory.
QScopedArrayPointer<double> matrix (new double[mCoefficientNumber * mCoefficientNumber]);
QScopedArrayPointer<double> vector0(new double[mPositions.count() * mCoefficientNumber]);
QScopedArrayPointer<double> vector1(new double[mPositions.count() * mCoefficientNumber]);
// Calculate coefficient matrix and vectors
for (iy = 0; iy < mCoefficientNumber; ++iy)
{
for (ix = 0; ix < mCoefficientNumber; ++ix)
{
matrix [iy* mCoefficientNumber+ix] = 0.0;
}
for (j = 0; j < (size_t)mPositions.count(); ++j)
{
vector0 [iy * mPositions.count() + j] = polyTerm (iy, mPositions.at(j).x(),
mPositions.at(j).y(), mPolynomeOrder);
for (ix = 0; ix < mCoefficientNumber; ++ix)
{
matrix [iy* mCoefficientNumber + ix] += (vector0 [iy * mPositions.count() + j]
* polyTerm (ix, mPositions.at(j).x(), mPositions.at(j).y(), mPolynomeOrder));
}
}
}
// Invert matrix.
matrixInv (matrix.data(), mCoefficientNumber);
// Multiply inverse matrix with vector.
for (iy = 0; iy < mCoefficientNumber; ++iy)
{
for (j = 0; j < (size_t)mPositions.count(); ++j)
{
vector1 [iy * mPositions.count() + j] = 0.0;
for (ix = 0; ix < mCoefficientNumber; ++ix)
{
vector1 [iy * mPositions.count() + j] += matrix [iy * mCoefficientNumber + ix]
* vector0 [ix * mPositions.count() + j];
}
}
}
// Store weights
//.........这里部分代码省略.........
示例7: draw
// ----------------------------------------------------------------------
void
DrawableNodeDefault::
draw( cairo_t* cr, double t, const Context& C )
const throw(std::runtime_error)
{
Drawable::draw(cr,t,C);
if( visible() )
{
shawn::Vec pos = position(t);
double size = node_properties().size(t);
shawn::Vec bg;
shawn::ConstTagHandle rtag = node().find_tag( "red" );
shawn::ConstTagHandle gtag = node().find_tag( "green" );
shawn::ConstTagHandle btag = node().find_tag( "blue" );
//if(rtag!=NULL && gtag!=NULL && btag!=NULL)
//{
// double r = dynamic_cast<const shawn::DoubleTag*>( rtag.get() )->value();
// double g = dynamic_cast<const shawn::DoubleTag*>( gtag.get() )->value();
// double b = dynamic_cast<const shawn::DoubleTag*>( btag.get() )->value();
//
// bg = shawn::Vec(r,g,b);
//}
//else
//{
bg = node_properties().background(t);
//}
int shape = node_properties().shape(t);
cairo_save(cr);
cairo_translate(cr,pos.x(),pos.y());
cairo_set_line_width( cr, 0 );
switch(shape)
{
case 2:
cairo_rectangle(cr,-size,-size,size*2,size*2);
break;
default:
cairo_arc(cr,0.0,0.0,size,0,2.0*M_PI);
break;
}
blend_set_color(cr,bg);
cairo_fill(cr);
if( C.draft_level()<2 ) {
double lw = node_properties().line_width(t);
shawn::Vec fg = node_properties().foreground(t);
cairo_set_line_width( cr, lw );
switch(shape)
{
case 2:
cairo_rectangle(cr,-size,-size,size*2,size*2);
break;
default:
cairo_arc(cr,0.0,0.0,size,0,2.0*M_PI);
break;
}
blend_set_color(cr,fg);
cairo_stroke(cr);
}
cairo_restore(cr);
}
}
示例8: setPosition
File* File::skipBytes(unsigned int numberOfBytes)
{
setPosition(position() + numberOfBytes);
return this;
}
示例9: perfTimer
void SixenseManager::update(float deltaTime) {
#ifdef HAVE_SIXENSE
Hand* hand = DependencyManager::get<AvatarManager>()->getMyAvatar()->getHand();
if (_isInitialized && _isEnabled) {
#ifdef __APPLE__
SixenseBaseFunction sixenseGetNumActiveControllers =
(SixenseBaseFunction) _sixenseLibrary->resolve("sixenseGetNumActiveControllers");
#endif
if (sixenseGetNumActiveControllers() == 0) {
_hydrasConnected = false;
return;
}
PerformanceTimer perfTimer("sixense");
if (!_hydrasConnected) {
_hydrasConnected = true;
UserActivityLogger::getInstance().connectedDevice("spatial_controller", "hydra");
}
#ifdef __APPLE__
SixenseBaseFunction sixenseGetMaxControllers =
(SixenseBaseFunction) _sixenseLibrary->resolve("sixenseGetMaxControllers");
#endif
int maxControllers = sixenseGetMaxControllers();
// we only support two controllers
sixenseControllerData controllers[2];
#ifdef __APPLE__
SixenseTakeIntFunction sixenseIsControllerEnabled =
(SixenseTakeIntFunction) _sixenseLibrary->resolve("sixenseIsControllerEnabled");
SixenseTakeIntAndSixenseControllerData sixenseGetNewestData =
(SixenseTakeIntAndSixenseControllerData) _sixenseLibrary->resolve("sixenseGetNewestData");
#endif
int numControllersAtBase = 0;
int numActiveControllers = 0;
for (int i = 0; i < maxControllers && numActiveControllers < 2; i++) {
if (!sixenseIsControllerEnabled(i)) {
continue;
}
sixenseControllerData* data = controllers + numActiveControllers;
++numActiveControllers;
sixenseGetNewestData(i, data);
// Set palm position and normal based on Hydra position/orientation
// Either find a palm matching the sixense controller, or make a new one
PalmData* palm;
bool foundHand = false;
for (size_t j = 0; j < hand->getNumPalms(); j++) {
if (hand->getPalms()[j].getSixenseID() == data->controller_index) {
palm = &(hand->getPalms()[j]);
foundHand = true;
}
}
if (!foundHand) {
PalmData newPalm(hand);
hand->getPalms().push_back(newPalm);
palm = &(hand->getPalms()[hand->getNumPalms() - 1]);
palm->setSixenseID(data->controller_index);
qCDebug(interfaceapp, "Found new Sixense controller, ID %i", data->controller_index);
}
// Disable the hands (and return to default pose) if both controllers are at base station
if (foundHand) {
palm->setActive(!_controllersAtBase);
} else {
palm->setActive(false); // if this isn't a Sixsense ID palm, always make it inactive
}
// Read controller buttons and joystick into the hand
palm->setControllerButtons(data->buttons);
palm->setTrigger(data->trigger);
palm->setJoystick(data->joystick_x, data->joystick_y);
// Emulate the mouse so we can use scripts
if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseMouseInput) && !_controllersAtBase) {
emulateMouse(palm, numActiveControllers - 1);
}
// NOTE: Sixense API returns pos data in millimeters but we IMMEDIATELY convert to meters.
glm::vec3 position(data->pos[0], data->pos[1], data->pos[2]);
position *= METERS_PER_MILLIMETER;
// Check to see if this hand/controller is on the base
const float CONTROLLER_AT_BASE_DISTANCE = 0.075f;
if (glm::length(position) < CONTROLLER_AT_BASE_DISTANCE) {
numControllersAtBase++;
}
// Transform the measured position into body frame.
glm::vec3 neck = _neckBase;
// Zeroing y component of the "neck" effectively raises the measured position a little bit.
neck.y = 0.0f;
position = _orbRotation * (position - neck);
//.........这里部分代码省略.........
示例10: prev
node_impl_pointer& prev(node_impl_pointer x)const
{
return prev_at(position(x));
}
示例11: displayMultiPlayer
static void displayMultiPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
{
char str[128];
int x = xOffset + psWidget->x;
int y = yOffset + psWidget->y;
unsigned player = psWidget->UserData; // Get the in game player number.
if (responsibleFor(player, 0))
{
displayExtraGubbins(widgGetFromID(psWScreen,MULTIMENU_FORM)->height);
}
iV_SetFont(font_regular); // font
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
const bool isHuman = isHumanPlayer(player);
const bool isAlly = aiCheckAlliances(selectedPlayer, player);
const bool isSelectedPlayer = player == selectedPlayer;
SetPlayerTextColor(alliances[selectedPlayer][player], player);
if (isHuman || (game.type == SKIRMISH && player<game.maxPlayers) )
{
ssprintf(str, "%d: %s", NetPlay.players[player].position, getPlayerName(player));
while (iV_GetTextWidth(str) >= MULTIMENU_C0 - MULTIMENU_C2 - 10)
{
str[strlen(str) - 1] = '\0';
}
iV_DrawText(str, x + MULTIMENU_C2, y + MULTIMENU_FONT_OSET);
//c3-7 alliance
//manage buttons by showing or hiding them. gifts only in campaign,
if (game.alliance != NO_ALLIANCES)
{
if (isAlly && !isSelectedPlayer && !giftsUp[player] )
{
if (game.alliance != ALLIANCES_TEAMS)
{
widgReveal(psWScreen, MULTIMENU_GIFT_RAD + player);
widgReveal(psWScreen, MULTIMENU_GIFT_RES + player);
}
widgReveal(psWScreen, MULTIMENU_GIFT_DRO + player);
widgReveal(psWScreen, MULTIMENU_GIFT_POW + player);
giftsUp[player] = true;
}
else if (!isAlly && !isSelectedPlayer && giftsUp[player])
{
if (game.alliance != ALLIANCES_TEAMS)
{
widgHide(psWScreen, MULTIMENU_GIFT_RAD + player);
widgHide(psWScreen, MULTIMENU_GIFT_RES + player);
}
widgHide(psWScreen, MULTIMENU_GIFT_DRO + player);
widgHide(psWScreen, MULTIMENU_GIFT_POW + player);
giftsUp[player] = false;
}
}
}
// Let's use the real score for MP games
if (NetPlay.bComms)
{
//c8:score,
if (Cheated)
{
sprintf(str, "(cheated)");
}
else
{
sprintf(str, "%d", getMultiStats(player).recentScore);
}
iV_DrawText(str, x + MULTIMENU_C8, y + MULTIMENU_FONT_OSET);
//c9:kills,
sprintf(str, "%d", getMultiStats(player).recentKills);
iV_DrawText(str, x + MULTIMENU_C9, y + MULTIMENU_FONT_OSET);
}
else
{
// estimate of score for skirmish games
sprintf(str, "%d", ingame.skScores[player][0]);
iV_DrawText(str, x + MULTIMENU_C8, y + MULTIMENU_FONT_OSET);
// estimated kills
sprintf(str, "%d", ingame.skScores[player][1]);
iV_DrawText(str, x + MULTIMENU_C9, y + MULTIMENU_FONT_OSET);
}
//only show player's and allies' unit counts, and nobody elses.
//c10:units
if (isAlly || getDebugMappingStatus())
{
sprintf(str, "%d", getNumDroids(player) + getNumTransporterDroids(player));
iV_DrawText(str, x + MULTIMENU_C10, y + MULTIMENU_FONT_OSET);
}
/* Display player power instead of number of played games
* and number of units instead of ping when in debug mode
*/
if (getDebugMappingStatus()) //Won't pass this when in both release and multiplayer modes
//.........这里部分代码省略.........
示例12: Cell
void File_v1::loadCell(CrochetTab *tab, QXmlStreamReader *stream)
{
Cell *c = new Cell();
Stitch *s = 0;
int row = -1, column = -1;
int group = -1;
QString bgColor;
QPointF position(0.0,0.0);
QPointF pivotPoint;
qreal angle = 0.0;
QPointF scale = QPointF(1.0,1.0);
QTransform transform;
qreal m11 = 1, m12 = 0, m13 = 0,
m21 = 0, m22 = 1, m23 = 0,
m31 = 0, m32 = 0, m33 = 1;
while(!(stream->isEndElement() && stream->name() == "cell")) {
stream->readNext();
QString tag = stream->name().toString();
if(tag == "stitch") {
QString st = stream->readElementText();
s = StitchLibrary::inst()->findStitch(st, true);
} else if(tag == "grid") {
row = stream->attributes().value("row").toString().toDouble();
column = stream->attributes().value("column").toString().toDouble();
stream->readElementText();
} else if(tag == "color") {
bgColor = stream->readElementText();
} else if(tag == "position") {
position.rx() = stream->attributes().value("x").toString().toDouble();
position.ry() = stream->attributes().value("y").toString().toDouble();
stream->readElementText();
} else if(tag == "angle") {
angle = stream->readElementText().toDouble();
} else if(tag == "scale") {
scale.rx() = stream->attributes().value("x").toString().toDouble();
scale.ry() = stream->attributes().value("y").toString().toDouble();
stream->readElementText();
} else if(tag == "pivotPoint") {
pivotPoint.rx() = stream->attributes().value("x").toString().toDouble();
pivotPoint.ry() = stream->attributes().value("y").toString().toDouble();
stream->readElementText();
} else if(tag == "group") {
group = stream->readElementText().toInt();
} else if(tag == "transformation") {
m11 = stream->attributes().value("m11").toString().toDouble();
m12 = stream->attributes().value("m12").toString().toDouble();
m13 = stream->attributes().value("m13").toString().toDouble();
m21 = stream->attributes().value("m21").toString().toDouble();
m22 = stream->attributes().value("m22").toString().toDouble();
m23 = stream->attributes().value("m23").toString().toDouble();
m31 = stream->attributes().value("m31").toString().toDouble();
m32 = stream->attributes().value("m32").toString().toDouble();
m33 = stream->attributes().value("m33").toString().toDouble();
transform.setMatrix(m11, m12, m13, m21, m22, m23, m31, m32, m33);
stream->readElementText();
}
}
tab->scene()->addItem(c);
if(row > -1 && column > -1) {
c->setStitch(s);
if(row % 2) {
QString colorName = Settings::inst()->value("stitchAlternateColor").toString();
c->setColor(QColor(colorName));
}
tab->scene()->grid[row].replace(column, c);
c->setZValue(100);
} else {
c->setStitch(s);
c->setZValue(10);
}
c->setTransform(transform);
c->setPos(position);
c->setBgColor(QColor(bgColor));
c->setTransformOriginPoint(pivotPoint);
c->setRotation(angle);
ChartItemTools::recalculateTransformations(c);
if(group != -1)
tab->scene()->addToGroup(group, c);
}
示例13: factory
void NavigationSubWidget::restoreSettings()
{
if (!m_navigationWidget || !factory())
return;
factory()->restoreSettings(position(), m_navigationWidget);
}
示例14: position
void World::Load(const std::string filepath, sf::RenderWindow &window, TextureManager &textureManager, FontManager &fontManager)
{
isGameOver = -1;
//open up the file
std::filebuf fb;
fb.open(filepath, std::ios::in);
//try to parse it
Json::Value root;
Json::Reader reader;
bool parseSuccessful = reader.parse(std::istream(&fb), root);
if(!parseSuccessful)
{
std::cerr << "Unsuccessful parse" << filepath << std::endl;
std::cerr << reader.getFormattedErrorMessages() << std::endl;
return;
}
//now we have it parsed we can close it
fb.close();
//set the background
std::string backgroundFilepath = root.get("background", "").asString();
if(!backgroundFilepath.empty())
{
worldSprite.setTexture(*textureManager.getResource(backgroundFilepath));
worldSprite.setScale((float)window.getSize().x / worldSprite.getTexture()->getSize().x, (float)window.getSize().y / worldSprite.getTexture()->getSize().y);
}
//hardcoded values
winTexture = *textureManager.getResource("Config/Content/Images/Menus/Backgrounds/WinBackground.png");
loseTexture = *textureManager.getResource("Config/Content/Images/Menus/Backgrounds/LoseBackground.png");
//build the walls
Json::Value walls = root["walls"];
for(unsigned int i = 0; i < walls.size(); i++)
{
Json::Value wall = walls[i];
std::string filepath = wall["name"].asString();
sf::Vector2f position(wall["position"]["x"].asFloat(), wall["position"]["y"].asFloat());
EntityBuilder::getInstance()->buildEntity(filepath, position);
}
//build the player
EntityBuilder::getInstance()->buildPlayer("Config/Entities/Characters/Player.json", sf::Vector2f(400, 300));
//set level mode, normal or survival
mode = (Mode) root.get("mode", NORMAL).asInt();
//build hud
Json::Value hudValue = root.get("hud", NULL);
const sf::Texture *healthBarPtr = textureManager.getResource(hudValue.get("healthBar", NULL).asString());
const sf::Texture *healthBarBackgroundPtr = textureManager.getResource(hudValue.get("healthBarBackground", NULL).asString());
hud.init(*healthBarPtr, *healthBarBackgroundPtr, entityManager.getVector(PLAYER), fontManager, mode);
//load the enemy waves, mode is important
enemySpawnManager.load(root, &entityManager, mode);
playerLoseClock.pause();
playerLoseClock.restart();
}
示例15: publish
void Shield::update(const sf::Time& dt) {
publish(ShieldMessage(position(), health()));
}