Skip to content

Commit

Permalink
environments: add Winter and Underwater; update Meadow; rename Island…
Browse files Browse the repository at this point in the history
… -> Offworld (for issue #1037) (#1038)

* environments: add Winter and Underwater; update Meadow; rename Island -> Offworld

* temporarily hide "Meadow" environment until new polished assets are ready

* revert whitespace change in BrowserWorld

* Fix underwater environment

* Add support for different env sizes

* Fallback to default is meadow was selected

* Change order and default
  • Loading branch information
cvan authored and MortimerGoro committed Mar 22, 2019
1 parent dc3efee commit e14805a
Show file tree
Hide file tree
Showing 61 changed files with 74 additions and 18 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -128,8 +128,9 @@ Note: the release APKs generated with a debug keystore can't be used for product
ETC2 compression is used to improve performance and memory usage. Raw assets are placed in the `uncompressed_assets` folder. You can generate the compressed textures using the compressor utility in `tools/compressor`. You need to set up [etc2comp](https://github.com/google/etc2comp) and make it available on your PATH before running the script. Run this command to generate the compressed assets:

```bash
cd tools/compressor
npm install
gulp compress
npm run compress
```

## Development troubleshooting
Expand Down
Expand Up @@ -52,7 +52,7 @@ SettingsStore getInstance(final @NonNull Context aContext) {
public final static int MAX_WINDOW_HEIGHT_DEFAULT = 1200;
public final static int POINTER_COLOR_DEFAULT_DEFAULT = Color.parseColor("#FFFFFF");
public final static int SCROLL_DIRECTION_DEFAULT = 0;
public final static String ENV_DEFAULT = "cave";
public final static String ENV_DEFAULT = "offworld";
public final static float BROWSER_WORLD_WIDTH_DEFAULT = 4.0f;
public final static float BROWSER_WORLD_HEIGHT_DEFAULT = 2.25f;
public final static int MSAA_DEFAULT_LEVEL = 1;
Expand Down Expand Up @@ -287,8 +287,12 @@ public void setMaxWindowHeight(int aMaxWindowHeight) {
}

public String getEnvironment() {
return mPrefs.getString(
mContext.getString(R.string.settings_key_env), ENV_DEFAULT);
String env = mPrefs.getString(mContext.getString(R.string.settings_key_env), ENV_DEFAULT);
// Remove when the meadow is ready
if (env.equalsIgnoreCase("meadow")) {
env = ENV_DEFAULT;
}
return env;
}

public void setEnvironment(String aEnv) {
Expand Down
Binary file modified app/src/main/assets/cubemap/meadow/negx.ktx
Binary file not shown.
Binary file modified app/src/main/assets/cubemap/meadow/negy.ktx
Binary file not shown.
Binary file modified app/src/main/assets/cubemap/meadow/negz.ktx
Binary file not shown.
Binary file modified app/src/main/assets/cubemap/meadow/posx.ktx
Binary file not shown.
Binary file modified app/src/main/assets/cubemap/meadow/posy.ktx
Binary file not shown.
Binary file modified app/src/main/assets/cubemap/meadow/posz.ktx
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added app/src/main/assets/cubemap/underwater/negx.ktx
Binary file not shown.
Binary file added app/src/main/assets/cubemap/underwater/negy.ktx
Binary file not shown.
Binary file added app/src/main/assets/cubemap/underwater/negz.ktx
Binary file not shown.
Binary file added app/src/main/assets/cubemap/underwater/posx.ktx
Binary file not shown.
Binary file added app/src/main/assets/cubemap/underwater/posy.ktx
Binary file not shown.
Binary file added app/src/main/assets/cubemap/underwater/posz.ktx
Binary file not shown.
Binary file added app/src/main/assets/cubemap/winter/negx.ktx
Binary file not shown.
Binary file added app/src/main/assets/cubemap/winter/negy.ktx
Binary file not shown.
Binary file added app/src/main/assets/cubemap/winter/negz.ktx
Binary file not shown.
Binary file added app/src/main/assets/cubemap/winter/posx.ktx
Binary file not shown.
Binary file added app/src/main/assets/cubemap/winter/posy.ktx
Binary file not shown.
Binary file added app/src/main/assets/cubemap/winter/posz.ktx
Binary file not shown.
14 changes: 12 additions & 2 deletions app/src/main/cpp/BrowserWorld.cpp
Expand Up @@ -1128,16 +1128,26 @@ BrowserWorld::CreateSkyBox(const std::string& aBasePath, const std::string& aExt
ASSERT_ON_RENDER_THREAD();
const bool empty = aBasePath == "cubemap/void";
const std::string extension = aExtension.empty() ? ".ktx" : aExtension;
const GLenum glFormat = extension == ".ktx" ? GL_COMPRESSED_RGB8_ETC2 : GL_RGB8;
float size = 1024;
if (aBasePath == "cubemap/underwater" || aBasePath == "cubemap/winter") {
size = 1000;
}
if (m.skybox && empty) {
m.skybox->SetVisible(false);
return;
} else if (m.skybox) {
m.skybox->SetVisible(true);
if (m.skybox->GetLayer() && m.skybox->GetLayer()->GetWidth() != size) {
VRLayerCubePtr oldLayer = m.skybox->GetLayer();
VRLayerCubePtr newLayer = m.device->CreateLayerCube(size, size, glFormat);
m.skybox->SetLayer(newLayer);
m.device->DeleteLayer(oldLayer);
}
m.skybox->Load(m.loader, aBasePath, extension);
return;
} else if (!empty) {
GLenum glFormat = extension == ".ktx" ? GL_COMPRESSED_RGB8_ETC2 : GL_RGB8;
VRLayerCubePtr layer = m.device->CreateLayerCube(1024, 1024, glFormat);
VRLayerCubePtr layer = m.device->CreateLayerCube(size, size, glFormat);
m.skybox = Skybox::Create(m.create, layer);
m.rootOpaqueParent->AddNode(m.skybox->GetRoot());
m.skybox->Load(m.loader, aBasePath, extension);
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/cpp/Skybox.cpp
Expand Up @@ -181,6 +181,32 @@ Skybox::Load(const vrb::ModelLoaderAndroidPtr& aLoader, const std::string& aBase
}
}

VRLayerCubePtr
Skybox::GetLayer() const {
return m.layer;
}

void
Skybox::SetLayer(const VRLayerCubePtr& aLayer) {
m.basePath = "";
m.layerTextureHandle = 0;
if (m.root->GetNodeCount() > 0) {
vrb::NodePtr layerNode = m.root->GetNode(0);
m.root->RemoveNode(*layerNode);
}
m.layer = aLayer;
m.layer->SetTintColor(m.tintColor);
vrb::CreationContextPtr create = m.context.lock();
m.root->AddNode(VRLayerNode::Create(create, m.layer));
m.layer->SetSurfaceChangedDelegate([=](const VRLayer& aLayer, VRLayer::SurfaceChange aChange, const std::function<void()>& aCallback) {
m.layerTextureHandle = m.layer->GetTextureHandle();
m.LoadLayer();
if (aCallback) {
aCallback();
}
});
}

void
Skybox::SetVisible(bool aVisible) {
m.root->ToggleAll(aVisible);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/cpp/Skybox.h
Expand Up @@ -22,6 +22,8 @@ class Skybox {
static std::string ValidateCustomSkyboxAndFindFileExtension(const std::string& aBasePath);
static SkyboxPtr Create(vrb::CreationContextPtr aContext, const VRLayerCubePtr& aLayer = nullptr);
void Load(const vrb::ModelLoaderAndroidPtr& aLoader, const std::string& aBasePath, const std::string& aExtension);
VRLayerCubePtr GetLayer() const;
void SetLayer(const VRLayerCubePtr& aLayer);
void SetVisible(bool aVisible);
void SetTransform(const vrb::Matrix& aTransform);
void SetTintColor(const vrb::Color& aTintColor);
Expand Down
Binary file modified app/src/main/res/drawable/environment_cave.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/environment_meadow.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/environment_winter.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 10 additions & 7 deletions app/src/main/res/values/options_values.xml
Expand Up @@ -3,23 +3,26 @@
<!-- Environments Options -->
<string-array name="developer_options_environments" translatable="false">
<item>@string/developer_options_env_void</item>
<item>@string/developer_options_env_island</item>
<item>@string/developer_options_env_cave</item>
<item>@string/developer_options_env_meadow</item>
<item>@string/developer_options_env_offworld</item>
<item>@string/developer_options_env_underwater</item>
<item>@string/developer_options_env_winter</item>
</string-array>

<string-array name="developer_options_environments_values" translatable="false">
<item>void</item>
<item>island</item>
<item>offworld</item>
<item>underwater</item>
<item>winter</item>
<item>cave</item>
<item>meadow</item>
</string-array>

<array name="developer_options_environments_images" translatable="false">
<item>@color/black</item>
<item>@drawable/environment_island</item>
<item>@drawable/environment_cave</item>
<item>@drawable/environment_meadow</item>
<item>@drawable/environment_offworld</item>
<item>@drawable/environment_underwater</item>
<item>@drawable/environment_winter</item>
</array>

<!-- Pointer Options -->
Expand Down Expand Up @@ -87,4 +90,4 @@
<item>ko-KR</item>
<item>it-IT</item>
</string-array>
</resources>
</resources>
16 changes: 11 additions & 5 deletions app/src/main/res/values/strings.xml
Expand Up @@ -155,7 +155,7 @@
<!-- This string is used in place of the 'settings_version' string (e.g., `version 1.1`) when the user is running
a developer-build version of the app. -->
<string name="settings_version_developer">Developer Build</string>

<!-- This string is the title of a dialog box shown to the user when a settings
change requires the application to restart. -->
<string name="restart_dialog_restart">Restart Required</string>
Expand Down Expand Up @@ -279,15 +279,21 @@
The 'Void' environment is an empty space that surrounds the user in empty, black space. -->
<string name="developer_options_env_void">Void</string>

<!-- This string labels the radio button that selects the 'Cave' environment. -->
<string name="developer_options_env_island">Island</string>
<!-- This string labels the radio button that selects the 'Offworld' environment. -->
<string name="developer_options_env_offworld">Offworld</string>

<!-- This string labels the radio button that selects the 'Cave' environment. -->
<string name="developer_options_env_cave">Cave</string>
<!-- This string labels the radio button that selects the 'Underwater' environment. -->
<string name="developer_options_env_underwater">Underwater</string>

<!-- This string labels the radio button that selects the 'Winter' environment. -->
<string name="developer_options_env_winter">Winter</string>

<!-- This string labels the radio button that selects the 'Meadow' environment. -->
<string name="developer_options_env_meadow">Meadow</string>

<!-- This string labels the radio button that selects the 'Cave' environment. -->
<string name="developer_options_env_cave">Cave</string>

<!-- This string describes the radio buttons used to select the pointer color. -->
<string name="developer_options_pointer_color">Pointer Color</string>

Expand Down
Binary file modified app/src/uncompressed_assets/main/assets/cubemap/meadow/negx.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/uncompressed_assets/main/assets/cubemap/meadow/negy.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/uncompressed_assets/main/assets/cubemap/meadow/negz.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/uncompressed_assets/main/assets/cubemap/meadow/posx.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/uncompressed_assets/main/assets/cubemap/meadow/posy.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/uncompressed_assets/main/assets/cubemap/meadow/posz.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions tools/compressor/package.json
Expand Up @@ -20,5 +20,9 @@
"readdirp": "^2.2.1",
"sharp": "^0.21.1",
"tmp": "0.0.33"
},
"scripts": {
"build": "npm run compress",
"compress": "gulp compress"
}
}

0 comments on commit e14805a

Please sign in to comment.