Forum

vp_parallel for a simple model!???????

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

vp_parallel for a simple model!???????

Postby Nahuel » Sun Aug 14, 2011 3:36 pm

Hello!!!! I need know what function can work so that the mdl of an entity behaves with the orientation of a sprite vp_parallel or something similar. I thought about something similar to ai_face (); but not for a monster, just for a simple model, more precisely to create fog. But I cannot use sprites because the shaders doesn´t work :( I do not know. Thank you very much, i am using darkplaces. :?: :?:
Last edited by Nahuel on Sun Aug 14, 2011 8:38 pm, edited 1 time in total.
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Postby necros » Sun Aug 14, 2011 7:23 pm

well, if all you want is to make a model 'face' the player, than it's just a matter of getting the direction vector from the model to the player, and then converting that to yaw, and feeding the yaw directly into the y component of the angles vector:


pl = player entity

local vector vec;
local float yaw;

vec = pl.origin - self.origin;
yaw = vectoyaw(vec);
self.angles_y = yaw;

do this every frame and it will behave just like a vp_parallel sprite.
necros
 
Posts: 77
Joined: Thu Dec 16, 2004 10:32 pm

Postby frag.machine » Sun Aug 14, 2011 8:28 pm

This wont work the same way because ai_face() doesn't take the z axis in account.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby Nahuel » Sun Aug 14, 2011 8:34 pm

necros wrote:well, if all you want is to make a model 'face' the player, than it's just a matter of getting the direction vector from the model to the player, and then converting that to yaw, and feeding the yaw directly into the y component of the angles vector:


pl = player entity

local vector vec;
local float yaw;

vec = pl.origin - self.origin;
yaw = vectoyaw(vec);
self.angles_y = yaw;

do this every frame and it will behave just like a vp_parallel sprite.

thank you necros :D !!! But I have a problem! how (and where) can i define the entity player ?? can you write an example!? I do not know I am still a noob :(
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Postby necros » Mon Aug 15, 2011 12:54 am

there are many ways to get the player entity.

probably the simplest is to just use nextent.

nextent is a builtin function that will cycle through all entities. this is normally slow, but player entities are ALWAYS the first 4 entities, so in this case, it's extremely fast.

simply do this:

local entity pl;

pl = nextent(world);

this finds the next entity after world (the top of the list, entity #0) which will be player 1.

a safer method would be to just do a find().

pl = find(world, classname, "player");

will find the first player. i think it's slightly more expensive but not overly so, since it'll find it right away.

edit: when i read 'ai_face' in your first post, i assumed you wanted the model to stay upright.
my post will cause the model to behave like upright_parallel.
to make it behave exactly like vp_parallel, you must do this:

vec = pl.origin - self.origin;
self.angles = vectoangles(vec);

note vectoangles INSTEAD of vectoyaw. this will make it 'face' the player in both yaw AND pitch, emulating vp_parallel behaviour.
necros
 
Posts: 77
Joined: Thu Dec 16, 2004 10:32 pm

Postby Nahuel » Mon Aug 15, 2011 12:49 pm

Thanks for your explanation Necros:) ! It was very clear for noobs like me! I have my "fog" working!!!! :)
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Postby Seven » Tue Aug 16, 2011 10:08 am

...that is why my winged-demon model always starts to lean back a little when flying upwards.

It is because ai_face() doesn't take the z axis in account !!

And when the entity´s z-position gets higher than the players, this happens...

Thank you frag.machine & necros.

Just like Nahuel said:
What would we noobs be, without all the kind + helpful people here at inside3d ?

Best wishes,
Seven
Seven
 
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest