Tuesday, April 16, 2024
HomeSample Page

Sample Page Title


I’m attempting to create a UI element for each object that I’ve on an array so I might change the values of them, and I’m doing this by a loop:

for (int i = 0; i < objs_array->dimension(); i++) {

    obj *current_obj = &objs_array->at(i);
    ImGui::PushID(current_obj->id.c_str()); 
    ImGui::Begin(current_obj->id.c_str());

    std::string label_x = "Translation x " + current_obj->id;
    std::string label_y = "Translation y " + current_obj->id;
    std::string label_z = "Translation z " + current_obj->id;
   
    ImGui::SliderFloat(label_x.c_str(), &current_obj->translation.x,-50.0f, 50.0f);
    ImGui::SliderFloat(label_y.c_str(), &current_obj->translation.y,-50.0f, 50.0f);
    ImGui::SliderFloat(label_y.c_str(), &current_obj->translation.z,-50.0f, 50.0f);

    ImGui::End();
    ImGui::PopID();
}

Just a small instance however the construction is just about the identical. With just one element every part works fantastic, nevertheless with a number of objects the final element created is altering the identical values to all different objects and the values of the remaining elements will get mounted at zeroes or with enormous random values.

I’ve additionally modified the PushID passing the precise object to it nevertheless the behaviour stays the identical.

enter image description here

Depending the best way I set the PushID, the values get mounted like within the picture or altering for enormous random values.

Is there one other means I could make this work? Or a solution to repair this might be superior.

Edit: the double id “translation y” is already mounted.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments