HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 How I can get the Center of an Effect?

View previous topic View next topic Go down 
AuthorMessage
Jack



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

PostSubject: How I can get the Center of an Effect?   Sat Oct 22, 2011 4:24 am

Hello,

I try to rotate an Effect by his middle point, but I doesn´t become it worked.
Tried many things but nothing worked, the last try was this:

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, MyPI * 10.0f);

   //Set Lifetime
   Model->setLifeTime(1115.0f, 1117.0f);

    //...

    System->SetCenter(10, 10); // I tried many values, dont worked
    System->Rotate(100 * App.GetFrameTime());
Thanks in advance!
Back to top Go down
View user profile
Juff
Developer


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

PostSubject: Re: How I can get the Center of an Effect?   Sat Oct 22, 2011 6:09 am

Hi, it depends what do you mean by the center of the effect ?

If it is defined by the origin of the system, then leave the center to (0,0) then it would be rotated around its translation point
You can defined the center by the center of the bounding box but it should lead to strange effect as the center change dynamically during execution.
Or it can be defined an arbitrary point like for instance the position of the emitter or whatever...

When you re saying its not working, what do you mean exactly ?
Back to top Go down
View user profile http://spark.developpez.com
Jack



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

PostSubject: Re: How I can get the Center of an Effect?   Sat Oct 22, 2011 6:32 am

I mean with dont worked, that the Effect dont rotate by his middle point, it rotates, but by a other point, so it fly´s arround the Level...
I will that the Effect rotate like a wheel by his middle point, thats what i mean.

But i dont become it work, my last try whas this:

Code:
      //Set Center
      EffectList.Get_Effect_Soul()->SetCenter(EffectList.Get_Effect_Soul()->getAABBMax().x,
                                               EffectList.Get_Effect_Soul()->getAABBMax().y);

And the rotation radius was shorter, but dont worked really...
I hope you understand my bad english. Razz
Back to top Go down
View user profile
Juff
Developer


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

PostSubject: Re: How I can get the Center of an Effect?   Sat Oct 22, 2011 6:38 am

That must be because your effect does not emit particles at (0.0) in its space.

Did you change the positions of emitters ?
Can I see the creation code of the effect ?

I took a look at the code and the setCenter is just an offset actually, so leaving it to (0,0) should rotate the effect around its "center"
Back to top Go down
View user profile http://spark.developpez.com
Jack



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

PostSubject: Re: How I can get the Center of an Effect?   Sat Oct 22, 2011 9:37 am

Mhh... thats the Code:
Code:
   //Texture
   sf::Image Texture;

   //Load
   Texture.LoadFromFile("res/flare.bmp");

   //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, MyPI * 10.0f);

   //Set Lifetime
   Model->setLifeTime(1115.0f, 1117.0f);

   //Create Model
   SPK::Model *Model_Track = 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_Track->setParam(SPK::PARAM_RED,  0.0f, 0.0f);
   Model_Track->setParam(SPK::PARAM_BLUE,  0.9f, 1.4f);
   Model_Track->setParam(SPK::PARAM_GREEN, 0.2f, 0.6f);
   Model_Track->setParam(SPK::PARAM_ALPHA, 0.8f, 0.0f);
   Model_Track->setParam(SPK::PARAM_ANGLE, 0.0f, MyPI * 10.0f);

   //Set Lifetime
   Model_Track->setLifeTime(2.0f, 4.0f);

   //Create our SFML Renderer
   SPK::SFML::SFMLPointRenderer* Renderer = SPK::SFML::SFMLPointRenderer::create(2.0f);

   //Set Texture
   Renderer->setImage(&Texture);

   //Set Blend Mode
   Renderer->setBlendMode(sf::Blend::Add);

   //Zone where the Particles are
   SPK::Sphere *Point = SPK::Sphere::create(SPK::Vector3D(X, Y, 0.0f), 10.0f * MyPI);

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

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

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

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

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

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

   //Enable it
   Group->enableAABBComputing(true);

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

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

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

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

   //Create a Group
   SPK::Group *Group_Track = SPK::Group::create(Model_Track, 1000);

   //Enable it
   Group_Track->enableAABBComputing(true);

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

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

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

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

   //Add Groups
   System->addGroup(Group);
   System->addGroup(Group_Track);
   
   //Share Model
   Model->setShared(true);

   //Share Renderer
   Renderer->setShared(true);

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

        //further in the code...

   if(App.GetInput().IsKeyDown(sf::Key::D))
   {
      //Move him to the Right
      System->Move(300 * App.GetFrameTime(), 0);

      //Set Center
      //System->SetCenter(EffectList.Get_Effect_Soul()->getAABBMax().x,
      //                              EffectList.Get_Effect_Soul()->getAABBMax().y);

      //Rotate
      System->Rotate(100 * App.GetFrameTime());

      //Add Particles
      System->getGroup(1)->addParticles(
SPK::Vector3D(System->getGroup(0)->getEmitter(0)->getZone()->getPosition().x + 50,  System->getGroup(0)->getEmitter(0)->getZone()->getPosition().y, 0),
SPK::Vector3D(System->getGroup(0)->getEmitter(0)->getZone()->getPosition().x - 250, System->getGroup(0)->getEmitter(0)->getZone()->getPosition().y, 0),
Emitter, 2);

I let SetCenter on 0,0 but it rotates dont by the center of the effect.. not like a wheel..
Back to top Go down
View user profile
Juff
Developer


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

PostSubject: Re: How I can get the Center of an Effect?   Sat Oct 22, 2011 10:12 am

As I said you dont emit particles from (0,0) in your example... but from an emitter which zone is a sphere located at (X,Y).

So either, instead of translating the emitter of (X,Y), you translate your system at (X,Y) and in this case its center is (0,0)
Or you leave your system like that but set the center to be (X,Y)
Back to top Go down
View user profile http://spark.developpez.com
Jack



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

PostSubject: Re: How I can get the Center of an Effect?   Sat Oct 22, 2011 10:39 am

Mhhh... I dont really understand what you mean...

Quote :
Or you leave your system like that but set the center to be (X,Y)
Like this (?):
Code:
   //Set Center
      System->SetCenter(System->getGroup(0)->getEmitter(0)->getZone()->getPosition().x, 
                     System->getGroup(0)->getEmitter(0)->getZone()->getPosition().y);
This dont worked, the Y Position changes on 0 and the Rotation is strange, its better than before but not really
like the rotation of a wheel...

Quote :
So either, instead of translating the emitter of (X,Y), you translate your system at (X,Y) and in this case its center is (0,0)
I maked this:
Code:
System = SPK::SFML::SFMLSystem::create(false);

//Enable AABB Computing
System->enableAABBComputing(true);
I thought that the Position of the Emitter and the System are the same? Or?
Back to top Go down
View user profile
Juff
Developer


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

PostSubject: Re: How I can get the Center of an Effect?   Sat Oct 22, 2011 2:09 pm

Hi, no the position of the emitter and the position of the system is not the same :

The system has a position in the world and the emitter has a position in the system (meaning its position is relative to the position of the system)

For instance, if the position of the zone of the emitter is (2,0) and then you set the position of the system to (5,7), then the position of the emitter will be (7,7).

This is because you can have as many emitters as you want per system, so you can position them in a group/system as you want and then move them all by moving the system.

But if you have only one emitter in your system, I advise you to set the position of the emitter to (0,0) and then only set the position of the system with the interface of Drawable.

Is that clear ?
Back to top Go down
View user profile http://spark.developpez.com
Jack



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

PostSubject: Re: How I can get the Center of an Effect?   Sat Oct 22, 2011 2:38 pm

It works, but not perfectly, because I have two groups in one system, and this two groups use two different emitter...
The Problem is that the two Groups rotate, but I only want that the first Group rotate, and the second Group of the System not.
Can I make this with one System?

But per se the Rotation like a wheel work with a little Problem, it rotates by the
Center of the Second Group of the System, how I can solve this?
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: How I can get the Center of an Effect?   Today at 10:12 am

Back to top Go down
 
How I can get the Center of an Effect?
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Chocolate Crisis Center Sweepstakes *colorado only*
» Review: Jefferson Headache Center (Philadelphia)
» Rollover Button Using CSS
» How Can I make a pun navlinks ribbon
» list of 10 headache treatment centers in US

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