4 registered members (ozgur, Ayumi, VHX, monarch),
1,161
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Proper gun positioning
[Re: 3run]
#472199
04/16/18 00:01
04/16/18 00:01
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Hi! Faced some troubles with your solution, txesmi! Fullscreen mode messes everything up.. Take a look at this code
void main(){
fps_max = 60;
level_load("");
wait(3);
camera->arc = 90;
my = ent_create("test.png", nullvector, NULL);
set(my, PASSABLE | NOFILTER | ZNEAR);
vec_fill(&my->scale_x, 1);
my->ambient = 100;
var distance = 16, size_z = 8;
while(my){
my->skill20 = fcos(0.5 * camera->arc, distance);
my->skill21 = 0;
my->skill22 = size_z - fsin(0.5 * camera->arc, distance) * screen_size.y / screen_size.x;
vec_set(&my->x, &my->skill20);
vec_rotate(&my->x, &camera->pan);
vec_add(&my->x, &camera->x);
my->pan = ang(camera->pan - 180);
my->tilt = -camera->tilt;
my->roll = -camera->roll;
wait(1);
}
}
And a small bmap to test it, here it goes (right click and save, it's 16x16): As far as I understood it should work correctly, but it does not :< Screen examples (notice that resolution is the same!) Windowed mode Fullscreen mode Greets!
|
|
|
Re: Proper gun positioning
[Re: 3run]
#472202
04/16/18 08:45
04/16/18 08:45
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
looks like the image is scaled along the screen y axis (which is weird)
maybe check if screen_size really contains the correct resolution?
Edit: another thing that might mess things up is the billboard rotation that the engine does for sprites (I think this is done when the sprite rotation is (0,0,0)).
Last edited by Kartoffel; 04/16/18 08:46.
POTATO-MAN saves the day! - Random
|
|
|
Re: Proper gun positioning
[Re: Kartoffel]
#472204
04/16/18 10:28
04/16/18 10:28
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
maybe check if screen_size really contains the correct resolution? Checked that, and it's correct (720x480 in both modes). As for rotation, as far as I know, when you manually change rotation of the sprite, engine won't rotate it by itself.
|
|
|
Re: Proper gun positioning
[Re: 3run]
#472207
04/16/18 12:38
04/16/18 12:38
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Hi, I noticed that the proportion of the projection area in full screen is always real screen sized. That is strange because while it computes the projection matrix by 'screen_size', it shows a rectangle with the real proportion of the screen, so it cuts part of the projection depending on the proportion difference. And at the end it renders in 'screen_size' resolution! It sounds like a bug for me. The good thing is that it is easy to work around xP
#include <acknex.h>
var distance = 16;
var cameraProp = 1;
var screenProp = 1;
void safe_video_switch (var _mode) {
video_mode = video_switch(_mode, 32, video_screen);
if(!video_mode)
video_mode = video_switch(7, 32, video_screen);
if (video_screen == 1)
cameraProp = distance * screenProp / camera->aspect;
else
cameraProp = distance * screen_size.y / (screen_size.x * camera->aspect);
}
void onQ () {
safe_video_switch(video_mode + 1);
}
void onW () {
video_screen = 1 + video_screen % 2;
safe_video_switch(video_mode);
}
void weaponLocate (ENTITY *_ent) {
var size_z = 8 * _ent->scale_z;
_ent->x = distance;
_ent->y = 0;
_ent->z = size_z - tanv(0.5 * camera->arc) * cameraProp;
vec_rotate(&_ent->x, &camera->pan);
vec_add(&_ent->x, &camera->x);
_ent->pan = ang(camera->pan - 180);
_ent->tilt = -camera->tilt;
_ent->roll = -camera->roll;
}
void main () {
screenProp = sys_metrics(1) / sys_metrics(0);
fps_max = 60;
video_mode = 7;
video_screen = 1;
wait(1);
on_q = onQ;
on_w = onW;
level_load("");
camera->arc = 90;
camera->aspect = 1;
safe_video_switch(7);
ENTITY *_ent = ent_create("sprite2.tga", nullvector, NULL);
set(_ent, PASSABLE | NOFILTER | ZNEAR | DECAL);
vec_fill(&_ent->scale_x, 1);
_ent->ambient = 100;
while (!key_esc) {
camera->pan = ang(camera->pan - mickey.x * 0.2);
camera->tilt = clamp(camera->tilt - mickey.y * 0.2, -90, 90);
weaponLocate(_ent);
wait(1);
}
sys_exit(NULL);
}
added 'camera->aspect' as it has full relevance on the computations. As for rotation, as far as I know, when you manually change rotation of the sprite, engine won't rotate it by itself. Remember the DECAL flag Salud!
|
|
|
Re: Proper gun positioning
[Re: 3run]
#472210
04/16/18 13:46
04/16/18 13:46
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
A little bump, what size is your "sprite2.tga" ? Edit: got it working, size was 16x16 if I understood correctly. Thank you one more time man!
|
|
|
|