merge
This commit is contained in:
@@ -122,7 +122,7 @@ void SceneAsset::stopAnimation(int index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SceneAsset::setTexture(const char* resourcePath, int renderableIndex) {
|
void SceneAsset::setTexture(const char* resourcePath, int renderableIndex) {
|
||||||
|
Log("Setting texture to %s for renderableIndex %d", resourcePath, renderableIndex);
|
||||||
ResourceBuffer imageResource = _loadResource(resourcePath);
|
ResourceBuffer imageResource = _loadResource(resourcePath);
|
||||||
|
|
||||||
polyvox::StreamBufferAdapter sb((char *)imageResource.data, (char *)imageResource.data + imageResource.size);
|
polyvox::StreamBufferAdapter sb((char *)imageResource.data, (char *)imageResource.data + imageResource.size);
|
||||||
@@ -137,10 +137,6 @@ void SceneAsset::setTexture(const char* resourcePath, int renderableIndex) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete inputStream;
|
|
||||||
|
|
||||||
_freeResource(imageResource.id);
|
|
||||||
|
|
||||||
uint32_t channels = image->getChannels();
|
uint32_t channels = image->getChannels();
|
||||||
uint32_t w = image->getWidth();
|
uint32_t w = image->getWidth();
|
||||||
uint32_t h = image->getHeight();
|
uint32_t h = image->getHeight();
|
||||||
@@ -173,6 +169,10 @@ void SceneAsset::setTexture(const char* resourcePath, int renderableIndex) {
|
|||||||
auto sampler = TextureSampler();
|
auto sampler = TextureSampler();
|
||||||
inst[0]->setParameter("baseColorIndex",0);
|
inst[0]->setParameter("baseColorIndex",0);
|
||||||
inst[0]->setParameter("baseColorMap",texture,sampler);
|
inst[0]->setParameter("baseColorMap",texture,sampler);
|
||||||
|
|
||||||
|
delete inputStream;
|
||||||
|
|
||||||
|
_freeResource(imageResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneAsset::updateEmbeddedAnimations() {
|
void SceneAsset::updateEmbeddedAnimations() {
|
||||||
@@ -258,6 +258,7 @@ void SceneAsset::transformToUnitCube() {
|
|||||||
Log("No asset, cannot transform.");
|
Log("No asset, cannot transform.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Log("Transforming asset to unit cube.");
|
||||||
auto &tm = _engine->getTransformManager();
|
auto &tm = _engine->getTransformManager();
|
||||||
auto aabb = _asset->getBoundingBox();
|
auto aabb = _asset->getBoundingBox();
|
||||||
auto center = aabb.center();
|
auto center = aabb.center();
|
||||||
@@ -269,6 +270,21 @@ void SceneAsset::transformToUnitCube() {
|
|||||||
tm.setTransform(tm.getInstance(_asset->getRoot()), transform);
|
tm.setTransform(tm.getInstance(_asset->getRoot()), transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SceneAsset::setPosition(float x, float y, float z) {
|
||||||
|
Log("Setting position to %f %f %f", x, y, z);
|
||||||
|
auto &tm = _engine->getTransformManager();
|
||||||
|
auto transform = tm.getTransform(tm.getInstance(_asset->getRoot()));
|
||||||
|
tm.setTransform(tm.getInstance(_asset->getRoot()), transform * math::mat4f::translation(math::float3(x,y,z)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SceneAsset::setRotation(float rads, float x, float y, float z) {
|
||||||
|
Log("Rotating %f radians around axis %f %f %f", x, y, z);
|
||||||
|
auto &tm = _engine->getTransformManager();
|
||||||
|
auto transform = tm.getTransform(tm.getInstance(_asset->getRoot()));
|
||||||
|
tm.setTransform(tm.getInstance(_asset->getRoot()), transform * math::mat4f::rotation(rads, math::float3(x,y,z)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const utils::Entity *SceneAsset::getCameraEntities() {
|
const utils::Entity *SceneAsset::getCameraEntities() {
|
||||||
return _asset->getCameraEntities();
|
return _asset->getCameraEntities();
|
||||||
}
|
}
|
||||||
@@ -277,4 +293,13 @@ size_t SceneAsset::getCameraEntityCount() {
|
|||||||
return _asset->getCameraEntityCount();
|
return _asset->getCameraEntityCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace polyvox
|
const Entity* SceneAsset::getLightEntities() const noexcept {
|
||||||
|
return _asset->getLightEntities();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t SceneAsset::getLightEntityCount() const noexcept {
|
||||||
|
return _asset->getLightEntityCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace polyvox
|
||||||
|
|||||||
@@ -65,10 +65,18 @@ namespace polyvox {
|
|||||||
|
|
||||||
void transformToUnitCube();
|
void transformToUnitCube();
|
||||||
|
|
||||||
|
void setPosition(float x, float y, float z);
|
||||||
|
|
||||||
|
void setRotation(float rads, float x, float y, float z);
|
||||||
|
|
||||||
const utils::Entity* getCameraEntities();
|
const utils::Entity* getCameraEntities();
|
||||||
|
|
||||||
size_t getCameraEntityCount();
|
size_t getCameraEntityCount();
|
||||||
|
|
||||||
|
const Entity* getLightEntities() const noexcept;
|
||||||
|
|
||||||
|
size_t getLightEntityCount() const noexcept;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FilamentAsset* _asset = nullptr;
|
FilamentAsset* _asset = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user