|
|
true facing of sprites?
#185946
02/27/08 07:52
02/27/08 07:52
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
this has probably been asked before...
we set: my.oriented=off; my.facing=on; for sprites in our space simulator. but since it's a space simulator, you can look at the sprites from any direction you want to. I'm not sure what angle it's at (I think when you look straight down or up and then see the sprite sitting there?), but the sprite turns in a weird way at some point. when you pan around and the sprite's in your view, at a certain point, it'll roll about 90 to 180 degrees at once. we don't want that. help?
Micha
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: true facing of sprites?
[Re: vlau]
#185948
02/28/08 17:45
02/28/08 17:45
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
hm. all right... but there must be some sort of workaround? I need to rotate the camera, making the camera not roll is no option. and since there's quite a few of these sprites, I'd like it to be a rather efficient way... I must admit, up to today, I can't get my head around angles in 3d space. I understand them, yes, but how to work with them when it comes to the whole euler angle calculations... bah!
Micha
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: true facing of sprites?
[Re: vlau]
#185950
02/28/08 20:07
02/28/08 20:07
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
no... the camera follows a space ship that cam move freely through space... the space ship can pan, tilt and roll at any point around it's own arbitrary axis.
sorry I wasn't clear on this... and thanks for helping!
Micha
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: true facing of sprites?
[Re: Nems]
#185952
02/29/08 04:32
02/29/08 04:32
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
...easier way. Ok, When a sprite uses it's ".facing" flag, it doesn't exactly point to the camera. Instead, it stays parallel to the viewing plane... ...this means if the sprites by the edge of your view, it will appear to be pointing behind you a bit. So to get around this, just hardcode you sprites to point towards the camera: Code:
action star() { while (my) { vec_diff(temp, camera.x, my.x); vec_to_angle(my.pan, temp); // wait(1); } }
xXxGuitar511 - Programmer
|
|
|
Re: true facing of sprites?
[Re: Germanunkol]
#185953
02/29/08 10:33
02/29/08 10:33
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
I'm guess the problem is your follow camera code. Here is my solutions, the idea is came from the Manual->chase camera example code : I'll create a dummy object as the target at runtime, it'll always stay the same position as the spaceship while you can pan and tilt of its own. The camera will follow the dummy's pan and tilt and maintain the distance from the spaceship, with that, you're free to look around the space with the spaceship as the aim point and those sprites (or camera) will not flip when the camera tilt angle reached 90 and 270 degrees. Hope that it was what are you looking for. Code:
var dist[3] = -2500,0,300; // play with it var speed = 5; // pan, tilt speed entity* dummy;
action theSprite { // Your sprites should have these lines my.passable = on; my.facing = on; my.oriented = off; //...other codes... }
action tSpaceShip { dummy = ent_create(NULL,my.x,NULL); dummy.passable = on; while(my) { //c_move(....); // move spaceship
vec_set(dummy.x,my.x); // same pos as the spaceship
// pan and tilt the camera to look around with wsad keys dummy.pan -= (key_a-key_d) * speed * time_step; dummy.tilt -= (key_w-key_s) * speed * time_step; // camera follow codes vec_set(camera.x,dist); vec_rotate(camera.x,dummy.pan); vec_add(camera.x,dummy.x); vec_set(camera.pan,dummy.pan);
// ...other codes...
wait(1); } }
|
|
|
Re: true facing of sprites?
[Re: vlau]
#185954
03/04/08 12:50
03/04/08 12:50
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
thanks for the replies! to be honest, I don't believe it's the camera script. I do: Code:
camera_height = camera_distance/2; vec_set(temp,vector(-camera_distance,0,camera_height)); vec_rotate(temp,cam_dummy_ent.pan); vec_add(temp,player.x); //target position of camera; vec_set(camera.x,temp);
or something along those lines (the camera lags behind as well, but that shouldn't change anything. your code only involves paning and tilting... how about rolling? may that be it? My space ship can roll as well... I understood your concept. i tried the same thing as well, when trying to make the player look around space without rotating the ship. reason I didn't put it in yet is that I wanted the cam to keep the angle/position relative to the ship's rotation if you let go off the key that lets you manually set the cam. ie: key shift is off: you can rotate the ship using the mouse. cam always stays behind the ship. key shift is on: you move the mouse and the ship does not rotate. instead, the camera rotates around the ship. you could, for example look at the ship from the right side. key shift is released: moving the mouse rotates the ship again. the camera will now stay on the right side of the ship no matter what, and stay at the right side of it, looking at the ship from the right at all times (until shift is once again pressed)... but that's another problem...? my problem: the sprites are always rotating by code (my.roll += tinme_step;) now, at some position (haven't yet found out which one exactly) they suddenly start rolling much faster if you pan the camera around. they face the cam in tilt and pan, but the rolling looks like it came "closer and closer to the edge, and then suddenly falls over", that is: rolls faster. then it slows down again once it's rolled about 90 or 180 degrees. when you pan back, it does the same thing, rolling in the other direction. WHY?...  looks very strange if your whole nebula suddenly starts rolling... :'( or is the problem really what you were talking about, vlau? Micha
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
|