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


C++ ParticleSystem类代码示例

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


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

示例1: Update

bool EnemyShip::Update(const float& dt, bool& warp, ParticleSystem& Psystem, BulletSystem& Bsystem, Spaceship* target, Walls& walls)
{
	changeTarget(target);
	turret.update(dt, shipPosition, Bsystem, (rand.RandomFloat() < 0.1));
	outofBoundsCheck(Psystem, warp);
	changeVelocity(dt, Psystem);

	Vector2 collision = walls.getCollisionVelocity(shipPosition, velocity);

	if (Engine::LengthSquared(collision) != 0)
	{
		Psystem.AddParticle(new COLLISIONPARTICLE);
	}

	velocity = velocity + collision;
	shipPosition = shipPosition + velocity;
	return (life > 0);
}
开发者ID:pokelege,项目名称:GeometryWars,代码行数:18,代码来源:EnemyShip.cpp

示例2: CCASSERT

void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag)
{
    CCASSERT( aChild != NULL, "Argument must be non-NULL");
    CCASSERT( dynamic_cast<ParticleSystem*>(aChild) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children");
    ParticleSystem* child = static_cast<ParticleSystem*>(aChild);
    CCASSERT( child->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "CCParticleSystem is not using the same texture id");
    // If this is the 1st children, then copy blending function
    if( _children->count() == 0 ) 
    {
        setBlendFunc(child->getBlendFunc());
    }

    CCASSERT( _blendFunc.src  == child->getBlendFunc().src && _blendFunc.dst  == child->getBlendFunc().dst, "Can't add a PaticleSystem that uses a different blending function");

    //no lazy sorting, so don't call super addChild, call helper instead
    unsigned int pos = addChildHelper(child,zOrder,tag);

    //get new atlasIndex
    int atlasIndex = 0;

    if (pos != 0) 
    {
        ParticleSystem* p = (ParticleSystem*)_children->getObjectAtIndex(pos-1);
        atlasIndex = p->getAtlasIndex() + p->getTotalParticles();

    }
    else
    {
        atlasIndex = 0;
    }

    insertChild(child, atlasIndex);

    // update quad info
    child->setBatchNode(this);
}
开发者ID:CryQ,项目名称:coclua,代码行数:36,代码来源:CCParticleBatchNode.cpp

示例3: DxDt

bool ParticleSystem::DxDt(double t, nvectord &x, nvectord &xdot, void *userData)
{
    ParticleSystem *pThis = static_cast<ParticleSystem *>(userData);
    assert(pThis);
        
    // Put data in x[] into particles
    pThis->ParticlesArrayToState(&x[0]);
        
    pThis->ClearForces();

    // evaluate all forces
    pThis->ApplyRegularForces();
    pThis->ApplyDragForces();
    pThis->ApplyConstraintForces();

    pThis->LimitStateChanges();

    pThis->DdtParticlesStateToArray(&xdot[0]);

    return false;
}
开发者ID:oliriley,项目名称:PhantomController,代码行数:21,代码来源:ParticleSystem.cpp

示例4: init

// Initialization: load and compile shaders, initialize camera(s), load models.
void init() {
  
  GLuint particleSystemShader;
  Screen *primScreen = Engine::instance()->mainScreen();
  Scene *rootScene = Engine::instance()->rootScene();
  
  particleSystemShader = Angel::InitShader( "shaders/vParticle2.glsl",
                                            "shaders/fParticle2.glsl",
                                            "shaders/gParticle.glsl",//"shaders/gParticle.glsl",
      GL_TRIANGLES, GL_TRIANGLE_STRIP, 12 );
  
  rootScene->shader( particleSystemShader );
  primScreen->_camList.shader( particleSystemShader );
  
  {
    ParticleSystem *particleSystem = new ParticleSystem( numberOfParticles, 
							 "emitter", 
							 particleSystemShader );

    particleSystem->setLifespan(8.0, 16.0);
    //particleSystem->setVectorField( ParticleFieldFunctions::userSupplied ) ;
    particleSystem->setVectorField( ParticleFieldFunctions::flame );
    particleSystem->setColorFunc( ColorFunctions::flame ) ;
    particleSystem->setEmitterRadius( 0.04 ) ;
    particleSystem->setEmitterShape(PS_HEMI_D);
    particleSystem->drawMode( GL_TRIANGLES ) ; // NEED THIS IF WE USE A GEOMETRY SHADER!
    //particleSystem->setSlaughterHeight(0.2455);
    //particleSystem->_trans._displacement.set(0.0, 0.25, 0.0);
    //particleSystem->_trans._offset.set( 0.0, 0.2, 0.0 );
    particleSystem->propagateOLD();
    //particleSystem->fillSystemWithParticles();
    rootScene->insertObject( particleSystem );
    // PARTICLE SYSTEMS buffer() THEMSELVES
  }
  
  glClearColor( 0.0, 0.0, 0.0, 1.0 );
  // if not using geo shader, we need this to render visible points
  // glPointSize( 1.1 );
}
开发者ID:C-Compton,项目名称:OpenGL,代码行数:40,代码来源:partTest2.cpp

示例5: loadOptions

void loadOptions (Options opts) {
	currentCamera = opts.currentCamera;
	cameraAngle = opts.cameraAngle;
	cameraElevation = opts.cameraElevation;
	cameraDistance = opts.cameraDistance;
	Particle::initialVelocity = opts.initialVelocity;
	gravityIntensity = opts.gravityIntensity;
	Particle::startLifeSpan = opts.startLifeSpan;
	renderMode = opts.renderMode;
	Particle::renderMode = (PARTICLERENDERMODE)renderMode;
	emitterCount = opts.emitterCount;
	emitterSpacing = opts.emitterSpacing;
	Particle::airResistance = opts.airResistance;
	emitFrequency = opts.emitFrequency;
	particleSystem.setEmitTicks(emitFrequency);
	ParticleEmitter::emitSpread = opts.emitSpread;
	ParticleSystem::perEmit = opts.perEmit;
	ParticleEmitter::show = opts.showEmitters;
	wireframe = opts.wireframe;
	makeSprinkler();
}
开发者ID:rd3k,项目名称:WaterSprinkler,代码行数:21,代码来源:ex1.cpp

示例6: createFluid

void SampleParticles::createParticleSystems()
{
	// create waterfall fluid
	{
		PxParticleFluid* px_fluid = createFluid(mFluidParticleCount, 0.3f, 60.0f, 45.0f, 0.001f, 0.8f);
		px_fluid->setSimulationFilterData(collisionGroupWaterfall);
		// This will be deleted by RenderParticleSystemActor
		ParticleSystem* fluid = SAMPLE_NEW(ParticleSystem)(px_fluid);
		mWaterfallParticleSystem = SAMPLE_NEW(RenderParticleSystemActor)(*getRenderer(), fluid, false);
		mWaterfallParticleSystem->setRenderMaterial(getMaterial(MATERIAL_WATERFALL));
		addRenderParticleSystemActor(*mWaterfallParticleSystem);
	}

	// create smoke particle system
	{
		PxParticleBase* px_ps = createParticleSystem(mSmokeParticleCount);
		px_ps->setDamping(0.5f);
		px_ps->setRestitution(0.0f);
		px_ps->setDynamicFriction(0.0f);
		px_ps->setExternalAcceleration(PxVec3(0.0f, 17.0f, 0.0f));
		px_ps->setSimulationFilterData(collisionGroupSmoke);
		// This will be deleted by RenderParticleSystemActor
		ParticleSystem* ps = SAMPLE_NEW(ParticleSystem)(px_ps, false);
		ps->setUseLifetime(true);
		ps->setLifetime(mSmokeLifetime);
		mSmokeParticleSystem = SAMPLE_NEW(RenderParticleSystemActor)(*getRenderer(), ps, false, true, mSmokeLifetime*1.5f);
		mSmokeParticleSystem->setRenderMaterial(getMaterial(MATERIAL_SMOKE));
		addRenderParticleSystemActor(*mSmokeParticleSystem);
	}

	// create debris particle system
#if !defined(RENDERER_ENABLE_GLES2)
	{
		PxParticleBase* px_ps = createParticleSystem(mDebrisParticleCount);
		px_ps->setStaticFriction(10.0f);
		px_ps->setSimulationFilterData(collisionGroupDebris);
		// This will be deleted by RenderParticleSystemActor
		ParticleSystem* ps = SAMPLE_NEW(ParticleSystem)(px_ps, true);
		ps->setUseLifetime(true);
		ps->setLifetime(5.0f);
		mDebrisParticleSystem = SAMPLE_NEW(RenderParticleSystemActor)(*getRenderer(), ps, true, false, 4.0f, 0.3f);
		mDebrisParticleSystem->setRenderMaterial(getMaterial(MATERIAL_DEBRIS));
		addRenderParticleSystemActor(*mDebrisParticleSystem);
	}
#endif
}
开发者ID:akurt5,项目名称:AIEShit,代码行数:46,代码来源:SampleParticles.cpp

示例7: main

int main(int argc, char** argv) {
  pSystem = ParticleSystem(Vector(0,-9.8, 0));
  determineFunction(argc, argv);
  createParticles();
  pSystem.initialize(dt);
  // dont need this now that we have opengl.
  // but we can use this if we don't want to display...i guess
  /*for(float j = 0; j < totalTime; j+=dt) {*/
  //cout << "//===========================================//" << endl
  //<< "// totalTime: " << j << "                                 //" << endl
  //<< "//===========================================//" << endl;
  //pSystem.update(dt);
  /*}*/
  glutInit(&argc, argv);
  glutInitWindowSize(frameWidth, frameHeight);
  glutInitWindowPosition(0, 0);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
  glutCreateWindow("CS184 Final");
  glClearColor(0.0, 0.0, 0.0, 1.0);
  glEnable(GL_POINT_SMOOTH);
  glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
  glPointSize(5.0f);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glEnable(GL_BLEND);
  glutKeyboardFunc(keyboard);

  if (useCubes) {
      mesh = Mesh(32, 33, 18, 1.0, -1.0, .5, -1.5, .5, -.5);
	  glutDisplayFunc(displayFunc1);
	  glutIdleFunc(displayFunc1);
  } else {
	  glutDisplayFunc(displayFunc);
	  glutIdleFunc(displayFunc);
  }
  glutReshapeFunc(changeSize);
  glutMainLoop();
  return 0;
}
开发者ID:Haider-BA,项目名称:Lagrangian-Fluid-Simulation,代码行数:38,代码来源:window.cpp

示例8: m_xmldocument

		ParticleSystem* ParticleIO::loadConfiguredSystem(string ref, const Color& mask) {
			TiXmlDocument m_xmldocument(ref.c_str());
			bool loadOkay = m_xmldocument.LoadFile();
			if (!loadOkay) {
				ErrorDialog::createAndShow(StringUtil::append("Could not load Particle System: ", ref));
				exit(0);
			}

			ParticleSystem* sys = new ParticleSystem(new Image("data/particle.png", mask));

			TiXmlElement* rootelement = m_xmldocument.FirstChildElement("system");
			if (rootelement == NULL) {
				ErrorDialog::createAndShow(string("Invalid particle system file. Root node must be <system>."));
			}
			if (strcmp(rootelement->Attribute("additive"), "true") == 0) {
				sys->setBlendingMode(ParticleSystem::BLEND_ADDITIVE);
			} else {
				sys->setBlendingMode(ParticleSystem::BLEND_COMBINE);
			}

			const char* points = rootelement->Attribute("points");
			if (points != NULL) {
				sys->setUsePoints(strcmp(points, "true") == 0);
			}

			TiXmlElement* emitter = 0;
			for (emitter = rootelement->FirstChildElement("emitter");
					emitter;
					emitter = emitter->NextSiblingElement("emitter")) {
				ConfigurableEmitter* e = new ConfigurableEmitter("new");
				elementToEmitter(e, emitter);
				sys->addEmitter(e);
			}

			sys->setRemoveCompletedEmitters(false);
			return sys;
		}
开发者ID:ashleygwinnell,项目名称:ark2d,代码行数:37,代码来源:ParticleIO.cpp

示例9: create

void ParticleFactory::create(const double elapsedSeconds, const Vec2f origin, const Listener& list, ParticleSystem & ps)
{
	ps.mUnderlays = 3;
	switch (d_particleToCreate)
	{
	
	case PARTICLE_A:{
		for (int i = 0; i < 3; ++i)
		{
			Particle* particle = new ParticleA(origin, list);
			particle->mOrientation = ps.mOrientation;
			ps.addParticle(particle);
		}
	}break;
	case PARTICLE_B:{
		Particle* particle = new ParticleB(origin, list);
			ps.addParticle(particle);
	}break;
	case PARTICLE_C:{
		Particle* particle = new ParticleC(origin, list);
			ps.addParticle(particle);
	}break;
	case PARTICLE_D:{
		for (int i = 0; i < (int)(list.getVolume()*20.f); ++i)
		{
			Particle* particle = new ParticleD(origin, list);
			ps.addParticle(particle);
		}
	}break;
	case PARTICLE_E:{
			Particle* particle = new ParticleE(origin, list);
			particle->mOrientation = ps.mOrientation;
			ps.addParticle(particle);
	}break;
	case PARTICLE_F:{
		for (int i = 0; i < 4; ++i)
		{
			Particle* particle = new ParticleF(origin, list);
			particle->mOrientation = ps.mOrientation;
			ps.addParticle(particle);
		}
	}break;
	case PARTICLE_G:{
			while (ps.mParticles.size() < 3)
			{
				Particle* particle = new ParticleG(origin, list);
				ps.addParticle(particle);
			}
	}break;
	case PARTICLE_H:{
		for (int i = 0; i < 4; ++i)
		{
			Particle* particle = new ParticleH(origin, list);
			ps.addParticle(particle);
		}
	}break;
	case PARTICLE_I:{
			Particle* particle = new ParticleI(origin, list);
			ps.addParticle(particle);
	}break;
	case PARTICLE_J:{
		Particle* particle = new ParticleJ(origin, list);
		ps.addParticle(particle);
	}break;
	case PARTICLE_K:{
		Particle* particle = new ParticleK(origin, list);
		ps.addParticle(particle);
	}break;
	case PARTICLE_L:{
		Particle* particle = new ParticleL(origin, list);
		ps.addParticle(particle);
	}break;
	case PARTICLE_M:{
		Particle* particle = new ParticleM(origin, list);
		particle->mOrientation = ps.mOrientation;
		ps.addParticle(particle);
		ps.mUnderlays = 1;
	}break;
	case PARTICLE_N:{
		Particle* particle = new ParticleN(origin, list);
		ps.addParticle(particle);
	}break;
	default:
		ci::app::console() << "UNKNOWN PARTICLE: " << d_particleToCreate;
		break;
	}
}
开发者ID:brucelane,项目名称:f2_Orbs,代码行数:87,代码来源:ParticleFactory.cpp

示例10: main

int main()
{
	glfwInit();

	GLFWwindow* window;
	window = glfwCreateWindow(800, 600, "ParticleSystemScene", NULL, NULL);
	glfwMakeContextCurrent(window);

	//CAM
	cam.setKeySpeed(4.0);
	iH.setAllInputMaps(cam);
	glfwSetKeyCallback(window, key_callback);
	cam.setFOV(50);
	cam.setNearFar(1, 100);

	glewInit();

	//TEXTURES
	Texture* smokeWhiteTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeWhite/smokeWhite01.png");
	Texture* smokeWhiteTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeWhite/smokeWhite02.png");
	Texture* smokeBlackTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeBlack/smokeBlack01.png");
	Texture* smokeBlackTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeBlack/smokeBlack02.png");
	Texture* snowTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/particle/snowflake.png"); //TODO better Resolution

	//FINAL EMITTER SNOW
	Emitter* snow = new Emitter(0, glm::vec3(0.0, 10.0, -5.0), 0.0, 0.166, 100, 30.0, true);
	snow->setVelocity(0);
	snow->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, 1.0), 0.5f);
	snow->setAreaEmitting(false, true, 10.0, 10000);
	snow->addTexture(snowTex, 0.0);
	snow->defineLook(true, 0.04, 2.0);
	snow->setMovable(true);

	//FINAL EMITTER WHITE SMOKE
	Emitter* smokeWhite = new Emitter(0, glm::vec3(0.0, 0.0, 5.0), 0.0, 0.4, 1, 8.0, true);
	smokeWhite->setVelocity(2);
	smokeWhite->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -0.8), 0.3f);
	smokeWhite->addTexture(smokeWhiteTex1, 1.0);
	smokeWhite->addTexture(smokeWhiteTex2, 0.25);
	std::vector<float> smokeWhiteSize{ 0.05f, 0.5f, 0.75f, 1.2f };
	std::vector<float> smokeWhiteTime{ 0.0f, 0.4f, 0.75f, 1.0f };
	smokeWhite->defineLook(true, smokeWhiteSize, smokeWhiteTime, 1.0, 4.0, 4.0, false, 0.3);
	smokeWhite->switchToGeometryShader();

	//FINAL EMITTER BLACK SMOKE
	Emitter* smokeBlack = new Emitter(0, glm::vec3(0.0, 0.0, -10.0), 0.0, 0.4, 1, 8.0, true);
	smokeBlack->setVelocity(2);
	smokeBlack->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -0.8), 0.3f);
	smokeBlack->addTexture(smokeBlackTex1, 1.0);
	smokeBlack->addTexture(smokeBlackTex2, 0.08);
	std::vector<float> smokeBlackSize{ 0.1f, 0.4f, 0.8f, 1.2f };
	std::vector<float> smokeBlackTime{ 0.0f, 0.2f, 0.75f, 1.0f };
	smokeBlack->defineLook(true, smokeBlackSize, smokeBlackTime, 1.0, 4.0, 4.0, false, 0.3);
	smokeBlack->switchToGeometryShader();

	//PARTICLE SYSTEM
	Effect* sn = new Effect();
	sn->addEmitter(snow);
	ParticleSystem* psSnow = new ParticleSystem(glm::vec3(0, 2, -5), sn);
	Node snowNode("snowNode");
	snowNode.setParticleActive(true);
	snowNode.setCamera(&cam);
	snowNode.addParticleSystem(psSnow);
	
	Effect* smWhi = new Effect();
	smWhi->addEmitter(smokeWhite);
	ParticleSystem* psSmokeWhite = new ParticleSystem(glm::vec3(0, 0, 3), smWhi);
	Node whiteSmokeNode("whiteSmokeNode");
	whiteSmokeNode.setParticleActive(true);
	whiteSmokeNode.setCamera(&cam);
	whiteSmokeNode.addParticleSystem(psSmokeWhite);
	
	Effect* smBla = new Effect();
	smBla->addEmitter(smokeBlack);
	ParticleSystem* psSmokeBlack = new ParticleSystem(glm::vec3(0, 0, -3), smBla);
	Node blackSmokeNode("blackSmokeNode");
	blackSmokeNode.setParticleActive(true);
	blackSmokeNode.setCamera(&cam);
	blackSmokeNode.addParticleSystem(psSmokeBlack);
	
	// Shader
	VertexShader vs(loadShaderSource(SHADERS_PATH + std::string("/ColorShader3D/ColorShader3D.vert")));
	FragmentShader fs(loadShaderSource(SHADERS_PATH + std::string("/ColorShader3D/ColorShader3D.frag")));
	ShaderProgram shader(vs, fs);

	// Renderer
	OpenGL3Context context;
	Renderer renderer(context);

	// Object
	Teapot teapot;
	teapot.loadBufferData();
	Node teapotNode("teapotNode");
	teapotNode.addGeometry(&teapot);
	teapotNode.setCamera(&cam);
	teapotNode.setModelMatrix(glm::translate(teapotNode.getModelMatrix(), glm::vec3(0.0, 0.0, -7.0)));
	
	//need scene here mainly because of input
	Level testLevel("testLevel");
	Scene testScene("testScene");
//.........这里部分代码省略.........
开发者ID:MaikKlein,项目名称:GeKo,代码行数:101,代码来源:main.cpp

示例11: getPosition


//.........这里部分代码省略.........
		if (Input::isHeld(Button_Up)) {
			mRopeVelocity.y -= 1;
		}

		if (Input::isHeld(Button_Down)) {
			mRopeVelocity.y += 1;
		}

		if (floatIsZero(mRopeVelocity)) {
			mRopeVelocity.x = (mFacingDirection == Direction_Left ? -1 : 1);
		}

		mRopeVelocity = adjustRopeDirection(normalize(mVelocity + normalize(mRopeVelocity) * ROPE_SPEED)) * ROPE_SPEED;

		if (mRopeVelocity.x < 0) {
			mFacingDirection = Direction_Left;
		} else if (mRopeVelocity.x > 0) {
			mFacingDirection = Direction_Right;
		}
	}

	if (mRopeState == RopeState_Moving) {
		const int substeps = 25;
		for (int i = 0; i < substeps; i++) {
			mRopePosition += mRopeVelocity / (substeps * Time::TicksPerSecond);
			int tileX = (int)(mRopePosition.x / mRoom->getTileWidth());
			int tileY = (int)(mRopePosition.y / mRoom->getTileHeight());
			if (mRoom->isHookable(tileX, tileY)) {
				//Sound::stopSample("data/sounds/rope.wav");
				Sound::playSample("data/sounds/hook.wav");
				mRopeState = RopeState_Attached;
				mJumpHeld = false;

				ParticleSystem* particleSystem = new ParticleSystem(
					mAnimationHookParticle,
					2,
					30,
					10,
					1,
					50,
					10,
					-normalize(mRopeVelocity)*10,
					1.0);

				particleSystem->setPosition(mRopePosition);

				mRoom->addEntity(particleSystem);

				break;
			}

			if (length(mRopePosition-mPosition) > mRopeMaxLenghth)
			{
				detachHook();
				Sound::playSample("data/sounds/no_hook.wav");
				break;
			}

			if (mRoom->isCollidable(tileX, tileY)) {
				detachHook();
				Sound::playSample("data/sounds/no_hook.wav");
				break;
			}

			if (mRoom->damageDone((int)(mRopePosition.x), (int)(mRopePosition.y))) {
				detachHook();
开发者ID:kulgan,项目名称:playn-greengrappler,代码行数:67,代码来源:Hero.cpp

示例12: main

int main()
{
    ModelerControl controls[NUMCONTROLS ];

	controls[BASE_ROTATION] = ModelerControl("base rotation (theta)", -180.0, 180.0, 0.1, 0.0 );
    controls[LOWER_TILT] = ModelerControl("lower arm tilt (phi)", 15.0, 95.0, 0.1, 55.0 );
    controls[UPPER_TILT] = ModelerControl("upper arm tilt (psi)", 0.0, 135.0, 0.1, 30.0 );
	controls[CLAW_ROTATION] = ModelerControl("claw rotation (cr)", -30.0, 180.0, 0.1, 0.0 );
    controls[BASE_LENGTH] = ModelerControl("base height (h1)", 0.5, 10.0, 0.1, 0.8 );
    controls[LOWER_LENGTH] = ModelerControl("lower arm length (h2)", 1, 10.0, 0.1, 3.0 );
	controls[UPPER_LENGTH] = ModelerControl("upper arm length (h3)", 1, 10.0, 0.1, 2.5);
	controls[PARTICLE_COUNT] = ModelerControl("particle count (pc)", 0.0, 5.0, 0.1, 5.0);
	controls[X_WIND] = ModelerControl("X_WIND", 0.0, 5.0, 0.1, 0.6);
	controls[Y_WIND] = ModelerControl("Y_WIND", 0.0, 5.0, 0.1, 0.0);
	controls[Z_WIND] = ModelerControl("Z_WIND", 0.0, 5.0, 0.1, 0.2);
	controls[WIND_MAGNITUDE] = ModelerControl("WIND_MAGNITUDE", 0.0, 10.0, 0.1, 2.0);
	controls[GRAVITY] = ModelerControl("GRAVITY", -10.0, 10.0, 1.0, 9.8);
    
    controls[XPOS] = ModelerControl("X Position", -5, 5, 0.1f, 0);
    controls[YPOS] = ModelerControl("Y Position", 0, 5, 0.1f, 0);
    controls[ZPOS] = ModelerControl("Z Position", -5, 5, 0.1f, 0);

    controls[XSCALE] = ModelerControl("X Scale", 0, 3, 0.1f, 1.0f);
    controls[YSCALE] = ModelerControl("Y Scale", 0, 3, 0.1f, 1.0f);
    controls[ZSCALE] = ModelerControl("Z Scale", 0, 3, 0.1f, 1.0f);

    controls[HEIGHT] = ModelerControl("Height", 1, 2.5, 0.1f, 1);
    controls[ROTATE] = ModelerControl("Rotate", -135, 135, 1, 0);

    controls[HEAD_SIZE] = ModelerControl("Head Size", 0.8, 2, 0.1f, 1);
    controls[HEAD_ROTATE] = ModelerControl("Head Rotate", -70, 70, 1, 0);
    controls[EAR_SIZE] = ModelerControl("Ear Size", 0, 2, 0.1f, 1);

    controls[UPPER_ARM_LENGTH] = ModelerControl("Upper Arm Length", 1, 5, 0.1f, 0.8);
    controls[LEFT_UPPER_ARM_ROTATE_X] = ModelerControl("Left Upper Arm Rotate X", 20, 120, 1.0f, 80);
    controls[LEFT_UPPER_ARM_ROTATE_Y] = ModelerControl("Left Upper Arm Rotate Y", -30, 90, 1.0f, 0);
    controls[RIGHT_UPPER_ARM_ROTATE_X] = ModelerControl("Right Upper Arm Rotate X", -90, 100, 1.0f, -40);
    controls[RIGHT_UPPER_ARM_ROTATE_Y] = ModelerControl("Right Upper Arm Rotate Y", -90, 30, 1.0f, 0);

    controls[LOWER_ARM_LENGTH] = ModelerControl("Lower Arm Length", 1, 5, 0.1f, 0.8);
    controls[LEFT_LOWER_ARM_ROTATE] = ModelerControl("Left Lower Arm Rotate", 20, 180, 1.0f, 80);
    controls[RIGHT_LOWER_ARM_ROTATE] = ModelerControl("Right Lower Arm Rotate", 20, 180, 1.0f, 180);
    controls[RIGHT_HAND_ANGLE] = ModelerControl("Right Hand Angle", 0, 70, 1, 0);
    controls[LEFT_HAND_ANGLE] = ModelerControl("Left Hand Angle", 0, 70, 1, 0);

    controls[LEG_LENGTH] = ModelerControl("Leg Length", 1, 5, 0.1f, 2);
    controls[LEFT_LEG_ROTATE_X] = ModelerControl("Left Leg Rotate X", 30, 150, 1.0f, 40);
    controls[LEFT_LEG_ROTATE_Y] = ModelerControl("Left Leg Rotate Y", -80, 90, 1.0f, 0);
    controls[RIGHT_LEG_ROTATE_X] = ModelerControl("Right Leg Rotate X", 30, 150, 1.0f, 140);
    controls[RIGHT_LEG_ROTATE_Y] = ModelerControl("Right Leg Rotate Y", -90, 80, 1.0f, 0);
    
    controls[TORUS_R] = ModelerControl("Torus R", 0, 10, 0.1f, 0.6);
    controls[TORUS_r] = ModelerControl("Torus r", 0, 10, 0.1f, 0.15);

    controls[FLOOR_SIZE] = ModelerControl("Floor Size", 0, 8, 0.1f, 5.0f);
    controls[FLOOR_DEPTH] = ModelerControl("Floor Depth", 0, 10, 1, 4);

    controls[DETAIL_LEVEL] = ModelerControl("Detail Level", 1, 5, 1, 3);


	// You should create a ParticleSystem object ps here and then
	// call ModelerApplication::Instance()->SetParticleSystem(ps)
	// to hook it up to the animator interface.

	ModelerApplication::Instance()->Init(&createRobotArm, controls, NUMCONTROLS);
	ParticleSystem *ps = new ParticleSystem();
	ModelerApplication::Instance()->SetParticleSystem(ps);
	Force* g = new Gravity((float)VAL(GRAVITY));
	//Force* g = new Gravity(9.8f);
	ps->addForce(g);
	Wind *wind = new Wind();
	wind->setDirection(Vec3f((float)-VAL(X_WIND) - 5.0f, (float)VAL(Y_WIND) - 5.0f, (float)VAL(Y_WIND) - 5.0f));
	//wind->setDirection(Vec3f(-0.4, 0, 0.2));
	wind->setMagnitube((float)VAL(WIND_MAGNITUDE));
	//wind->setMagnitube(6.0);
	ps->addForce(wind);
	

    return ModelerApplication::Instance()->Run();
}
开发者ID:billytotochan,项目名称:anime,代码行数:80,代码来源:robotarm.cpp

示例13: surf

void Fluid2DParticlesApp::draw()
{
    // clear out the window with black
    gl::clear( Color( 0, 0, 0 ) );

    gl::color( ColorAf( 1.0f, 1.0f, 1.0f, 0.999f ) );
    float* data = const_cast<float*>( (float*)mFluid2D.rgb().data() );
    Surface32f surf( data, mFluid2D.resX(), mFluid2D.resY(), mFluid2D.resX()*sizeof(Colorf), SurfaceChannelOrder::RGB );


    if ( ! mTex ) {
        mTex = gl::Texture::create( surf );
    } else {
        mTex->update( surf );
    }
    gl::draw( mTex, getWindowBounds() );
    mTex->unbind();
    mParticles.draw();
    mParams.draw();
}
开发者ID:roshan2010,项目名称:CinderFx,代码行数:20,代码来源:Fluid2DParticlesApp.cpp

示例14: Particle

void Fluid2DParticlesApp::mouseDrag( MouseEvent event )
{
    float x = (event.getX()/(float)getWindowWidth())*mFluid2D.resX();
    float y = (event.getY()/(float)getWindowHeight())*mFluid2D.resY();
    float s = 10;

    if( event.isLeftDown() ) {
        vec2 dv = vec2( event.getPos() ) - mPrevPos;
        mFluid2D.splatVelocity( x, y, mVelScale*dv );
        mFluid2D.splatRgb( x, y, mRgbScale*mColor );
        if( mFluid2D.isBuoyancyEnabled() ) {
            mFluid2D.splatDensity( x, y, mDenScale );
        }
        //
        for( int i = 0; i < 10; ++i ) {
            vec2 partPos = vec2( event.getPos() ) + vec2( Rand::randFloat( -s, s ), Rand::randFloat( -s, s ) );
            float life = Rand::randFloat( 2.0f, 4.0f );
            mParticles.append( Particle( partPos, life, mColor ) );
        }
    }

    mPrevPos = event.getPos();
}
开发者ID:roshan2010,项目名称:CinderFx,代码行数:23,代码来源:Fluid2DParticlesApp.cpp

示例15: setup

void msaFluidParticlesApp::setup()
{
	console() << "ciMSAFluid Demo | (c) 2009 Mehmet Akten | www.memo.tv" << std::endl;
	
	// setup fluid stuff
	fluidSolver.setup(100, 100);
    fluidSolver.enableRGB(true).setFadeSpeed(0.002).setDeltaT(0.5).setVisc(0.00015).setColorDiffusion(0);
	fluidDrawer.setup( &fluidSolver );
	particleSystem.setFluidSolver( &fluidSolver );
	
	fluidCellsX			= 150;
	
	drawFluid			= true;
	drawParticles		= true;
	renderUsingVA		= true;
	
	setFrameRate( 60.0f );
	
	pMouse = getWindowCenter();
	resizeFluid			= true;
	
	gl::enableAlphaBlending();
}
开发者ID:AaronMeyers,项目名称:Cinder,代码行数:23,代码来源:msaFluidParticlesApp.cpp


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