ch.dieseite.colladaloader.asmbeans

## Class ASUtils

- java.lang.Object
- - ch.dieseite.colladaloader.asmbeans.ASUtils

-     public class ASUtils
      extends java.lang.Object

  This class contains utility tools for all common or proprietary assembling classes.

  This source is free; you can redistribute it and/or modify it under the terms of the GNU General Public License and by nameing of the originally author

  Version:
    3.1
  Author:
    Markus Zimmermann http://www.die-seite.ch

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `ASUtils.Point2D` cloneable Wrapper
    `(package private) static class` | `ASUtils.Point3D` cloneable Wrapper

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ASUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>` | `back(SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> record, int depth)` jump (n = depth) times to previous record It uses the "Record.info.back" field for it.
    `static SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>` | `childBySearch(SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> parent, java.lang.String searchPtrn)` returns the first match of the children from current Record that matches to search pattern.
    `static int[]` | `demuxPArray(int[] pArray, int offset, int muxCnt)` extract from a multiplexed <p> array the required indices for a Point2D or Point3D array
    `static SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>` | `execArgs(java.lang.String args, SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> r)` runs childBySearch() back() and next() in args order.
    `static <T> T` | `getParam(java.util.ArrayList<DataAssembler.Param> p, int index)` returns and casts the nth param value from param list
    `static PImage` | `loadTexture(java.lang.String texName, java.lang.String daeFile)` loads a PImage from file using Processing API
    `static SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>` | `next(SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> record, int depth)` jump (n = depth) times to next record (NOT into Children) It uses the "Record.info.next" field for it.
    `static ASUtils.Point2D[]` | `to2DPoints(float[] floatarray, float width, float height)` converts a collada <float_array> into 2D Texture Points.
    `static ASUtils.Point3D[]` | `to3DPoints(float[] floatarray)` converts a collada <float_array> into 3D Points.
    `static float[]` | `toFloats(java.lang.String floatArray)` converts float values from string separated by " " (space) to an Array of floats
    `static int[]` | `toInts(java.lang.String intArray)` converts int values from string separated by " " (space) to an Array of integer

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ASUtils

          public ASUtils()

  - ### Method Detail

    - #### next

          public static SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> next(SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> record,
                                                                                         int depth)

      jump (n = depth) times to next record (NOT into Children) It uses the "Record.info.next" field for it. If this is null then jumping is aborted with a null return
      Parameters:
        `current` - record
        `depth` -
      Returns:
        null if depth too high

    - #### childBySearch

          public static SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> childBySearch(SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> parent,
                                                                                                  java.lang.String searchPtrn)

      returns the first match of the children from current Record that matches to search pattern. A pattern syntax can be a collada tag name or tag name plus attribute criteria
      Parameters:
        `current` - record
        `searchPtrn` - either "tagname" or "tagname#attribute=value"
      Returns:
        null if nothing found

    - #### execArgs

          public static SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> execArgs(java.lang.String args,
                                                                                             SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> r)

      runs childBySearch() back() and next() in args order. The syntax format for each argument is "[[j][b] depth][c tagname]" separated by one space char

      commands j = next, c = childBySearch, b = back

      an Example can be: "j 2 c instance_effect j 1"

      Parameters:
        `args` -
        `current` - record
      Returns:

    - #### back

          public static SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> back(SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> record,
                                                                                         int depth)

      jump (n = depth) times to previous record It uses the "Record.info.back" field for it. If this is null then jumping is aborted with a null returns
      Parameters:
        `current` - record
        `depth` -
      Returns:
        null if depth too high

    - #### toFloats

          public static float[] toFloats(java.lang.String floatArray)

      converts float values from string separated by " " (space) to an Array of floats
      Parameters:
        `floatArray` -
      Returns:

    - #### toInts

          public static int[] toInts(java.lang.String intArray)

      converts int values from string separated by " " (space) to an Array of integer
      Parameters:
        `intArray` -
      Returns:

    - #### loadTexture

          public static PImage loadTexture(java.lang.String texName,
                                           java.lang.String daeFile)

      loads a PImage from file using Processing API
      Parameters:
        `image` - file name, relative to collada file path (i.e untitled/texture0.jpg)
        `collada` - file path, relative to "data" path (i.e models/untitled.dae)
      Returns:
        a new image

    - #### to3DPoints

          public static ASUtils.Point3D[] to3DPoints(float[] floatarray)

      converts a collada <float_array> into 3D Points. Its also doing a coordinate convert from Collada to processing. Creates cloneable Points

      per definition is:

      processing x = Collada x

      processing y = Collada -z

      processing z = Collada -y

      Parameters:
        `floatarray` -
      Returns:
        a converted drawable 3DPoint Array

    - #### to2DPoints

          public static ASUtils.Point2D[] to2DPoints(float[] floatarray,
                                                     float width,
                                                     float height)

      converts a collada <float_array> into 2D Texture Points. Its also doing a coordinate convert from collada to processing.Creates cloneable Points

      per definition is:

      textureProcessing x = textureSketchup x * picture.width

      textureProcessing y = picture.height - textureSketchup y * picture.height

      Parameters:
        `floatarray` -
        `imageWidth` -
        `imageHeight` -
      Returns:
        a converted drawable 2DPoint Array

    - #### demuxPArray

          public static int[] demuxPArray(int[] pArray,
                                          int offset,
                                          int muxCnt)

      extract from a multiplexed <p> array the required indices for a Point2D or Point3D array
      Parameters:
        `pArray` - (=all indices values from <p> tag)
        `offset` - (= attribute value from collada <input> tag)
        `muxCnt` - (=how many float arrays is packed/multiplexed in <p> tag resp. in pArray)
      Returns:
        indices for access a raw Point[] array correctly

    - #### getParam

          public static <T> T getParam(java.util.ArrayList<DataAssembler.Param> p,
                                       int index)

      returns and casts the nth param value from param list
      Parameters:
        `p` -
        `index` -
      Returns: