Problem Re-Declaring UCGO Cargo Slots

Ares

Donator
Donator
Joined
Sep 17, 2008
Messages
9
Reaction score
0
Points
0
Hello orbiter! :tiphat:

After playing around with orbiter on and off for a while, I’ve decided to try to create my own vessel. My mesh is a long tether with an engine at either end, along which the hab module slides. Kind of like a bead on a string.

The hab module consists of two centrifuges, docking ports, UMMU airlock and a UCGO cargo bay. So far I’ve managed to animate the hab so that it slides on the tether, pulling along the centrifuge animations, any docked vessels and the locations of the UMMU airlock. However, I’ve hit a problem with the cargo.

Currently, I define the positions and rotations of the cargo slots in clbkSetClassCaps as in the UCGO documentation. Then, in clbkPostStep I check if the hab is moving. If it is, I:
1. Record the cargo descriptions in each cargo slot with GetCargoDescriptionString,
2. Delete all cargos with DeleteLoadedCargo,
3. Re-define the cargo slots in their new positions with DeclareCargoSlot,
4. Replace the cargo with ScnEditor_AddLastSelectedCargoToSlot.


Code:
[FONT=Consolas]void Valkyrie::clbkPostStep(double SimT, double SimDT, double MJD)[/FONT]
[FONT=Consolas]{[/FONT]
[FONT=Consolas]if (hab_moving) {[/FONT]
[FONT=Consolas]// Update hab animations [/FONT]
[FONT=Consolas]// Update dock positions[/FONT]
[FONT=Consolas]// Update UMMU airlock positions[/FONT]
 
[FONT=Consolas]for (i=0; i<36; i++) {[/FONT]
[FONT=Consolas]sprintf(shipcargos[i],"%s",hUcgo.GetCargoDescriptionString(i));[/FONT]
[FONT=Consolas]hUcgo.DeleteLoadedCargo(i);[/FONT]
[FONT=Consolas]}[/FONT]
 
[FONT=Consolas]hUcgo.DeclareCargoSlot(0,_V(0,2.14852,hab_position-23.83982),_V(0,0,0));[/FONT] 
[FONT=Consolas]hUcgo.DeclareCargoSlot(1,_V(0,2.14852,hab_position-25.323),_V(0,0,0));[/FONT]
[FONT=Consolas]// etc.[/FONT]
 
[FONT=Consolas]for (i=0; i<36; i++) {[/FONT]
[FONT=Consolas]if (strcmp("none",shipcargos[i])!=0) { [/FONT]
[FONT=Consolas] for (j=0; j<ndiskcargos; j++) {[/FONT]
[FONT=Consolas]  if (strcmp(diskcargos[j],shipcargos[i])==0) break;[/FONT]
[FONT=Consolas] }[/FONT]
[FONT=Consolas] SetUCGOList(j);[/FONT]
[FONT=Consolas] hUcgo.ScnEditor_AddLastSelectedCargoToSlot(i);[/FONT]
[FONT=Consolas]}[/FONT]
[FONT=Consolas]}[/FONT]
 
[FONT=Consolas]}[/FONT]
[FONT=Consolas]}[/FONT]


This compiles and everything works in the simulation when there is no cargo loaded. When a cargo is loaded it starts at the correct place wherever the hab is on the tether. However, when the animation is activated and a cargo is present the cargo moves correctly but the hab mesh remains stationary. Detaching the cargo allows the hab to move, but the mesh does not update to the correct position from where the cargo was released.

Exiting and loading the current state puts the hab back where it should be.

So, can anyone spot what I'm doing wrong? Thanks!

---------- Post added 07-26-12 at 11:56 AM ---------- Previous post was 07-25-12 at 10:12 PM ----------

I've found a work-around, but I don't know why it works. In clbkPostStep I alternate setting the animation with setting up the cargo slots, so that SetAnimation and DeclareCargoSlots are not called at the same time step.

Code:
[FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] Valkyrie::clbkPostStep([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] SimT, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] SimDT, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] MJD) {[/SIZE][/FONT][/SIZE][/FONT]
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] if (status == movemesh) {[/SIZE][/FONT][/SIZE][/FONT]
[FONT=Consolas]   // move mesh[/FONT]
[FONT=Consolas]   status = movecargo[/FONT]
[FONT=Consolas] }[/FONT]
[FONT=Consolas] else if (status == movecargo) {[/FONT]
[FONT=Consolas]   // move cargo[/FONT]
[FONT=Consolas]   status = movemesh[/FONT]
[FONT=Consolas] }[/FONT]
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]}[/SIZE][/FONT][/SIZE][/FONT]
 
Top