Package com.ngt.jopenmetaverse.shared.types

Examples of com.ngt.jopenmetaverse.shared.types.Color4


      for (int x = 0; x < 256; x++)
      {
        float normHeight = heightmap[x][y] / 255f;
        normHeight = Utils.clamp(normHeight, BASE_HSV_V, 1.0f);
        //        System.out.print(normHeight + " ");
        Color4 color = Color4.fromHSV(BASE_HSV_H, BASE_HSV_S, normHeight);

        //        int k = y*256 + x;
        int pixel = (int)(color.getB() * 255f) | ( ((int)(color.getG() * 255f)) << 8) | ( ((int)(color.getR() * 255f)) <<  16) | (0xff << 24);  
        bitmap.setRGB(x, y, pixel);

        //                        byte* ptr = (byte*)bitmapData.Scan0 + y * bitmapData.Stride + x * 3;
        //                        *(ptr + 0) = (byte)(color.B * 255f);
        //                        *(ptr + 1) = (byte)(color.G * 255f);
 
View Full Code Here


      if (teFace == null)
        continue;

      // Don't render transparent faces
      Color4 RGBA = teFace.getRGBA();

      if (data.TextureInfo.FullAlpha || RGBA.getA() <= 0.01f) continue;

      boolean switchedLightsOff = false;

      if (pass == RenderPass.Picking)
      {
        data.PickingID = pickingID;
        byte[] primNrBytes = new byte[2];
        Utils.uint16ToBytes(pickingID, primNrBytes, 0);
        //                    byte[] faceColor = new byte[] { primNrBytes[0], primNrBytes[1], (byte)j, (byte)255 };
        GL11.glColor4f( primNrBytes[0], primNrBytes[1], (byte)j, (byte)255);
      }
      else if (pass == RenderPass.Invisible)
      {
        if (!data.TextureInfo.IsInvisible) continue;
        HasInvisibleFaces = true;
      }
      else
      {
        //        System.out.println("Pass is Simple..");
        if (data.TextureInfo.IsInvisible)
        {
          System.out.println("Primitive is invisible.. so skipping texturing...");
          continue;
        }
        boolean belongToAlphaPass = (RGBA.getA() < 0.99f) || (data.TextureInfo.HasAlpha && !data.TextureInfo.IsMask);
        //TODO only for debugging
        if (belongToAlphaPass && pass != RenderPass.Alpha) continue;
        if (!belongToAlphaPass && pass == RenderPass.Alpha) continue;

        //        System.out.println("Going to Activate Texture");

        if (pass == RenderPass.Simple)
        {
          HasSimpleFaces = true;
        }
        else if (pass == RenderPass.Alpha)
        {
          HasAlphaFaces = true;
        }

        if (teFace.getFullbright())
        {
          GL11.glDisable(GL11.GL_LIGHTING );
          switchedLightsOff = true;
        }

        float shiny = 0f;
        switch (teFace.getShiny())
        {
        case High:
          shiny = 0.96f;
          break;

        case Medium:
          shiny = 0.64f;
          break;

        case Low:
          shiny = 0.24f;
          break;
        }

        if (shiny > 0f)
        {
          //TODO need to handle
          //                        scene.StartShiny();
        }
        GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, shiny);
        GL11.glColor4f(RGBA.getR(), RGBA.getG(), RGBA.getB(), RGBA.getA());

        //Optmized by keeping a instance buffer, as materialData is constant
        //        float[] materialData = new float[] { 0.5f, 0.5f, 0.5f, 1f };
        //        final FloatBuffer materialDataBuffer = ByteBuffer
        //            .allocateDirect(materialData.length*4).order(ByteOrder.nativeOrder()).asFloatBuffer();
 
View Full Code Here

  /// passed as list of ColorParamInfo tuples</param>
  /// <returns>Base color/tint for the wearable</returns>
  private Color4 GetColorFromParams(List<ColorParamInfo> param)
  {
    // Start off with a blank slate, black, fully transparent
    Color4 res = new Color4(0, 0, 0, 0);

    // Apply color modification from each color parameter
    for (ColorParamInfo p : param)
    {
      int n = p.VisualColorParam.Colors.length;

      Color4 paramColor = new Color4(0, 0, 0, 0);

      if (n == 1)
      {
        // We got only one color in this param, use it for application
        // to the final color
        paramColor = p.VisualColorParam.Colors[0];
      }
      else if (n > 1)
      {
        // We have an array of colors in this parameter
        // First, we need to find out, based on param value
        // between which two elements of the array our value lands

        // Size of the step using which we iterate from Min to Max
        float step = (p.VisualParam.MaxValue - p.VisualParam.MinValue) / ((float)n - 1);

        // Our color should land inbetween colors in the array with index a and b
        int indexa = 0;
        int indexb = 0;

        int i = 0;

        for (float a = p.VisualParam.MinValue; a <= p.VisualParam.MaxValue; a += step)
        {
          if (a <= p.Value)
          {
            indexa = i;
          }
          else
          {
            break;
          }

          i++;
        }

        // Sanity check that we don't go outside bounds of the array
        if (indexa > n - 1)
          indexa = n - 1;

        indexb = (indexa == n - 1) ? indexa : indexa + 1;

        // How far is our value from Index A on the
        // line from Index A to Index B
        float distance = p.Value - (float)indexa * step;

        // We are at Index A (allowing for some floating point math fuzz),
        // use the color on that index
        if (distance < 0.00001f || indexa == indexb)
        {
          paramColor = p.VisualColorParam.Colors[indexa];
        }
        else
        {
          // Not so simple as being precisely on the index eh? No problem.
          // We take the two colors that our param value places us between
          // and then find the value for each ARGB element that is
          // somewhere on the line between color1 and color2 at some
          // distance from the first color
          Color4 c1 = paramColor = p.VisualColorParam.Colors[indexa];
          Color4 c2 = paramColor = p.VisualColorParam.Colors[indexb];

          // Distance is some fraction of the step, use that fraction
          // to find the value in the range from color1 to color2
          paramColor = Color4.lerp(c1, c2, distance / step);
        }
View Full Code Here

          }
        }
      }
    }

    Color4 wearableColor = Color4.White; // Never actually used
    if (colorParams.size() > 0)
    {
      wearableColor = GetColorFromParams(colorParams);
      JLogger.debug("Setting tint " + wearableColor + " for " + wearable.WearableType);
    }
View Full Code Here

        /// <param name="pos"></param>
        public LightData(byte[] data, int pos)
        {
            if (data.length - pos >= 16)
            {
                Color = new Color4(data, pos, false);
                Radius = Utils.bytesToFloatLit(data, pos + 4);
                Cutoff = Utils.bytesToFloatLit(data, pos + 8);
                Falloff = Utils.bytesToFloatLit(data, pos + 12);

                // Alpha in color is actually intensity
View Full Code Here

        public byte[] GetBytes()
        {
            byte[] data = new byte[16];

            // Alpha channel in color is intensity
            Color4 tmpColor = Color;
            tmpColor.setA(Intensity);
            System.arraycopy(tmpColor.getBytes(), 0, data, 0, 4);
            System.arraycopy(Utils.floatToBytesLit(Radius), 0, data, 4, 4);
            System.arraycopy(Utils.floatToBytesLit(Cutoff), 0, data, 8, 4);
            System.arraycopy(Utils.floatToBytesLit(Falloff), 0, data, 12, 4);
            return data;
        }
View Full Code Here

            {
                OSDMap map = (OSDMap)osd;

                TextureEntryFace face = new TextureEntryFace(defaultFace);
                faceNumber[0] = (map.containsKey("face_number")) ? map.get("face_number").asInteger() : -1;
                Color4 rgba = face.getRGBA();
                rgba = ((OSDArray)map.get("colors")).asColor4();
                face.setRGBA(rgba);
                face.setRepeatU((float)map.get("scales").asReal());
                face.setRepeatV((float)map.get("scalet").asReal());
                face.setOffsetU((float)map.get("offsets").asReal());
View Full Code Here

            }

            public Object clone()
            {
                TextureEntryFace ret = new TextureEntryFace(this.DefaultTexture == null ? null : (TextureEntryFace)this.DefaultTexture.clone());
                ret.rgba = new Color4(rgba);
                ret.repeatU = repeatU;
                ret.repeatV = repeatV;
                ret.offsetU = offsetU;
                ret.offsetV = offsetV;
                ret.rotation = rotation;
View Full Code Here

//                sb.append(String.format("\nTextureEntry Texture End: \n%s", Utils.bytesToHexDebugString(ArrayUtils.subarray(data, i[0], data.length),  "")));

                //endregion Texture

                //region Color
                DefaultTexture.setRGBA(new Color4(data, i[0], true));
                i[0] += 4;

                while (ReadFaceBitfield(data, i, faceBits, bitfieldSize))
                {
                    Color4 tmpColor = new Color4(data, i[0], true);
                    i[0] += 4;

                    for (int face = 0, bit = 1; face < bitfieldSize[0]; face++, bit <<= 1)
                        if ((faceBits[0] & bit) != 0)
                            CreateFace(face).setRGBA(tmpColor);
View Full Code Here

        return quaternion;
    }

    public  Color4 asColor4()
    {
        Color4 color = Color4.Black;

        if (this.count()== 4)
        {
            color.setR((float)this.get(0).asReal());
            color.setG((float)this.get(1).asReal());
            color.setB((float)this.get(2).asReal());
            color.setA((float)this.get(3).asReal());
        }

        return color;
    }
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.types.Color4

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.