Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


WiredCat

Member Since 09 Apr 2011
Online Last Active Today, 05:55 AM

#5211913 From AngularAcc from torque to angles : )

Posted by WiredCat on 20 February 2015 - 10:19 AM

ok i get your point however your first post was totally in 100% correct i just was using one airlieron to determine the rotation which obvious produce yaw moment too.

i added second airlieron to the code and it produces now correct roll without yaw, 

 

math was good. code was good too :P

 

 

 

I ignored your code,

 

HOW COULD YOU ? :P    ph34r.png




#5210642 How to create code to map function for Coefficient of Lift

Posted by WiredCat on 14 February 2015 - 03:32 AM

your diagram looks simple

 

notice that  from aoa -1 to 15 it almost rises lineary so you could just make a function y=ax+b or something similar, then with that last curve i belive single y=x^2*a+b should do, but since your flight model is really simplified you can even make another linear funciton that decreases linearly from 15 to 20 this approach will require 3 ifs

 

 

 

but the best thing is,  you make a table of angles and a table of coefficients then you lerp between them or make a mean

 

where 

inline template <class type> type Lerp(type a, type b, type x) { return a + x * (b - a); } 

you just go through an angle array and check if angletable[i] <= your aoa and angletable[i+1]  > aoa) then you lerp between these two

or make a mean this will force you to use one if




#5210639 Aircraft Rotation forces on takeoff. And how the vertical stabalizer works.

Posted by WiredCat on 14 February 2015 - 03:25 AM

for your question go see that new topic you have made i am just answering it right now.




#5210636 Blending textures with transparency

Posted by WiredCat on 14 February 2015 - 03:20 AM

i would suggest you to use a shader on that face then you will simply bind a texture (that with clouds) read the color and if the color is bigger than 0 you will perform blending (in this case you make your own one) anyway what sort of glBlendFUnc are you using i am pretty sure this will help:

 

http://www.andersriggelsen.dk/glblendfunc.php

 

and 

 

use gl_src_color and maybe gl_dst_color, becasue i see that your texture has wrong alpha values, additionally i am not sure but you will have to disable depth testing for this case,

 

so the answer is simple use shader for that.




#5202774 OpenGL 4 Shadow Map Problem

Posted by WiredCat on 08 January 2015 - 03:16 AM

Furthermore GL_DEPTH_COMPONENT32 may not work (i dont know why my geforce gt 520 doesnt want to use 32bit depthbuffer and when i try to use it whole driver cracks)

 

and

 

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);

 

is iuseless since you are not using hardware extension for comparsion but shader.

 

 

now whats below i am possibly wrong 

 

but 

glBindTexture( GL_TEXTURE_BUFFER, shadowmap_texture ); should you use GL_TEXTURE_2D in your case?




#5201154 Aircraft physics once again

Posted by WiredCat on 01 January 2015 - 12:03 PM

the question is about calculating drag and lift, absnf is my funciton its a template function that returns absolute value

 

"Main problem for now is wrong calculation of velocity vector since drag doesn’t make velocity vector to cover with thrust vector (which is the pitch vector of the jet) , so the problem is right there calculation of drag and lift vectors (and maybe the rotation itself which for now I don’t know really how to handle)"

 

 

Anyway buck i thought that the more describe the problem it will be easier for someone to reply/solve tongue.png

 

since lift and drag are related to calculate proper velocity i thought it woul be good to put everything there.

 

Videos show that jet is moving upwards instead of flying almost plain forward or going down.

 

I deleted that first of all etc but i think it contains revelant data.

 

Anyway i cant make it shorter now ;[ <cries badly>

 

And yes i know putting whole code and that surface area pictures are useless. i just wanted to describe everything clearly. Now i really dont know how to change it. 

 

oh and 





template <class type> type __fastcall absnf(type x){ if (x < 0 ) return -x;  return x; }



#5200793 Pressure equation (gravity force at lattitude 45*degs) <- what does that...

Posted by WiredCat on 30 December 2014 - 07:57 AM

Hi im trying to write a pressure equation:

 

pres.jpg

 

 

 

 

i came to this:



const double eGForce = 9.810; 
const double TEMP_AT_SEALEVEL_STD = 288.150; //Kelvins
const double PRESSURE_AT_SEALEVEL_STD = 101.3250; //Pascals


double GEOPOTENTIAL_ALTITUDE(double obj_height) { return earth_radius*obj_height/ (earth_radius+obj_height); }
											  //288.15 kelvins T0 15 C at sea level
double TEMPERATURE(double height) { return (TEMP_AT_SEALEVEL_STD − (0.00650*GEOPOTENTIAL_ALTITUDE(height))); } //0.0065*C m-1 temp lapse


double Pressure /*Pa*/ (double height) {             
return PRESSURE_AT_SEALEVEL_STD * pow(2.71828,  ( (sin(45.0*imopi)*eGForce * 28.96440) / (8314.32 * -0.00650) ) * log(TEMP_AT_SEALEVEL_STD / TEMPERATURE(height)) );
}

what is i do not understand is 

g0 is the acceleration of gravity (m/s2 at a latitude of 45 ◦) and how can i calculate this

 

 

another thing is is my function correctly written?

 

 

 

 

 

 




#5199234 C++ how to declare something that isn't declared?!?

Posted by WiredCat on 20 December 2014 - 05:01 AM

Just to be clear __fastcall get off me you little rat.

 

I am not following any borland conventions i am not following any convention except my own convention:







struct TSubparticle
{
double * charm;
TSubparticleP * ConsistsOf;

virtual void ReactWith(TSubparticle * p) {}

		TSubparticle& operator=(const TSubparticle& in)
		{
			charm = in.charm;
			ConsistsOf = in.ConsistsOf;
			return *this;
		}
};

My convention is simple structNameP = equals to array of this structure* (array of pointers)

so when i have this i can easily







TSubparticle MEME;

MEME.ConsistsOf = new TSubparticleP[ number ];

for (int i; i < number; i++) MEME.ConsistsOf[i] = new TSubparticle(); //or attach other



the main reason was in the past ONCE UPON A TIME i had a problem :P i couldnt manage to make TSubparticle ** arr; to create an array of pointers

so i used typedef instead


END OF STORY

TSubparticle




#5198939 C++ how to declare something that isn't declared?!?

Posted by WiredCat on 18 December 2014 - 08:22 AM

struct TSubparticle
{
TSubparticleP * <-- here i want to declare that typedef below
};

typedef TSubparticle * TSubparticleP;

cheers.




#5191509 Extracting From Final Transform Matrix

Posted by WiredCat on 06 November 2014 - 07:39 AM

if you are delaing with rot pos and scale its doable (after getting info from matrix, you must untransform results )

 

for gl matrix its like:

 

if not using that gllike matrix you need to transpose it and you will get everything you need: (i dont know where scaling is its probably where zeros are)



			AIR_MATRIX[0] = rr.x; //right
			AIR_MATRIX[1] = rr.y;
			AIR_MATRIX[2] = rr.z;
			AIR_MATRIX[3] = 0.0;
			AIR_MATRIX[4] = ru.x; //up
			AIR_MATRIX[5] = ru.y;
			AIR_MATRIX[6] = ru.z;
			AIR_MATRIX[7] = 0.0;
			AIR_MATRIX[8]  = -rf.x; //front
			AIR_MATRIX[9]  = -rf.y;
			AIR_MATRIX[10] = -rf.z;
			AIR_MATRIX[11] = 0.0;
			AIR_MATRIX[12] =  0.0;  //point
			AIR_MATRIX[13] =  0.0;
			AIR_MATRIX[14] =  0.0;
			AIR_MATRIX[15] = 1.0;




#5188001 Ray plane intersection problem (need verification to the code)

Posted by WiredCat on 19 October 2014 - 09:40 AM

pls buckeye dont eat me lol :P ok ill debug it




#5186692 Drawing a cricle on the plane

Posted by WiredCat on 13 October 2014 - 07:10 AM

SOLVED        SOLVED        SOLVED      SOLVED

 

 

 

 

 

So i have a plane that has a normal n and distance d (normal normalzied)

 

 

i want to draw a circle on it (set some vertices there on the surface)

 

my code looks like this:

determine what direction face (plane) is facing (x or y or z)

 

go through a loop



if (ShockSurfH.algined == 2) { //Y algin so XZ calculus
t1.y = 0;
t1.x = cos(angle*imopi)*(radius-1.0f);
t1.z = sin(angle*imopi)*(radius-1.0f);

t2.y = 0;
t2.x = cos(angle*imopi)*radius;
t2.z = sin(angle*imopi)*radius;

t3.y = 0;
t3.x = cos(angle2*imopi)*radius;
t3.z = sin(angle2*imopi)*radius;

t4.y = 0;
t4.x = cos(angle2*imopi)*(radius-1.0f);
t4.z = sin(angle2*imopi)*(radius-1.0f);

							 }


shockwaveH[i*4+0] = pos+ ( nH * (t1*nH));
shockwaveH[i*4+1] = pos+ ( nH * (t2*nH));
shockwaveH[i*4+2] = pos+ ( nH * (t3*nH));
shockwaveH[i*4+3] = pos+ ( nH * (t4*nH));

i set circle verts on the 'axis' and then project it onto the plane (the 2nd code) however the bigger slope of the plane circle starts to look like an ellipse.

 

How to draw a normal circle?




#5185527 Dropping a not guided bomb

Posted by WiredCat on 07 October 2014 - 08:04 AM

 

Just a comment, but your weight-force looks suspicious as it appears to be based on position (and you don't mention what "Q") is. If you're trying to account for the slight change of gravity due to height, you should base it only on height, not position.



float Q = eGForce * Weight; // gravity force val  eGForce is 9.81 gravity const     Q euals to m * g //in school they tought me that Q = mg 
(maybe you name it somehow differently)

float squareSpeed = VectorLength(vel); //speed squared ;p

t3dpoint WeightForce = Normalize(-pos) * Q; //since i have almost round globe (not just flat ground with heightmap) 
i Normalize reversed position to obtain a gravity direction vector and multiple it by weight force

t3dpoint DragForce = Normalize(-vel) * (DragCoeff * ((1.250 * squareSpeed)/2.0f) * 0.760f); bla bla bla 0.768 is an area for mk84 ;] and 1.250 is air dens 
(here constant but i have a function for determining the proper airdens)

t3dpoint Acceleration = (WeightForce + DragForce) / Weight; yep still no stabilizators, but it hink they will make bomb go further (checked it by shooting 
arrows with bow ;])

pos = pos + (vel * dt);
vel = vel + (Acceleration * dt); //where dt is time between frames

btw thanks for your replies i will iterate towards ground




#5184121 Problem with positioning an object after no collision :) sounds strange?:P

Posted by WiredCat on 30 September 2014 - 01:44 PM

Hi, i have a problem with calculating position of a tank that its position is calculated from 4 points (see image below there are 4 spheres on the corners of tank hull - red green white and blue)

 

tankf.jpg

 

 

 

So i do following steps:

 

First i calculate forces that are acting on the tank (in this example tank is dropped from 20 meters above the surface), i simplified the formula so force acting on the tank is gravity (weight) only. It should fall to the point on the surface this big red sphere ;]

 

Then after setting new position of a tank i check whenever there was a collision with the surface[ from tank old position to the new one) and if there was i set the tank to the proper position. BUT problem occurs when theres no collision at all

 

let me start from begin:

 

calculate forces acting on tank

for each collision sphere (white,red,green,blue):

check collision (from old position to the new position - new pos, is a pos where we want to go with the tank) if there was no collision return that point where we want to go (new pos)









fl = col->SPHERE_INTERSECT_POLYGON(col_front_left,col_front_left + movement_ray,2.0f,sector,facei,rfl); <-- last value is the returned point
fr = col->SPHERE_INTERSECT_POLYGON(col_front_right,col_front_right + movement_ray,2.0f,sector,facei,rfr);

rl = col->SPHERE_INTERSECT_POLYGON(col_rear_left,col_rear_left + movement_ray,2.0f,sector,facei,rrl);
rr = col->SPHERE_INTERSECT_POLYGON(col_rear_right,col_rear_right + movement_ray,2.0f,sector,facei,rrr);

col_front_left, col_front_right, col_rear_left, col_rear_right are positions of these collision spheres. the return point of collision or no collision is

rfl for front left , rfr for front right, rrl for rear left, rrr for rear right

 

fl,fr,rl,rr are bools to help me determinate where collision occured.

 

then i calculate the actual pitch and roll of the tank, and the new roll and pitch after collision(or no collision)

 

then i subtract them to see the difference (and then i can rotate tank by this angle)

 

a(anglename) stands for actual(anglename)         n(anglename) stands for new(anglename)









t3dpoint aroll  = ( (col_front_left - col_front_right) + (col_rear_left - col_rear_right) ) /2.0f;

t3dpoint apitch = ( (col_front_left - col_rear_left) + (col_front_right - col_rear_right) ) /2.0f;

t3dpoint nroll 	= ( (rfl - rfr) + (rrl - rrr) ) / 2.0f;

t3dpoint npitch = ( (rfl - rrl) + (rfr - rrr) ) / 2.0f;

so now we are here since tank position and rotation is represented by 4 points (these collision spheres)

i calculate the position like

 

pos = (rfl+rfr+rrl+rrr) / 4.0f; (add all sphere positions  and then divide it by the amount of spheres) and this is the main line causing problems, whenever i want to go down it goes infront...

 

heres the full code:











void __fastcall CheckForCollision()
{
int facei = ReturnFaceIndex(oldc);

t3dpoint movement_ray = vectorAB(oldc,pos); //oldc is a point before movement, pos is a point where we want to go (after movement).

t3dpoint rfl, rfr, rrl, rrr;
bool fl,fr,rl,rr;

rfl = col_front_left;
rfr = col_front_right;

rrl = col_rear_left;
rrr = col_rear_right;

     // &PS, //
fl = col->SPHERE_INTERSECT_POLYGON(col_front_left,col_front_left + movement_ray,2.0f,sector,facei,rfl);
fr = col->SPHERE_INTERSECT_POLYGON(col_front_right,col_front_right + movement_ray,2.0f,sector,facei,rfr);

rl = col->SPHERE_INTERSECT_POLYGON(col_rear_left,col_rear_left + movement_ray,2.0f,sector,facei,rrl);
rr = col->SPHERE_INTERSECT_POLYGON(col_rear_right,col_rear_right + movement_ray,2.0f,sector,facei,rrr);



t3dpoint aroll  = ( (col_front_left - col_front_right) + (col_rear_left - col_rear_right) ) /2.0f;

t3dpoint apitch = ( (col_front_left - col_rear_left) + (col_front_right - col_rear_right) ) /2.0f;

t3dpoint nroll 	= ( (rfl - rfr) + (rrl - rrr) ) / 2.0f;

t3dpoint npitch = ( (rfl - rrl) + (rfr - rrr) ) / 2.0f;


//. u = v - n * dot(n, v)
//
// cross(n, cross(v, n))

t3dpoint A,B, n;

A =  vectorAB(sector->VBO_V[sector->VBO_BE[facei].INDEX_START],sector->VBO_V[sector->VBO_BE[facei].INDEX_START+1]);

B =  vectorAB(sector->VBO_V[sector->VBO_BE[facei].INDEX_START],
sector->VBO_V[sector->VBO_BE[facei].INDEX_START+3]);
n = vectorcross(A,B);

t3dpoint proj_surfacev_apitch = n * (apitch*n);
t3dpoint proj_surfacev_npitch = vectorcross(n, vectorcross(npitch,n));

t3dpoint proj_surfacev_aroll = vectorcross(n, vectorcross(aroll,n));
t3dpoint proj_surfacev_nroll = vectorcross(n, vectorcross(nroll,n));

float pitcha = AngleBetweenVectors(proj_surfacev_apitch, apitch);
float rolla = AngleBetweenVectors(proj_surfacev_aroll, aroll);
float pitchn = AngleBetweenVectors(proj_surfacev_npitch, npitch);
float rolln = AngleBetweenVectors(proj_surfacev_nroll, nroll);

float res_pitch = pitchn - pitcha;
float res_roll = rolln - rolla;


hull.rotation.pitch( cos(res_pitch), sin(res_pitch) );
hull.rotation.DoRotation();

hull.rotation.roll( cos(res_roll), sin(res_roll) );
hull.rotation.DoRotation();



pos = (rfl+rfr+rrl+rrr) / 4.0f;

}


any suggestions? i think the code is fine, maybe someone else will tell me that,  it should work but somehow it isn'teverything btween las sphere_intersect_polygon and pos = (xx) / 4.0f is irrevelant to the topic.

 

 

so the code that is responsible for this is like:



void __fastcall CheckForCollision()
{
int facei = ReturnFaceIndex(oldc);

t3dpoint movement_ray = vectorAB(oldc,pos); //oldc is a point before movement, pos is a point where we want to go (after movement).

t3dpoint rfl, rfr, rrl, rrr;
bool fl,fr,rl,rr;

rfl = col_front_left;
rfr = col_front_right;

rrl = col_rear_left;
rrr = col_rear_right;

     // &PS, //
fl = col->SPHERE_INTERSECT_POLYGON(col_front_left,col_front_left + movement_ray,2.0f,sector,facei,rfl);
fr = col->SPHERE_INTERSECT_POLYGON(col_front_right,col_front_right + movement_ray,2.0f,sector,facei,rfr);

rl = col->SPHERE_INTERSECT_POLYGON(col_rear_left,col_rear_left + movement_ray,2.0f,sector,facei,rrl);
rr = col->SPHERE_INTERSECT_POLYGON(col_rear_right,col_rear_right + movement_ray,2.0f,sector,facei,rrr);



pos = (rfl+rfr+rrl+rrr) / 4.0f;

}

maybe il post a vid what i get:

 

 




#5183545 OpenGL rotation matrix, [math] rotates in different direction

Posted by WiredCat on 28 September 2014 - 02:59 PM

First of all i would like you to see this:

tank01.jpg

 

 

 

 

Image shows a tank (not rotated, static) with 4 collision spheres (white, red, green, blue) 

 

 

/ note: three lines what you see (white,red,green) show the positive side of an axis, so for red its +x, for green its +y and for white its +z,

 

 

My problem is whenever i try to rotate a tank spheres are rotated backwards. like on this video:

 

 

To rotate a tank i use exactly the same rotation matrix i use to rotate these spheres.

 

 

 

now to explain it more deeply: sphere base position (in relation to unrotated tank) is calculated like this:

 

 

front_left sphere which is white (span_dist, 0, front_dist) [xyz]

front_right (red) (-span_dist, 0, front_dist) [xyz]

 

 

rear_left (green) (span_dist, 0, -front_dist)

rear_right (blue) (-span_dist, 0, -front_dist)

 

 

 

 

i draw the tank like this:





glPushMatrix();
glLoadIdentity();

gluLookAt(eyepos.x,eyepos.y,eyepos.z,lookat.x,lookat.y,lookat.z,up.x,up.y,up.z);

glTranslatef(pos.x,pos.y,pos.z);
glMultMatrixf(hull.rotation.AIR_MATRIX);
 
						hull.model->DrawSimpleModel();

glPopMatrix(); 

hull.rotation.AIR_MATRIX <- this is my rotation matrix (it only has rotation data, - no translation and scale data)

 

 

now i calculate spheres positions like:



float rotm[16];    int i;
for (i=0; i<16;i++) rotm[i] = hull.rotation.AIR_MATRIX[i];

col_front_left = front_left * rotm;
col_front_left = col_front_left + pos;

col_front_right = front_right * rotm;
col_front_right = col_front_right + pos;

col_rear_left = rear_left * rotm;
col_rear_left = col_rear_left + pos;

col_rear_right = rear_right * rotm;
col_rear_right = col_rear_right + pos;

where rotm is a copied hull.rotation.AIR_MATRIX (ofc same values)

a code for multiplying a vertex by a matrix is:



	  t3dpoint operator*(const float in[16]) const
		{     //since its an opengl engine i use this order
		//note that i do not add translation data and do not use scaling
			return t3dpoint(
in[0]*x+in[1]*y+in[2]*z,

in[4]*x+in[5]*y+in[6]*z,

in[8]*x+in[9]*y+in[10]*z);
		}

No i should say something about how do i calculate rotation matrix:

lets say i have three vectors front, right and up vector

 

 

i rotate them by calling pitch, yaw, roll funcitons

and then i build a matrix like this:



			AIR_MATRIX[0] = rr.x; //right
			AIR_MATRIX[1] = rr.y;
			AIR_MATRIX[2] = rr.z;
			AIR_MATRIX[3] = 0.0f;
			AIR_MATRIX[4] = ru.x; //up
			AIR_MATRIX[5] = ru.y;
			AIR_MATRIX[6] = ru.z;
			AIR_MATRIX[7] = 0.0f;
			AIR_MATRIX[8]  = -rf.x; //front
			AIR_MATRIX[9]  = -rf.y;
			AIR_MATRIX[10] = -rf.z;
			AIR_MATRIX[11] = 0.0f;
			AIR_MATRIX[12] =  0.0f;  //point
			AIR_MATRIX[13] =  0.0f;
			AIR_MATRIX[14] =  0.0f;
			AIR_MATRIX[15] = 1.0f;

Hopefully its enough info for someone that can help me ;x

 

oh i forgot to add that whenever i try to pitch the rotation matrix (opengl model draws properly) but i get stranger spheres pos.






PARTNERS