1 /* 2 * Copyright 2024 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 17 package androidx.xr.scenecore 18 19 import androidx.annotation.IntDef 20 import androidx.annotation.RestrictTo 21 22 /** 23 * Dimensions of a 3D object. 24 * 25 * @param width Width. 26 * @param height Height. 27 * @param depth Depth. 28 */ 29 @Suppress("DataClassDefinition") 30 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) 31 public data class Dimensions( 32 public val width: Float = 0f, 33 public val height: Float = 0f, 34 public val depth: Float = 0f, 35 ) { toStringnull36 override fun toString(): String { 37 return super.toString() + ": w $width x h $height x d $depth" 38 } 39 } 40 41 /** 42 * Dimensions of a 2D surface in Pixels. 43 * 44 * @param width Integer Width. 45 * @param height Integer Height. 46 */ 47 @Suppress("DataClassDefinition") 48 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) 49 public data class PixelDimensions(public val width: Int = 0, public val height: Int = 0) { toStringnull50 override fun toString(): String { 51 return super.toString() + ": w $width x h $height" 52 } 53 } 54 55 /** 56 * The angles (in radians) representing the sides of the view frustum. These are not expected to 57 * change over the lifetime of the session but in rare cases may change due to updated camera 58 * settings. 59 */ 60 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) 61 public class Fov( 62 public val angleLeft: Float, 63 public val angleRight: Float, 64 public val angleUp: Float, 65 public val angleDown: Float, 66 ) { 67 equalsnull68 override fun equals(other: Any?): Boolean { 69 if (this === other) return true 70 if (other !is Fov) return false 71 72 return angleLeft == other.angleLeft && 73 angleRight == other.angleRight && 74 angleUp == other.angleUp && 75 angleDown == other.angleDown 76 } 77 hashCodenull78 override fun hashCode(): Int { 79 var result = angleLeft.hashCode() 80 result = 31 * result + angleRight.hashCode() 81 result = 31 * result + angleUp.hashCode() 82 result = 31 * result + angleDown.hashCode() 83 return result 84 } 85 toStringnull86 override fun toString(): String { 87 return "Fov(angleLeft=$angleLeft, angleRight=$angleRight, angleUp=$angleUp, angleDown=$angleDown)" 88 } 89 90 @JvmOverloads copynull91 public fun copy( 92 angleLeft: Float = this.angleLeft, 93 angleRight: Float = this.angleRight, 94 angleUp: Float = this.angleUp, 95 angleDown: Float = this.angleDown, 96 ): Fov { 97 return Fov(angleLeft, angleRight, angleUp, angleDown) 98 } 99 } 100 101 /** Type of plane based on orientation i.e. Horizontal or Vertical. */ 102 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) 103 public object PlaneType { 104 public const val HORIZONTAL: Int = 0 105 public const val VERTICAL: Int = 1 106 public const val ANY: Int = 2 107 } 108 109 @RestrictTo(RestrictTo.Scope.LIBRARY) 110 @Retention(AnnotationRetention.SOURCE) 111 @IntDef(PlaneType.HORIZONTAL, PlaneType.VERTICAL, PlaneType.ANY) 112 @Target(AnnotationTarget.TYPE, AnnotationTarget.PROPERTY, AnnotationTarget.VALUE_PARAMETER) 113 internal annotation class PlaneTypeValue 114 115 /** Semantic plane types. */ 116 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) 117 public object PlaneSemantic { 118 public const val WALL: Int = 0 119 public const val FLOOR: Int = 1 120 public const val CEILING: Int = 2 121 public const val TABLE: Int = 3 122 public const val ANY: Int = 4 123 } 124 125 @RestrictTo(RestrictTo.Scope.LIBRARY) 126 @Retention(AnnotationRetention.SOURCE) 127 @IntDef( 128 PlaneSemantic.WALL, 129 PlaneSemantic.FLOOR, 130 PlaneSemantic.CEILING, 131 PlaneSemantic.TABLE, 132 PlaneSemantic.ANY, 133 ) 134 @Target(AnnotationTarget.TYPE, AnnotationTarget.PROPERTY, AnnotationTarget.VALUE_PARAMETER) 135 internal annotation class PlaneSemanticValue 136