Package engine.base

Examples of engine.base.Vector4


    m_Gradient.clear();
    int num = s.nextInt();
    for (int i = 0; i < num; i++) {
      // !!TODO: this is a workaround for a weirded windows s.nextFloat bug;
      //m_Gradient.addEntry(new Vector4(s.nextFloat(), s.nextFloat(), s.nextFloat(), s.nextFloat()), s.nextFloat());
      m_Gradient.addEntry(new Vector4(Float.parseFloat(s.next()),Float.parseFloat(s.next()),Float.parseFloat(s.next()),Float.parseFloat(s.next())),Float.parseFloat(s.next()));
    }
    notifyParamChangeListener();
  }
View Full Code Here


          progress.setProgress(y / (float) img.getHeight());
        for (int x = 0; x < img.getWidth(); x++) {
          float u = (float) (x + px * img.getWidth()) / (float) globalXres;
          float v = (float) (y + py * img.getHeight()) / (float) globalYres;

          final Vector4 col;
          if (tce == null) col = c.valueRGBA(u, v);
          else col = tce.sample(x, y);
         
          final Vector3 color = new Vector3();
          int val;
          // !!UGH TODO: optimize this!!
          if (mode == 0) {
            color.set(col.getVector3());
            val = Utils.vector3ToINTColor(color);
          } else if (mode == 1) {
            float bg = ((((x + y) / 8) % 2) != 0) ? 1.0f : 0.75f;
            col.x = col.x * col.w + bg * (1.0f - col.w);
            col.y = col.y * col.w + bg * (1.0f - col.w);
            col.z = col.z * col.w + bg * (1.0f - col.w);
            color.set(col.getVector3());
            val = Utils.vector3ToINTColor(color);
          } else if (mode == 2) {
            color.set(col.w);
            val = Utils.vector3ToINTColor(color);
          } else if (mode == 3) {
            color.set(col.getVector3());
            val = Utils.vector4ToINTColor_ARGB(col);
          } else {
            Logger.logError(null, "Wrong in computeImage");
            val = Utils.vector3ToINTColor(color);
          }
View Full Code Here

    if (img == null)
      img = new BufferedImage(xres, yres, BufferedImage.TYPE_INT_RGB);
    for (int y = 0; y < img.getHeight(); y++) {
      for (int x = 0; x < img.getWidth(); x++) {
        float pos = (float) x / (float) img.getWidth();
        Vector4 col = grad.getColor(pos);
        float bg = ((((x + y) / 8) % 2) != 0) ? 1.0f : 0.75f;
        col.x = col.x * col.w + bg * (1.0f - col.w);
        col.y = col.y * col.w + bg * (1.0f - col.w);
        col.z = col.z * col.w + bg * (1.0f - col.w);
        img.setRGB(x, y, Utils.floatRGBToINTColor(col.x, col.y, col.z));
View Full Code Here

  public void refreshGradientImage() {
    for (int y = 0; y < gradientImage.getHeight(); y++) {
      for (int x = 0; x < gradientImage.getWidth(); x++) {
        float pos = (float) x / (float) gradientImage.getWidth();

        Vector4 col = m_ActiveGradient.getColor(pos);

        if (y < 8) { // convert to grayscale preview
          float c = (col.x + col.y + col.z) * (1.0f / 3.0f);
          col.x = col.y = col.z = c;
        } else { // if (y < 16) { // color with alpha preview
View Full Code Here

    } else if (command.equals("Random")) {
      ms_Presets.get(0).updateGradient(m_ActiveGradient); // remember the old one at the first position
      m_ActiveGradient.clear();
      int num = 4;
      for (int i = 0; i < num; i++) {
        m_ActiveGradient.addEntry(new Vector4(FMath.random(), FMath.random(), FMath.random(), 1.0f), i/(float)(num-1));
      }
      setColorGradient(m_ActiveGradient);
    } else if (command.equals("Darken All")) {
      for (int i = 0; i < m_ActiveGradient.getNumEntries(); i++) {
        m_ActiveGradient.getEntryColor(i).multComp_ip(0.8f,0.8f,0.8f,1.0f);
View Full Code Here

      System.err.println("Invalid channel access in " + this);
    return OutputType.SCALAR;
  }

  private final Vector4 _function(Vector4 in0, Vector4 normalmap) {
    normalmap.add_ip(new Vector4(-0.5f));
    normalmap.mult_ip(2.0f);
    Vector3 lightDir = new Vector3();
    lightDir.setDir(theta.get() * (FMath.PI / 180.0f), phi.get() * (FMath.PI / 180.0f));

    Vector3 reflect = (new Vector3(0, 0, -1)).reflect(normalmap.getVector3());
View Full Code Here

  protected void cache_function(Vector4 out, TileCacheEntry[] caches, int localX, int localY, float u, float v) {
    _function(out, caches[0].sample(localX, localY), caches[1].sample(localX, localY), caches[2].sample(localX, localY), caches[3].sample(localX, localY));
  }
   
  protected Vector4 _valueRGBA(float u, float v) {
    Vector4 c0 = inputChannels[0].valueRGBA(u, v);
    Vector4 c1 = inputChannels[1].valueRGBA(u, v);
    Vector4 c2 = inputChannels[2].valueRGBA(u, v);
    Vector4 c3 = inputChannels[3].valueRGBA(u, v);
    Vector4 ret = new Vector4();

    _function(ret, c0, c1, c2, c3);
   
    return ret;
  }
View Full Code Here

    else System.err.println("Invalid channel access in " + this);
    return OutputType.SCALAR;
  }

  private final Vector4 _function(Vector4 in0, float u, float v) {
    Vector4 c = new Vector4(in0);
    float m = modulus.get();
    float s = normalize.get() ? 1f / m : 1f;
    float bias = u * m * xBias.get();
    c.x = Math.max(0.0f, Math.min(1.0f, ((c.x + bias) % m) * s));
    c.y = Math.max(0.0f, Math.min(1.0f, ((c.y + bias) % m) * s));
 
View Full Code Here

    out.set(_function(caches[0].sample(localX, localY), u, v));
  }


  protected Vector4 _valueRGBA(float u, float v) {
    Vector4 c0 = inputChannels[0].valueRGBA(u, v);
    return _function(c0, u, v);
  }
View Full Code Here

    return OutputType.RGBA;
  }
 
 
  private Vector4 performFilter(Vector4 out, TileCacheEntry[] caches, float u, float v) {
    Vector4 val = new Vector4();
   
    float r = radius.get()/100.0f;
    float weightSum = 0.0f;
   
    float rotU = FMath.cos(FMath.PI*angle.get()/180.0f);
    float rotV = FMath.sin(FMath.PI*angle.get()/180.0f);
   
    if (weightFunction.getEnumPos() == 0 && r > 0.0f) { // Gaussian
      for (int i = 0; i < numSamples.get(); i++) {
        float du = (FMath.radicalInverse_vdC(2, i)*2.0f - 1.0f)*r;
        float dv = (FMath.radicalInverse_vdC(3, i)*2.0f - 1.0f)*r;
        // apply anisotropy
        du *= (1.0f - anisotropy.get());
        float nu = du*rotU - dv*rotV;
        float nv = dv*rotU + du*rotV;
        du = nu;
        dv = nv;

        float l = FMath.sqrt(du*du + dv*dv);
        float w = FMath.exp(-(l/r));
       
       
        if (caches != null) val.add_ip(caches[0].sample_Normalized(du+u, dv+v).mult_ip(w));
        else val.add_ip(inputChannels[0].valueRGBA(du+u, dv+v).mult_ip(w));
        weightSum += w;
      }
    } else { // Box
      for (int i = 0; i < numSamples.get(); i++) {
        float du = (FMath.radicalInverse_vdC(2, i)*2.0f - 1.0f)*r;
        float dv = (FMath.radicalInverse_vdC(3, i)*2.0f - 1.0f)*r;
        // apply anisotropy
        du *= (1.0f - anisotropy.get());
        float nu = du*rotU - dv*rotV;
        float nv = dv*rotU + du*rotV;
        du = nu;
        dv = nv;

        if (caches != null) val.add_ip(caches[0].sample_Normalized(du+u, dv+v));
        else val.add_ip(inputChannels[0].valueRGBA(du+u, dv+v));
        weightSum += 1.0f;
      }
   
    }
   
    val.mult_ip(1.0f/weightSum);
    if (out != null) out.set(val);
    return val;
  }
View Full Code Here

TOP

Related Classes of engine.base.Vector4

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.