本文整理汇总了C++中position函数的典型用法代码示例。如果您正苦于以下问题:C++ position函数的具体用法?C++ position怎么用?C++ position使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了position函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:joevandyk,项目名称:osg,代码行数:95,代码来源:osgpick.cpp
示例2: position
position operator/(const position &a, double n)
{
return position(a.x/n, a.y/n);
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:4,代码来源:object.cpp
示例3: destroy
void Shield::shot() {
if (--m_health <= 0) {
destroy();
publish(ExplosionMessage(position()));
}
}
开发者ID:maurisvh,项目名称:SpaceInvaders,代码行数:6,代码来源:shield.cpp
示例4: position
void LCD_Display::selectLineOne(){ //puts the cursor at line 0 char 0.
position(1,0); //position
}
开发者ID:amirante,项目名称:LCD_Utils,代码行数:3,代码来源:LCD_Utils.cpp
示例5: init_sizes
void ChannelChatTab::setSplitPos(int x)
{
init_sizes();
position(userList_->x(), 0, x, 0);
}
开发者ID:cleanrock,项目名称:flobby,代码行数:5,代码来源:ChannelChatTab.cpp
示例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
//.........这里部分代码省略.........
开发者ID:Match-Yang,项目名称:digikam,代码行数:101,代码来源:weights.cpp
示例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);
}
}
开发者ID:MarcStelzner,项目名称:shawn,代码行数:72,代码来源:vis_drawable_node_default.cpp
示例8: setPosition
File* File::skipBytes(unsigned int numberOfBytes)
{
setPosition(position() + numberOfBytes);
return this;
}
开发者ID:CynicRus,项目名称:falltergeist,代码行数:5,代码来源:File.cpp
示例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);
//.........这里部分代码省略.........
开发者ID:Ian-Mills,项目名称:hifi,代码行数:101,代码来源:SixenseManager.cpp
示例10: prev
node_impl_pointer& prev(node_impl_pointer x)const
{
return prev_at(position(x));
}
开发者ID:00liujj,项目名称:dealii,代码行数:4,代码来源:rnd_index_loader.hpp
示例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
//.........这里部分代码省略.........
开发者ID:ShadowWolfTJC,项目名称:warzone2100,代码行数:101,代码来源:multimenu.cpp
示例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);
}
开发者ID:DoubleYouEl,项目名称:CrochetCharts,代码行数:95,代码来源:file_v1.cpp
示例13: factory
void NavigationSubWidget::restoreSettings()
{
if (!m_navigationWidget || !factory())
return;
factory()->restoreSettings(position(), m_navigationWidget);
}
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:6,代码来源:navigationsubwidget.cpp
示例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();
}
开发者ID:Kerswill,项目名称:Bacterium,代码行数:61,代码来源:World.cpp
示例15: publish
void Shield::update(const sf::Time& dt) {
publish(ShieldMessage(position(), health()));
}
开发者ID:maurisvh,项目名称:SpaceInvaders,代码行数:3,代码来源:shield.cpp
示例16: position
void Player::atirar(Portal* portal)
{
portal->visible(true);
portal->position() = position();
portal->velocity() = (Mouse::ray() * 300);
}
开发者ID:andrefpc,项目名称:TrabalhoCG,代码行数:6,代码来源:Player.cpp
示例17: DBGP
/*! Uses the \a projCoords and \a fixedCoordSet (which identifies the indices
of the fixed coordinates) to project the 6D hyperplanes of the Grasp Wrench
Space into 3D. The \a projCoords is an array of 6 values, but only 3 are used.
It then calls qhull to perform a halfspace intersection to get the vertices
of the 3D volume. These vertices are stored in \a hullCoords, and indices
of the individual faces that make up the volume are stored in \a hullIndices
(an Indexed Face Set).
*/
int
GWS::projectTo3D(double *projCoords, std::set<int> fixedCoordSet,
std::vector<position> &hullCoords, std::vector<int> &hullIndices)
{
int i,j,k,validPlanes,numCoords,numInLoop;
double **planes;
int freeCoord[3],fixedCoord[3];
// qhull variables
boolT ismalloc;
int curlong,totlong,exitcode;
char options[200];
facetT *facet;
if (numHyperPlanes == 0) {
DBGP("No hyperplanes");
return SUCCESS;
}
planes = (double **) malloc(numHyperPlanes * sizeof(double *));
if (!planes) {
#ifdef GRASPITDBG
pr_error("GWS::ProjectTo3D,Out of memory allocating planes array");
printf("NumHyperplanes: %d\n",numHyperPlanes);
#endif
return FAILURE;
}
validPlanes = 0;
// determine which dimensions are free and which are fixed
// the set keeps things ordered
for (i=0,j=0,k=0;i<6;i++) {
if (fixedCoordSet.find(i) == fixedCoordSet.end()) {
freeCoord[k++] = i;
} else {
fixedCoord[j++] = i;
}
}
// project the hyperplanes to three dimensional planes
for (i=0;i<numHyperPlanes;i++) {
double len = sqrt(hyperPlanes[i][freeCoord[0]]*hyperPlanes[i][freeCoord[0]] +
hyperPlanes[i][freeCoord[1]]*hyperPlanes[i][freeCoord[1]] +
hyperPlanes[i][freeCoord[2]]*hyperPlanes[i][freeCoord[2]]);
if (len>1e-11) {
planes[validPlanes] = (double *) malloc(4 * sizeof(double));
if (!planes[validPlanes]) {
pr_error("Out of memory allocating planes array");
DBGP("Out of memory allocating planes array");
return FAILURE;
}
planes[validPlanes][0] = hyperPlanes[i][freeCoord[0]]/len;
planes[validPlanes][1] = hyperPlanes[i][freeCoord[1]]/len;
planes[validPlanes][2] = hyperPlanes[i][freeCoord[2]]/len;
planes[validPlanes][3] = (hyperPlanes[i][6] +
hyperPlanes[i][fixedCoord[0]]*projCoords[fixedCoord[0]] +
hyperPlanes[i][fixedCoord[1]]*projCoords[fixedCoord[1]] +
hyperPlanes[i][fixedCoord[2]]*projCoords[fixedCoord[2]])/len;
validPlanes++;
}
}
if (validPlanes<numHyperPlanes) {
DBGP("Ignored " << numHyperPlanes-validPlanes <<
" hyperplanes which did not intersect this 3-space");
}
if (!validPlanes) {
DBGA("No valid planes in 3D projection!");
return FAILURE;
}
//
// call qhull to do the halfspace intersection
//
coordT *array = new coordT[validPlanes*3];
coordT *p = &array[0];
boolT zerodiv;
coordT *point, *normp, *coordp, **pointp, *feasiblep;
vertexT *vertex, **vertexp;
#ifdef GRASPITDBG
printf("Calling qhull to perform a 3D halfspace intersection of %d planes...\n",validPlanes);
#endif
ismalloc = False; // True if qh_freeqhull should 'free(array)'
// I want to get rid of this but qh_init needs some sort of file pointer
//.........这里部分代码省略.........
开发者ID:BerkeleyAutomation,项目名称:google_goggles_project,代码行数:101,代码来源:gws.cpp
示例18: north
position north() { return position(cent.x, cent.y + dim.y/2.0); }
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:1,代码来源:object.cpp
示例19: handle
int Flu_Combo_Box::Popup :: handle( int event )
{
if( event == FL_MOVE )
{
// FL_MOVE is also generated while the window is moving
// this attempts to keep the popup window moving with the enclosing window
//position( combo->window()->x()+combo->x()-2, combo->window()->y()+combo->y()+combo->h()-2 );
position( global_x(combo)-2, global_y(combo)+combo->h()-2 );
// this lets the mouse move event also move the selected item
combo->_hilight( Fl::event_x(), Fl::event_y() );
}
if( event == FL_DRAG )
dragging = true;
// if push outside the popup window, popdown
if( event == FL_PUSH &&
!Fl::event_inside( child(0) ) )
{
combo->_popped = false;
return 0;
}
// if release after dragging outside the popup window, popdown
if( event == FL_RELEASE && dragging &&
!Fl::event_inside( child(0) ) )
{
combo->_popped = false;
return 0;
}
if( event == FL_KEYDOWN )
{
if( Fl::event_key( FL_Escape ) )
{
combo->_popped = false;
return 0;
}
else if( Fl::event_key( FL_Up ) )
{
const char *s = combo->_previous();
if( s )
selected = s;
return 1;
}
else if( Fl::event_key( FL_Down ) )
{
const char *s = combo->_next();
if( s )
selected = s;
return 1;
}
else if( Fl::event_key( FL_Enter ) || Fl::event_key( ' ' ) )
{
if( selected )
{
combo->value( selected );
combo->selected( selected );
}
combo->_popped = false;
return 1;
}
}
return Fl_Double_Window::handle( event );
}
开发者ID:BlitzMaxModules,项目名称:maxgui.mod,代码行数:66,代码来源:Flu_Combo_Box.cpp
注:本文中的position函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论