I added it.
Now the questions?
What should tgt and REFVEC be?
Now the questions?
What should tgt and REFVEC be?
I added it.
Now the questions?
What should tgt and REFVEC be?
oapiGetRelativePos(hme, hv, &tgt);
CONE_ANGLE=1;
const double COSCONE = cos(CONE_ANGLE);
REFVEC=_V(0,0,1);
sprintf(oapiDebugString(),"x%2f COSCONE%2f ",costgt,COSCONE);
costgt = dotp(tgt, REFVEC)/ length(tgt);
if(costgt <= COSCONE) {//it is inside this cone
Is there a way to look all around. Or would I have to do different vectors?
I am confused then. What is the CONEANGLE?
So if a vessel is in area 1 show mesh 1, if a vessel is where vessel 2 is then show mesh 2. ,.... It will not be precise as the meshes would not chnage but there would be several meshes to cover 360 around
Otherwise Should I have 4 different zones of detection?
CONE_ANGLE=0; // 0 degrees in front
const double COSCONE = cos(CONE_ANGLE);
REFVEC=_V(0,0,1);
sprintf(oapiDebugString(),"costgt%2f COSCONE%2f Distance%2f",costgt,COSCONE,d);
costgt = dotp(tgt, REFVEC)/ length(tgt);
if(costgt <= COSCONE) {//it is inside this cone
CONE_ANGLE=0;
const double COSCONE = cos(CONE_ANGLE);
REFVEC=_V(0,-1,0);
sprintf(oapiDebugString(),"costgt%2f COSCONE%2f Distance%2f",costgt,COSCONE,d);
costgt = dotp(tgt, REFVEC)/ length(tgt);
Is there a way to compare my location and another vessels location. if his x is larger then he is to the right?,......
for ( unsigned int i = 0; i<cnt; i++)
{hv = oapiGetVesselByIndex (i);
//if (hV == GetHandle()) continue;
if (hme == hv) continue;
oapiGetGlobalPos (hv, &tpos);
d=dist (gpos,tpos);
oapiGetRelativePos(hme, hv, &tgt);
CONE_ANGLE=0;
const double COSCONE = cos(CONE_ANGLE);
REFVEC=_V(0,-1,0);
//sprintf(oapiDebugString(),"costgt%2f COSCONE%2f Distance%2f",costgt,COSCONE,d);
costgt = dotp(tgt, REFVEC)/ length(tgt);
Do you mean this code:
Then I am confused.
Would that cone of space work. But i am not sure what the cone angle and what solution values I get would mean?
for ( unsigned int i = 0; i<cnt; i++)
{hv = oapiGetVesselByIndex (i);
//if (hV == GetHandle()) continue;
if (hme == hv) continue;
oapiGetGlobalPos (hv, &tpos);
d=dist (gpos,tpos);
oapiGetRelativePos(hme, hv, &tgt);
CONE_ANGLE=0;
const double COSCONE = cos(CONE_ANGLE);
REFVEC=_V(0,-1,0);
//sprintf(oapiDebugString(),"costgt%2f COSCONE%2f Distance%2f",costgt,COSCONE,d);
costgt = dotp(tgt, REFVEC)/ length(tgt);
ALT=GetAltitude();
if(costgt <= COSCONE) {//it is inside this cone
DWORD cnt= oapiGetVesselCount(); {
OBJHANDLE hme = GetHandle(),hv;
VECTOR3 gpos,tpos,WHERETARGET,REFVEC,tgt;
GetGlobalPos (gpos);
double d,CONE_ANGLE;
for ( unsigned int i = 0; i<cnt; i++)
{hv = oapiGetVesselByIndex (i);
//if (hV == GetHandle()) continue;
if (hme == hv) continue;
oapiGetGlobalPos (hv, &tpos);
d=dist (gpos,tpos);
oapiGetRelativePos(hme, hv, &tgt);
CONE_ANGLE=45;
const double COSCONE = cos(CONE_ANGLE);
REFVEC=_V(0,0,1);
sprintf(oapiDebugString(),"costgt%2f COSCONE%2f ",costgt,COSCONE);
costgt = dotp(tgt, REFVEC)/ length(tgt);
ALT=GetAltitude();
if(costgt <= COSCONE) {//it is inside this cone
if (ALT<30)
But if I move forward so now the vessel is behind should the costgt be greater COSCONE?