2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Serious User
|
Serious User
Joined: Aug 2009
Posts: 1,438
Spain
|
something like this?
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
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Hey, man! Is this what you are looking for?
#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 Best regards!
Last edited by 3run; 05/12/17 09:15.
|
|
|
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
OP
Expert
|
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
|
|
|
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
OP
Expert
|
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:
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.
|
|
|
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
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
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
#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 ();
}
|
|
|
|