AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Place model\image\sprite in constant position on screen (https://forums.alliedmods.net/showthread.php?t=94295)

Bugsy 06-09-2009 13:10

Place model\image\sprite in constant position on screen
 
I am trying to place an image on the screen that will remain at a constant position regardless of player view movement. I am a 100% noob with calculating angles and all that jazz so any help will be appreciated. The overall goal is to have a image rest behind a HUD message as a background. Possible?

Arkshine 06-09-2009 13:40

Re: Place model\image\sprite in constant position on screen
 
I think the best way is to build the model so it's in a position on your view and attach it.

Using a sprite would be need some calculating angles. If I'm right you have to calculate the eye position ( pev_origin + pev_view_ofs ) then adjusting to put more in left, right etc..

Bugsy 06-09-2009 13:46

Re: Place model\image\sprite in constant position on screen
 
Quote:

Originally Posted by arkshine (Post 844983)
Using a sprite would be need some calculating angles. If I'm right you have to calculate the eye position ( pev_origin + pev_view_ofs ) then adjusting to put more in left, right etc..

This is the part that I am totally clueless on. Maybe stupok will chime in for me since this is his area of expertise

joaquimandrade 06-09-2009 13:48

Re: Place model\image\sprite in constant position on screen
 
Both me and stupok, tried to put sprites as if they were in the hud but with no success, when the user moves. The sprite position is always delayed. I even tried to added the vector velocity but it just make it worst. Maybe it can be achieved but I doubt it.

This is the code I was using:

PHP Code:

ent create_entity("env_sprite")
entity_set_model(ent,spriteModel)
set_pev(ent,pev_scale,0.02)
DispatchSpawn(ent); 

PHP Code:

static Float:start[3], Float:view_ofs[3], Float:origin[3]

pev(id,pev_origin,origin);

new 
Float:angles[3]
pev(id,pev_v_angle,angles)

new 
Float:path[3]

angle_vector(angles,ANGLEVECTOR_FORWARD,path)
xs_vec_normalize(path,path)
xs_vec_mul_scalar(path,4.0,path);
xs_vec_add(path,origin,origin)

angle_vector(angles,ANGLEVECTOR_RIGHT,path)
xs_vec_normalize(path,path)
xs_vec_mul_scalar(path,-2.5,path);
xs_vec_add(path,origin,origin)

angle_vector(angles,ANGLEVECTOR_UP,path)
xs_vec_normalize(path,path)
xs_vec_mul_scalar(path,-2.0,path);
xs_vec_add(path,origin,origin)

new 
Float:vofs[3]
pev(id,pev_view_ofs,vofs)
xs_vec_add(origin,vofs,origin)

entity_set_origin(ent,origin);
set_pev(ent,pev_angles,angles

About this code, you shall create the entity anywhere and then use a forward, i tried with PlayerPreThink, to do the calculations.

Bugsy 06-09-2009 13:58

Re: Place model\image\sprite in constant position on screen
 
:(

Ty quim

joaquimandrade 07-24-2009 18:24

Re: Place model\image\sprite in constant position on screen
 
Bugsy, if you are still interested in this:

I have been playing with it more and with AddToFullpack and setting the entity movetype to MOVETYPE_NONE I managed to make it.

Problems: going through ladders or barely walking with cl_bob bigger than 0 makes it move (And I doubt that it can be fixed). Still, if you want to use it in clients without speed it works fine.

Edit: I mean stairs not ladders

joaquimandrade 07-24-2009 21:40

Re: Place model\image\sprite in constant position on screen
 
1 Attachment(s)
Here it goes an example. It is like a menu to chose a weapon from a list.

http://www.youtube.com/watch?v=Z9ZcC_UhFSw

ConnorMcLeod 07-24-2009 22:02

Re: Place model\image\sprite in constant position on screen
 
Very nice job.

Bugsy 07-24-2009 23:49

Re: Place model\image\sprite in constant position on screen
 
Good work quim. You should post the code in the code snippers\tuts section for others. Or a mod can move this thread.

Tirant 07-25-2009 01:28

Re: Place model\image\sprite in constant position on screen
 
Wow that's really cool joaquim. If you want, i got a model i made somewhere that is compatible for images. I might have lost it though because I never got around to getting code to attach it to player's screens, i was planning to use it as a type of zombie infected overlay. I'm not sure if that's what your looking for though.


All times are GMT -4. The time now is 06:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.