Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Commit

Permalink
GVR Android SDK v1.70.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cyisrael committed Jul 13, 2017
1 parent a27f768 commit e4eeb86
Show file tree
Hide file tree
Showing 42 changed files with 186 additions and 71 deletions.
Binary file modified apks/controller_emulator.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ task clean(type: Delete) {
// The dependencies for NDK builds live inside the .aar files so they need to
// be extracted before NDK targets can build.
task extractAudioSo(type: Copy) {
from zipTree("${project.rootDir}/libraries/sdk-audio-1.60.1.aar")
from zipTree("${project.rootDir}/libraries/sdk-audio-1.70.0.aar")
into "${project.rootDir}/libraries/"
include "jni/**/libgvr_audio.so"
}

task extractGvrSo(type: Copy) {
from zipTree("${project.rootDir}/libraries/sdk-base-1.60.1.aar")
from zipTree("${project.rootDir}/libraries/sdk-base-1.70.0.aar")
into "${project.rootDir}/libraries/"
include "jni/**/libgvr.so"
}
Expand Down
11 changes: 7 additions & 4 deletions libraries/headers/vr/gvr/capi/include/gvr.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extern "C" {
/// right_eye_matrix);
/// AppSetRenderTarget(primary_display);
///
/// gvr_frame_submit(&frame, viewport_list, head_matrix);
/// gvr_frame_submit(&frame, viewport_list, head_view);
/// }
///
/// // Cleanup memory.
Expand Down Expand Up @@ -219,8 +219,7 @@ void gvr_destroy(gvr_context** gvr);

/// Initializes necessary GL-related objects and uses the current thread and
/// GL context for rendering. Please make sure that a valid GL context is
/// available when this function is called. This should never be called more
/// than once on the same GL context (doing so would cause resource leaks).
/// available when this function is called.
///
/// @param gvr Pointer to the gvr instance to be initialized.
void gvr_initialize_gl(gvr_context* gvr);
Expand Down Expand Up @@ -689,6 +688,10 @@ void gvr_swap_chain_resize_buffer(gvr_swap_chain* swap_chain, int32_t index,
/// is finished and all its constituent buffers are ready, call
/// gvr_frame_submit() to display it while applying lens distortion.
///
/// When this is called, the current thread's GL context must be the same
/// context that was current when gvr_initialize_gl() was called, or at least be
/// in a share group with the initialization context.
///
/// @param swap_chain The swap chain.
/// @return Handle to the acquired frame. NULL if the swap chain is invalid,
/// or if acquire has already been called on this swap chain.
Expand Down Expand Up @@ -1542,7 +1545,7 @@ class SwapChain {
/// AppDoSomeRenderingForEye(
/// right_eye_viewport.GetSourceUv(), right_eye_view);
/// frame.Unbind();
/// frame.Submit(viewport_list, head_matrix);
/// frame.Submit(viewport_list, head_view);
/// }
///
class GvrApi {
Expand Down
75 changes: 66 additions & 9 deletions libraries/headers/vr/gvr/capi/include/gvr_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ extern "C" {
/// NOTE: If a sound object, soundfield or stereo sound is created with a file
/// that has not been preloaded, that audio will be streamed.
///
/// **Spatializtion of sound objects**
/// **Spatialization of sound objects**
///
/// The GVR Audio System allows the user to create virtual sound objects which
/// can be placed anywhere in space around the listener.
Expand All @@ -149,6 +149,23 @@ extern "C" {
/// gvr_audio_set_sound_volume(gvr_audio_context* api,
/// gvr_audio_source_id source_id, float volume);
///
/// The GVR Audio System also support directivity patterns per sound source
/// which define a shape or pattern that describes the way in which sound
/// emanates from a source in different directions. The directivity pattern
/// takes two values: alpha and order. Alpha is a weighting balance between a
/// figure-8 pattern and omnidirectional pattern for source emission in the
/// range [0, 1]. A value of 0.5 results in a cardioid pattern. Order is applied
/// to computed directivity. Higher values will result in narrower and sharper
/// directivity patterns, with a range of [1, inf).
///
/// void gvr_audio_set_sound_object_directivity(
/// gvr_audio_context* api, gvr_audio_source_id sound_object_id,
/// float alpha, float order);
///
/// void gvr_audio_set_sound_object_rotation(
/// gvr_audio_context* api, gvr_audio_source_id sound_object_id,
/// gvr_quatf sound_object_rotation);
///
/// The behavior of Sound Objects with respect to their distance from the
/// listener can be controlled via calls to the following method:
///
Expand Down Expand Up @@ -424,8 +441,9 @@ void gvr_audio_unload_soundfile(gvr_audio_context* api, const char* filename);
///
/// @param api Pointer to a gvr_audio_context.
/// @param filename The path/name of the file to be played.
/// @return Id of new sound object. Returns kInvalidId if the sound file has not
/// been preloaded or if the number of input channels is > 1.
/// @return Id of new sound object. Returns GVR_AUDIO_INVALID_SOURCE_ID if the
/// sound file has not been preloaded or if the number of input channels
/// is > 1.
gvr_audio_source_id gvr_audio_create_sound_object(gvr_audio_context* api,
const char* filename);

Expand All @@ -435,9 +453,9 @@ gvr_audio_source_id gvr_audio_create_sound_object(gvr_audio_context* api,
///
/// @param api Pointer to a gvr_audio_context.
/// @param filename The path/name of the file to be played.
/// @return Id of new soundfield. Returns kInvalidId if the sound file has not
/// been preloaded or if the number of input channels does not match that
/// required.
/// @return Id of new soundfield. Returns GVR_AUDIO_INVALID_SOURCE_ID if the
/// sound file has not been preloaded or if the number of input channels
/// does not match that required.
gvr_audio_source_id gvr_audio_create_soundfield(gvr_audio_context* api,
const char* filename);

Expand All @@ -447,9 +465,9 @@ gvr_audio_source_id gvr_audio_create_soundfield(gvr_audio_context* api,
///
/// @param api Pointer to a gvr_audio_context.
/// @param filename The path/name of the file to be played..
/// @return Id of new stereo non-spatialized source. Returns kInvalidId if the
/// sound file has not been preloaded or if the number of input channels is
/// > 2;
/// @return Id of new stereo non-spatialized source. Returns
/// GVR_AUDIO_INVALID_SOURCE_ID if the sound file has not been preloaded or
/// if the number of input channels is > 2;
gvr_audio_source_id gvr_audio_create_stereo_sound(gvr_audio_context* api,
const char* filename);

Expand Down Expand Up @@ -511,6 +529,29 @@ void gvr_audio_set_sound_object_position(gvr_audio_context* api,
gvr_audio_source_id sound_object_id,
float x, float y, float z);

/// Sets the sound object directivity constants for an existing sound object.
///
/// @param api Pointer to a gvr_audio_context.
/// @param sound_object_id Id of the sound object to configure.
/// @param alpha A weighting balance between a figure-8 pattern and
/// omnidirectional pattern for source emission in the range [0, 1]. A value
/// of 0.5 results in a cardioid pattern.
/// @param order Applied to computed directivity. Higher values will result in
/// narrower and sharper directivity patterns, with a range of [1, inf).
void gvr_audio_set_sound_object_directivity(gvr_audio_context* api,
gvr_audio_source_id sound_object_id,
float alpha, float order);

/// Sets the given sound object's rotation. Only applies if
/// gvr_audio_set_sound_object_directivity has been called on the sound.
///
/// @param api Pointer to a gvr_audio_context.
/// @param soundfield_id Id of the sound object to be rotated.
/// @param object_rotation Quaternion representing the sound object rotation.
void gvr_audio_set_sound_object_rotation(gvr_audio_context* api,
gvr_audio_source_id sound_object_id,
gvr_quatf sound_object_rotation);

/// Sets the given ambisonic soundfields's rotation.
///
/// @param api Pointer to a gvr_audio_context.
Expand Down Expand Up @@ -747,6 +788,22 @@ class AudioApi {
gvr_audio_set_sound_object_position(context_, sound_object_id, x, y, z);
}

/// Sets directivity constants for an existing sound object.
/// For more information, see gvr_audio_set_sound_object_directivity.
void SetSoundObjectDirectivity(AudioSourceId sound_object_id, float alpha,
float order) {
gvr_audio_set_sound_object_directivity(context_, sound_object_id, alpha,
order);
}

/// Sets the rotation for an existing sound object.
/// For more information, see gvr_audio_set_sound_object_rotation.
void SetSoundObjectRotation(AudioSourceId sound_object_id,
const Quatf& sound_object_quat) {
gvr_audio_set_sound_object_rotation(context_, sound_object_id,
sound_object_quat);
}

void SetSoundObjectDistanceRolloffModel(
AudioSourceId sound_object_id,
gvr_audio_distance_rolloff_type rolloff_model, float min_distance,
Expand Down
47 changes: 38 additions & 9 deletions libraries/headers/vr/gvr/capi/include/gvr_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ void gvr_controller_destroy(gvr_controller_context** api);
/// Calling this when already paused is a no-op.
/// Thread-safe (call from any thread).
///
/// @param api Pointer to a pointer to a gvr_controller_context.
/// @param api Pointer to a gvr_controller_context.
void gvr_controller_pause(gvr_controller_context* api);

/// Resumes the controller. Call this when your app/game regains focus.
/// Calling this when already resumed is a no-op.
/// Thread-safe (call from any thread).
///
/// @param api Pointer to a pointer to a gvr_controller_context.
/// @param api Pointer to a gvr_controller_context.
void gvr_controller_resume(gvr_controller_context* api);

/// Convenience to convert an API status code to string. The returned pointer
Expand Down Expand Up @@ -196,9 +196,9 @@ void gvr_controller_state_destroy(gvr_controller_state** state);
/// const getter: it has side-effects. In particular, some of the
/// gvr_controller_state fields (the ones documented as "transient") represent
/// one-time events and will be true for only one read operation, and false
/// in subsequente reads.
/// in subsequent reads.
///
/// @param api Pointer to a pointer to a gvr_controller_context.
/// @param api Pointer to a gvr_controller_context.
/// @param flags Optional flags reserved for future use. A value of 0 should be
/// used until corresponding flag attributes are defined and documented.
/// @param out_state A pointer where the controller's state
Expand All @@ -207,6 +207,26 @@ void gvr_controller_state_destroy(gvr_controller_state** state);
void gvr_controller_state_update(gvr_controller_context* api, int32_t flags,
gvr_controller_state* out_state);

/// Sets up arm model with user's handedness, gaze behavior and head rotation.
/// This setting needs to be applied for every frame. User preferences of
/// handedness and gaze behavior can be changed as needed in a sequence of
/// frames. This needs to be called before gvr_controller_state_update() to
/// apply arm model. GVR_CONTROLLER_ENABLE_ARM_MODEL flag needs to be enabled
/// to apply arm model.
///
/// @param api Pointer to a gvr_controller_context.
/// @param handedness User's preferred handedness (GVR_CONTROLLER_RIGHT_HANDED
/// or GVR_CONTROLLER_LEFT_HANDED). Arm model will assume this is the hand
/// that is holding the controller and position the arm accordingly.
/// @param behavior User's preferred gaze behavior (SYNC_GAZE / FOLLOW_GAZE
/// / IGNORE_GAZE). Arm model uses this to determine how the body rotates as
/// gaze direction (i.e. head rotation) changes.
/// @param head_space_from_start_space_rotation User's head rotation with
/// respect to start space.
void gvr_controller_apply_arm_model(
gvr_controller_context* api, int32_t handedness, int32_t behavior,
gvr_mat4f head_space_from_start_space_rotation);

/// Gets the API status of the controller state. Returns one of the
/// gvr_controller_api_status variants, but returned as an int32_t for ABI
/// compatibility.
Expand Down Expand Up @@ -245,8 +265,8 @@ int32_t gvr_controller_state_get_connection_state(
/// time due to controller/headset drift. A recentering operation will bring
/// the two spaces back into sync.
///
/// Remember that a quaternion expresses a rotation. Given a rotation of theta
/// radians about the (x, y, z) axis, the corresponding quaternion (in
/// Remember that a unit quaternion expresses a rotation. Given a rotation of
/// theta radians about the (x, y, z) axis, the corresponding quaternion (in
/// xyzw order) is:
///
/// (x * sin(theta/2), y * sin(theta/2), z * sin(theta/2), cos(theta/2))
Expand Down Expand Up @@ -441,7 +461,6 @@ const char* gvr_controller_battery_level_to_string(int32_t level);
} // extern "C"
#endif


// Convenience C++ wrapper.
#if defined(__cplusplus) && !defined(GVR_NO_CPP_WRAPPER)

Expand Down Expand Up @@ -600,8 +619,18 @@ class ControllerApi {
/// @name Wrapper manipulation
/// @{
/// Creates a C++ wrapper for a C object and takes ownership.
explicit ControllerApi(gvr_controller_context* context)
: context_(context) {}
explicit ControllerApi(gvr_controller_context* context) : context_(context) {}

/// For more information, see
/// gvr_controller_apply_arm_model(gvr_controller_context* api, int32_t
/// handedness, int32_t behavior, gvr_mat4f
/// head_space_from_start_space_rotation);
void ApplyArmModel(const ControllerHandedness handedness,
const ArmModelBehavior behavior,
const Mat4f& head_space_from_start_space_rotation) {
gvr_controller_apply_arm_model(context_, handedness, behavior,
head_space_from_start_space_rotation);
}

/// Returns the wrapped C object. Does not affect ownership.
gvr_controller_context* cobj() { return context_; }
Expand Down
26 changes: 25 additions & 1 deletion libraries/headers/vr/gvr/capi/include/gvr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ enum {
GVR_CONTROLLER_ENABLE_POSITION = 1 << 6,
/// Indicates that controller battery data should be reported.
GVR_CONTROLLER_ENABLE_BATTERY = 1 << 7,
/// Indicates that elbow model should be enabled.
GVR_CONTROLLER_ENABLE_ARM_MODEL = 1 << 8,
};

/// Constants that represent the status of the controller API.
Expand Down Expand Up @@ -431,6 +433,16 @@ typedef enum {
GVR_CONTROLLER_LEFT_HANDED = 1,
} gvr_controller_handedness;

/// Types of gaze behaviors used for arm model.
typedef enum {
// Body rotation matches head rotation all the time.
GVR_ARM_MODEL_SYNC_GAZE = 0,
// Body rotates as head rotates, but at a smaller angle.
GVR_ARM_MODEL_FOLLOW_GAZE = 1,
// Body doesn't rotate as head rotates.
GVR_ARM_MODEL_IGNORE_GAZE = 2,
} gvr_arm_model_behavior;

typedef struct gvr_user_prefs_ gvr_user_prefs;

// Anonymous enum for miscellaneous integer constants.
Expand All @@ -444,6 +456,9 @@ enum {
/// gvr_buffer_viewport_set_source_buffer_index() to use the external surface
/// as the buffer contents.
GVR_BUFFER_INDEX_EXTERNAL_SURFACE = -1,
/// Invalid source id that can be used to initialize source id variables
/// during construction.
GVR_AUDIO_INVALID_SOURCE_ID = -1,
};

/// @}
Expand Down Expand Up @@ -540,6 +555,10 @@ const ControllerBatteryLevel kControllerBatteryLevelFull =
const int32_t kUninitializedExternalSurface = GVR_BUFFER_INDEX_EXTERNAL_SURFACE;
/// The default source buffer index for viewports.
const int32_t kDefaultBufferIndex = 0;
/// Invalid source id that can be used to initialize source id variables
/// during construction.
typedef gvr_audio_source_id AudioSourceId;
const AudioSourceId kInvalidSourceId = GVR_AUDIO_INVALID_SOURCE_ID;

typedef gvr_eye Eye;

Expand All @@ -566,7 +585,6 @@ typedef gvr_quatf ControllerQuat;
typedef gvr_audio_rendering_mode AudioRenderingMode;
typedef gvr_audio_material_type AudioMaterialName;
typedef gvr_audio_distance_rolloff_type AudioRolloffMethod;
typedef gvr_audio_source_id AudioSourceId;
typedef gvr_audio_surround_format_type AudioSurroundFormat;

typedef gvr_color_format_type ColorFormat;
Expand Down Expand Up @@ -599,6 +617,12 @@ const ControllerHandedness kControllerRightHanded =
const ControllerHandedness kControllerLeftHanded =
static_cast<ControllerHandedness>(GVR_CONTROLLER_LEFT_HANDED);

typedef gvr_arm_model_behavior ArmModelBehavior;
const ArmModelBehavior kArmModelBehaviorFollowGaze =
static_cast<ArmModelBehavior>(GVR_ARM_MODEL_FOLLOW_GAZE);
const ArmModelBehavior kArmModelBehaviorSyncGaze =
static_cast<ArmModelBehavior>(GVR_ARM_MODEL_SYNC_GAZE);

typedef gvr_error Error;
const Error kErrorNone = static_cast<Error>(GVR_ERROR_NONE);
const Error kErrorControllerCreateFailed =
Expand Down
Binary file removed libraries/sdk-audio-1.60.1.aar
Binary file not shown.
Binary file added libraries/sdk-audio-1.70.0.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.google.vr</groupId>
<artifactId>sdk-audio</artifactId>
<version>1.60.1</version>
<version>1.70.0</version>
<packaging>aar</packaging>

<name>Google VR SDK-Audio</name>
Expand All @@ -19,7 +19,7 @@
<groupId>com.google.vr</groupId>
<artifactId>sdk-base</artifactId>
<type>aar</type>
<version>1.60.1</version>
<version>1.70.0</version>
</dependency>
</dependencies>
</project>
Binary file removed libraries/sdk-base-1.60.1.aar
Binary file not shown.
Binary file added libraries/sdk-base-1.70.0.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.google.vr</groupId>
<artifactId>sdk-base</artifactId>
<version>1.60.1</version>
<version>1.70.0</version>
<packaging>aar</packaging>

<name>Google VR SDK-Base</name>
Expand All @@ -19,7 +19,7 @@
<groupId>com.google.vr</groupId>
<artifactId>sdk-common</artifactId>
<type>aar</type>
<version>1.60.1</version>
<version>1.70.0</version>
</dependency>
</dependencies>
</project>
Binary file removed libraries/sdk-common-1.60.1.aar
Binary file not shown.
Binary file added libraries/sdk-common-1.70.0.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.google.vr</groupId>
<artifactId>sdk-common</artifactId>
<version>1.60.1</version>
<version>1.70.0</version>
<packaging>aar</packaging>

<name>Google VR SDK-Common</name>
Expand Down
Binary file not shown.
Loading

0 comments on commit e4eeb86

Please sign in to comment.