Forum

orientation of trace_plane_normal

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

orientation of trace_plane_normal

Postby toneddu2000 » Sun Feb 17, 2019 11:52 am

Hi guys, I'm trying to orientate a tripod model near a slope, using trace_plane_normal
This is the tripod in global coordinates: It has red for x axis, green for y axis and blue for z axis
Image
Now, if I use this code I created
Code: Select all
//self is camera entity, which has its own coordinates, but, in this case, it moves on global coordinates except for turning Y axis as yaw
void Orient_Think()
{
   makevectors(self.angles);
   traceline(self.origin,self.origin+(-v_up*128),MOVE_HITMODEL,self);
   fracdown = trace_fraction;
   local vector v = trace_plane_normal;
   makevectors(trace_plane_normal);
   vectest = vectoangles(v);
   setorigin(tripod,trace_endpos);
   tripod.angles = vectest;
   self.nextthink = time + 1;
   self.think = Orient_Think;
}

And, as you can see, orientation changes accordingly to slop perpendicular vector, but x axis and z axis are switched, plus y axis is inverted :!:
Image

Now, I also created a code for make sure tripod turns on yaw accordingly to camera orientation like so
Code: Select all
makevectors(self.angles);
   traceline(self.origin,self.origin+(-v_up*128),MOVE_HITMODEL,self);
   fracdown = trace_fraction;
   if(trace_fraction < 1){
      local vector v = normalize(trace_plane_normal);
      vectest = vectoangles([v_x,v_y,v_z],-v_forward);
   }
   setorigin(tripod,trace_endpos);
      tripod.angles = vectest;

And, it rotates on Y axis, but still X and Z axis are switched
I also tried to invert axis using something like
Code: Select all
vectest = vectoangles([v_z,v_y,v_x],-v_forward);

but orientation is all messed up, so I presume it's not the correct way to do it.
How can I retrieve correct orientation of a trace_plane_normal and how can I manage those data to rotate the axis ternary as I want?

Thanks a lot for any clarification, because, on this subject I'm completely ignorant (it requires math..GAHHH :lol: )!
Meadow Fun!! - my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1352
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest