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.

DarkBASIC Professional Discussion / Changing direction of an object to point at a particular set of 3d coordinates

Author
Message
Philip
23
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 16th Jul 2003 19:00
As part of the game I am slowly writing, I need to write a function to make NPC spacecraft point themselves at a particular set of destination coords (x, y, z).

This is proving tricky. I was wondering whether some kindly soul might save me many hours of anguished conceptualising and pouring over my well thumbed trig books to let me know the easiest way to do this.

I wish to stress that I'm not referring to the "point object" command. Its no use for my purposes because it instantly points the object towards the set of coords - I need a more realistic gradual movement.

What I have presently in my "tool box" are my object's origin co-ords, its current direction's co-ords and the destination co-ords. I also have the vectors to both, mathematically normalised to a 1.0 scalar.

Possible solutions to the problem which I am considering are:

1. calculating the Y angles of both then pitching the ship up and down to make the direction Y angle = the destination Y angle, then moving the ship through the X and Z axises; or

2. rotating the NPC object through its own local Z axis (not the absolute world Z axis) until the destination Z coord is equal to the object's own local Z axis, then just rotating the object through the X axis (pitch up or down) until its pointing at the direction; or

3. saying b***** it very loudly to upset the neighbours and then moving to Tibet, where I could live as a happy violin playing goat.

Cheers all

Phil
What do you mean, bears aren't supposed to wear hats and a tie?
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 16th Jul 2003 19:22
Option 3!

Sorry. This is the sort of problem I could and would solve, but it'd probably take me just as much head scratching as you, and I can't afford to scratch my head anymore than I currently am

*looks over at his painfully tricky physics system*

Good luck. May the radians be with you.

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
randi
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United States
Posted: 16th Jul 2003 19:50
The way I do it...
Is by placing a hidden object at the same position the object you want to rotate at.
Then use the 'point object' command on the hidden object to point it in the right direction.
Then use the 'rotate' commands along with 'curveangle' to rotate the other object towards the angle of the hidden object.
This will cause the gradual movement you are looking for.
I hope that makes sense. x-d

Randi
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 16th Jul 2003 23:41 Edited at: 16th Jul 2003 23:45
Delete stupidity. :-s

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
Philip
23
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 17th Jul 2003 20:06
It won't work... er... Randi (??? [1]) because "point object" is abrupt. It just instantly points the object at the other object. Hence my dismissal of this in my original post.

I want to conduct the same equations in my code, but gradually.

Phil

[1] What kind of name is Randi?

What do you mean, bears aren't supposed to wear hats and a tie?
Philip
23
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 17th Jul 2003 20:07
Sorry. The postscript could have been taken to be a rude comment. That was not my intention.

Forgive a poor, confused, English bear.

Phil

What do you mean, bears aren't supposed to wear hats and a tie?
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Jul 2003 20:10
I think you misunderstood the explanation.

You need two hidden objects. One is placed at the target, one is placed at the source and pointed at the target. You now have the final angles that you need to adjust your non-hidden object to.

You can then use the curveangle function to adjust the x/y/z angle of your object until it matches the hidden source object.
randi
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United States
Posted: 18th Jul 2003 01:33
Yes... you misunderstood.

place a hidden object at the position of your object to be rotated.
Point the hidden object towards the desired position using 'point object'.
Now use the rotate commands along with the curveangle command and object angle(hidden object) to rotate the desired object.
So the first thing to do is learn about the curveangle.

And "Randi"...
It's like Brandi with out the B
It's like when guys are named Randall or Randolph and you call them Randy.
Well... it's the female version of that.
It's my Moms idea, not mine.


Randi
randi
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United States
Posted: 18th Jul 2003 09:51
OK Phil
I made this just for you.

This will show you how to use curveangle like I was talking about.

This sample makes a matrix for a scene...
Then it makes a cube to chase you...
Then a hidden control cube for the chasing cube...
Then a hidden control cube for the camera rotation...
Then it uses the arrow keys to move the camera around...
Then has the cube chase you.

Very easy.
This will do what you want it to do.
Turn into the desired direction gradually.



Enjoy.

Randi
keeblerElf
23
Years of Service
User Offline
Joined: 11th Jun 2003
Location: United States
Posted: 18th Jul 2003 18:07
let the two positions of the objects be at vectors A and B. Let C= Arccos (z/|A|) and let D=Arccos[x/A|*Sin C)] and let E=Arccos (z/|B|) and let F=Arccos[x/B|*Sin C)] then the angle between the two points on the x and y axis' is C-E and the angle between the two points on the x and z axis' is (90-D)-(90-F). I trust you know how to gradually rotate your space ship once you know the angle between the two

keeblerElf
23
Years of Service
User Offline
Joined: 11th Jun 2003
Location: United States
Posted: 18th Jul 2003 18:12
Whow those smiley faces screwed crap up. Let me fix that real quick. C= Arccos (z1/|A|) D=Arccos[x1/( |A|*Sin C)] E=Arccos (z2/|B|) F=Arccos[x2/( |B|*Sin C)] where the two spaceships are at points (x1,y1,z1) and (x2,y2,z2)

Philip
23
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 18th Jul 2003 19:42
This bear is impressed and, yet again, humbled.

He bows in the direction of Randi and duly hands across a lunch hamper in thanks for her help!

He'd give IanM a lunch hamper too but he's already given IanM at least three hampers in the last week and he feels sure that IanM won't thank him if he made IanM put on too much weight! So, instead, he'll just hand across a nice glass of Stella Artois. Its reassuringly expensive, don't you know?

Cheers

Phil (a more educated bear)

What do you mean, bears aren't supposed to wear hats and a tie?
Philip
23
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 18th Jul 2003 19:48
He also bows to KeeblerElf.

Phil

What do you mean, bears aren't supposed to wear hats and a tie?
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 18th Jul 2003 20:45
What about me?!?!?! I said something stupid and completely unhelpful! What do I get?

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Jul 2003 20:53
Hey, I was getting to depend on the handouts

Still, I won't say no to a beer
randi
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United States
Posted: 18th Jul 2003 21:26
Fallout, all you get is a kick in the "bum", as you Brits call it.



Randi
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 18th Jul 2003 23:50
I think we prefer the term ARSE, and I could tell you a few other english words if you like, and what you do with them.

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
Philip
23
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 19th Jul 2003 14:08
Be nice, Fallout.

Phil

What do you mean, bears aren't supposed to wear hats and a tie?
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 19th Jul 2003 15:29
Don't worry about it Phil. It's the game we play - always having a go at each other.

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
Philip
23
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 19th Jul 2003 19:45
I know, mate, I know.

Phil

What do you mean, bears aren't supposed to wear hats and a tie?

Login to post a reply

Server time is: 2026-07-21 12:57:54
Your offset time is: 2026-07-21 12:57:54