jwildfire.org

The official JWildfire forum
It is currently Thu Jun 24, 2021 6:38 am

All times are UTC+01:00




Post new topic Reply to topic  [1 post ] 
Author Message
 Post subject: PDJ3D
PostPosted:Mon Dec 07, 2020 3:05 am 
Offline
User avatar

Joined:Sun May 31, 2015 2:39 pm
Posts:693
added some 3D variables to the pdj variation. Variables e and g are more "useful" but f and h are nice as well.

Image
Code:
/*
  JWildfire - an image and animation processor written in Java 
  Copyright (C) 1995-2011 Andreas Maschke
  This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser 
  General Public License as published by the Free Software Foundation; either version 2.1 of the 
  License, or (at your option) any later version.
 
  This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
  Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License along with this software; 
  if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jwildfire.create.tina.variation;

import org.jwildfire.create.tina.base.XForm;
import org.jwildfire.create.tina.base.XYZPoint;

import static org.jwildfire.base.mathlib.MathLib.cos;
import static org.jwildfire.base.mathlib.MathLib.sin;

public class PDJ3DFunc extends VariationFunc {
  private static final long serialVersionUID = 1L;

  private static final String PARAM_A = "a";
  private static final String PARAM_B = "b";
  private static final String PARAM_C = "c";
  private static final String PARAM_D = "d";
  private static final String PARAM_E = "e";
  private static final String PARAM_F = "f";  
  private static final String PARAM_G = "g";
  private static final String PARAM_H = "h";    
  private static final String[] paramNames = {PARAM_A, PARAM_B, PARAM_C, PARAM_D, PARAM_E, PARAM_F, PARAM_G, PARAM_H};

  private double a = 1;
  private double b = 2;
  private double c = 3;
  private double d = 4;
  private double e = 2;
  private double f = 0;
  private double g = 2;
  private double h = 0;  

  @Override
  public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
   // 3D variables added by Brad Stefanov.     
    pVarTP.x += pAmount * (sin(a * pAffineTP.y) - cos(b * pAffineTP.x));
    pVarTP.y += pAmount * (sin(c * pAffineTP.x) - cos(d * pAffineTP.y));
    pVarTP.z += pAmount * (sin(e * pAffineTP.y) - cos(f * pAffineTP.z))*cos(g * pAffineTP.x) + sin(h * pAffineTP.z) ;

    

  }

  @Override
  public String[] getParameterNames() {
    return paramNames;
  }

  @Override
  public Object[] getParameterValues() {
    return new Object[]{a, b, c, d, e, f, g, h};
  }

  @Override
  public void setParameter(String pName, double pValue) {
    if (PARAM_A.equalsIgnoreCase(pName))
      a = pValue;
    else if (PARAM_B.equalsIgnoreCase(pName))
      b = pValue;
    else if (PARAM_C.equalsIgnoreCase(pName))
      c = pValue;
    else if (PARAM_D.equalsIgnoreCase(pName))
      d = pValue;
    else if (PARAM_E.equalsIgnoreCase(pName))
      e = pValue;
    else if (PARAM_F.equalsIgnoreCase(pName))
      f = pValue;
    else if (PARAM_G.equalsIgnoreCase(pName))
      g = pValue;
    else if (PARAM_H.equalsIgnoreCase(pName))
      h = pValue;
    else
      throw new IllegalArgumentException(pName);
  }

  @Override
  public String getName() {
    return "pdj3D";
  }

}


Top
   
Display posts from previous: Sort by 
Post new topic Reply to topic  [1 post ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited
Theme Created by HOLLYSMOKE
Theme updated to phpBB 3.1.6 by KamijouTouma
Theme Version is 3.1.6-ss2