Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, aliswee), 835 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Proper gun positioning [Re: 3run] #469846
12/11/17 12:35
12/11/17 12:35
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
You are welcome laugh

I realized/remembered there is a better trigonometric relation between cathetus and angles... the tangent! blush cry



Salud!

Re: Proper gun positioning [Re: txesmi] #469847
12/11/17 12:48
12/11/17 12:48
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Thank you very much bro! laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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 Offline OP
Senior Expert
3run  Offline 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
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!)
Quote:
Windowed mode

Fullscreen mode


Greets!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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 Offline
Expert
Kartoffel  Offline
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 Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: Kartoffel
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.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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 Offline
Serious User
txesmi  Offline
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

Code:
#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.

Originally Posted By: 3run
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: txesmi] #472209
04/16/18 12:50
04/16/18 12:50
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Thank you very much, man! I'll dive in to the code laugh

Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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 Offline OP
Senior Expert
3run  Offline 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! laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Proper gun positioning [Re: 3run] #472217
04/16/18 19:35
04/16/18 19:35
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
glad of been of help wink

Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1