コード例 #1
0
ファイル: Fence.java プロジェクト: rmelton/ChefX3D
  public void initialize() {
    // System.out.println("Creating Fence geometry");
    int num = 0;
    int len = startField.getSize();
    float[] start = new float[3];
    float[] end = new float[3];
    float height;

    // One shape for a panel, panelTop and post, post Top
    int shape_groups = 4;

    int num_panels = len;
    int num_panels_per_shape = fencesPerShapeField.getValue();
    int num_shapes = (num_panels / num_panels_per_shape) * shape_groups;
    int num_posts_per_shape = num_panels_per_shape;

    // System.out.println("Number of posts: " + len);
    // System.out.println("Number of panels: " + num_panels);
    // System.out.println("Number of shapes: " + num_shapes);
    // System.out.println("Number of panels per shape: " + num_panels_per_shape);
    // System.out.println("Number of posts per shape: " + num_posts_per_shape);

    X3DNode[] shapes = new X3DNode[num_shapes];

    X3DExecutionContext mainScene = browser.getExecutionContext();

    // Create a common Appearance to share

    X3DNode[] appearances = new X3DNode[appearanceField.getSize()];
    appearanceField.getValue(appearances);

    X3DNode panel_appearance = appearances[panelAppearanceField.getValue()];
    X3DNode panelTop_appearance = appearances[panelTopAppearanceField.getValue()];
    X3DNode panelRail_appearance = appearances[panelRailAppearanceField.getValue()];
    X3DNode post_appearance = appearances[postAppearanceField.getValue()];
    X3DNode postTop_appearance = appearances[postTopAppearanceField.getValue()];

    int shape_idx = 0;

    // Create Panels

    X3DNode[] new_shapes =
        createSegmentGeom(
            mainScene,
            panel_appearance,
            postField,
            postGeometryField,
            panelHeightField,
            startField,
            endField,
            false,
            null,
            len,
            (num_shapes / shape_groups),
            num_posts_per_shape,
            true,
            true,
            1,
            1);

    for (int i = 0; i < new_shapes.length; i++) {
      shapes[shape_idx++] = new_shapes[i];
    }

    // Create PanelTops
    new_shapes =
        createSegmentGeom(
            mainScene,
            panelTop_appearance,
            postField,
            postGeometryField,
            panelTopHeightField,
            startField,
            endField,
            true,
            panelHeightField,
            len,
            (num_shapes / shape_groups),
            num_posts_per_shape,
            true,
            true,
            15,
            10);

    for (int i = 0; i < new_shapes.length; i++) {
      X3DNode panel_shape = mainScene.createNode("Shape");
      shapes[shape_idx++] = new_shapes[i];
    }

    // Create Posts
    new_shapes =
        createVertexGeom(
            mainScene,
            post_appearance,
            postField,
            postGeometryField,
            postSizeField,
            startField,
            endField,
            false,
            null,
            (num_shapes / shape_groups),
            num_posts_per_shape);

    for (int i = 0; i < new_shapes.length; i++) {
      X3DNode panel_shape = mainScene.createNode("Shape");
      shapes[shape_idx++] = new_shapes[i];
    }

    // Create PostTops
    new_shapes =
        createVertexGeom(
            mainScene,
            postTop_appearance,
            postTopField,
            postTopGeometryField,
            postTopSizeField,
            startField,
            endField,
            true,
            postSizeField,
            (num_shapes / shape_groups),
            num_posts_per_shape);

    for (int i = 0; i < new_shapes.length; i++) {
      shapes[shape_idx++] = new_shapes[i];
    }

    childrenField.setValue(shapes.length, shapes);

    // System.out.println("Done creating fence geometry");
  }
コード例 #2
0
 /**
  * Return the topTexture value in the argument X3DNode[]
  *
  * @param val The X3DNode[] to initialize.
  */
 public void getTopTexture(X3DNode[] val) {
   if (topTexture == null) {
     topTexture = (MFNode) getField("topTexture");
   }
   topTexture.getValue(val);
 }
コード例 #3
0
 /**
  * Return the textureTransform value in the argument X3DNode[]
  *
  * @param val The X3DNode[] to initialize.
  */
 public void getTextureTransform(X3DNode[] val) {
   if (textureTransform == null) {
     textureTransform = (MFNode) getField("textureTransform");
   }
   textureTransform.getValue(val);
 }
コード例 #4
0
 /**
  * Return the bottomTexture value in the argument X3DNode[]
  *
  * @param val The X3DNode[] to initialize.
  */
 public void getBottomTexture(X3DNode[] val) {
   if (bottomTexture == null) {
     bottomTexture = (MFNode) getField("bottomTexture");
   }
   bottomTexture.getValue(val);
 }
コード例 #5
0
 /**
  * Return the rightTexture value in the argument X3DNode[]
  *
  * @param val The X3DNode[] to initialize.
  */
 public void getRightTexture(X3DNode[] val) {
   if (rightTexture == null) {
     rightTexture = (MFNode) getField("rightTexture");
   }
   rightTexture.getValue(val);
 }
コード例 #6
0
 /**
  * Return the leftTexture value in the argument X3DNode[]
  *
  * @param val The X3DNode[] to initialize.
  */
 public void getLeftTexture(X3DNode[] val) {
   if (leftTexture == null) {
     leftTexture = (MFNode) getField("leftTexture");
   }
   leftTexture.getValue(val);
 }
コード例 #7
0
 /**
  * Return the frontTexture value in the argument X3DNode[]
  *
  * @param val The X3DNode[] to initialize.
  */
 public void getFrontTexture(X3DNode[] val) {
   if (frontTexture == null) {
     frontTexture = (MFNode) getField("frontTexture");
   }
   frontTexture.getValue(val);
 }
コード例 #8
0
 /**
  * Return the backTexture value in the argument X3DNode[]
  *
  * @param val The X3DNode[] to initialize.
  */
 public void getBackTexture(X3DNode[] val) {
   if (backTexture == null) {
     backTexture = (MFNode) getField("backTexture");
   }
   backTexture.getValue(val);
 }