HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 SPARK Move a System?

View previous topic View next topic Go down 
AuthorMessage
Jack



Messages : 11
Date d'inscription : 2011-10-12

PostSubject: SPARK Move a System?   Fri Oct 14, 2011 11:36 am

Hello,

I want to move a SPARK System so the Effect, but my Problem is that if i try to Move the System it begins
from X Position Zero and Y Position Zero, but i have setted the X and Y Pos on 400, 300 as example and
in the Window the Effect dont moves...
So I think i have again a strange problem...

My Code:
Code:
   //Create Model
   SPK::Model *Model = SPK::Model::create(SPK::FLAG_RED | SPK::FLAG_GREEN | SPK::FLAG_BLUE | SPK::FLAG_ANGLE,
                                SPK::FLAG_ALPHA,
                                SPK::FLAG_RED  | SPK::FLAG_GREEN | SPK::FLAG_ANGLE);

   //Set Parameter
   Model->setParam(SPK::PARAM_RED,  0.0f, 0.0f);
   Model->setParam(SPK::PARAM_BLUE,  0.9f, 1.4f);
   Model->setParam(SPK::PARAM_GREEN, 0.2f, 0.6f);
   Model->setParam(SPK::PARAM_ALPHA, 0.8f, 0.0f);
   Model->setParam(SPK::PARAM_ANGLE, 0.0f, PI * 10.0f);

   //Set Lifetime
   Model->setLifeTime(5.0f, 7.0f);

   //Create our SFML Renderer
   SPK::SFML::SFMLPointRenderer* Renderer = SPK::SFML::SFMLPointRenderer::create(2.0f);
   Renderer->setImage(&Texture);
   Renderer->setBlendMode(sf::Blend::Add);

   //Zone where the Particles are
   SPK::Sphere *Point = SPK::Sphere::create(SPK::Vector3D(400.0f, 300.0f, 100.0f), 10.0f * PI);

   //The Emitter
   SPK::SphericEmitter *Emitter = SPK::SphericEmitter::create((SPK::Vector3D(0.0f, 0.0f, 100.0f), 0.0, 10.0f * PI));

   //Set Name
   Emitter->setName("Emitter");

   //Set Force
   Emitter->setForce(3.2f, 3.2f);

   //Set Zone
   Emitter->setZone(Point);

   //Set Tank
   Emitter->setTank(15000);

   //Set Flow
   Emitter->setFlow(-1);

   //Create a Group
   SPK::Group *Group = SPK::Group::create(Model, 15000);

   //Set Emitter for the Group
   Group->addEmitter(Emitter);

   //Set Renderer
   Group->setRenderer(Renderer);

   //Set Gravity
   Group->setGravity(SPK::Vector3D(0.0f, -1.0f, 0.0f));

   //Set Friction
   Group->setFriction(2.0f);

   //Create SFML System
   SPK::SFML::SFMLSystem *System = SPK::SFML::SFMLSystem::create();

   //Add Group
   System->addGroup(Group);

   //Set Render Target
   System->setRenderTarget(&App);

   //Set Shared
   Model->setShared(true);
   Renderer->setShared(true);

   //Set Z Factor
   Renderer->setZFactor(1.0f);

        //Couts 0 but i set 400
   cout << "X:" << System->GetPosition().x << endl;

   //Loop
   while(App.IsOpened())
   {
      while(App.GetEvent(Event))
      {
         if(Event.Type == sf::Event::Closed)
         {
            App.Close();
         }
      }

      //Clear
      App.Clear();

      //Check
      if(App.GetInput().IsKeyDown(sf::Key::Right))
      {
         //Couts a wrong Position
         cout << "X: " << System->GetPosition().x << endl;

         //Moves, it moves, but it moves not really
                        //cant describe it..
         System->Move(100 * App.GetFrameTime(), 0);
      }

      //Update System
      System->update(0.001f);

      //Draw
      System->render();

      //Display
      App.Display();
   }
I hope for help.. Smile
Back to top Go down
View user profile
Juff
Developer


Messages : 539
Date d'inscription : 2009-07-14
Age : 34

PostSubject: Re: SPARK Move a System?   Fri Oct 14, 2011 1:44 pm

Hi,

there are 2 ways to spawn particles in SPARK : either local to the system or in the world

  • local : particles are moving as the system moves. They are emitted in the system space
  • world : particles are spawned in the world, once emitted they have their own life and dont care about the system's position. However, newly spawned particles used the system's position.


By default your in world mode. If you want to emit particles locally to the system, creates your system by passing false to the first parameter (worldTransformed)

Moreover if your using particle in a truly 2D environment, you can set the zFactor to 0

Regarding what outputs GetPosition which is not consistent with SetPosition, that's strange because its SFML code only.

Hope this helps
Back to top Go down
View user profile http://spark.developpez.com
Jack



Messages : 11
Date d'inscription : 2011-10-12

PostSubject: Re: SPARK Move a System?   Fri Oct 14, 2011 1:55 pm

Thank you very much!

You have solved my two problems, the other problem was that the Circle looks
so wide because the Z Factor was on 1 Razz

Thanks again! And thanks for this beautiful particle engine! cheers
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: SPARK Move a System?   Today at 9:30 am

Back to top Go down
 
SPARK Move a System?
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» How to move my selenium test cases from Rc to Grid
» [SOLVED] Used V1.05- Cant rename folders or move folders
» [IMPLEMENTED] Registry tweak to disable File System Tunneling
» [Javascript] Move topic popup [Moderator panel improvement]
» Latest Topic System v5

Permissions in this forum:You cannot reply to topics in this forum
 :: English Forum :: Questions (en)-
Jump to: