1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.cts.verifier.sensors.sixdof.Utils.Path.PathUtilityClasses; 17 18 import com.android.cts.verifier.sensors.sixdof.Renderer.Renderable.RingRenderable; 19 20 import java.util.ArrayList; 21 22 /** 23 * Ring object, contains all the information about a ring. 24 */ 25 public class Ring { 26 private final float[] mLocation; 27 private final ArrayList<float[]> mRectangleHitBox; 28 private final float[] mRotation; 29 private final int mPathNumber; 30 private boolean mEntered; 31 private RingRenderable mRingRenderable; 32 private boolean mSoundPlayed = false; 33 34 /** 35 * Constructor to the ring. The ring is always initialised to not entered. 36 * 37 * @param location the location of the center of the ring 38 * @param pathNumber the path that the ring is located along 39 * @param rotation the orientation of the ring 40 * @param rectangleHitBox the four corners of the rectangular hit box covered by the ring in a 41 * top down view 42 */ Ring(float[] location, int pathNumber, float[] rotation, ArrayList<float[]> rectangleHitBox)43 public Ring(float[] location, int pathNumber, 44 float[] rotation, ArrayList<float[]> rectangleHitBox) { 45 mLocation = location; 46 mEntered = false; 47 mPathNumber = pathNumber; 48 mRotation = rotation; 49 mRectangleHitBox = rectangleHitBox; 50 mSoundPlayed = false; 51 } 52 53 /** 54 * Sets whether the ring has been entered or not. 55 * 56 * @param entered true if the ring is entered, false if the ring has not been entered 57 */ setEntered(boolean entered)58 public void setEntered(boolean entered) { 59 mEntered = entered; 60 } 61 62 /** 63 * Sets whether the sound has been played or not. 64 * 65 * @param soundPlayed the state of whether the sound has been played or not 66 */ setSoundPlayed(boolean soundPlayed)67 public void setSoundPlayed(boolean soundPlayed) { 68 mSoundPlayed = soundPlayed; 69 } 70 71 /** 72 * Returns the location if the center of the ring. 73 */ getLocation()74 public float[] getLocation() { 75 return mLocation; 76 } 77 78 /** 79 * Returns the path the ring is located along. 80 */ getPathNumber()81 public int getPathNumber() { 82 return mPathNumber; 83 } 84 85 /** 86 * Returns the coordinates of the four corners of the rectangular hit box. 87 */ getRectangleHitBox()88 public ArrayList<float[]> getRectangleHitBox() { 89 return new ArrayList<>(mRectangleHitBox); 90 } 91 92 /** 93 * Returns the orientation the ring is at. 94 */ getRingRotation()95 public float[] getRingRotation() { 96 return mRotation; 97 } 98 99 /** 100 * Returns true if the ring had been entered, false if the ring has not been entered. 101 */ isEntered()102 public boolean isEntered() { 103 return mEntered; 104 } 105 getRingRenderable()106 public RingRenderable getRingRenderable() { 107 return mRingRenderable; 108 } 109 110 /** 111 * Returns true if the sound has been played, false if the sound has not been played. 112 */ isSoundPlayed()113 public boolean isSoundPlayed() { 114 return mSoundPlayed; 115 } 116 setRingRenderable(RingRenderable mRingRenderable)117 public void setRingRenderable(RingRenderable mRingRenderable) { 118 this.mRingRenderable = mRingRenderable; 119 } 120 } 121