Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by CocaCola
Today at 02:42
CyberCycle Adaptive Cy
by AndrewAMD
Yesterday at 18:54
How does Zorro handle new strategy/asset?
by Seymour
Yesterday at 15:29
About 1M entities!
by txesmi
Yesterday at 14:16
Montecarlo statistical mode parameter optimization
by AndrewAMD
Yesterday at 13:36
Strategy Development
by OptimusPrime
Yesterday at 02:08
Intercept Friday Daily Close
by tradingest
12/12/18 21:40
AUM Magazine
Latest Screens
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Evonet Beta v1.0 : Online Project Development Template
Lake scene
Who's Online
10 registered (Ayumi, MINER, wdlmaster, kvm, MatPed, 3run, jenGs, 3 invisible), 488 Guests and 6 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
rssflc, mahomed, bondz, Neil_G, bobby4h
18118 Registered Users
Page 2 of 2 < 1 2
Topic Options
Rate This Topic
#469846 - 12/11/17 13:35 Re: Proper gun positioning [Re: 3run]
txesmi Online
Serious User

Registered: 06/13/07
Posts: 1194
Loc: 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!

Top
#469847 - 12/11/17 13:48 Re: Proper gun positioning [Re: txesmi]
3run Online
Senior Expert

Registered: 05/05/09
Posts: 5104
Loc: Caucasus
Thank you very much bro! laugh
_________________________
Looking for free stuff?? Take a look here: http://badcom.at.ua

Top
#472199 - 04/16/18 02:01 Re: Proper gun positioning [Re: 3run]
3run Online
Senior Expert

Registered: 05/05/09
Posts: 5104
Loc: 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

Top
#472202 - 04/16/18 10:45 Re: Proper gun positioning [Re: 3run]
Kartoffel Offline
Expert

Registered: 06/11/09
Posts: 2210
Loc: 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)).


Edited by Kartoffel (04/16/18 10:46)
_________________________
POTATO-MAN saves the day! - Random

Top
#472204 - 04/16/18 12:28 Re: Proper gun positioning [Re: Kartoffel]
3run Online
Senior Expert

Registered: 05/05/09
Posts: 5104
Loc: 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

Top
#472207 - 04/16/18 14:38 Re: Proper gun positioning [Re: 3run]
txesmi Online
Serious User

Registered: 06/13/07
Posts: 1194
Loc: 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!

Top
#472209 - 04/16/18 14:50 Re: Proper gun positioning [Re: txesmi]
3run Online
Senior Expert

Registered: 05/05/09
Posts: 5104
Loc: 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

Top
#472210 - 04/16/18 15:46 Re: Proper gun positioning [Re: 3run]
3run Online
Senior Expert

Registered: 05/05/09
Posts: 5104
Loc: 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

Top
#472217 - 04/16/18 21:35 Re: Proper gun positioning [Re: 3run]
txesmi Online
Serious User

Registered: 06/13/07
Posts: 1194
Loc: Hiporope and its pain
glad of been of help wink

Top
Page 2 of 2 < 1 2


Moderator:  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