Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ For ViroCore Android, HelloWorld samples should have the corresponding file at t

## Manual Building of the Renderer

If you would like to modify / make changes to the renderer directly. These are the instructions for building the renderer and ViroCore platform.
If you would like to modify / make changes to the renderer directly. These are the instructions for building the renderer and ViroCore platform.

### Building the ViroCore platform:
1. Follow the same prerequisite directions above from our [Quick start guide](https://virocore.viromedia.com/docs/getting-started).
Expand Down
45 changes: 44 additions & 1 deletion ViroRenderer/VROARFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define VROARFrame_h

#include "VROARPointCloud.h"
#include "VROMatrix4f.h"

#include <memory>
#include <vector>
Expand All @@ -37,7 +38,7 @@
class VROARCamera;
class VROARAnchor;
class VROARHitTestResult;
class VROMatrix4f;
class VROTexture;
enum class VROARHitTestResultType;
enum class VROCameraOrientation;

Expand Down Expand Up @@ -115,6 +116,48 @@ class VROARFrame {
Retrieves the point cloud from this frame.
*/
virtual std::shared_ptr<VROARPointCloud> getPointCloud() = 0;

/*
Get the depth texture for this frame, if available.
Returns nullptr if depth is not supported or not enabled.
The texture contains depth values in meters as 16-bit unsigned integers
(millimeters on ARCore, meters on ARKit).
*/
virtual std::shared_ptr<VROTexture> getDepthTexture() { return nullptr; }

/*
Get the confidence texture for depth values, if available.
Returns nullptr if not supported. Values range from 0-255 where
higher values indicate higher confidence.
*/
virtual std::shared_ptr<VROTexture> getDepthConfidenceTexture() { return nullptr; }

/*
Check if depth data is available for this frame.
*/
virtual bool hasDepthData() const { return false; }

/*
Get the width of the depth image in pixels.
*/
virtual int getDepthImageWidth() const { return 0; }

/*
Get the height of the depth image in pixels.
*/
virtual int getDepthImageHeight() const { return 0; }

/*
Returns the transform matrix to convert from camera texture coordinates
to depth texture coordinates. The depth map may have a different
orientation/resolution than the camera image, so this transform is needed
to correctly sample the depth texture.

By default returns identity (assumes depth texture UVs match camera UVs).
*/
virtual VROMatrix4f getDepthTextureTransform() const {
return VROMatrix4f::identity();
}
};

#endif /* VROARFrame_h */
44 changes: 42 additions & 2 deletions ViroRenderer/VROARSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ enum class VROCloudAnchorProvider {
ARCore,
};

/*
The occlusion mode determines how virtual content is occluded
by real-world objects.
*/
enum class VROOcclusionMode {
Disabled, // No occlusion - virtual objects always render on top
DepthBased, // Use depth data to occlude virtual objects behind real-world surfaces
PeopleOnly // Only occlude virtual objects behind detected people (iOS 13+/Android with ARCore)
};

/*
Manages the device camera and motion tracking for AR.
*/
Expand Down Expand Up @@ -311,15 +321,45 @@ class VROARSession {
each frame.
*/
virtual void setVisionModel(std::shared_ptr<VROVisionModel> visionModel) = 0;


/*
Set the occlusion mode for AR rendering. When enabled, virtual objects
will be properly occluded by real-world surfaces or people.
*/
virtual void setOcclusionMode(VROOcclusionMode mode) {
_occlusionMode = mode;
}

/*
Get the current occlusion mode.
*/
VROOcclusionMode getOcclusionMode() const {
return _occlusionMode;
}

/*
Returns true if occlusion is supported on this device.
*/
virtual bool isOcclusionSupported() const {
return false;
}

/*
Returns true if the specified occlusion mode is supported on this device.
*/
virtual bool isOcclusionModeSupported(VROOcclusionMode mode) const {
return mode == VROOcclusionMode::Disabled;
}

protected:

VROTrackingType _trackingType;

private:

VROWorldAlignment _worldAlignment;
VROImageTrackingImpl _imageTrackingImpl;
VROOcclusionMode _occlusionMode = VROOcclusionMode::Disabled;
std::shared_ptr<VROScene> _scene;
std::weak_ptr<VROARSessionDelegate> _delegate;

Expand Down
59 changes: 59 additions & 0 deletions ViroRenderer/VROByteBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ int VROByteBuffer::readInt() {
return value;
}

unsigned int VROByteBuffer::readUnsignedInt() {
passert(_pos + 4 <= _capacity);

unsigned int value;
memcpy(&value, _buffer + _pos, 4);

_pos += 4;

return value;
}

short VROByteBuffer::readShort() {
passert(_pos + 2 <= _capacity);

Expand Down Expand Up @@ -638,6 +649,22 @@ void VROByteBuffer::writeByte(char value) {
_pos++;
}

void VROByteBuffer::writeUnsignedByte(unsigned char value) {
#if k_bufferDebugOverruns
const size_t newPos = _pos + 1;
if (newPos > _capacity) {
perr("Overrun! writeUnsignedByte newPos=%zu > _capacity=%zu", newPos, _capacity);
#if k_bufferAbortOverruns
pabort();
#endif
return;
}
#endif

_buffer[_pos] = value;
_pos++;
}

void VROByteBuffer::writeShort(short value) {
#if k_bufferDebugOverruns
const size_t newPos = _pos + 2;
Expand All @@ -654,6 +681,22 @@ void VROByteBuffer::writeShort(short value) {
_pos += 2;
}

void VROByteBuffer::writeUnsignedShort(unsigned short value) {
#if k_bufferDebugOverruns
const size_t newPos = _pos + 2;
if (newPos > _capacity) {
perr("Overrun! writeUnsignedShort newPos=%zu > _capacity=%zu", newPos, _capacity);
#if k_bufferAbortOverruns
pabort();
#endif
return;
}
#endif

memcpy(_buffer + _pos, &value, 2);
_pos += 2;
}

void VROByteBuffer::writeInt(int value) {
#if k_bufferDebugOverruns
const size_t newPos = _pos + 4;
Expand All @@ -670,6 +713,22 @@ void VROByteBuffer::writeInt(int value) {
_pos += 4;
}

void VROByteBuffer::writeUnsignedInt(unsigned int value) {
#if k_bufferDebugOverruns
const size_t newPos = _pos + 4;
if (newPos > _capacity) {
perr("Overrun! writeUnsignedInt newPos=%zu > _capacity=%zu", newPos, _capacity);
#if k_bufferAbortOverruns
pabort();
#endif
return;
}
#endif

memcpy(_buffer + _pos, &value, 4);
_pos += 4;
}

void VROByteBuffer::writeHalf(float value) {
writeShort(VROFloatToFloat16(value));
}
Expand Down
4 changes: 4 additions & 0 deletions ViroRenderer/VROByteBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class VROByteBuffer final {
float readFloat();
double readDouble();
int readInt();
unsigned int readUnsignedInt();
uint64_t readUInt64();
short readShort();
unsigned short readUnsignedShort();
Expand Down Expand Up @@ -188,8 +189,11 @@ class VROByteBuffer final {
*/
void writeBool(bool value);
void writeByte(char value);
void writeUnsignedByte(unsigned char value);
void writeShort(short value);
void writeUnsignedShort(unsigned short value);
void writeInt(int value);
void writeUnsignedInt(unsigned int value);
void writeHalf(float value);
void writeFloat(float value);
void writeFloats(float *pValues, const int numFloats);
Expand Down
Loading
Loading