Let see if I'm understanding. You want to pick up something, translate it to somewhere else, then drop it and have it attach automatically where it is dropped ?
yes and dock in between.
Code:
if ((ROD2_proc>=1)&& (ROD3_check==0)&& (attach1==0)) DetachChild(POD1,0);
So if the 2nd rotation is complete and the 3rd is moving then detach POD1. This allows what was attached to be docked as the dock is placed where the attachment is/was.
the user presses a key
Code:
if (PADSel==1){
attach1=1;
if (ROD3_proc<1)toggle_attach();
set attach1 to 1 telling it needs to attach. this is so it will not dettach in the earlier step.
if the 3 sequence is not finished then attach. This is where it attaches another vessel already attached but not the one there.
PaD1= CreateAttachment (false,_V(-1.9, -10.931 , 12),_V(1,0,0),_V(0,1,0),"POD1",false);
PaD2= CreateAttachment (false,_V(-1.9, -6.6 , 12),_V(1,0,0),_V(0,1,0),"POD2",false);
from the scenario:
BEGIN_SHIPS
POD1
OD1
STATUS Orbiting Earth
RPOS 3848380.27 -34.52 8915000.38
RVEL -6548.607 -0.004 3741.743
AROT -180.00 3.81 -180.00
ATTACHED 0:1,PODBAY
AFCMODE 7
PRPLEVEL 0:1.000000
IDS 0:588 100
NAVFREQ 0 0
XPDR 0
END
PODBAY
ODBAY
STATUS Orbiting Earth
RPOS 2835762.68 8.70 6408734.33
RVEL -6896.691 -0.004 3051.575
AROT 180.00 -86.19 -180.00
AFCMODE 7
PRPLEVEL 0:1.000000
IDS 0:0 100
NAVFREQ 0 0
XPDR 0
PAD 2
END
pod2
OD2
STATUS Orbiting Earth
RPOS 2835774.80 3.46 6408735.73
RVEL -6896.691 -0.004 3051.575
AROT -180.00 3.81 -180.00
ATTACHED 0:1,PODBAY
AFCMODE 7
PRPLEVEL 0:1.000000
IDS 0:588 100
NAVFREQ 0 0
XPDR 0
END
END_SHIPS
---------- Post added 05-01-13 at 06:11 AM ---------- Previous post was 04-30-13 at 06:38 PM ----------
One solution I thought of it to make separate id for each vessel. that way each pad/attachment point can allow attach that id. So attachment point #1 can only attach a vessel with an id of 1.
Code:
const char *id = v->GetAttachmentId (hAtt);
if (strncmp (id, "POD1", 4))PODID=1;
if (strncmp (id, "POD2", 4))PODID=2;
if (strncmp (id, "POD3", 4))PODID=3;
if (strncmp (id, "POD", 3)) continue; // attachment point not compatible
v->GetAttachmentParams (hAtt, shippos, shipdir, shiprot); //lets get the attach point position
v->Local2Global (shippos, gpship); // and change it to a global position Recycle of gpship cause I can
if (dist (gpship, gaph) < 10) { // Is it close enough to grab?
apd = dist(gpship, gaph);
if ((PADSel==1)&& (PODID==1)){
AttachChild (hV, PaD1, hAtt);
break;}
if ((PADSel==2)&& (PODID==2)){
AttachChild (hV, PaD2, hAtt);
break;}
if ((PADSel==3)&& (PODID==3)){
AttachChild (hV, PaD3, hAtt);
break;}
but when I run it the selected vessel as an attachment ID of POD2. But when I check the id it says 3?
PODID 3
---------- Post added at 09:31 PM ---------- Previous post was at 06:11 AM ----------
ok a solution is to when the vessel is in the right area. Sequence 3. then dock to the vessel.
But I am not sure how to tell it to dock to the dock automatically. That way I don't have to deal with the attachment issue.
Code:
8.51.3.271 int VESSEL::Dock (OBJHANDLE target, UINT n, UINT tgtn, UINT mode) const
Dock to another vessel.
both docking numbers are 0. so I think I need to get the target vessel handle.