Raised This Month: $51 Target: $400
 12% 

Place model\image\sprite in constant position on screen


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-09-2009 , 13:10   Place model\image\sprite in constant position on screen
Reply With Quote #1

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?
__________________
Bugsy is online now
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-09-2009 , 13:40   Re: Place model\image\sprite in constant position on screen
Reply With Quote #2

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..
__________________
Arkshine is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-09-2009 , 13:46   Re: Place model\image\sprite in constant position on screen
Reply With Quote #3

Quote:
Originally Posted by arkshine View Post
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
__________________
Bugsy is online now
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 06-09-2009 , 13:48   Re: Place model\image\sprite in constant position on screen
Reply With Quote #4

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.
__________________

Last edited by joaquimandrade; 06-09-2009 at 13:53.
joaquimandrade is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-09-2009 , 13:58   Re: Place model\image\sprite in constant position on screen
Reply With Quote #5



Ty quim
__________________
Bugsy is online now
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-24-2009 , 18:24   Re: Place model\image\sprite in constant position on screen
Reply With Quote #6

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
__________________

Last edited by joaquimandrade; 07-24-2009 at 18:46.
joaquimandrade is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-24-2009 , 21:40   Re: Place model\image\sprite in constant position on screen
Reply With Quote #7

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
Attached Files
File Type: sma Get Plugin or Get Source (test_.sma - 1981 views - 4.3 KB)
__________________

Last edited by joaquimandrade; 07-24-2009 at 21:42.
joaquimandrade is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-24-2009 , 22:02   Re: Place model\image\sprite in constant position on screen
Reply With Quote #8

Very nice job.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
zombieplague
Veteran Member
Join Date: Apr 2009
Old 11-29-2009 , 12:35   Re: Place model\image\sprite in constant position on screen
Reply With Quote #9

Quote:
Originally Posted by joaquimandrade View Post
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
This only work for ak47, deagle, knife ?
zombieplague is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 02-29-2016 , 05:26   Re: Place model\image\sprite in constant position on screen
Reply With Quote #10

Quote:
Originally Posted by joaquimandrade View Post
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
Doesnt seems to be working, nothing shows when i press E.
Syturi0 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:49.


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