Menu

Find all SourcePFXeffects

Help
Daniel
2017-10-27
2017-10-30
  • Daniel

    Daniel - 2017-10-27

    Hi everyone!

    I'm trying to find a way to get all excisting sourcePFXeffects so that I can pause them.
    The reason is that I want to fast forward time in my game, and I want to stop generating particles while the time is speeded up.

    I can get all the managers by doing:

    for i := form1.ComponentCount - 1 downto 0 do
          begin
                  if form1.Components[i] is TGLPerlinPFXManager then
                  begin
                  //Do stuff
                  end;
          end;
    

    But how do I get all the individual behaviours/effects?

    Thanks!
    /Daniel

     
  • Jerome.D (BeanzMaster)

    I don't understand what do mean, exactly. To get Behaviours/effetcts from glscene's objects, you can just travel your scene and test if the Behaviours/Effects properties are set (not nil) for each object.

     

    Last edit: Jerome.D (BeanzMaster) 2017-10-30
  • Daniel

    Daniel - 2017-10-30

    Exactly, but I cannot figure out the code to do it runtime...
    Because I create some behaviours during runtime.
    I need to check for all currently excisting behaviours and set them to enabled := false; during runtime.

    Lets say I do not know how many objects has children, and the children might have more children.

     
  • Jerome.D (BeanzMaster)

    Ok i think the best it's to create Behaviours in an array and then each assign to your objects, it will be more easiest and more optimizing rather than travel all the scene. Or you can make a record

    Type
    MyBehaviourRec = packed record
    IsEnabled : Boolean;
    ....
    Behaviour : TGLBehaviour;
    end;;
    MyBehaviours : Array of MyBehaviourRec;

    If you need to travel the scene you must code a recursive function.

     
  • Daniel

    Daniel - 2017-10-31

    Thanks once again for your help Jerome!
    I tried to use a code to travel a set of dummyCubes for now, which works in this case.
    But it will not work unless I know how many children there is.

    if AIShipHolderCube.Count > 0 then
          begin
              for x := 0 to AIShipHolderCube.Count - 1 do
              begin
                  if AIShipHolderCube.Children[x].Count > 0 then
                  begin
                  y := AIShipHolderCube.Children[x].Count - 1;
                      for z := 0 to y do
                      begin
                            if AIShipHolderCube.Children[x].Children[z].effects.Count > 0 then
                            begin
                              if AIShipHolderCube.Children[x].Children[z].effects[0] <> nil then
                              begin
                              fx := AIShipHolderCube.Children[x].Children[z].Effects.ObjectEffect[0];
    
                                      if tc > 1 then
                                      begin
                                              with fx as tglSourcePFXEffect do
                                              enabled := false;
                                      end
                                      else
                                      begin
                                              with fx as tglSourcePFXEffect do
                                              Enabled := true;
                                      end;
    
                              end;
                            end;
                      end;
                  end;
            end;
    
        end;
    
     
  • Jerome.D (BeanzMaster)

    Hi Daniel you can easly convert this to an recursive procedure

    a code From Scratch (will be needed some corrections)

    procedure TravelSceneObject(anObject : TGLObject)
    var
    i, j : Integer;
    begin
       if anObject.count>0 then
       begin
         for I:=0 to anObject.count-1 do
         begin
            if anObject.Children[i].count > 0 then TravelSceneObject( anObject.Children[i]);
          end;
        end  
        else     
        begin
            if  anObject.effects.count > 0 then
            begin
                 For j:=0 to anObject.effects.count-1 do
                 begin
                     fx := anObject.effects[j].Object;
                     if tc>1 then
                     begin
                        with fx as tglSourcePFXEffect do enabled := false;
                     end
                    else
                    begin
                        with fx as tglSourcePFXEffect do enabled := True;
                    end
               end;  
          end;
       end;
    end;
    
     

    Last edit: Jerome.D (BeanzMaster) 2017-11-01
  • Daniel

    Daniel - 2017-11-01

    Hey Jerome!!
    Thanks alot!! Never occured to me that I could call the procedure inside itself.
    That is why it's called a recursive procedure I asume?
    Thanks you very much!

     
  • Jerome.D (BeanzMaster)

    That is why it's called a recursive procedure I asume?
    Yes it is. On web you can find many samples, for example search for the quick sort Algo which is often recusive :)

    you're welcome

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.