See site in english Voir le site en francais
Website skin:
home  download  forum  link  contact

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

Author Topic: sdk question_ action area  (Read 6309 times)

0 Members and 2 Guests are viewing this topic.

Offline gattico

  • Sr. Member
  • ****
  • Posts: 339
  • Country: United States us
  • Karma: 15
08 February 2010, 01:17:03
I have looked at the sdk.  Not seen how to set it so an ummu can open doors,...  Saw how it can set off a wav though


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15410
  • Karma: 265
  • Hein, quoi !?
    • FsPassengers
Reply #1 - 08 February 2010, 01:27:52
Did you looked at the ShuttlePB example ?
Declaration and process are explained.

Dan


Offline gattico

  • Sr. Member
  • ****
  • Posts: 339
  • Country: United States us
  • Karma: 15
Reply #2 - 08 February 2010, 02:34:50
I saw this in the Ummu
//----------------------------------------------------------------------------
   // OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL
   // DetectActionAreaActivated
   // This function will detect one keypress of UMMU inside one action area (see "DeclareActionArea" above)
   // It can be used to open doors, activate things, repair system etc. etc.
   int ActionAreaReturnCode=Crew.DetectActionAreaActivated();
   if(ActionAreaReturnCode>-1)
   {
      // this is just an example, we have four area declared
      // action area ID 0 triggered
      if(ActionAreaReturnCode==0)
      {
         // do something cool here
      }
      // action area ID 1 triggered
      else if(ActionAreaReturnCode==1)
      {
         // As you can edit action area in real time: relocation, sound, text, state
         // the possiblity are endless. you can for example order a UMMU to go to an external panel
         // and open it, then go to engine exhaust and "repair" it then back to panel to close it etc.
         if(iActionAreaDemoStep==0)
         {
            Crew.SetActionAreaText(1,"You are still on the right but this is 2nd keypress");
            iActionAreaDemoStep++;
            // do something cool here
         }
         else if(iActionAreaDemoStep==1)
         {
            // remember you change action area's parameter for the NEXT keypress of UMMU
            Crew.SetActionAreaText(1,"You are still on the right but this is 3rd keypress");
            iActionAreaDemoStep++;
            // do something cool here
         }
         else
         {
            Crew.SetActionAreaText(1,"You are still on the right but this is last keypress");
            // and of course you can change sound, location, state, text, here some examples:
            //Crew.SetActionAreaPos(1,_V(5,0,5)); // change location
            //Crew.SetActionAreaWav(1,"MyAddon\PlayRepaired.wav"); // change sound
            //Crew.SetActionAreaWav(1,"MyAddon\DoorClosed.wav"); // change sound
            //Crew.SetActionAreaText(1,NULL); // sound or text are not mandatory, here we set no text.
            // etc. etc.
         }
      }
      // action area ID 2 triggered
      else if(ActionAreaReturnCode==2)
      {
         // do something cool here
      }
      // action area ID 3 triggered
      else if(ActionAreaReturnCode==3)
      {
         // do something cool here
      }
   }
But I see no animation action like open doors,...

//----------------------------------------------------------------
   // OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL
   // DeclareActionArea
   // Ever wanted to be able to open a door, repair a system or trigger something in your vessel from an UMMU ?
   // Here come a new feature of UMMU 2.0: Action area. See UMmuSDK.h and PDF doc for complete explanation and see
   // "DetectActionAreaActivated" below.
   Crew.DeclareActionArea(0,_V(-5,0,0),2.5,TRUE,"action_activated.wav","You are on the left of the ship");
   Crew.DeclareActionArea(1,_V(5,0,0),2.5,TRUE, "action_repaired.wav","You are on the right of the ship");
   Crew.DeclareActionArea(2,_V(0,0,5),2.5,TRUE, "action_activated.wav","You are in front of the ship");
   Crew.DeclareActionArea(3,_V(0,0,-5),2.5,TRUE,"action_activated.wav","You are behind the ship");
   iActionAreaDemoStep=0;   // this is just to show a feature of action area, see below "DetectActionAreaActivated"


In the PDF there is this:
Crew.DeclareActionArea(AZURELIFT, _V(0,-22,83),12

I get the vector and radius but it is the get the animation to work


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15410
  • Karma: 265
  • Hein, quoi !?
    • FsPassengers
Reply #3 - 08 February 2010, 02:48:16
Action area is simply a way to pass an "action information" from UMmu to your vessel, what you do with this information is up
to you: Sound, system, animation, whatewer.

Dan


Offline gattico

  • Sr. Member
  • ****
  • Posts: 339
  • Country: United States us
  • Karma: 15
Reply #4 - 08 February 2010, 03:35:45
Ok but how to I get it to run an animation.

In your example if the ummu is in range it can operate the lift.  I understand the range it is the getting the animation to work.


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15410
  • Karma: 265
  • Hein, quoi !?
    • FsPassengers
Reply #5 - 08 February 2010, 04:18:57
Sorry ?

If you have a dll you can define an animation and control it.
Instead of using a keypress to set it's state simply get if
an action area was triggered from outside and change
animation state.

How to set an animation is up to Orbiter SDK not UMmu SDK.

Action area is only meant to trigger vessel things from UMmu (outside your ship)
not to design all your vessel animation and system for you with two functions.

Hope it's clear ?

Dan


Offline gattico

  • Sr. Member
  • ****
  • Posts: 339
  • Country: United States us
  • Karma: 15
Reply #6 - 08 February 2010, 04:42:48
Ok I guess I am not clear.  I have animation set up in a vessel when I press a key G it performs the animation.  But Can I
have the Ummu do that same function?  That is my question.  

if(key==OAPI_KEY_G) // pad elevator
{
   RevertLP();
         return 1;
      }


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15410
  • Karma: 265
  • Hein, quoi !?
    • FsPassengers
Reply #7 - 08 February 2010, 06:45:31
Code: [Select]
int ActionAreaReturnCode=Crew.DetectActionAreaActivated();
if(ActionAreaReturnCode==0)
{
      RevertLP();
}

It's really obvious ;) one question: is it your first dll ?

Dan


Offline gattico

  • Sr. Member
  • ****
  • Posts: 339
  • Country: United States us
  • Karma: 15
Reply #8 - 08 February 2010, 12:31:18
yes.  This is what I have but no action.  The animation works if I do from the vessel:

   Crew.DeclareActionArea(0,_V(-28,0,32.8),10,TRUE,"action_activated.wav","Open/Close Travel Tube Doors");
   Crew.DeclareActionArea(1,_V(58.8,0,0),10,TRUE, "action_activated.wav","Open/Close Travel Tube Doors");

I get inside action area.  So I know that is right

int ActionAreaReturnCode=Crew.DetectActionAreaActivated();
   if(ActionAreaReturnCode>-1)
   {
      // this is just an example, we have four area declared
      // action area ID 0 triggered
      if(ActionAreaReturnCode==0)
      {
         RevertDD1();
      }


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15410
  • Karma: 265
  • Hein, quoi !?
    • FsPassengers
Reply #9 - 08 February 2010, 13:48:38
Yes but are the function DetectActionAreaActivated inside clbkPostStep ?

Dan


Offline gattico

  • Sr. Member
  • ****
  • Posts: 339
  • Country: United States us
  • Karma: 15
Reply #10 - 08 February 2010, 14:33:01
Yes right here:
void ALPHAPAD2::clbkPostStep(double simt, double simdt, double mjd)
{

   // OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL
   // DetectActionAreaActivated
   // This function will detect one keypress of UMMU inside one action area (see "DeclareActionArea" above)
   // It can be used to open doors, activate things, repair system etc. etc.
   int ActionAreaReturnCode=Crew.DetectActionAreaActivated();
   if(ActionAreaReturnCode>-1)
   {
      // this is just an example, we have four area declared
      // action area ID 0 triggered
      if(ActionAreaReturnCode==0)
      {
         RevertDD1();


and this:
void ALPHAPAD2::clbkSetClassCaps_UMMu(void)
   Crew.DeclareActionArea(0,_V(-28,0,32.8),10,TRUE,"action_activated.wav","Open/Close Travel Tube Doors");
   Crew.DeclareActionArea(1,_V(58.8,0,0),10,TRUE, "action_activated.wav","Open/Close Travel Tube Doors");


Offline gattico

  • Sr. Member
  • ****
  • Posts: 339
  • Country: United States us
  • Karma: 15
Reply #11 - 09 February 2010, 03:44:13
This what I have:
// OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL
   // DetectActionAreaActivated
   // This function will detect one keypress of UMMU inside one action area (see "DeclareActionArea" above)
   // It can be used to open doors, activate things, repair system etc. etc.
   int ActionAreaReturnCode=Crew.DetectActionAreaActivated();
   if(ActionAreaReturnCode>-1)
   {
      // this is just an example, we have four area declared
      // action area ID 0 triggered
      if(ActionAreaReturnCode==0)
      {
         RevertDD1();
      }
      // action area ID 1 triggered
      else if(ActionAreaReturnCode==1)
      {
         // As you can edit action area in real time: relocation, sound, text, state
         // the possiblity are endless. you can for example order a UMMU to go to an external panel
         // and open it, then go to engine exhaust and "repair" it then back to panel to close it etc.
         if(iActionAreaDemoStep==0)
         {
            Crew.SetActionAreaText(1,"Open/Close Travel tube doors");
            iActionAreaDemoStep++;
            // do something cool here
         }
         else if(iActionAreaDemoStep==1)
         {
            // remember you change action area's parameter for the NEXT keypress of UMMU
            Crew.SetActionAreaText(1,"Open/Close Travel tube doors");
            iActionAreaDemoStep++;
            // do something cool here
         }
         //else
         //{
            //Crew.SetActionAreaText(1,"You are still on the right but this is last keypress");
            // and of course you can change sound, location, state, text, here some examples:
            //Crew.SetActionAreaPos(1,_V(5,0,5)); // change location
            //Crew.SetActionAreaWav(1,"MyAddon\PlayRepaired.wav"); // change sound
            //Crew.SetActionAreaWav(1,"MyAddon\DoorClosed.wav"); // change sound
            //Crew.SetActionAreaText(1,NULL); // sound or text are not mandatory, here we set no text.
            // etc. etc.
         //}
      }
      // action area ID 2 triggered
      else if(ActionAreaReturnCode==2)
      {
         RevertDD2();
      }
      // action area ID 3 triggered
      //else if(ActionAreaReturnCode==3)
      //{
         // do something cool here
      //}
   }

When I get in the area and press return I get the msg:Open/Close Travel tube doors  but that is it.


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15410
  • Karma: 265
  • Hein, quoi !?
    • FsPassengers
Reply #12 - 09 February 2010, 04:01:26
Copying/pasting roughly without understanding what you do will not teach you anything.

You can ask one question per C++ line during the 5 next years if you do not do an effort to
search and understand by yourself. It's all about that: good coders are NOT the one that
understand/know everything and every function BUT those that know how/where to search
informations.

See doc in the SDK header (h file) for an explaination of the two area functions.

1-You declare one area at init time
2-At run time (every frame) one function search if this area was triggered by one Ummu and do what you want.

Now you trigger your door for ID 2

Code: [Select]
else if(ActionAreaReturnCode==2)
{
RevertDD2();
}

What's the ID of the action area you declare ? Are you sure they are the same ?
If you are not sure simplify, declare only one area and detect only one area.


Hope this help ?

Dan


Offline gattico

  • Sr. Member
  • ****
  • Posts: 339
  • Country: United States us
  • Karma: 15
Reply #13 - 10 February 2010, 18:19:29
Yeah got it to work!!!!!!!!!!!


Now to work on getting my own mesh to work as a UMMU.  Any advice.  I could get it to work with 1.5


Offline gattico

  • Sr. Member
  • ****
  • Posts: 339
  • Country: United States us
  • Karma: 15
Reply #14 - 13 February 2010, 18:34:22
Is there a way to have to action area in the same location?


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15410
  • Karma: 265
  • Hein, quoi !?
    • FsPassengers
Reply #15 - 13 February 2010, 20:01:25
Quote
gattico a écrit:
Is there a way to have to action area in the same location?

Why would you want to do this ? It's the same has having two doors for the same entry !?

Dan


Offline gattico

  • Sr. Member
  • ****
  • Posts: 339
  • Country: United States us
  • Karma: 15
Reply #16 - 13 February 2010, 20:10:26
If you have an airlock with 2 doors (inner and outer)  You would not want to open both at the same time.


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15410
  • Karma: 265
  • Hein, quoi !?
    • FsPassengers
Reply #17 - 14 February 2010, 07:34:32
Aaah, as there is at least two/three meter difference beetween inner and outer just make one "bubble" in front of each.

Dan

« Last Edit: 14 February 2010, 07:34:32 by DanSteph »