示例#1
0
文件: osgpick.cpp 项目: joevandyk/osg
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
0
position operator/(const position &a, double n)
{
  return position(a.x/n, a.y/n);
}
示例#3
0
position object::origin()
{
  return position(0.0,0.0);
}
示例#4
0
 void Shield::shot() {
     if (--m_health <= 0) {
         destroy();
         publish(ExplosionMessage(position()));
     }
 }
示例#5
0
position operator+(const position &a, const position &b)
{
  return position(a.x + b.x, a.y + b.y);
}
示例#6
0
void LCD_Display::selectLineOne(){  //puts the cursor at line 0 char 0.
   position(1,0);    //position
}
示例#7
0
void ChannelChatTab::setSplitPos(int x)
{
    init_sizes();
    position(userList_->x(), 0, x, 0);
}
示例#8
0
bool RenderProgress::isDeterminate() const
{
    return 0 <= position();
}
示例#9
0
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

    // Allocate mPositions.count() matrices.
    mWeightMatrices = new double** [mPositions.count()];

    for (i=0 ; i < (size_t)mPositions.count() ; ++i)
    {
        // Allocate mHeight rows on each position
        mWeightMatrices[i] = new double*[mHeight];

        for (j=0 ; j < mHeight ; ++j)
        {
            // Allocate mWidth columns on each row
            mWeightMatrices[i][j] = new double[mWidth];
        }
    }

    for (y = 0; y < (int) mHeight; ++y)
    {
        for (x = 0; x < (int) mWidth; ++x)
        {
            for (j = 0; j < (size_t)mPositions.count(); ++j)
            {
                mWeightMatrices [j][y][x] = 0.0;

                for (iy = 0; iy < mCoefficientNumber; ++iy)
                {
                    mWeightMatrices [j][y][x] += vector1 [iy * mPositions.count() + j]
                                                 * polyTerm (iy, x, y, mPolynomeOrder);
                }

                mWeightMatrices [j][y][x] *= (double) mPositions.count();
            }
        }
    }
}
   // ----------------------------------------------------------------------
   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);
         }
   }
示例#11
0
IntRect RenderProgress::valuePartRect() const
{
    IntRect rect(borderLeft() + paddingLeft(), borderTop() + paddingTop(), lround((width() - borderLeft() - paddingLeft() - borderRight() - paddingRight()) * position()), height()  - borderTop() - paddingTop() - borderBottom() - paddingBottom());
    if (style()->direction() == RTL)
        rect.setX(width() - borderRight() - paddingRight() - rect.width());
    return rect;
}
示例#12
0
File* File::skipBytes(unsigned int numberOfBytes)
{
    setPosition(position() + numberOfBytes);
    return this;
}
示例#13
0
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);
            
            //  Rotation of Palm
            glm::quat rotation(data->rot_quat[3], -data->rot_quat[0], data->rot_quat[1], -data->rot_quat[2]);
            rotation = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f)) * _orbRotation * rotation;
            
            //  Compute current velocity from position change
            glm::vec3 rawVelocity;
            if (deltaTime > 0.0f) {
                rawVelocity = (position - palm->getRawPosition()) / deltaTime;
            } else {
                rawVelocity = glm::vec3(0.0f);
            }
            palm->setRawVelocity(rawVelocity);   //  meters/sec
            
            // adjustment for hydra controllers fit into hands
            float sign = (i == 0) ? -1.0f : 1.0f;
            rotation *= glm::angleAxis(sign * PI/4.0f, glm::vec3(0.0f, 0.0f, 1.0f));
            
            //  Angular Velocity of Palm
            glm::quat deltaRotation = rotation * glm::inverse(palm->getRawRotation());
            glm::vec3 angularVelocity(0.0f);
            float rotationAngle = glm::angle(deltaRotation);
            if ((rotationAngle > EPSILON) && (deltaTime > 0.0f)) {
                angularVelocity = glm::normalize(glm::axis(deltaRotation));
                angularVelocity *= (rotationAngle / deltaTime);
                palm->setRawAngularVelocity(angularVelocity);
            } else {
                palm->setRawAngularVelocity(glm::vec3(0.0f));
            }
            
            if (_lowVelocityFilter) {
                //  Use a velocity sensitive filter to damp small motions and preserve large ones with
                //  no latency.
                float velocityFilter = glm::clamp(1.0f - glm::length(rawVelocity), 0.0f, 1.0f);
                position = palm->getRawPosition() * velocityFilter + position * (1.0f - velocityFilter);
                rotation = safeMix(palm->getRawRotation(), rotation, 1.0f - velocityFilter);
                palm->setRawPosition(position);
                palm->setRawRotation(rotation);
            } else {
                palm->setRawPosition(position);
                palm->setRawRotation(rotation);
            }
            
            // Store the one fingertip in the palm structure so we can track velocity
            const float FINGER_LENGTH = 0.3f;   //  meters
            const glm::vec3 FINGER_VECTOR(0.0f, 0.0f, FINGER_LENGTH);
            const glm::vec3 newTipPosition = position + rotation * FINGER_VECTOR;
            glm::vec3 oldTipPosition = palm->getTipRawPosition();
            if (deltaTime > 0.0f) {
                palm->setTipVelocity((newTipPosition - oldTipPosition) / deltaTime);
            } else {
                palm->setTipVelocity(glm::vec3(0.0f));
            }
            palm->setTipPosition(newTipPosition);
        }
        
        if (numActiveControllers == 2) {
            updateCalibration(controllers);
        }
        _controllersAtBase = (numControllersAtBase == 2);
    }
#endif  // HAVE_SIXENSE
}
示例#14
0
 node_impl_pointer& prev(node_impl_pointer x)const
 {
   return prev_at(position(x));
 }
示例#15
0
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
	{
		//c11: Player power
		sprintf(str, "%u", (int)getPower(player));
		iV_DrawText(str, MULTIMENU_FORM_X + MULTIMENU_C11, y + MULTIMENU_FONT_OSET);
	}
	else if (runningMultiplayer())
	{
		//c11:ping
		if (!isSelectedPlayer && isHuman)
		{
			if (ingame.PingTimes[player] < PING_LIMIT)
			{
				sprintf(str, "%03d", ingame.PingTimes[player]);
			}
			else
			{
				sprintf(str, "∞");
			}
			iV_DrawText(str, x + MULTIMENU_C11, y + MULTIMENU_FONT_OSET);
		}
	}
	else
	{
		//c11: Structures
		if (isAlly || getDebugMappingStatus())
		{
			// NOTE, This tallys up *all* the structures you have. Test out via 'start with no base'.
			int num = 0;
			for (STRUCTURE *temp = apsStructLists[player]; temp != NULL; temp = temp->psNext)
			{
				++num;
			}
			sprintf(str, "%d", num);
			iV_DrawText(str, x + MULTIMENU_C11, y + MULTIMENU_FONT_OSET);
		}
	}

	// a droid of theirs.
	DROID *displayDroid = apsDroidLists[player];
	while (displayDroid != NULL && !displayDroid->visible[selectedPlayer])
	{
		displayDroid = displayDroid->psNext;
	}
	if (displayDroid)
	{
		pie_SetGeometricOffset( MULTIMENU_FORM_X+MULTIMENU_C1 ,y+MULTIMENU_PLAYER_H);
		Vector3i rotation(-15, 45, 0);
		Position position(0, 0, 2000);  // Scale them.
		if (displayDroid->droidType == DROID_SUPERTRANSPORTER)
		{
			position.z = 7850;
		}
		else if (displayDroid->droidType == DROID_TRANSPORTER)
		{
			position.z = 4100;
		}

		displayComponentButtonObject(displayDroid, &rotation, &position, false, 100);
	}
	else if (apsDroidLists[player])
	{
		// Show that they have droids, but not which droids, since we can't see them.
		iV_DrawImageTc(IntImages, IMAGE_GENERIC_TANK, IMAGE_GENERIC_TANK_TC, MULTIMENU_FORM_X + MULTIMENU_C1 - iV_GetImageWidth(IntImages, IMAGE_GENERIC_TANK)/2, y + MULTIMENU_PLAYER_H - iV_GetImageHeight(IntImages, IMAGE_GENERIC_TANK), pal_GetTeamColour(getPlayerColour(player)));
	}

	// clean up widgets if player leaves while menu is up.
	if (!isHuman && !(game.type == SKIRMISH && player < game.maxPlayers))
	{
		if (widgGetFromID(psWScreen, MULTIMENU_CHANNEL + player) != NULL)
		{
			widgDelete(psWScreen, MULTIMENU_CHANNEL + player);
		}

		if (widgGetFromID(psWScreen, MULTIMENU_ALLIANCE_BASE + player) != NULL)
		{
			widgDelete(psWScreen, MULTIMENU_ALLIANCE_BASE + player);
			widgDelete(psWScreen, MULTIMENU_GIFT_RAD + player);
			widgDelete(psWScreen, MULTIMENU_GIFT_RES + player);
			widgDelete(psWScreen, MULTIMENU_GIFT_DRO + player);
			widgDelete(psWScreen, MULTIMENU_GIFT_POW + player);
			giftsUp[player] = false;
		}
	}
}
示例#16
0
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);

}
void NavigationSubWidget::restoreSettings()
{
    if (!m_navigationWidget || !factory())
        return;
    factory()->restoreSettings(position(), m_navigationWidget);
}
示例#18
0
bool RenderProgress::isDeterminate() const
{
    return (HTMLProgressElement::IndeterminatePosition != position()
            && HTMLProgressElement::InvalidPosition != position());
}
示例#19
0
void LCD_Display::selectLineTwo(){  //puts the cursor at line 2 char 0.
   position(2,0);    //position
}
示例#20
0
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();
}
示例#21
0
 void Shield::update(const sf::Time& dt) {
     publish(ShieldMessage(position(), health()));
 }
示例#22
0
void Scene_c3t3_item::draw(CGAL::Three::Viewer_interface* viewer) const {
  Scene_c3t3_item* ncthis = const_cast<Scene_c3t3_item*>(this);

  if (!are_buffers_filled)
  {
    ncthis->compute_elements();
    ncthis->initialize_buffers(viewer);
  }

  vaos[Grid]->bind();
  program = getShaderProgram(PROGRAM_WITHOUT_LIGHT);
  attrib_buffers(viewer, PROGRAM_WITHOUT_LIGHT);
  program->bind();
  program->setAttributeValue("colors", QColor(Qt::black));
  QMatrix4x4 f_mat;
  for (int i = 0; i<16; i++)
    f_mat.data()[i] = frame->matrix()[i];
  program->setUniformValue("f_matrix", f_mat);
  viewer->glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(positions_grid.size() / 3));
  program->release();
  vaos[Grid]->release();

  vaos[Facets]->bind();
  program = getShaderProgram(PROGRAM_C3T3);
  attrib_buffers(viewer, PROGRAM_C3T3);
  program->bind();
  QVector4D cp(this->plane().a(),this->plane().b(),this->plane().c(),this->plane().d());
  program->setUniformValue("cutplane", cp);
  // positions_poly_size is the number of total facets in the C3T3
  // it is only computed once and positions_poly is emptied at the end
  viewer->glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(positions_poly_size / 3));
  program->release();
  vaos[Facets]->release();


  if(!frame->isManipulated()) {
    if (!are_intersection_buffers_filled)
    {
      ncthis->compute_intersections();
      ncthis->initialize_intersection_buffers(viewer);
    }
    vaos[iFacets]->bind();
    program = getShaderProgram(PROGRAM_WITH_LIGHT);
    attrib_buffers(viewer, PROGRAM_WITH_LIGHT);
    program->bind();

    // positions_poly is also used for the faces in the cut plane
    // and changes when the cut plane is moved
    viewer->glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(positions_poly.size() / 3));
    program->release();
    vaos[iFacets]->release();
  }

  if(spheres_are_shown)
  {
    vaos[Spheres]->bind();
    program_sphere->bind();
    //ModelViewMatrix used for the transformation of the camera.
    QMatrix4x4 mvp_mat;
    // ModelView Matrix used for the lighting system
    QMatrix4x4 mv_mat;
    GLdouble d_mat[16];
    GLint is_both_sides = 0;
    viewer->camera()->getModelViewProjectionMatrix(d_mat);
    //Convert the GLdoubles matrices in GLfloats
    for (int i=0; i<16; ++i){
      mvp_mat.data()[i] = GLfloat(d_mat[i]);
    }
    viewer->camera()->getModelViewMatrix(d_mat);
    for (int i=0; i<16; ++i)
      mv_mat.data()[i] = GLfloat(d_mat[i]);
    QVector4D position(0.0f,0.0f,1.0f, 1.0f );
    QVector4D ambient(0.4f, 0.4f, 0.4f, 0.4f);
    // Diffuse
    QVector4D diffuse(1.0f, 1.0f, 1.0f, 1.0f);
    // Specular
    QVector4D specular(0.0f, 0.0f, 0.0f, 1.0f);
    viewer->glGetIntegerv(GL_LIGHT_MODEL_TWO_SIDE, &is_both_sides);

    QVector4D cp(this->plane().a(),this->plane().b(),this->plane().c(),this->plane().d());

    program_sphere->setUniformValue("cutplane", cp);
    program_sphere->setUniformValue("mvp_matrix", mvp_mat);
    program_sphere->setUniformValue("mv_matrix", mv_mat);
    program_sphere->setUniformValue("light_pos", position);
    program_sphere->setUniformValue("light_diff",diffuse);
    program_sphere->setUniformValue("light_spec", specular);
    program_sphere->setUniformValue("light_amb", ambient);
    program_sphere->setUniformValue("spec_power", 51.8f);
    program_sphere->setUniformValue("is_two_side", is_both_sides);

    viewer->glDrawArraysInstanced(GL_TRIANGLES, 0,
                                  static_cast<GLsizei>(s_vertex.size()/3),
                                  static_cast<GLsizei>(s_radius.size()));
    program_sphere->release();
    vaos[Spheres]->release();
  }
}
示例#23
0
position operator-(const position &a)
{
  return position(-a.x, -a.y);
}
示例#24
0
void Scene_c3t3_item::draw_edges(CGAL::Three::Viewer_interface* viewer) const {
  if(renderingMode() == FlatPlusEdges)
  {
    GLint renderMode;
    glGetIntegerv(GL_RENDER_MODE, &renderMode);
    if(renderMode == GL_SELECT) return;
  }
  Scene_c3t3_item* ncthis = const_cast<Scene_c3t3_item*>(this);
  if (!are_buffers_filled)
  {
    ncthis->compute_elements();
    ncthis->initialize_buffers(viewer);
  }

  if(renderingMode() == Wireframe)
  {
    vaos[Grid]->bind();
    program = getShaderProgram(PROGRAM_WITHOUT_LIGHT);
    attrib_buffers(viewer, PROGRAM_WITHOUT_LIGHT);
    program->bind();
    program->setAttributeValue("colors", QColor(Qt::black));
    QMatrix4x4 f_mat;
    for (int i = 0; i<16; i++)
        f_mat.data()[i] = frame->matrix()[i];
    program->setUniformValue("f_matrix", f_mat);
    viewer->glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(positions_grid.size() / 3));
    program->release();
    vaos[Grid]->release();
  }
  vaos[Edges]->bind();
  program = getShaderProgram(PROGRAM_C3T3_EDGES);
  attrib_buffers(viewer, PROGRAM_C3T3_EDGES);
  program->bind();
  QVector4D cp(this->plane().a(),this->plane().b(),this->plane().c(),this->plane().d());
  program->setUniformValue("cutplane", cp);
  program->setAttributeValue("colors", QColor(Qt::black));
  viewer->glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(positions_lines_size / 3));
  program->release();
  vaos[Edges]->release();

  if(!frame->isManipulated()) {
    if (!are_intersection_buffers_filled)
    {
      ncthis->compute_intersections();
      ncthis->initialize_intersection_buffers(viewer);
    }
    vaos[iEdges]->bind();
    program = getShaderProgram(PROGRAM_NO_SELECTION);
    attrib_buffers(viewer, PROGRAM_NO_SELECTION);
    program->bind();
    program->setAttributeValue("colors", QColor(Qt::black));
    viewer->glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(positions_lines.size() / 3));
    program->release();
    vaos[iEdges]->release();
  }

  if(spheres_are_shown)
  {
      vaos[Wired_spheres]->bind();
      program_sphere->bind();
      //ModelViewMatrix used for the transformation of the camera.
      QMatrix4x4 mvp_mat;
      // ModelView Matrix used for the lighting system
      QMatrix4x4 mv_mat;
      GLdouble d_mat[16];
      GLint is_both_sides = 0;
      viewer->camera()->getModelViewProjectionMatrix(d_mat);
      //Convert the GLdoubles matrices in GLfloats
      for (int i=0; i<16; ++i){
          mvp_mat.data()[i] = GLfloat(d_mat[i]);
      }
      viewer->camera()->getModelViewMatrix(d_mat);
      for (int i=0; i<16; ++i)
          mv_mat.data()[i] = GLfloat(d_mat[i]);
      QVector4D position(0.0f,0.0f,1.0f, 1.0f );
      QVector4D ambient(0.4f, 0.4f, 0.4f, 0.4f);
      // Diffuse
      QVector4D diffuse(1.0f, 1.0f, 1.0f, 1.0f);
      // Specular
      QVector4D specular(0.0f, 0.0f, 0.0f, 1.0f);
      viewer->glGetIntegerv(GL_LIGHT_MODEL_TWO_SIDE, &is_both_sides);


      program_sphere->setUniformValue("mvp_matrix", mvp_mat);
      program_sphere->setUniformValue("mv_matrix", mv_mat);
      program_sphere->setUniformValue("light_pos", position);
      program_sphere->setUniformValue("light_diff",diffuse);
      program_sphere->setUniformValue("light_spec", specular);
      program_sphere->setUniformValue("light_amb", ambient);
      program_sphere->setUniformValue("spec_power", 51.8f);
      program_sphere->setUniformValue("is_two_side", is_both_sides);

      viewer->glDrawArraysInstanced(GL_TRIANGLES, 0,
                                    static_cast<GLsizei>(ws_vertex.size()/3),
                                    static_cast<GLsizei>(s_radius.size()));
      program_sphere->release();
      vaos[Wired_spheres]->release();
  }
}
示例#25
0
position operator-(const position &a, const position &b)
{
  return position(a.x - b.x, a.y - b.y);
}
示例#26
0
void Player::atirar(Portal* portal)
{
    portal->visible(true);
    portal->position() = position();
    portal->velocity() = (Mouse::ray() * 300);
}
示例#27
0
position operator*(const position &a, double n)
{
  return position(a.x*n, a.y*n);
}
/*! 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
  // for stdout and stderr
  FILE *qhfp = fopen("logfile","w");

  if (!qhfp) {
	fprintf(stderr,"Could not open qhull logfile!\n");
	qh_init_A(NULL, stdout, stderr, 0, NULL);
  }
  else
   qh_init_A(NULL, qhfp, qhfp, 0, NULL);

  if ((exitcode = setjmp(qh errexit))) {
    delete [] array;
	qh NOerrexit= True;
	qh_freeqhull(!qh_ALL);
	qh_memfreeshort (&curlong, &totlong);
	if (curlong || totlong)  	/* optional */
	   fprintf (stderr, "qhull internal warning (main): did not free %d bytes of long memory (%d pieces)\n",
		 totlong, curlong);
    for (i=0;i<validPlanes;i++)
      free(planes[i]);
    free(planes);
	if (qhfp) fclose(qhfp);
	DBGP("Qhull forces the exit; probably no valid intersection");
    return FAILURE; //exit(exitcode);
  }
  sprintf(options, "qhull -H0,0,0 Pp");
  qh_initflags(options);
  qh_setfeasible(3);
  if (!(qh feasible_point)) printf("why is qh_qh NULL?\n");
  for(i=0;i<validPlanes;i++) {
    qh_sethalfspace (3, p, &p, planes[i],&(planes[i][3]), qh feasible_point);
  }

  qh_init_B(&array[0], validPlanes, 3, ismalloc);
  qh_qhull();
  qh_check_output();
  if (qhfp) fclose(qhfp);

  //
  // Collect the vertices of the volume
  //
  hullCoords.clear();
  numCoords = qh num_facets;
  hullCoords.reserve(numCoords);
  int *indices = new int[numCoords];

  double scale = grasp->getMaxRadius(); // Hmm, is this right?

  point= (pointT*)qh_memalloc (qh normal_size);

  FORALLfacets {
    coordp = point;
	if (facet->offset > 0)
      goto LABELprintinfinite;
	
    normp= facet->normal;
    feasiblep= qh feasible_point;
    if (facet->offset < -qh MINdenom) {
      for (k= qh hull_dim; k--; )
        *(coordp++)= (*(normp++) / - facet->offset) + *(feasiblep++);
    }else {
      for (k= qh hull_dim; k--; ) {
        *(coordp++)= qh_divzero (*(normp++), facet->offset, qh MINdenom_1,&zerodiv) + *(feasiblep++);
        if (zerodiv) {
          goto LABELprintinfinite;
        }
      }
    }    
    hullCoords.push_back(position(point[0]*scale,point[1]*scale,
				  point[2]*scale));
    continue;
    LABELprintinfinite:
    hullCoords.push_back(position(qh_INFINITE,qh_INFINITE,qh_INFINITE));
    fprintf(stderr,"intersection at infinity!\n");
  }
  qh_memfree (point, qh normal_size);


  //
  // use adjacency information to build faces of the volume
  //
  double dot;
  vec3 testNormal, refNormal;

  int numfacets, numsimplicial, numridges, totneighbors, numneighbors, numcoplanars;
  setT *vertices, *vertex_points, *coplanar_points;
  int numpoints= qh num_points + qh_setsize (qh other_points);
  int vertex_i, vertex_n;
  facetT *neighbor, **neighborp;
  int unused_numnumtricoplanarsp; //added because countfacets takes more arguments in qhull 2012
								  //FIXME - understand what this argument does. 
  qh_countfacets (qh facet_list, NULL, !qh_ALL, &numfacets, &numsimplicial, 
      &totneighbors, &numridges, &numcoplanars, &unused_numnumtricoplanarsp);  /* sets facet->visitid */

  qh_vertexneighbors();
  vertices= qh_facetvertices (qh facet_list, NULL, !qh_ALL);
  vertex_points= qh_settemp (numpoints);
  coplanar_points= qh_settemp (numpoints);
  qh_setzero (vertex_points, 0, numpoints);
  qh_setzero (coplanar_points, 0, numpoints);
  FOREACHvertex_(vertices)
    qh_point_add (vertex_points, vertex->point, vertex);
  FORALLfacet_(qh facet_list) {
    FOREACHpoint_(facet->coplanarset)
      qh_point_add (coplanar_points, point, facet);
  }
示例#29
0
 position north() { return position(cent.x, cent.y + dim.y/2.0); }
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 );
}