SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 05/02/2019, 04:50 PM   #11
Lunoxx
Big Clucker
 
Join Date: Feb 2015
Posts: 54
Reputation: 0
Default Re: Need help with spatial geometry

Same result.
Code: https://i.imgur.com/8kPEo7a.png
Results:
Code:
values 1: 0.000000 0.000000 -0.009998 -0.469998 0.000000 90.000000 // offsets of crane cabine
values ret: -383.852844 1154.011108 -0.009998 -0.469991 0.000000 136.199996 // returned by function
And real position of crane-base:
Code:
-1541.100219,130.634063,26.704730,0.000000,0.000000,46.199996 // position of crane base (CreateDynamicObject)
(Crane cabine is directly attached to crane-base)
__________________
Skype: alin.m99
Discord: lunoxx#1155
FB Page: f.a.c.e.book.com/pawnscripts
Lunoxx is offline   Reply With Quote
Old 05/02/2019, 07:04 PM   #12
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,892
Reputation: 1321
Default Re: Need help with spatial geometry

You messed up you are passing rotation values for position and rotation.

@Edit

Show me your attached offset positions.

Last edited by Pottus; 05/02/2019 at 08:00 PM.
Pottus is offline   Reply With Quote
Old 05/02/2019, 08:45 PM   #13
Lunoxx
Big Clucker
 
Join Date: Feb 2015
Posts: 54
Reputation: 0
Default Re: Need help with spatial geometry

Quote:
Originally Posted by Pottus View Post
You messed up you are passing rotation values for position and rotation.

@Edit

Show me your attached offset positions.
Code:
AttachDynamicObjectToObject_lnx(cabina, baza, 0.000000,0.000000,-0.009999,-0.469999,0.000000,90.000000); // cabine to base
AttachDynamicObjectToObject_lnx(brat, cabina, 0.000000,-2.069998,8.448098,0.000000,0.000000,0.000000); // crane-arm (i think) to cabine
AttachDynamicObjectToObject_lnx(cablu0, brat, 0.000000,36.869819,-0.569999,0.000000,0.000000,0.000000); // cable to arm
AttachDynamicObjectToObject_lnx(magnet, cablu0, 0.000000, 0.000000,-7.440086,0.000000,0.000000,0.000000); // magnet to cable
AttachDynamicObjectToObject_lnx(cablu1, magnet, 0.000000, 0.000000,7.440086,0.000000,0.000000,0.000000); // suplimentary cable for "effect go-down"
EDIT: _lnx because I saved in this function offsets in variables.
__________________
Skype: alin.m99
Discord: lunoxx#1155
FB Page: f.a.c.e.book.com/pawnscripts
Lunoxx is offline   Reply With Quote
Old 05/02/2019, 09:26 PM   #14
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,892
Reputation: 1321
Default Re: Need help with spatial geometry

Show me the values basepos[]

@Edit

I also noticed you are attaching objects to object to object etc.. that means you need to rotate the point several times! Using the result as the next point of reference and translating the offsets to the next position rotation. It sounds complicated but it's very easy.

Code:
// List of attached objects to the base we need to calculate sequentially in
// order to figure out the position of the last attached object
static Float:CraneOffsets[6][6] = {
	{ 0.000000,0.000000,-0.009999,-0.469999,0.000000,90.000000 },// cabine to base
	{ 0.000000,-2.069998,8.448098,0.000000,0.000000,0.000000 },// crane-arm (i think) to cabine
	{ 0.000000,36.869819,-0.569999,0.000000,0.000000,0.000000 },// cable to arm
	{ 0.000000, 0.000000,-7.440086,0.000000,0.000000,0.000000 },// magnet to cable
	{ 0.000000, 0.000000,7.440086,0.000000,0.000000,0.000000 }// suplimentary cable for "effect go-down"
};


FindCraneOffset()
{
	// Get the position of the cranebase (unless it doesn't change you can set this)
	new Float:ret[6];
	GetDynamicObjectPos(ret[0], ret[1], ret[2]);
	GetDynamicObjectRot(ret[3], ret[4], ret[5]);

	// The first return reference is of course the base!
	for(new i = 0; i < 6; i++)
	{
		// Loop through each offset and rotation calculate real world position
		AttachPoint(CraneOffsets[i][0], CraneOffsets[i][1], CraneOffsets[i][2], CraneOffsets[i][3], CraneOffsets[i][4], CraneOffsets[i][5],
		ret[0], ret[1], ret[2], ret[3], ret[4], ret[5],
		ret[0], ret[1], ret[2], ret[3], ret[4], ret[5]);
	}
	return 1;
}
Didn't test it but the idea is you start with the base it's position+rotation.
Now you need to calculate the real world position of the first object based on it's offsets and rotation.
Then the next based off the last...
etc...

Get it? Maybe? Sort of? You also might not have to do all the objects only up to where you need to but that is how it is done.

Last edited by Pottus; 05/02/2019 at 10:01 PM.
Pottus is offline   Reply With Quote
Old 05/02/2019, 10:44 PM   #15
Lunoxx
Big Clucker
 
Join Date: Feb 2015
Posts: 54
Reputation: 0
Default Re: Need help with spatial geometry

Quote:
Originally Posted by Pottus View Post
Show me the values basepos[]

@Edit

I also noticed you are attaching objects to object to object etc.. that means you need to rotate the point several times! Using the result as the next point of reference and translating the offsets to the next position rotation. It sounds complicated but it's very easy.

Code:
// List of attached objects to the base we need to calculate sequentially in
// order to figure out the position of the last attached object
static Float:CraneOffsets[6][6] = {
	{ 0.000000,0.000000,-0.009999,-0.469999,0.000000,90.000000 },// cabine to base
	{ 0.000000,-2.069998,8.448098,0.000000,0.000000,0.000000 },// crane-arm (i think) to cabine
	{ 0.000000,36.869819,-0.569999,0.000000,0.000000,0.000000 },// cable to arm
	{ 0.000000, 0.000000,-7.440086,0.000000,0.000000,0.000000 },// magnet to cable
	{ 0.000000, 0.000000,7.440086,0.000000,0.000000,0.000000 }// suplimentary cable for "effect go-down"
};


FindCraneOffset()
{
	// Get the position of the cranebase (unless it doesn't change you can set this)
	new Float:ret[6];
	GetDynamicObjectPos(ret[0], ret[1], ret[2]);
	GetDynamicObjectRot(ret[3], ret[4], ret[5]);

	// The first return reference is of course the base!
	for(new i = 0; i < 6; i++)
	{
		// Loop through each offset and rotation calculate real world position
		AttachPoint(CraneOffsets[i][0], CraneOffsets[i][1], CraneOffsets[i][2], CraneOffsets[i][3], CraneOffsets[i][4], CraneOffsets[i][5],
		ret[0], ret[1], ret[2], ret[3], ret[4], ret[5],
		ret[0], ret[1], ret[2], ret[3], ret[4], ret[5]);
	}
	return 1;
}
Didn't test it but the idea is you start with the base it's position+rotation.
Now you need to calculate the real world position of the first object based on it's offsets and rotation.
Then the next based off the last...
etc...

Get it? Maybe? Sort of? You also might not have to do all the objects only up to where you need to but that is how it is done.
Yes, I understand what you said.. but, don`t work
Returned by your code: https://i.imgur.com/Q8YeDPB.png

Anyway, thank you, maybe you have a another ideea? :d

@ Firstly, I tried to get only cabine coordonates with AttachPoint function, to test function, but, without success..
__________________
Skype: alin.m99
Discord: lunoxx#1155
FB Page: f.a.c.e.book.com/pawnscripts
Lunoxx is offline   Reply With Quote
Old 05/02/2019, 10:48 PM   #16
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,892
Reputation: 1321
Default Re: Need help with spatial geometry

I told you what you need to do but I know there is something you are over looking. How am I supposed to know without seeing all the code ?
Pottus is offline   Reply With Quote
Old 05/02/2019, 10:55 PM   #17
Lunoxx
Big Clucker
 
Join Date: Feb 2015
Posts: 54
Reputation: 0
Default Re: Need help with spatial geometry

Quote:
Originally Posted by Pottus View Post
I told you what you need to do but I know there is something you are over looking. How am I supposed to know without seeing all the code ?
I will send you all of code in PM.

edit: Done.
__________________
Skype: alin.m99
Discord: lunoxx#1155
FB Page: f.a.c.e.book.com/pawnscripts
Lunoxx is offline   Reply With Quote
Old 06/02/2019, 04:13 PM   #18
Lunoxx
Big Clucker
 
Join Date: Feb 2015
Posts: 54
Reputation: 0
Default Re: Need help with spatial geometry

Bump?
__________________
Skype: alin.m99
Discord: lunoxx#1155
FB Page: f.a.c.e.book.com/pawnscripts
Lunoxx is offline   Reply With Quote
Old 07/02/2019, 05:50 PM   #19
Lunoxx
Big Clucker
 
Join Date: Feb 2015
Posts: 54
Reputation: 0
Default Re: Need help with spatial geometry

another idea?
__________________
Skype: alin.m99
Discord: lunoxx#1155
FB Page: f.a.c.e.book.com/pawnscripts
Lunoxx is offline   Reply With Quote
Old 09/02/2019, 09:35 PM   #20
Lunoxx
Big Clucker
 
Join Date: Feb 2015
Posts: 54
Reputation: 0
Default Re: Need help with spatial geometry

Bumppp
__________________
Skype: alin.m99
Discord: lunoxx#1155
FB Page: f.a.c.e.book.com/pawnscripts
Lunoxx is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pawno Geometry cengiz6155 Scripting Help 26 25/04/2018 11:46 AM


All times are GMT. The time now is 05:11 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.