Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, EternallyCurious, Petra, 1 invisible), 764 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Entity look at camera keeping it's orientation #465779
05/12/17 08:31
05/12/17 08:31
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
I want an entity to look at the camera and keep the same orientation as the camera. So basically it should just behave like a panel. I couldn't wrap my head around the vector calculations needed. Thanks in advance.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Entity look at camera keeping it's orientation [Re: alibaba] #465780
05/12/17 09:10
05/12/17 09:10
Joined: Aug 2009
Posts: 1,438
Spain
painkiller Offline
Serious User
painkiller  Offline
Serious User

Joined: Aug 2009
Posts: 1,438
Spain
something like this?

Code:
VECTOR temp_vec;

...

vec_diff(temp_vec,camera.x,my.x);
vec_to_angle(my.pan,temp_vec); //always look to camera



3D Gamestudio A8 Pro
AMD FX 8350 4.00 Ghz
16GB RAM
Gigabyte GeForce GTX 960 4GB
Re: Entity look at camera keeping it's orientation [Re: alibaba] #465781
05/12/17 09:14
05/12/17 09:14
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Hey, man!

Is this what you are looking for?
Code:
#define PRAGMA_POINTER

void main(){
	
	shadow_stencil = 2;
	warn_level = 6;
	fps_max = 60;
	level_load("");
	wait(3);
	
	def_move();
	
	ENTITY *ground = ent_create(CUBE_MDL, vector(0, 0, -32), NULL);
	vec_set(&ground->scale_x, vector(20, 20, 1));
	
	ENTITY *panel_like = ent_create(CUBE_MDL, vector(200, 0, 0), NULL);
	vec_set(&panel_like->scale_x, vector(1, 5, 1));
	set(panel_like, SHADOW);
	
	VECTOR offset_vec;
	vec_fill(&offset_vec.x, 0);
	
	while(panel_like){
		
		
		
		vec_set(&offset_vec.x, vector(200, 0, 0));
		vec_rotate(&offset_vec.x, &camera->pan);
		vec_add(&offset_vec.x, &camera->x);
		
		vec_set(&panel_like->x, &offset_vec.x);
		vec_set(&panel_like->pan, &camera->pan);
		
		wait(1);
	}
	
	sys_exit(NULL);
}



Edit: painkiller was faster grin

Best regards!

Last edited by 3run; 05/12/17 09:15.

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Entity look at camera keeping it's orientation [Re: 3run] #465782
05/12/17 09:26
05/12/17 09:26
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
@Painkiller Well that's the standard way to do it. But it does not keep the orientation. You can see what I mean when you change the cameras roll angle.

@3run Yeah that's nearly the behavior I want, but the object should stay in place and not move with the camera.

Thanks for you answers so far laugh


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Entity look at camera keeping it's orientation [Re: alibaba] #465784
05/12/17 09:34
05/12/17 09:34
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
What's the use case for this?
If the entity stays in place you will probably get (different) perspective distortions when you rotate the camera - if I'm not mistaken. Maybe it would help to use a custom/ special view matrix in the vertex shader for that object, like an isometric/ orthographic one?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Entity look at camera keeping it's orientation [Re: Superku] #465785
05/12/17 09:37
05/12/17 09:37
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
The view distortion is not a big deal. I want to place a kind of goal marker on the map.
Anyway, the answer was easier than I thought:

Code:
vec_set(panelEnt.pan, camera_view.pan);
ang_rotate(panelEnt.pan,vector(180,0,0));



Thank you all!

EDIT: the actual reason for using this way is because I'm working on a splitscreen game, but panels don't clip a the cameras border, so one panel can overlap with the view next to it etc. If you know a way how I can keep the rendering of a panel inside a specific view, then I'd prefer using panels.

Last edited by alibaba; 05/12/17 09:40.

Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Entity look at camera keeping it's orientation [Re: alibaba] #465793
05/12/17 16:40
05/12/17 16:40
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
Originally Posted By: alibaba
If you know a way how I can keep the rendering of a panel inside a specific view, then I'd prefer using panels.

Here goes a try I did some time ago
Code:
#include <acknex.h>
#include <default.c>

#define PRAGMA_PATH "%EXE_DIR%\templates\images";
#define PRAGMA_PATH "%EXE_DIR%\templates\models";

action actIcon ()
{
	BMAP *_bmp = bmap_create ( "schaden.tga" );
	PANEL *_pan = pan_create ( "", 1 );
	pan_setwindow ( _pan, 0, 0, 0, bmap_width(_bmp), bmap_height(_bmp), _bmp, &_pan->skill_x, &_pan->skill_y );
	while ( !key_esc )
	{
		VECTOR _v;
		vec_set ( &_v, &my->x );
		vec_to_screen ( &_v, camera );
		_pan->pos_x = floor(_v.x) - bmap_width(_bmp) / 2;
		_pan->pos_y = floor(_v.y) - bmap_height(_bmp) / 2;
		var _upperX = minv ( bmap_width(_bmp), camera->pos_x + camera->size_x - _pan->pos_x );
		var _upperY = minv ( bmap_height(_bmp), camera->pos_y + camera->size_y - _pan->pos_y );
		_pan->skill_x = maxv ( 0, camera->pos_x - _pan->pos_x );
		_pan->skill_y = maxv ( 0, camera->pos_y - _pan->pos_y );
		if ( ( _upperX < 1 ) || ( _upperY < 1 ) || ( _pan->skill_x > bmap_width(_bmp) ) || ( _pan->skill_y > bmap_height(_bmp) ) )
			_pan->flags &= ~SHOW;
		else
		{
			var _winSizeX = minv ( bmap_width(_bmp) - _pan->skill_x, _upperX );
			var _winSizeY = minv ( bmap_height(_bmp) - _pan->skill_y, _upperY );
			pan_setwindow ( _pan, 1, _pan->skill_x, _pan->skill_y, _winSizeX, _winSizeY, _bmp, &_pan->skill_x, &_pan->skill_y );
			_pan->flags |= SHOW;
		}
		wait(1);
	}
}

void main ()
{
	wait(1);
	level_load ( "" );
	camera->size_x = screen_size.x - 200;
	camera->size_y = screen_size.y - 200;
	camera->pos_x = 100;
	camera->pos_y = 100;
	ent_createlayer ( "skycube+6.tga", SKY | CUBE, 1 );
	ent_create ( "pistol.mdl", vector(300,0,0), actIcon );
	def_move ();
}



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