当前位置: 首页>>代码示例>>C++>>正文


C++ Vec2f函数代码示例

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


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

示例1: Col3f

void myApp02::init() {

	globalAmbient = Col3f(1, .1, .1);
	shadowsOn();
	// wall
	plane = GroundPlane(Vec3(), Vec3(), Dim2f(8, 7), Col4f(1, 1, 0, 1), 1, 1, "orange.jpg");
	//Plane.textureOn();
	plane.setBumpMap("white_tile.jpg");
	plane.setTextureScale(Vec2f(.5));
	//Plane.setAmbientMaterial(Col4f(.02, .02, .02, 1.0));
	plane.setSpecularMaterial(Col4f(.1, .1, .1, 1.0));
	plane.setShininess(100);


	//tube = ProtoTube();

	float radius = .107;
	Vec3f v(0, 0, 0);

	int segments = 5; // 60;
	v = Vec3f(0, 0, 0);
	Vec3f spd(0, 0, 0);

	//cps.push_back(v);
	float turbulence = .1f;
	Dim3f size(4.25, 4.25, 4.25);


	float startY = -.5;

	int ribCount = 13;// 17;
	float ribSpan = 4.5;
	float ribRadius = 0;
	float ribRadiusMax = 2.0;
	float ribTheta = 0;

	float ribGap = ribSpan / ribCount;

	for (int i = 0; i < ribCount; ++i){

		float theta = 0, weaveTheta = 0;
		std::vector <Vec3> cps;
		Spline3 spline;
		ribRadius = fabs(sin(ribTheta) * ribRadiusMax);
		for (int j = 0; j < segments; ++j){
			//spd = Vec3(random(-turbulence*.1, turbulence*.1), 0, random(-turbulence*.1, turbulence*.1));
			//v = spd + Vec3f(sin(theta)*2+random(-turbulence, turbulence), startY+=.1, cos(theta)*2+random(-turbulence, turbulence));
			//cps.push_back(Vec3(v.x, v.y, v.z));
			cps.push_back(Vec3(sin(theta) * ribRadius, -ribSpan / 2 + ribGap*i + sin(weaveTheta) * .15, cos(theta) * ribRadius));
			theta += TWO_PI / segments;
			//weaveTheta += j*j*j*.125 * PI / 180;
			weaveTheta += TWO_PI / segments * (ribRadius * 4);
		}
		//trace("ribradius = ", ribRadius*4);
		ribTheta += PI / ribCount;

		//spline = Spline3(cps, 4, false, .5);
		spline = Spline3(cps, 5, false, .5);

		TransformFunction t1 = TransformFunction(TransformFunction::SINUSOIDAL, Tup2f(.02, .95 + (ribRadius*random(.07, .31))), 1/*int(random(1, 3))*/);

		ribs.push_back(ProtoTube(Vec3f(), Vec3f(), Dim3f(1), Col4f(1), spline, .09, 12, t1, true, "pitted.jpg", Vec2f(1, random(.0825, .2))));
		ribs.at(i).setIsClosed(0);
		ribs.at(i).setSpecularMaterial(Col4f(.4, .275, .1, 1));
		ribs.at(i).setShininess(6);
		ribs.at(i).setBumpMap("pitted.jpg");

		// rib tendrils
		std::vector <Vec3> ribCps;
		for (int j = 0; j < ribs.at(i).getFrenetFrameLength(); j += int(random(1, 3))){
			for (int k = 0; k < ribs.at(i).getCrossSectionDetail(); k += int(random(1, 3))){
				ribCps.push_back(ribs.at(i).getVertices().at(j*ribs.at(i).getCrossSectionDetail() + k).pos);
			}
		}

		Spline3 ribSpline = Spline3(ribCps, 3, false, .5);
		TransformFunction ribT = TransformFunction(TransformFunction::SINUSOIDAL, Tup2f(random(.05, .1), random(.1, .2)), int(random(1, 12)));
		ribBands.push_back(ProtoTube(Vec3f(), Vec3f(), Dim3f(1), Col4f(1), ribSpline, .09, 12, ribT, true, "vascular.jpg", Vec2f(1, random(.0825, .2))));
		ribBands.at(i).setIsClosed(0);
		ribBands.at(i).setSpecularMaterial(Col4f(.4, .275, .1, 1));
		ribBands.at(i).setShininess(6);
		ribBands.at(i).setBumpMap("vascular.jpg");
	}

	
	//yRot = xRot = 0;
	//xRotLast = yRotLast = 0;
	//mouseXIn = mouseYIn = 0;

}
开发者ID:irajgreenberg,项目名称:Protobyte_0.1.1_quark,代码行数:90,代码来源:myApp02+(SMU114357's+conflicted+copy+2014-08-12).cpp

示例2: Vec2f

void Oscillator::update()
{
    angle += velocity;
    display = Vec2f( sin( angle.x ) * amplitude.x, sin( angle.y ) * amplitude.y );
}
开发者ID:ilzxc,项目名称:The-Nature-of-Cinder,代码行数:5,代码来源:Oscillator.cpp

示例3: Q_ASSERT_X


//.........这里部分代码省略.........
		// Both X and Y need to be at least 1 so we don't create an empty image 
		// (doesn't work with textures)
		const int requiredWidth  = std::max(1, extents.width() + 1 + static_cast<int>(0.02f * extents.width()));
		const int requiredHeight = std::max(1, extents.height());
		// Create temporary image and render text into it

		// QImage is used solely to reuse existing QGLTextureBackend constructor 
		// function. QPixmap could be used as well (not sure which is faster, 
		// needs profiling)
		QImage image = areNonPowerOfTwoTexturesSupported() 
		             ? QImage(requiredWidth, requiredHeight, QImage::Format_ARGB32_Premultiplied) 
		             : QImage(StelUtils::smallestPowerOfTwoGreaterOrEqualTo(requiredWidth), 
		                      StelUtils::smallestPowerOfTwoGreaterOrEqualTo(requiredHeight),
		                      QImage::Format_ARGB32);
		image.fill(Qt::transparent);

		QPainter fontPainter(&image);
		fontPainter.setFont(painter->font());
		fontPainter.setRenderHints(QPainter::TextAntialiasing, true);
		fontPainter.setPen(Qt::white);

		// The second argument ensures the text is positioned correctly even if 
		// the image is enlarged to power-of-two.
		fontPainter.drawText(-extents.x(), 
		                     image.height() - requiredHeight - extents.y(), 
		                     params.string_);

		textTexture = StelQGLTextureBackend::constructFromImage
			(this, QString(), TextureParams().filtering(TextureFiltering_Linear), image);
		const QSize size = textTexture->getDimensions();
		if(!textTexture->getStatus() == TextureStatus_Loaded)
		{
			qWarning() << "Texture error: " << textTexture->getErrorMessage();
			Q_ASSERT_X(false, Q_FUNC_INFO, "Failed to construct a text texture");
		}
		textTextureCache.insert(hash, textTexture, 4 * size.width() * size.height());
	}

	// Even if NPOT textures are not supported, we always draw the full rectangle 
	// of the texture. The extra space is fully transparent, so it's not an issue.

	// Shortcut variables to calculate the rectangle.
	const QSize size   = textTexture->getDimensions();
	const float w      = size.width();
	const float h      = size.height();
	const float xShift = params.xShift_;
	const float yShift = params.yShift_;

	const float angleDegrees = 
		params.angleDegrees_ + 
		(params.noGravity_ ? 0.0f : projector->getDefaultAngleForGravityText());
	// Zero out very small angles.
	// 
	// (this could also be used to optimize the case with zero angled
	//  to avoid sin/cos if needed)
	const bool  angled = std::fabs(angleDegrees) >= 1.0f * M_PI / 180.f;
	const float cosr   = angled  ? std::cos(angleDegrees * M_PI / 180.0) : 1.0f;
	const float sinr   = angled  ? std::sin(angleDegrees * M_PI / 180.0) : 0.0f;

	// Corners of the (possibly rotated) texture rectangle.
	const Vec2f ne(round(x + cosr * xShift       - sinr * yShift),
	               round(y + sinr * xShift       + cosr * yShift));
	const Vec2f nw(round(x + cosr * (w + xShift) - sinr * yShift),
	               round(y + sinr * (w + xShift) + cosr * yShift));
	const Vec2f se(round(x + cosr * xShift       - sinr * (h + yShift)),
	               round(y + sinr * xShift       + cosr * (h + yShift)));
	const Vec2f sw(round(x + cosr * (w + xShift) - sinr * (h + yShift)),
	               round(y + sinr * (w + xShift) + cosr * (h + yShift)));

	// Construct the text vertex buffer if it doesn't exist yet, otherwise clear it.
	if(NULL == textBuffer)
	{
		textBuffer = createVertexBuffer<TexturedVertex>(PrimitiveType_TriangleStrip);
	}
	else
	{
		textBuffer->unlock();
		textBuffer->clear();
	}

	textBuffer->addVertex(TexturedVertex(ne, Vec2f(0.0f, 0.0f)));
	textBuffer->addVertex(TexturedVertex(nw, Vec2f(1.0f, 0.0f)));
	textBuffer->addVertex(TexturedVertex(se, Vec2f(0.0f, 1.0f)));
	textBuffer->addVertex(TexturedVertex(sw, Vec2f(1.0f, 1.0f)));
	textBuffer->lock();

	// Draw.
	const BlendMode oldBlendMode = blendMode;
	setBlendMode(BlendMode_Alpha);
	textTexture->bind(0);
	drawVertexBuffer(textBuffer);
	setBlendMode(oldBlendMode);

	// Reset user-bound texture.
	if(NULL != currentTexture)
	{
		currentTexture->bind(0);
	}
	viewport.disablePainting();
}
开发者ID:meetshah1995,项目名称:stellarium-finger,代码行数:101,代码来源:StelQGLRenderer.cpp

示例4: LoadLevelScreen

void LoadLevelScreen(long num) {
	
	// resets status
	if(num < -1) {
		delete tc, tc = NULL;
		lastloadednum = -1;
		lastnum = -1;
		PROGRESS_BAR_TOTAL = 0;
		return;
	}
	
	if(num == -1) {
		num = lastnum;
	}
	lastnum = num;
	
	if(num < 0) {
		return;
	}
	
	static u32 last_progress_bar_update = Time::getMs();
	
	// only update if time since last update to progress bar > 16ms
	// and progress bar's value has actually changed
	if (Time::getElapsedMs(last_progress_bar_update) > 16 &&
		 OLD_PROGRESS_BAR_COUNT != PROGRESS_BAR_COUNT)
	{
		GRenderer->GetTextureStage(0)->setMinFilter(TextureStage::FilterLinear);
		GRenderer->GetTextureStage(0)->setMagFilter(TextureStage::FilterLinear);

		float ratio = (PROGRESS_BAR_TOTAL > 0.f ? PROGRESS_BAR_COUNT / PROGRESS_BAR_TOTAL : 0); 

		ratio = glm::clamp(ratio, 0.f, 1.f);

		GRenderer->Clear(Renderer::ColorBuffer | Renderer::DepthBuffer);
		
		GRenderer->SetRenderState(Renderer::DepthTest, true);
		GRenderer->SetCulling(Renderer::CullNone);
		GRenderer->SetRenderState(Renderer::DepthWrite, true);
		GRenderer->SetRenderState(Renderer::Fog, false);
		GRenderer->SetRenderState(Renderer::AlphaBlending, false);
		
		if (num == 10) {
			pbar = TextureContainer::LoadUI("graph/interface/menus/load_full");
		} else {
			pbar = TextureContainer::LoadUI("graph/interface/menus/load_full_level");
		}
		
		nopbar = 1;
		
		if(num != lastloadednum) {
			delete tc, tc = NULL;
			lastloadednum = num;
			char temp[256];
			char tx[256];
			GetLevelNameByNum(num, tx);
			sprintf(temp, "graph/levels/level%s/loading", tx);
			tc = TextureContainer::LoadUI(temp, TextureContainer::NoColorKey);
		}
		
		float scale = minSizeRatio();
		
		if(tc) {
			GRenderer->SetRenderState(Renderer::ColorKey, false);
			
			Vec2f size = (num == 10) ? Vec2f(640, 480) : Vec2f(320, 390);
			size *= scale;
			EERIEDrawBitmap2(g_size.center().x - size.x * 0.5f, g_size.center().y - size.y * 0.5f,
												size.x, size.y, 0.001f, tc, Color::white);
			
			GRenderer->SetRenderState(Renderer::ColorKey, true);
		}
		
		if(pbar) {
			float px = g_size.center().x - 100 * scale;
			float py = g_size.center().y + ((num == 10) ? 221 : 35) * scale;
			float px2 = ratio * 200 * scale;
			float py2 = 8 * scale;
			EERIEDrawBitmap_uv(px, py, px2, py2, 0.f, pbar, Color::white, 0.f, 0.f, ratio, 1.f);
		}
		
		mainApp->getWindow()->showFrame();
		
		OLD_PROGRESS_BAR_COUNT = PROGRESS_BAR_COUNT;
		last_progress_bar_update = Time::getMs();
	}
}
开发者ID:zhaozw,项目名称:ArxLibertatis,代码行数:87,代码来源:LoadLevelScreen.cpp

示例5: Vec2f

Vec2f JitteredSampler::getSamplePosition(int n) {
	// YOUR CODE HERE (R9)
	// Return a randomly generated sample through Nth subpixel.
	return Vec2f(0,0);
}
开发者ID:cerendikmen,项目名称:CG-Assignment-5,代码行数:5,代码来源:Sampler.cpp

示例6: GravityCalculation

Vec2f GravityCalculation(Vec2f move)
{
  return Vec2f(move.x(), move.y() - GR);
}
开发者ID:ryo0306,项目名称:Hikusyon,代码行数:4,代码来源:Gravity.cpp

示例7: Vec2f

Vec2f Component::getContentRequestedSize(void) const
{
    return Vec2f(0.0,0.0);
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:4,代码来源:OSGComponent.cpp

示例8: Vec2f

void Entity::setPos(float x, float y) {
    pos = Vec2f(x, y);
    body->SetTransform(b2Vec2(x, y), body->GetAngle());
}
开发者ID:GameOrganization,项目名称:Potart,代码行数:4,代码来源:Entity.cpp

示例9: Vec2f

void StateMap::setupLvDisplay() {
    // Create display element
    m_lvInfo = UIElement::create( "MapLevelInfo" );
    // Register the display in UI manager
    UI_MANAGER.addElement( m_lvInfo );

    const Vec2f displaySize  = Vec2f( 600, 380 );
    const Vec2i windowCenter = Game::getWindowCenter();

    // Set size and position
    m_lvInfo->setSize( displaySize );
    m_lvInfo->setCenter( windowCenter );

    // Hide the display by default
    m_lvInfo->setActive( false );
    m_lvInfo->setVisible( false );

    /** Sprites */
    {
        // Create sprite for display background
        Sprite* bgSprite = new Sprite();
        bgSprite->setName( "MapLevelInfoSprite" );
        bgSprite->setSprite( "window_map_levelinfo" );

        // Create sprite for level display
        Sprite* levelSprite = new Sprite();
        levelSprite->setName( "MapLevelInfoLevelSprite" );
        levelSprite->setScale( 0.25, 0.25 );
        levelSprite->setPos( 45, 92 );

        // Add sprites to the display
        m_lvInfo->addChild( bgSprite );
        m_lvInfo->addChild( levelSprite, 1 );
    }

    /** Level name */
    {
        Text* name = new Text();
        name->setName( "MapLevelName" );
        name->setFont( "" );
        name->setCharSize( 18 );
        name->setColor( sf::Color::Yellow );
        name->setAlign( Text::Align_Center );
        name->setPos( displaySize.x / 2, 20 );

        m_lvInfo->addChild( name, 1 );
    }

    /** Buttons */
    {
        const Vec2f buttonSize  = Vec2f( 130, 25 );
        const int   offset      = 20;

        UIButton* play = UIButton::create( "MapButtonPlay", "button_dev" );
        play->setSize( buttonSize );
        play->setPos( offset, displaySize.y - buttonSize.y - offset );
        play->setButtonCallback( UIButton::Clicked, DOS_FUNC_BIND_1( &StateMap::cbLevelPlay, this ) );

        UIButton* cancel = UIButton::create( "MapButtonCancel", "button_dev" );
        cancel->setSize( buttonSize );
        cancel->setPos(
                      displaySize.x - buttonSize.x - offset,
                      displaySize.y - buttonSize.y - offset
                    );
        cancel->setButtonCallback( UIButton::Clicked, DOS_FUNC_BIND_1( &StateMap::cbLevelCancel, this ) );

        m_lvInfo->addChild( play, 1 );
        m_lvInfo->addChild( cancel, 1 );
    }
}
开发者ID:Smeky,项目名称:TestTD,代码行数:70,代码来源:StateMap.cpp

示例10: main

int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    /******************************************************

             Add MouseListeners and WindowListeners
             to the WindowEvent.

    ******************************************************/

    TutorialMouseListener TheTutorialMouseListener;
    TutorialMouseListener1 BasicListener;
    TutorialMouseMotionListener TheTutorialMouseMotionListener;
    TutorialWindow->addMouseListener(&TheTutorialMouseListener);
    TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);

    // Make Torus Node (creates Torus in background of scene)
    NodeRefPtr TorusGeometryNode = makeTorus(90, 270, 16, 16);

    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(TorusGeometryNode);

    // Create the Graphics
    GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();

    // Initialize the LookAndFeelManager to enable default settings
    LookAndFeelManager::the()->getLookAndFeel()->init();


    LoadButton = Button::create();

    LoadButton->setMinSize(Vec2f(50, 25));
    LoadButton->setMaxSize(Vec2f(200, 100));
    LoadButton->setPreferredSize(Vec2f(100, 50));
    LoadButton->setToolTipText("Click to open a file browser window");
    LoadButton->setText("Load File");

    LoadButton->addActionListener(&BasicListener);

    SaveButton = Button::create();

    SaveButton->setMinSize(Vec2f(50, 25));
    SaveButton->setMaxSize(Vec2f(200, 100));
    SaveButton->setPreferredSize(Vec2f(100, 50));
    SaveButton->setToolTipText("Click to save the currently opened file");
    SaveButton->setText("Save File");

    SaveButton->addActionListener(&BasicListener);

    theTextEditor = TextEditor::create();
    theTextEditor->setPreferredSize(Vec2f(600,400));

    /*

    UIFontRefPtr _Font = UIFont::create();
    _Font->setFamily("SANS");
    _Font->setGap(3);
    _Font->setGlyphPixelSize(46);
    _Font->setSize(15);
    _Font->setTextureWidth(0);
    _Font->setStyle(TextFace::STYLE_PLAIN);

    ExampleTextDomArea->setPreferredSize(Vec2f(600, 400));
    ExampleTextDomArea->setWrapStyleWord(false);
    ExampleTextDomArea->setMinSize(Vec2f(600,400));
    ExampleTextDomArea->setFont(_Font);

    ExampleAdvancedTextDomArea = OSG::AdvancedTextDomArea::create();
    ExampleAdvancedTextDomArea->setPreferredSize(Vec2f(600,400));
    ExampleAdvancedTextDomArea->setMinSize(Vec2f(600,400));
    ExampleAdvancedTextDomArea->setGutterVisible(true);
    ExampleAdvancedTextDomArea->pushToChildren(ExampleTextDomArea);
    ExampleAdvancedTextDomArea->setLayout(LayoutRefPtr(OSG::FlowLayout::create()));
    ExampleAdvancedTextDomArea->setPreferredSize(Vec2f(600,400));
    ExampleAdvancedTextDomArea->setMinSize(Vec2f(600,400));

    ScrollPanelRefPtr TextAreaScrollPanel = ScrollPanel::create();
    TextAreaScrollPanel->setPreferredSize(Vec2f(600,400));
    TextAreaScrollPanel->setMinSize(Vec2f(600,400));
    TextAreaScrollPanel->setViewComponent(ExampleAdvancedTextDomArea);

    */

    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
    MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

    LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
//.........这里部分代码省略.........
开发者ID:pjcamp,项目名称:OpenSGToolbox,代码行数:101,代码来源:07UIRectTextDomArea.cpp

示例11: main

int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    {
        // Set up Window
        WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
        TutorialWindow->initWindow();

        // Create the SimpleSceneManager helper
        SimpleSceneManager sceneManager;
        TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);

        //Attach to events
        TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
        TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
        TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
        TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));

        //Particle System Material
        PointChunkRefPtr PSPointChunk = PointChunk::create();
        PSPointChunk->setSize(5.0f);
        PSPointChunk->setSmooth(true);

        BlendChunkRefPtr PSBlendChunk = BlendChunk::create();
        PSBlendChunk->setSrcFactor(GL_SRC_ALPHA);
        PSBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);

        MaterialChunkRefPtr PSMaterialChunkChunk = MaterialChunk::create();
        PSMaterialChunkChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
        PSMaterialChunkChunk->setDiffuse(Color4f(0.7f,0.7f,0.7f,1.0f));
        PSMaterialChunkChunk->setSpecular(Color4f(0.9f,0.9f,0.9f,1.0f));
        PSMaterialChunkChunk->setColorMaterial(GL_NONE);

        ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
        PSMaterial->addChunk(PSPointChunk);
        PSMaterial->addChunk(PSMaterialChunkChunk);
        PSMaterial->addChunk(PSBlendChunk);

        //Particle System
        ParticleSystemRefPtr ExampleParticleSystem = ParticleSystem::create();
        ExampleParticleSystem->addParticle(Pnt3f(0,25,0),
                                           Vec3f(0.0,0.0f,1.0f),
                                           Color4f(1.0,1.0,1.0,1.0), 
                                           Vec3f(1.0,1.0,1.0), 
                                           0.1, 
                                           Vec3f(0.0f,0.0f,0.0f), //Velocity
                                           Vec3f(0.0f,0.0f,0.0f)
                                          );
        ExampleParticleSystem->addParticle(Pnt3f(0,-25,0),
                                           Vec3f(0.0,0.0f,1.0f),
                                           Color4f(1.0,1.0,1.0,1.0), 
                                           Vec3f(1.0,1.0,1.0), 
                                           0.1, 
                                           Vec3f(0.0f,0.0f,0.0f), //Velocity
                                           Vec3f(0.0f,0.0f,0.0f)
                                          );
        ExampleParticleSystem->attachUpdateProducer(TutorialWindow);

        //Particle System Drawer (Point)
        PointParticleSystemDrawerRecPtr ExamplePointParticleSystemDrawer = PointParticleSystemDrawer::create();

        //Particle System Drawer (line)
        LineParticleSystemDrawerRecPtr ExampleLineParticleSystemDrawer = LineParticleSystemDrawer::create();
        ExampleLineParticleSystemDrawer->setLineDirectionSource(LineParticleSystemDrawer::DIRECTION_VELOCITY);
        ExampleLineParticleSystemDrawer->setLineLengthSource(LineParticleSystemDrawer::LENGTH_SIZE_X);
        ExampleLineParticleSystemDrawer->setLineLength(2.0f);
        ExampleLineParticleSystemDrawer->setEndPointFading(Vec2f(0.0f,1.0f));

        //Create a Rate Particle Generator
        RateParticleGeneratorRefPtr ExampleGenerator = RateParticleGenerator::create();

        //Attach the function objects to the Generator
        ExampleGenerator->setPositionDistribution(createPositionDistribution());
        ExampleGenerator->setLifespanDistribution(createLifespanDistribution());
        ExampleGenerator->setGenerationRate(200);

        UniformParticleAffectorRecPtr ExampleUniformAffector = UniformParticleAffector::create();
        ExampleUniformAffector->setMagnitude(20.0); // force which the field exerts on particles (negative = towards the air field's beacon location)
        NodeRefPtr UniformBeacon = Node::create();
        ExampleUniformAffector->setBeacon(UniformBeacon); // set to 'emulate' from (0,0,0)
        ExampleUniformAffector->setDirection(Vec3f(1.0,0.0,0.0)); // direction which field is exerted
        ExampleUniformAffector->setMaxDistance(-1.0); // particles affected regardless of distance from
        ExampleUniformAffector->setAttenuation(0.0); // strength of uniform field dimishes by dist^attenuation, in this case it is constant regardless of distance
        ExampleUniformAffector->setParticleMass(10.0);



        //Attach the Generator and Affector to the Particle System
        ExampleParticleSystem->pushToGenerators(ExampleGenerator);
        ExampleParticleSystem->pushToAffectors(ExampleUniformAffector);
        ExampleParticleSystem->setMaxParticles(500);


        //Particle System Node
//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:101,代码来源:19UniformFieldParticleAffector.cpp

示例12: Inherited

SegmentDistribution1DBase::SegmentDistribution1DBase(void) :
    Inherited(),
    _sfSegment                (Vec2f(0.0,1.0))
{
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:5,代码来源:OSGSegmentDistribution1DBase.cpp

示例13: if

/** Liang-Barsky polygon clip.  [see Foley & Van Damn 19.1.3] */
void SceneCuller::clipVisibleQuad(vector<Vec2f> &in) {
	const float min_x = 0.f, min_y = 0.f;
	const float max_x = World::getCurrWorld()->getMap()->getW() - 2.01f;
	const float max_y = World::getCurrWorld()->getMap()->getH() - 2.01f;

	vector<Vec2f> &out = visiblePoly;

	float	xIn, yIn, xOut, yOut;
	float	tOut1, tIn2, tOut2;
	float	tInX, tOutX, tInY, tOutY;
	float	deltaX, deltaY;
	
	out.clear();

	for (unsigned i=0; i < in.size() - 1; ++i) {
		deltaX = in[i+1].x - in[i].x;
		deltaY = in[i+1].y - in[i].y;
		
		// find paramater values for x,y 'entry' points
		if (deltaX > 0 || (deltaX == 0.f && in[i].x > max_x)) {
			xIn = min_x; xOut = max_x;
		} else {
			xIn = max_x; xOut = min_x;
		}
		if (deltaY > 0 || (deltaY == 0.f && in[i].y > max_y)) {
			yIn = min_y; yOut = max_y;
		} else {
			yIn = max_y; yOut = min_y;
		}

		// find parameter values for x,y 'exit' points
		if (deltaX) {
			tOutX = (xOut - in[i].x) / deltaX;
		} else if (in[i].x <= max_x && min_x <= in[i].x ) {
			tOutX = numeric_limits<float>::infinity();
		} else {
			tOutX = -numeric_limits<float>::infinity();
		}
		if (deltaY) {
			tOutY = (yOut - in[i].y) / deltaY;
		} else if (in[i].y <= max_y && min_y <= in[i].y) {
			tOutY = numeric_limits<float>::infinity();
		} else {
			tOutY = -numeric_limits<float>::infinity();
		}
		
		if (tOutX < tOutY) {
			tOut1 = tOutX;  tOut2 = tOutY;
		} else {
			tOut1 = tOutY;  tOut2 = tOutX;
		}

		if (tOut2 > 0.f) {
			if (deltaX) {
				tInX = (xIn - in[i].x) / deltaX;
			} else {
				tInX = -numeric_limits<float>::infinity();
			}
			if (deltaY) {
				tInY = (yIn - in[i].y) / deltaY;
			} else {
				tInY = -numeric_limits<float>::infinity();
			}

			if (tInX < tInY) {
				tIn2 = tInY;
			} else {
				tIn2 = tInX;
			}

			if (tOut1 < tIn2) { // edge does not cross map
				if (0.f < tOut1 && tOut1 <= 1.f) {
					// but it does go across a corner segment, add corner...
					if (tInX < tInY) {
						out.push_back(Vec2f(xOut, yIn));
					} else {
						out.push_back(Vec2f(xIn, yOut));
					}
				}
			} else {
				if (0.f < tOut1 && tIn2 <= 1.f) {
					if (0.f < tIn2) { // edge enters map
						if (tInX > tInY) {
							out.push_back(Vec2f(xIn, in[i].y + tInX * deltaY));
						} else {
							out.push_back(Vec2f(in[i].x + tInY * deltaX, yIn));
						}
					}
					if (1.f > tOut1) { // edge exits map
						if (tOutX < tOutY) {
							out.push_back(Vec2f(xOut, in[i].y + tOutX * deltaY));
						} else {
							out.push_back(Vec2f(in[i].x + tOutY * deltaX, yOut));
						}
					} else {
						out.push_back(Vec2f(in[i+1].x, in[i+1].y));
					}
				}
			}
//.........这里部分代码省略.........
开发者ID:MoLAoS,项目名称:Mandate,代码行数:101,代码来源:scene_culler.cpp

示例14: RootBall

void ProtoRootBall02::init() {

	//170, 150
	// set Materials for composite objects - or setup as multiple inheritance/interface
	rootBallCore = RootBall(Vec3f(), Vec3f(), Dim3f(2.55f), Col4f(.9f), 1, 30, .2, Tup2f(.5, 2.25), "shipPlate_yellow.jpg", 8);
	TransformFunction t1 = TransformFunction(TransformFunction::SINUSOIDAL, Tup2f(.2f, .75f), 3); // local, so can't be sent as reference
	rootBallCore.setTransformFunction(t1);


	//rootBall = RootBall(Vec3f(), Vec3f(), Dim3f(1.345f), Col4f(.9f), 1, 40, .2, Tup2f(.2, 3), "vascular3.jpg", 1);
	TransformFunction t2 = TransformFunction(TransformFunction::SINUSOIDAL, Tup2f(.14f, .22f), 80); // local, so can't be sent as reference
	//rootBall.setTransformFunction(t2);
	//std::vector<Tup4v> vs = rootBall.getGeomData();

	// export geometry data to 
	//std::vector<Tup4v> vs;
	//std::vector<Tup4v> temp = rootBallCore.getGeomData();
	//vs.insert(vs.end(), temp.begin(), temp.end());
	//std::vector<Tup4v> temp2 = rootBall.getGeomData();
	//vs.insert(vs.end(), temp2.begin(), temp2.end());
	//export(vs, STL);

	// wall
	plane = GroundPlane(Vec3(), Vec3(), Dim2f(8, 7), Col4f(1, 1, 1, 1), 1, 1, "leather2.jpg");
	//plane.textureOn();
	plane.setBumpMap("leather2.jpg");
	//plane.loadBumpMapTexture("shipPlate_normal.jpg");
	plane.setTextureScale(Vec2f(.5));
	//plane.setAmbientMaterial(Col4f(.02, .02, .02, 1.0));
	plane.setSpecularMaterial(Col4f(1, .9, 1, 1.0));
	plane.setShininess(4);
	//trace("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS =", GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);

	// ground
	ground = GroundPlane(Vec3(), Vec3(), Dim2f(8, 7), Col4f(1, 1, 1, 1), 1, 1, "pink2.jpg");
	//plane.textureOn();
	ground.setBumpMap("pink2.jpg");
	//plane.loadBumpMapTexture("shipPlate_normal.jpg");
	ground.setTextureScale(Vec2f(.25));
	//plane.setAmbientMaterial(Col4f(.02, .02, .02, 1.0));
	ground.setSpecularMaterial(Col4f(1, 1, 1, 1.0));
	ground.setShininess(3);
	//trace("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS =", GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);


	std::string texs[] = { "pebbles.jpg", "gold_foil2.jpg", "vascular.jpg", "greenCrocSkin.jpg", "pink2.jpg", "metal_screwHeads.jpg", "woodPlank.jpg", "metal_blue.jpg", "shipPlate_yellow.jpg", "reptile2_invert.jpg", "corroded_metal.jpg", "giraffe.jpg", "shipPlate.jpg", "metal_grate.jpg" };

	for (int i = 0; i < W*H*D; ++i){
		int sub = int(random(14));
		toroids[i] = Toroid(Vec3f(), Vec3f(random(45), random(45), random(45)), Dim3f(3, 3, 3), Col4f(.5, .5, .5, 1), 12, 12, 3, 1.2, texs[sub]);
		toroids[i].setBumpMap(texs[sub]);
		//toroids[i].setBumpMap("grime.jpg");
		toroids[i].setDiffuseMaterial(Col4f(.65, .75, 1, 1.0));
		toroids[i].setSpecularMaterial(Col4f(1, 1, 1, 1.0));
		toroids[i].setTextureScale(Vec2f(random(.25, 8.5)));
		toroids[i].setShininess(int(random(15, 40)));
	}



}
开发者ID:irajgreenberg,项目名称:Protobyte_0.1.1_quark,代码行数:61,代码来源:ProtoRootBall02.cpp

示例15: Vec2f

void MapScreen::scroll(Vec2f new_cam_pos, Camera& cam)
{
	new_cam_pos = new_cam_pos + Vec2f(-16 - 8, -16 - 8);
	cam.position(Vec2f(round(new_cam_pos.x()), round(new_cam_pos.y())));
}
开发者ID:alesegdia,项目名称:thyknite,代码行数:5,代码来源:mapscreen.cpp


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