Forum for the Development Team associated with the Mount&Blade Module Prophesy of Pendor Development
 
HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 Triangle-Point Collision Detection Algorithm

View previous topic View next topic Go down 
AuthorMessage
abhuva
Mind Reader
Mind Reader


Posts : 191
Join date : 2011-06-27
Age : 37
Location : Germany

PostSubject: Triangle-Point Collision Detection Algorithm   Thu Oct 06, 2011 12:52 pm

You may wonder what this shall be, so let me introduce first to my basic idea:

I wanted to be able to check what region a given party is into (for example if player is in snake land, or ashenborn etc..). Based on this i want to further improve my Unique Battlefields idea (region specific battlefields).
Now to implement this i wanted to put hidden partys at the regions border points and check if the player is inside the n-poly this forms.

The solution is to break this down further and make a check if the player is inside a given triangle.
Based on this article: http://www.blackpawn.com/texts/pointinpoly/default.html
i tried my own implementation into the module-system.
After some problems (ms dont let me use floating point variables) i finally have a working algorithm.

Now we could use this for a lot of stuff.
Basicly it just checks if a party A is inside the triangle formed from party B,C and D...
This can be either towns etc.. but also moving parties like lords.

Maybe this is usefull for other stuff too like AI-coding, rumors-coding (rumors based on the land you are in) etc...

Currently the code is still in development, but i wanted to share my first working version:
Spoiler:
 

You pass 4 party id´s .. the first is the party which shall get tested.
reg0 will be 0 if its failed and 1 if its inside the triangle.

Example:
(call_script,"script_point_triangle_collision","p_main_party","p_town_7","p_village_30","p_village_31"),
(try_begin),
(gt, reg0, 0),
(display_message, "@Test passed..."),
(else_try),
(display_message, "@Test failed..."),
(try_end),


Last edited by abhuva on Thu Oct 06, 2011 1:29 pm; edited 1 time in total
Back to top Go down
View user profile http://abhuva.wordpress.com
Mordred
Insidious Diety
Insidious Diety
avatar

Posts : 2523
Join date : 2009-07-17

PostSubject: Re: Triangle-Point Collision Detection Algorithm   Thu Oct 06, 2011 1:02 pm

Impressive stuff Abhuva. We could also use this to create zones around Town (connect all the villages around it up) and then do a check to see what is inside that. This could then connect to the rumour system and be able to give out info.

Say Syla was inside the "Rachim Zone" then a rumour would say "X told me that Syla has been seen near Rachim"
Back to top Go down
View user profile
abhuva
Mind Reader
Mind Reader


Posts : 191
Join date : 2011-06-27
Age : 37
Location : Germany

PostSubject: Re: Triangle-Point Collision Detection Algorithm   Thu Oct 06, 2011 1:30 pm

Updated first post with the script and a example how to use.
Back to top Go down
View user profile http://abhuva.wordpress.com
Sponsored content




PostSubject: Re: Triangle-Point Collision Detection Algorithm   

Back to top Go down
 
Triangle-Point Collision Detection Algorithm
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Trigger Point Injections
» A trigger point causing extra pain.
» What're your suggestions on good 200-300 point DSiware games?
» Entry Point Error Message
» Position

Permissions in this forum:You cannot reply to topics in this forum
Prophesy of Pendor Dev Forum :: Siege Workshop-
Jump to: