Problem Add a different kind of thrust effect

TMHLIVE

Sci-Fi Test Pilot
Joined
Feb 21, 2014
Messages
182
Reaction score
0
Points
0
OK. Everyone by now knows about me and that's fine. Even if I am not super impressed about why. Anyways I thought I would give it one more go to get help on a different issue then in the past. As for the most part that was a waste of time.

My developer friend and I are in a bit of a pickle. We are building the neb is everyone might know. That's the hovercraft from the matrix that the humans uses. Well there's a few of them. anyways...

These things fly using the magnetic field and pads. When the ship ergo the pads get close to something a bunch of lightning comes from that pad and hits what ever it is as the field is reacting to whatever it is close to.

is this possible?
here is a vid that shows it and what I mean. See how the pads react to the doors and walls.
http://youtu.be/Jt5z3OEjDzU?t=48s
I have heard him talk about collision detection. He has tried to explain it to me. But everyone knows I'm a idiot when it comes to the workings of orbiter.

thanks in advance.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,632
Reaction score
2,350
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Sure it is possible. But it is no thruster. A thruster works by ejecting mass and exchange of impulse. You can make a thruster act like something else, but that's pretty messy.

Better would be to simply use touchdown points and fake the actual "pseudo-physics" in a DLL.
 

TMHLIVE

Sci-Fi Test Pilot
Joined
Feb 21, 2014
Messages
182
Reaction score
0
Points
0
ya cause of how orbiter is. We are assigning pads to thrusters as well as the animation. It looks really cool we have been ironing out the movement for a while now. The mesh looks killer as well. ok so it is possible.

this is how we have her right now from what I understand anyways. (very limited)

we have landing gear on her. they have touchdown points i assume???

we need to add more touchdown points and assign animation to them? to get the lighting effect?

can you make like 6 or 7 different effects so that its not just the same one?

I get what your saying in concept but i still don't get how one would go about doing it.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,632
Reaction score
2,350
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
You have only tree touchdown points, which is all you really need. Three such points form a triangle. This triangle tries to lie flat on Earth. Changing the location of the touchdown points moves the spacecraft as well, including making the spacecraft jump, if you move them too fast.
 

TMHLIVE

Sci-Fi Test Pilot
Joined
Feb 21, 2014
Messages
182
Reaction score
0
Points
0
so the same touchdown points could be used a ref points for the lightning?
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,632
Reaction score
2,350
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
so the same touchdown points could be used a ref points for the lightning?

Sure. Or you use different points for the light and only calculate the triangle that is in contact with the surface.
 

TMHLIVE

Sci-Fi Test Pilot
Joined
Feb 21, 2014
Messages
182
Reaction score
0
Points
0
Thanks...i padded on your advice. he seems to understand my babble'ins so all is now good. thanks again.
 

Loru

Retired Staff Member
Retired Staff
Addon Developer
Donator
Joined
Sep 30, 2008
Messages
3,731
Reaction score
6
Points
36
Location
Warsaw
As for visual effect itself:

Lightning effect is achievable by creating bunch of semitransparent meshgroups covered in emmisive lightning textures and turning them on and off while near the object.

You won't hit exactly the target but this effect is certainly within capabilities of orbiter's API.

You can add 1-2 local light sources to enchance the effect.

Rest is just detecting near object and activating effects on certain "pads" (eg if object is on right then you activate effects on right pads).
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,734
Reaction score
2,702
Points
203
Location
Dallas, TX
Great, But how would you tell which direction/ distance another vessel is?
 

Loru

Retired Staff Member
Retired Staff
Addon Developer
Donator
Joined
Sep 30, 2008
Messages
3,731
Reaction score
6
Points
36
Location
Warsaw
Great, But how would you tell which direction/ distance another vessel is?

Usually it's done by comparing coordinates of both objects :p
 

TMHLIVE

Sci-Fi Test Pilot
Joined
Feb 21, 2014
Messages
182
Reaction score
0
Points
0
I think what he said he is gonna try is...and he would know better on how to explain it.

he is going to set up something that says if the ship is at this alt do this till this alt.

again I am no expert by any means on the coding. Hope it makes sense. :)

---------- Post added at 06:55 PM ---------- Previous post was at 06:54 PM ----------

Great, But how would you tell which direction/ distance another vessel is?

well, right from the man him self. He knows far far more then I.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,734
Reaction score
2,702
Points
203
Location
Dallas, TX
I know this code will check to see about attachments and are they close. But that would tell me if another vessel is near by. But how could I tell if that ship is in front. behind, above,.... my ship?

Code:
 for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
                    OBJHANDLE hV = oapiGetVesselByIndex (i);    //get handle for ship
        //            if (strncmp (hV->GetClassName(), "QJFFS", 5)!=0  ){  //restrict to only QuadJ ships to make it easy.

                    // Look for any ship with a child attach point. This allows the Mule to grap any object
                    if (hV == GetHandle()) continue; // If self then continue onward because we don't want to grapple ourselves ...

                    oapiGetGlobalPos (hV, &gpship); // get global postion of ship and put into gpship


                       VESSEL *v = oapiGetVesselInterface (hV);
                       // Only look for child attach point
                       DWORD nAttach = v->AttachmentCount (true); //Get attachment count. I do this so that I can grap any child point.
                       if (nAttach > 0){ // Only continue if ship has a child attach point
                           for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate and check how far away from the attach point it is
                               ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle (true, j);
                               /* this would allow me to filter out all but QJ ships but I don't want to right now
                               const char *id = v->GetAttachmentId (hAtt);
                               if (strncmp (id, "GS", 2)) 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) < MAX_GRAP_DIST) { // Is it close enough to grab?
                                   apd = dist(gpship, gaph);
 

TMHLIVE

Sci-Fi Test Pilot
Joined
Feb 21, 2014
Messages
182
Reaction score
0
Points
0
OMG...That's part of the code for the neb...scary. I don't have a clue what all that even means.

Props to you all. where's the universal translator?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,734
Reaction score
2,702
Points
203
Location
Dallas, TX
Actually it is part of the attachment code. But Not sure how to tell what direction a vessel is from me.
 

thepenguin

Flying Penguin
Addon Developer
Joined
Jul 27, 2013
Messages
220
Reaction score
1
Points
16
Location
Earth-Moon Lagrange Point (L4)
Actually it is part of the attachment code. But Not sure how to tell what direction a vessel is from me.

oapiGetRelativePos(VESSEL3 target, VESSEL3 reference, VECTOR3* distance);

Give it the two vessels, and take the vector. You get an exact relative position from the orbiter core.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,734
Reaction score
2,702
Points
203
Location
Dallas, TX
This is what I have. But not sure about direction

Code:
DWORD cnt= oapiGetVesselCount();  {
OBJHANDLE hme = GetHandle(),hv; 
VECTOR3 gpos,tpos;
GetGlobalPos (gpos);
double d;

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);
if (d<30) SetMeshVisibilityMode (PADSON1, MESHVIS_ALWAYS);
}
}
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,734
Reaction score
2,702
Points
203
Location
Dallas, TX
So what does this return look like?
GetRelativePos
Returns vessel’s current position with respect to another object.
Synopsis:
void GetRelativePos (OBJHANDLE hRef, VECTOR3 &pos) const
Parameters:
hRef reference object handle
pos vector receiving position
Notes:
· Results are w.r.t. ecliptic frame at equinox and ecliptic of J2000.0.
· Equivalent to oapiGetRelativePos (GetHandle(), hRef, &pos)



oapiGetRelativePos(VESSEL3 target, VESSEL3 reference, VECTOR3* distance);

Give it the two vessels, and take the vector. You get an exact relative position from the orbiter core.

---------- Post added 04-23-14 at 06:01 AM ---------- Previous post was 04-22-14 at 09:51 AM ----------

I have this. but get an error. But how can I get it more multiple vessel and it store compare the locations?
Code:
DWORD cnt= oapiGetVesselCount();  {
OBJHANDLE hme = GetHandle(),hv; 
VECTOR3 gpos,tpos,WHERETARGET;
GetGlobalPos (gpos);
double d,DISTANCE;

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, WHERETARGET);


if (d<30) 
{//do something
}





\NEB.CPP(924) : error C2664: 'oapiGetRelativePos' : cannot convert parameter 3 from 'VECTOR3' to 'VECTOR3 *'
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,632
Reaction score
2,350
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
If you need a pointer to a variable, just use:

Code:
&WHERETARGET

It is different to the VESSEL::GetRelativePos function, which takes a reference (VECTOR3 &) instead of a pointer (VECTOR3 *). For references, you need no & in front of the variable, because the reference is always set to a pointer to an existing variable (while pointers can point everywhere, including nowhere at all).

And remember, that you need to rotate this vector back into local coordinates, should you decide to do anything in local coordinates with it.
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,734
Reaction score
2,702
Points
203
Location
Dallas, TX
Thanks. I have this:
Code:
DWORD cnt= oapiGetVesselCount();  {
OBJHANDLE hme = GetHandle(),hv; 
VECTOR3 gpos,tpos,WHERETARGET;
GetGlobalPos (gpos);
double d,DISTANCE;

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, &WHERETARGET);
No errors.
But i expected some values other than zero's
Code:
sprintf(oapiDebugString(),"x%2f y%2f z%2f",WHERETARGET.x,WHERETARGET.y,WHERETARGET.z);

I can set it so it only checks direction for vessels

But how can I have it check for vessel#1,#2,....
So something would happen if a vessel is to left, and another vessel to the right,....
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,632
Reaction score
2,350
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
So something would happen if a vessel is to left, and another vessel to the right,....

You could turn a reference direction of your vessel into a vector in global/relative coordinates (GlobalRot, I think, sadly I have my tablet with the Orbiter docs at home right now) and then check if the angle between reference vector and vector from your ship to the target is smaller than a constant opening angle of a cone.

This is simply in quick pseudo-code (because I think its easier to read than correct C++ code in this special case):

Code:
 const double COSCONE = cos(CONE_ANGLE);
 const VECTOR3 REFVEC; //defined somewhere else, normalized
  
 double costgt;
 VECTOR3 tgt;
  
 costgt = dotp(tgt, REFVEC)/ length(tgt);
  
 if(costgt <= COSCONE) //it is inside this cone
 
Top