Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Function to find the normal (or angle) of a face of any model

Author
Message
eat much pie
20
Years of Service
User Offline
Joined: 9th Apr 2004
Location: Within the mind of a lowly mortal...
Posted: 3rd May 2004 18:28 Edited at: 19th May 2004 20:05
After much pain and struggle (of about 4 hours) I've come up with the code to find the normal of a face. It uses intersect object, so there are some limitations to its use (ie. you can't scale the object to which the face belongs).
Just type in the syntax as you would with intersect object, and the normal data will be stored in the second 3d vector, so to access it, you need to:
YourVariableX#=x vector(2)
YourVariableY#=y vector(2)
YourVariableZ#=z vector(2)

Put the following code at the beginning of the program:



Put the following code with all your other functions or gosubs:



NB: this function will return the distance between start point and collision point (the same as interect object).

http://www.nuclearglory.com/?i=453288050 , AMAZING COLLISION SYSTEM!
French gui
20
Years of Service
User Offline
Joined: 11th May 2004
Location: France
Posted: 21st May 2004 02:53
Very good, it's helping me a lot for my mini golf game. Don't know why I'm only the first to post a message 'cos your snippet's very cool...

My English is not so good I'm just French
eat much pie
20
Years of Service
User Offline
Joined: 9th Apr 2004
Location: Within the mind of a lowly mortal...
Posted: 22nd May 2004 16:09 Edited at: 22nd May 2004 16:11
Je l'ai fait sans les objets!

Cough...

Anyway, I've just finished the second version of my normals finding function, in which there are no objects at all! I used triganometry and vectors instead! Oh, and if you release a game that uses my function, please give credit to me in the credits.


put this before the main loop



put this with all your other funcitons or 'gosubs'


To use the Normals data:



If anyone has any questions, feel free to ask. I check the forums every day.

http://www.nuclearglory.com/?i=453288050 : Nuclear Glory, AMAZING COLLISION SYSTEM!
eat much pie
20
Years of Service
User Offline
Joined: 9th Apr 2004
Location: Within the mind of a lowly mortal...
Posted: 22nd May 2004 16:17 Edited at: 22nd May 2004 16:31
To use my command, use it as you would with the intersect object command, so let's say you want to find out the normals data of a plane belonging to a 'castle' that a bullet went through (starting from the camera position).



that does the calculating, then let's say you want to put a bullet hole where the bullet and castle collided:



And voila! the bullet hole is rotated and positioned at the right values!

NB. You could use maths to figure out the collided positoin as opposed to using an object, but I really can't be bothered to explain it to you at the moment. If you want me to explain how to do it, just let me know.

http://www.nuclearglory.com/?i=453288050 : Nuclear Glory, AMAZING COLLISION SYSTEM!

Login to post a reply

Server time is: 2024-11-23 21:46:01
Your offset time is: 2024-11-23 21:46:01