Skip to content
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion n64/engine/include/scene/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace P64
fm_vec3_t pos{0,0,0};
fm_vec3_t scale{1,1,1};
fm_quat_t rot{0,0,0,1};
uint16_t groupId{0};
uint16_t objectId{0};
};

Expand Down Expand Up @@ -178,13 +179,15 @@ namespace P64
* @param pos initial pos (default origin)
* @param scale initial scale (default 1)
* @param rot initial rotation (none)
* @param desiredGroupId id for the parent object
* @return ID of the new object
*/
uint16_t addObject(
uint32_t prefabIdx,
const fm_vec3_t &pos = {0,0,0},
const fm_vec3_t &scale = {1,1,1},
const fm_quat_t &rot = {0,0,0,1}
const fm_quat_t &rot = {0,0,0,1},
uint16_t desiredGroupId = 0
);

void removeObject(Object &obj);
Expand Down
5 changes: 4 additions & 1 deletion n64/engine/src/scene/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ void P64::Scene::update(float deltaTime)
loadObject((uint8_t*&)data.prefabData, [&](Object &obj)
{
obj.id = data.objectId;
obj.group = data.groupId;
obj.pos = data.pos;
obj.scale = data.scale;
obj.rot = data.rot;
Expand Down Expand Up @@ -332,14 +333,16 @@ uint16_t P64::Scene::addObject(
uint32_t prefabIdx,
const fm_vec3_t &pos,
const fm_vec3_t &scale,
const fm_quat_t &rot
const fm_quat_t &rot,
uint16_t desiredGroupId
) {
auto *prefabData = AssetManager::getByIndex(prefabIdx);
objectsToAdd.push_back({
.prefabData = prefabData,
.pos = pos,
.scale = scale,
.rot = rot,
.groupId = desiredGroupId,
.objectId = ++nextId,
});
return nextId;
Expand Down
Loading