Gamestudio Links
Zorro Links
Newest Posts
Mixed frequency history (M1+D)
by jcl
Today at 12:21
New Zorro version 2.12
by jcl
Today at 11:48
This is my fault-tolerant ATR indicator for you
by OptimusPrime
05/18/19 16:35
missing trade variables
by AndrewAMD
05/18/19 12:37
export asset to .txt file
by sdh309795gaas
05/17/19 16:21
LookBack mysteries
by sdh309795gaas
05/17/19 06:28
It is easy for you.
by AndrewAMD
05/16/19 16:39
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online
11 registered (AndrewAMD, kvm, jumpman, mk_1, Dalla, MatPed, FLD, Realspawn, JeyKey II, 1 invisible), 460 Guests and 6 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
h4h4rd, ccm, Pippo, hurleydood, JohnLouderback
18222 Registered Users
Topic Options
Rate This Topic
#475697 - 01/04/19 04:01 Need a Math Pro (Parent / Child Rotation and XY coords)
Garrettwademan Offline
Member

Registered: 01/26/06
Posts: 242
Loc: PA
Okay guys, I am really sorry for this question, it seems so basic but I can't seem to get it. What I am trying to do is make a parent model (in this case the Computer Case) and child models (like CPU, RAM, Connectors) rotate in synconry yet keep their reletive X and Y positions to the computer case. Here is a video of what I have now, and here is the code I am using to do it. Is it because each model isn't aligned in its own axis in MED? Any help is greatly appreciated.

Its close, but not where it should be as it rotates.

YouTube Rotate Demo Current

Code:
//my is each object such as CPU, RAM, Hard Drive, Circuit Board
//arcade_Case is the Parent
//varLocDifX is the offset of the my model, relative to the arcade_Case

varLocDifX = my.x - arcade_Case.x;
varLocDifY = my.y - arcade_Case.y;
varLocDifZ = my.z - arcade_Case.z;

my.pan = arcade_Case.pan;		
my.x = arcade_Case.x + varLocDifX * cos(arcade_Case.pan + 90);
my.y = arcade_Case.y + varLocDifY * sin(arcade_Case.pan + 90);
my.z = arcade_Case.z + varLocDifZ;



Edited by Garrettwademan (01/04/19 04:05)
_________________________
Current Project: Computer Repair Simulator
https://www.computer-repair-simulator.com

Top
#475702 - 01/04/19 10:30 Re: Need a Math Pro (Parent / Child Rotation and XY coords) [Re: Garrettwademan]
txesmi Offline
Serious User

Registered: 06/13/07
Posts: 1216
Loc: Hiporope and its pain
Hi,
a 2d vector rotation is computed as follows

Code:
x1 = x * cos - y * sin;
y1 = x * sin + y * cos;



Anyway, the computation of the offset vector should not be performed each frame. Otherway it will continuously lose a little length caused by the accuracy limits of the variables.

Code:
vec_diff(my.skill1, my.x, entParent.x); // save the offset vector into three skills
while(1) {
   vec_set(my.x, my.skill1);
   vec_rotate(my.x, entParent.pan);
   vec_add(my.x, entParent.x);
   vec_set(my.pan, entParent.pan);
   wait(1);
}



Salud!

Top
#475720 - 01/05/19 02:42 Re: Need a Math Pro (Parent / Child Rotation and XY coords) [Re: txesmi]
Garrettwademan Offline
Member

Registered: 01/26/06
Posts: 242
Loc: PA
Yea, that did the trick, amazing. Thank you! I am going to study more on these because I think this will help me with a bunch of other stuff too.
_________________________
Current Project: Computer Repair Simulator
https://www.computer-repair-simulator.com

Top
#475760 - 01/07/19 07:08 Re: Need a Math Pro (Parent / Child Rotation and XY coords) [Re: txesmi]
Garrettwademan Offline
Member

Registered: 01/26/06
Posts: 242
Loc: PA
I was able to use what you had and build upon it. You were very helpful. Here is a video of it all working perfectly now.

YouTube Demo Video
_________________________
Current Project: Computer Repair Simulator
https://www.computer-repair-simulator.com

Top
#475761 - 01/07/19 10:08 Re: Need a Math Pro (Parent / Child Rotation and XY coords) [Re: Garrettwademan]
txesmi Offline
Serious User

Registered: 06/13/07
Posts: 1216
Loc: Hiporope and its pain
Congratulations! laugh

Top


Moderator:  HeelX, TSG_Torsten 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de