|
Re: Maths trig problem, angle to camera
[Re: MrGuest]
#341499
09/17/10 14:15
09/17/10 14:15
|
Joined: Aug 2009
Posts: 1,438 Spain
painkiller
Serious User
|
Serious User
Joined: Aug 2009
Posts: 1,438
Spain
|
Is this what you are looking for?
action angletocamera()
{
VECTOR temppos;
while(1)
{
vec_diff(temppos, camera.x, my.x);
vec_to_angle(my.pan, temppos);
wait(1);
}
}
}
Last edited by painkiller; 09/17/10 14:16.
3D Gamestudio A8 Pro AMD FX 8350 4.00 Ghz 16GB RAM Gigabyte GeForce GTX 960 4GB
|
|
|
Re: Maths trig problem, angle to camera
[Re: painkiller]
#341502
09/17/10 15:18
09/17/10 15:18
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
OP
Serious User
|
OP
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
Unfortunately not, Here's a screenshot of what I currently have: As you can see the highlighted areas are hiding some yellow as their orientation matches the cameras. There's a small adjustment I need to find to get them to face their position relative to the camera position, rather than the centre of the camera. Thanks for your post.
|
|
|
Re: Maths trig problem, angle to camera
[Re: MrGuest]
#341506
09/17/10 16:51
09/17/10 16:51
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
What code/formula are you using to get them looking at the cam-center, as they are now?
And if not too complex, what is your cam-code doing? Post? Does it use a entity as a camera target or anything?
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Maths trig problem, angle to camera
[Re: EvilSOB]
#341510
09/17/10 17:10
09/17/10 17:10
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
OP
Serious User
|
OP
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
Currently, it looks a bit like this
while(int_gameState == gameState_ingame){
proc_mode = PROC_LATE;
for(i = 0; i < hand_max; i++){
pos.x = camera.pos_x + (camera.size_x / 2);
pos.y = camera.pos_y + (camera.size_y / 2);
pos.z = 20; //dist
pos.x += (sin((i+0) * 60) * 250);
pos.y -= (cos((i+0) * 60) * 250);
vec_for_screen(pos, camera);
vec_set(ent_gameHand[i].x, pos);
ent_gameHand[i].pan = camera.pan - 90;
ent_gameHand[i].roll = camera.tilt + 90;
}
wait(1);
}
Just to clarify, the entities stay exactly where they should be after any camera movement, just need a final angle adjustment. The camera doesn't target anything atm, but if necessary can do, using default camera will give the same effect.
|
|
|
Re: Maths trig problem, angle to camera
[Re: MrGuest]
#341513
09/17/10 17:35
09/17/10 17:35
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
OK, nothing there to help or hinder me then. I also assume by looking at the code that ... A> The entities 'ent_gameHand[xx]' are the ones that need to face the screen. B> The vector "pos" is no longer needed after the "vec_set(ent_gameHand[i].x, pos);" So, as untested code, give this a try...
//Replace your existing lines ...
...
ent_gameHand[i].pan = camera.pan - 90;
ent_gameHand[i].roll = camera.tilt + 90;
...
//With the following code ...
...
//set 'pos' to x,y screen co-ords of entity position (z unused)
vec_set(pos, ent_gameHand[i].x);
vec_to_screen(pos, camera);
//set 'pos' to XYZ co-ords of screen-plane over entity
pos.z = 0;
vec_for_screen(pos, camera);
//make entity "face" the XYZ co-ords of screen over entity
vec_diff(pos, pos, ent_gameHand[i].x);
vec_to_angle(ent_gameHand[i].pan, pos);
...
This code isnt 'optimised' at all, in order for you to see the logic... This code IS optimised but still untested...
...
vec_to_screen(vec_set(pos,ent_gameHand[i].x),camera);
pos.z = 0; vec_for_screen(pos,camera);
vec_to_angle(ent_gameHand[i].pan,vec_diff(0,pos,ent_gameHand[i].x));
...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Maths trig problem, angle to camera
[Re: EvilSOB]
#341516
09/17/10 18:14
09/17/10 18:14
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
OP
Serious User
|
OP
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
Again, unfortunatley not, It's similar to the logic that I've previously tried, but the tiles rotate only around pan and roll, tilt needs to remain at 0. Variations of changing tilt to roll I've tried still causes problems. With what you've sent, and minusing 90 from tilt gives: , but I was still unable to find a way to get sorted from here, and changing the camera tilt no longer 'locks' their position. Your assumptions 1 and 2 are right.
|
|
|
Re: Maths trig problem, angle to camera
[Re: MrGuest]
#341519
09/17/10 18:39
09/17/10 18:39
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Try adding this line AFTER all mine, still inside the for-loop, but without the tilt=-90...
vec_rotate(ent_gameHand[i].pan, vector(0,-90,0));
Is there any way to post the project, or a mini-project version, or even a video of what happen when you move the camera around?
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Maths trig problem, angle to camera
[Re: MrGuest]
#341523
09/17/10 18:58
09/17/10 18:58
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Hmmm, we can try... alex.littler@fujitsu.com.au
But this is from work, and many ports are blocked so FTP and the like often fail. If I cant get through, we can try alex.littler@internode.net.au in a few hours when Im at home.
PM me any details you need kept quiet... Or alternatively, email both my above addresses.
Thanks.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|