3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1] 2

Author Topic: Android log-in Swip pattern for 3Drad  (Read 645 times)

« on: December 25, 2013, 10:52:12 AM »
So i got the idea to remake the swipe pattern log-in in 3drad for projects that use usernames. Basically, this swipe pattern would be the account password.

So i got the idea to use a sprite ( 16x4 ) as the source of the line process.

Then by clicking on screen to get the start location, stretch the sprite to the mouse screen location.

This would recreate the swipe pattern process.

So i have 1 question -

#1 How to get a sprite at a mouse selected screen location, rotate and point towards ( follow ) the mouse on-screen, while keeping it's start location.

I know how to adjust the sprite size to create the stretching effect.

Figuring the math to position it for a start location and stretch it to an end location... i'll nave to work on that :P

The two included pictures are the swipe pattern ( for anyone who's never seen the smart-phone unlock swipe pattern screen ).

The other is the intended sprite for the line process.
« Reply #1 on: December 26, 2013, 10:49:41 PM »
Hi Tin the code is a little function I used to position and scale sprites on the screen.

Hope this helps

n_iron


Code: [Select]
/// positions and scales sprite
void positionSprite(int obj, float scaleX,float scaleY, float posX, float posY){
   iObjectScaleSet(obj,Vector3(scaleX,scaleY,0.0)); // main menu
   iObjectLocationSet(obj,Vector3(posX,posY,0.0));
   iObjectShow(obj);
}
« Reply #2 on: December 28, 2013, 01:56:36 AM »
we'll see , thankyou
« Reply #3 on: December 28, 2013, 05:12:17 AM »
I gave it a try, it's a good question.

Below is a function which draws a line from one point to another.

Code: [Select]
void DrawLine(int obj, Vector3 loc1, Vector3 loc2, float thickness)
{
   Vector3 avLoc = Vector3( (loc1.x+loc2.x)/2, (loc1.y+loc2.y)/2, (loc1.z+loc2.z)/2);
   iObjectLocationSet(obj,avLoc);

   Vector3 difLoc = loc1 - loc2;
   Quaternion q;
   iQuaternionLookAt(q,difLoc,Vector3(0,0,1));
   iObjectOrientationSet(obj,q);

   iObjectScaleSet(obj,Vector3(thickness, iVectorLength(difLoc), 1));
}

void Main()
{
   Vector3 locA, locB;
   iObjectLocation(OBJ_22,locA);
   iObjectLocation(OBJ_44,locB);

   DrawLine(OBJ_0, locA, locB, 0.1);
}

I'm sure you could get this converted to Sprite imposters or something.
Good luck.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #4 on: December 29, 2013, 01:25:34 AM »
Thankyou RobertooMolvadoo

Sweet, this will do the stretchy job perfectly :).
« Reply #5 on: December 29, 2013, 01:40:55 AM »
Oh RobertooMolvadoo

I have to thankyou again for this, it's exactly what i needed.

I did a quick test and added screen mouse locations to LocB and away we go.

the line follows the mouse perfectly
Code: [Select]
/// OBJ_0 = sprite to use for the line source
/// OBJ_22 = is used to get the start screen position
/// OBJ_44 = unused at this point, but can be used as the
///          line screen end point
///
/// what i've done below is just update locB.x & locB.y with the
/// mouse screen x & y positions.

void DrawLine(int obj, Vector3 loc1, Vector3 loc2, float thickness)
{
   Vector3 avLoc = Vector3( (loc1.x+loc2.x)/2, (loc1.y+loc2.y)/2, (loc1.z+loc2.z)/2);
   iObjectLocationSet(obj,avLoc);

   Vector3 difLoc = loc1 - loc2;
   Quaternion q;
   iQuaternionLookAt(q,difLoc,Vector3(0,0,1));
   iObjectOrientationSet(obj,q);

   iObjectScaleSet(obj,Vector3(thickness, iVectorLength(difLoc), 1));
}

void Main()
{
   Vector3 locA, locB;
   iObjectLocation(OBJ_22,locA);

   locB.x = iMouseX()*32.0-16.0;
   locB.y = 12.0-iMouseY()*24.0;
   locB.z = 0.0;
   //iObjectLocation(OBJ_44,locB);

   DrawLine(OBJ_0, locA, locB, 0.8);
}

what you get is a line that follows the mouse on screen :)
« Reply #6 on: December 29, 2013, 02:40:52 AM »
Always happy to help.  ;)
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #7 on: December 31, 2013, 02:37:23 AM »
an update to the swipe pattern.

I was spending some time thinking on how to setup imposter sprites.

Then just now figured it wasn't really needed, it would make the script more efficient but in my setup, i plan to use the log-in / password ( swipe screen) as a seperate program that calls the main program once a successful log-in has been entered.

With this design, efficiency isn't  required, due to the overall limited scripting needed.

So i'm using instead 12 buttons & 12 sprite lines, each button has it's own line.

As you click & hold and select a button, that actives the buttons line till you hit another ( mouse over ) the next button which repeats the process with the new buttons line.

pretty simple setup.

each button = a password value, & each button can only be selected once per pattern for 12 possible character or value password.

12 character passwords or minimum 4, should keep everyone happy, plus the ability to update/change the password after logging in.

To add to that, the possible use of player names and what ever data can be added for actual accounts to be created.

That's the current vision / design i'm creating.

I'll be back crying, when i hit a brick wall :P, fingers crossed i'll swerve in time..
« Reply #8 on: January 03, 2014, 09:52:01 AM »
when you get this done could you post a short video of it in action...

i'm not an avid  smart phone user, so i have no idea what this is all about...

thx

--Mike
« Reply #9 on: January 04, 2014, 02:48:05 AM »
i will
« Reply #10 on: January 11, 2014, 12:23:09 AM »
put the two included sprites in your sprite>data folder
usually ( 3DRad_res\objects\Sprite\data ).

So i been playing with this imposter sprite lines & buttons.

For some reason the imposter stretching isn't quite working as i need it to..

I'm sure it's a simple issue, but i don't understand Quaternions enough to figure it out in my head how to fix the stretching.

Somebody wanna take a look and guide me ? 
« Reply #11 on: January 11, 2014, 03:30:06 AM »
This is very odd.

It works fine when you use the object itself instead of an imposter. I have no clue what could be wrong.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #12 on: January 11, 2014, 11:32:57 AM »
Found the problem i think.

it appears an offset issue is happening with the imposter positioning, i can't say if this an error with imposters or just the script setup.

adding a offset to the imposter position is heading in the right direction, but the maths are off just a bit.

Replace the whole script with this
( i've only added one line, but think replacing the whole script is easier for everyone, rather then saying, "edit the script" like this).

Note the "drawline()" script line added -
"   loc1.x -= difLoc.x/2;  '  & it's effect.

It appears just an offset is required, or maybe to be undone, to correct the imposter positioning ?
Code: [Select]
int[] MBO(14);

float Mx, My;

/// OBJ_0  = sprite line source
/// OBJ_22 = Sprite button source & used for start screen positioning
/// OBJ_44 = ValuePrint
/// OBJ_66 = ValuePrint

void DrawLine(int obj, Vector3 loc1, Vector3 loc2, float thickness)
{
   Vector3 avLoc = Vector3( (loc1.x+loc2.x)/2, (loc1.y+loc2.y)/2, (loc1.z+loc2.z)/2);
   iObjectLocationSet(obj,avLoc);

   Vector3 difLoc = loc1 - loc2;

   Quaternion q;
   iQuaternionLookAt(q,difLoc,Vector3(0,0,1));
 
   iObjectOrientationSet(obj,q);
   iObjectScaleSet(obj,Vector3(thickness, iVectorLength(difLoc), 1));

   loc1.x -= difLoc.x/2;

   iObjectImposterShow(obj,0);
   iObjectImposterSet(obj,0,q,loc1);
}

void Main()
{
   if (iInitializing()) DoInt();
   if (iDeinitializing()) DoDeInt();
   
   Mx = iMouseX()*32.0-16.0;
   My = 12.0-iMouseY()*24.0;

   OUT_44 = Mx;
   OUT_66 = My;

   if (iMouseButtonDown(0)){
   Vector3 locA, locB;
   iObjectLocation(OBJ_22,locA);
   iObjectShow(OBJ_0);

   locB.x = Mx;
   locB.y = My;
   locB.z = 0.0;

   DrawLine(OBJ_0, locA, locB, 0.8);
   }
}

//-----------------------
void DoInt(){
   for(int A=0;A<14;A++)MBO[A]=-1;

   iObjectImpostersCreate(OBJ_0,12);  //  Lines
   iObjectImpostersCreate(OBJ_22,12); //  Buttons
   Quaternion q;

   int B=0, C=4;
   float X=-9.0, Y=6.0, Z=0;
 
   for(int A=0;A<4;A++){
      for(B;B<C;B++){
         iObjectImposterSet(OBJ_0,B,q,Vector3(X,Y,Z));
         iObjectImposterHide(OBJ_0,B);
         iObjectImposterSet(OBJ_22,B,q,Vector3(X,Y,Z));
         X += 6;
      }
      X=-9.0; Y-=6.0; C+=4;
   }
}
//------------------------
void DoDeInt(){
   iObjectImpostersDestroy(OBJ_0);
   iObjectImpostersDestroy(OBJ_22);
}
« Reply #13 on: January 11, 2014, 12:06:46 PM »
final edit, fixed the problem.

as before replace the WHOLE script with this & note the "drawline" function & the 2 added offset lines.
Code: [Select]
int[] MBO(14);

float Mx, My;

/// OBJ_0  = sprite line source
/// OBJ_22 = Sprite button source & used for start screen positioning
/// OBJ_44 = ValuePrint
/// OBJ_66 = ValuePrint

void DrawLine(int obj, Vector3 loc1, Vector3 loc2, float thickness)
{
   Vector3 avLoc = Vector3( (loc1.x+loc2.x)/2, (loc1.y+loc2.y)/2, (loc1.z+loc2.z)/2);
   iObjectLocationSet(obj,avLoc);

   Vector3 difLoc = loc1 - loc2;

   Quaternion q;
   iQuaternionLookAt(q,difLoc,Vector3(0,0,1));
 
   iObjectOrientationSet(obj,q);
   iObjectScaleSet(obj,Vector3(thickness, iVectorLength(difLoc), 1));

/// these 2 lines correct the offset showing with the imposter
   loc1.x -= difLoc.x/2;
   loc1.y -= difLoc.y/2;

/// hide the original sprite
/// so we only see the imposter
   iObjectHide(obj);

   iObjectImposterShow(obj,0);
   iObjectImposterSet(obj,0,q,loc1);

   OUT_44 = loc1.x;
   OUT_66 = loc1.y;
}

void Main()
{
   if (iInitializing()) DoInt();
   if (iDeinitializing()) DoDeInt();
   
   Mx = iMouseX()*32.0-16.0;
   My = 12.0-iMouseY()*24.0;


   if (iMouseButtonDown(0)){
   Vector3 locA, locB;
   iObjectLocation(OBJ_22,locA);
   iObjectShow(OBJ_0);

   locB.x = Mx;
   locB.y = My;
   locB.z = 0.0;

   DrawLine(OBJ_0, locA, locB, 0.8);
   }
}

//-----------------------
void DoInt(){
   for(int A=0;A<14;A++)MBO[A]=-1;

   iObjectImpostersCreate(OBJ_0,12);  //  Buttons
   iObjectImpostersCreate(OBJ_22,12); //  Lines
   Quaternion q;

   int B=0, C=4;
   float X=-9.0, Y=6.0, Z=0;
 
   for(int A=0;A<4;A++){
      for(B;B<C;B++){
         iObjectImposterSet(OBJ_0,B,q,Vector3(X,Y,Z));
         iObjectImposterHide(OBJ_0,B);
         iObjectImposterSet(OBJ_22,B,q,Vector3(X,Y,Z));
         X += 6;
      }
      X=-9.0; Y-=6.0; C+=4;
   }
}
//------------------------
void DoDeInt(){
   iObjectImpostersDestroy(OBJ_0);
   iObjectImpostersDestroy(OBJ_22);
}
« Reply #14 on: March 09, 2014, 08:45:56 AM »
So i got the idea to remake the swipe pattern log-in in 3drad for projects that use usernames. Basically, this swipe pattern would be the account password.

So i got the idea to use a sprite ( 16x4 ) as the source of the line process.

Then by clicking on screen to get the start location, stretch the sprite to the mouse screen location.

This would recreate the swipe pattern process.

So i have 1 question -

#1 How to get a sprite at a mouse selected screen location, rotate and point towards ( follow ) the mouse on-screen, while keeping it's start location.

I know how to adjust the sprite size to create the stretching effect.

Figuring the math to position it for a start location and stretch it to an end location... i'll nave to work on that :P

The two included pictures are the swipe pattern ( for anyone who's never seen the smart-phone unlock swipe pattern screen ).

The other is the intended sprite for the line process.
I don't know what are you saying. how can you run 3d rad on android?
Pages: [1] 2