Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 09 Apr 2011
Offline Last Active Today, 06:11 AM

#5277923 how do i use printf to display an int?

Posted by WiredCat on 24 February 2016 - 12:22 PM

SInce i never used printf but wanted to see if int x = 7; int y = 8;


int z = x / y; will give me 0 or 1 since they are ints not floats casted to int like int c = int( float(x) / float(y) );


without takin much effort i decided to use ideone that online cpp compiler and i am unable to compile that




i have no idea how to use it though. any suggestions?

#5277741 Determine whenever box is visible in frustum

Posted by WiredCat on 23 February 2016 - 10:48 AM

sorry for -1 rep

#5277270 Correct way of doing Mouse Picking

Posted by WiredCat on 21 February 2016 - 05:44 AM

vec3 DirectionFromScreen(int x, int y, int sw, int sh, float fov, float z_near, float z_far, float aspect)

mat4 mvm = CAM_MODEL * CAM_VIEW;
vec3 dirX, dirY;
	dirX.x = mvm.m[0];
	dirX.y = mvm.m[4];
	dirX.z = mvm.m[8];

	dirY.x =	mvm.m[1];
	dirY.y =	mvm.m[5];
	dirY.z =	mvm.m[9];

	float a = fov / 2.0;
float cotangent = 1.0 / tan( a * imopi );

float ax = z_near / cotangent;

float screen_w = 2.0*ax;

float screen_h = screen_w;// * yratio;

screen_w = screen_w * aspect;

float scr_coord_x = float(x) / float(sw);
float scr_coord_y = float(sh - y) / float(sh);

vec3 dir = FPP_CAM->ReturnFrontVector();

//move to lower left corner
vec3 start_pos = (FPP_CAM->pos + dir * z_near) + (-dirX * (screen_w / 2.0)) + (-dirY * (screen_h/2.0));

vec3 start = start_pos + (dirX * (screen_w * scr_coord_x)) + (dirY * (screen_h * scr_coord_y));

return Normalize( vectorAB(FPP_CAM->pos, start) );

FPP_CAM->pos camera position


fov is fovy actually, so it has to be converted into horizontal fov


since its opengl code int y has to be scrheight - y


CAM_MODEL is always identity


z_far is not used at all

#5275451 Triangle rendered white only.

Posted by WiredCat on 12 February 2016 - 02:01 PM

layout(location = 0) out vec4 out_color; in fragment shader


i dont understand why you are applying any layouts in fragment shader, cant you just define; out vec4 out_color;?



second thing might be



//you can use offsetof to get the offset of an attribute



there are few things here and in other parts of code:


first of all you should frist define vertexattribpointers

then enable them



glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,sizeof(VertexFormat),(void*)0);   (void*)0 this looks like a fail use this:






GLuint vao;
GLuint vbo;


this->vao = vao;

this is another potential problem with sharing opengl data between structures, you shouldn't do that at least you are sure that you this->vao = vao; will return the same object. In my opinion you should make: 

GLuint vao; GLuint vbo;, and somehow i have feeling that aobject after quit are destroyed.




EDIT. Yes SlicerChubu is right you should additionally call ggeterror after every openglcall and log it somehow

void ShowGLERROR()
GLenum res = glGetError();

in ex:

ALOG("Creating vertex array object");



ALOG("binding vao");



#5274117 Weather simulation

Posted by WiredCat on 03 February 2016 - 02:51 PM

code is irrevelant


look at the title and read that pdf

*  A Method for Modeling Clouds based on Atmospheric Fluid Dynamics
*	Ryo Miyazaki Satoru Yoshida Yoshinori Dobashi† Tomoyuki Nishita
*	University of Tokyo †Hokkaido University
*	7-3-1, Hongo, Bunkyo-ku Kita 13, Nishi 8, Kita-ku,
*	Tokyo, 113-0033, Japan Sapporo, 060-8628, Japan
* 	{ryomiya, yoshida, nis}@nis-lab.is.s.u-tokyo.ac.jp doba@nis-ei.eng.hokudai.ac.jp
*  Coded by me ;]

//deltaV / deltaT = -(grad(pressure) / density) + visc_coeff*grad(V)   ---- velocity

// grad(div) is the flow caused by the gradient of the mass flow around lattices
// Let vx be the x component of the velocity v for the current time step and vx* be the x component of v for the next time step.

Velocity field update / Viscosity and Pressure Effect

vx is of course the x part of velocity vector

//vx*[x][y][z] = vx[x][y][z] + kv * grad(vx)[x][y][z] + kp * grad(diw)x  //for the same cell

//kv is the viscosity ratio
//kp is the coefficient of the pressure effect

grad(vx)[x][y][z] = divBy6 * ( cell[x+1][y][z].v.x + cell[x-1][y][z].v.x + cell[x][y+1][z].v.x +
cell[x][y-1][z].v.x + cell[x][y][z+1].v.x + cell[x][y][z-1].v.x - 6.0f * cell[x][y][x].v.x );

grad(diw)x = divBy2 * ( cell[x+1][y][z].v.x + cell[x-1][y][z].v.x - 2.0f * cell[x][y][z].v.x   ) +
divBy4 * (  cell[x+1][y+1][z].v.y + cell[x-1][y-1][z] - cell[x-1][y+1][z].v.y - cell[x+1][y-1][z].v.y +
cell[x+1][y][z+1].v.z + cell[x-1][y][z-1].v.z - cell[x-1][y][z+1].v.z - cell[x+1][y][z-1].v.z );



  Wv*[x][y][z] = Wv[x][y][z] + temperature_coeff * grad(Wv)[x][y][z];

  grad(Wv) = divBy6 * ( cell[x+1][y][z].w + cell[x-1][y][z].w + cell[x][y+1][z].w +
cell[x][y-1][z].w + cell[x][y][z+1].w + cell[x][y][z-1].w - 6.0f * cell[x][y][x].w );


  Thermal Diffusion

   E*[x][y][z] = E[x][y][z] + temp_diff_coeff * grad(E)[x][y][z];

  grad(E) = divBy6 * ( cell[x+1][y][z].temp + cell[x-1][y][z].temp + cell[x][y+1][z].temp +
cell[x][y-1][z].temp + cell[x][y][z+1].temp + cell[x][y][z-1].temp - 6.0f * cell[x][y][x].temp );


  Buoyancy      AD NOTE 2.: since in paper we have z versor pointing upward we need to convert it to y component since we have lefthanded(or righthanded ;p) system  

kb is the coefficient affecting the strength of the
buoyancy force.

Vz*(x,y,z) = Vz(x,y,z) + kb * divBy4 * (  4.0f * E[x][y][z] - E[x+1][y][z] - E[x-1][y][z] - E[x][y+1][z] - E[x][y-1][z]  );

so the code seems to be like this: (rewritten to y as up vector)

cell[x][y][z].v.y* = cell[x][y][z].y + kb * divBy4 * ( 4.0f * cell[x][y][z].temp - cell[x+1][y][z].temp - cell[x-1][y][z].temp -
cell[x][y][z+1] - cell [x][y][z-1] );


 (6) Phase Transition
The amount of water droplets generated by the phase
transition is determined in proportion to the difference
between the maximum amount of water vapor and the
amount of water vapor in each lattice. The maximum
amount of water vapor for a unit volume of air is a
function of its temperature (see appendix for details ).


The amount of water droplets is proportional to the
difference between the maximum amount, 'wmax', of water
vapor 'wv' and the amount of water droplets 'wl' of each
lattice. That is, the amount of water droplets created at
each time step is computed by the following equation.

where alpha is the phase transition rate. Q is the latent heat.
wmax is a function of the temperature T[K] and is given by
the following equation:
( ) 217.0 exp[19.482 4303.4 /( 29.5)] / . max w T = - T - T (A.2)

const long double viscosity_coeff = 0.9670;
const long double waterVapor_coeff = 0.9670;
const long double temperature_coeff = 0.9670;
const long double divBy6 = 0.16670; //1.(6)
const long double divBy4 = 0.250;
const long double divBy2 = 0.50;
		 /* Deleted bullcrap not even worth watching */


The problem with this is I really need to work out an ambient temperature value for each location on the map.



There are many topogrpahic temperature maps, by studying them you could create your own initial value map


Has anyone come across a way of calculating an ambient temperature for a location based on date/time/location data?


Thats almost impossible to achieve, unless your run fullscale simulation, and learn your program, how things change. (still it will be far from ideal due to external forces)


And the wind that causes temperature to move (cool down heat up).

I believe there are heat maps on nasa page, so you could make some kind of one year peroid temperature map (with maybe data from each month, or only for winter, spring, summer, autsomething tongue.png, you wont be able to get acutal day, time, hour weather without running some simple simulation. or lerping <- which is bad as f



still code is wrong there, (didint have time to fix it) but the pdf is really good.


vital is to add third dimension. gravity, coriolis force or whatever its called


i am a bit to late with that post but was searchign for that code and pdf name.



but now i dont know if this is answered or what, still i could write an essay about weather

#5273522 Window Creation in Win 7

Posted by WiredCat on 31 January 2016 - 02:41 PM

winapi + createwindowex

you set size and flag as maximized without border additionally you change screen resolution before window creation.





#5271434 Shadow map projection issue

Posted by WiredCat on 16 January 2016 - 12:17 PM

-dot(normal, direction_light_to_vertex) if that is 0 or below 0 then fragment is not facing the light thus it should be shadowed, if  you set the color for this case to shadow color then you will get rid of that.

#5270546 Comparing two textures in openGL

Posted by WiredCat on 11 January 2016 - 10:26 AM

which version of ogles are you using if 1.0 forget about performance,

for 2.0 and above theres something in glsl like texture2d(for sampler2d)


values are between 0..1 for all channels.


either way you always load textures from a file so you could do that on cpu when loading textures to opengl.


but like mhagain said you must tell us more like which ver of ogles, and what are you trying to do.

#5270522 Air combat AI

Posted by WiredCat on 11 January 2016 - 07:05 AM

you could also check how ai behaves on sims like f22 lightning 2 or 3 or f/a 18 operation iraqi freedom, (motion of ai is fixed and they always pitch, yaw roll by some defined angles, no matter what)

#5270399 When are Shaders needed ? (wich context vers.)

Posted by WiredCat on 10 January 2016 - 09:25 AM

shaders are needed (in most cases) when you want to draw something on the screen,cool.png

#5269049 Rotation angle needed to make two dependant vectors point into direction x

Posted by WiredCat on 03 January 2016 - 01:27 PM

next time grab ruler, pencil or pen and white paper.then draw the problem or at least draw it in paint, anyway your idea of putting the E to T seems kinda silly but here it is:





or maybe you want to project a vector onto another then this:

//Project A onto B
template <class type> t3dpoint<type>  __fastcall VectorProjectionBDIR(t3dpoint<type> A, t3dpoint<type> B,bool NormalizedB)
t3dpoint<type> i = B;

if ( NormalizedB == false ) i = Normalize( i );
type dotp = Dot(A,i);
return i * dotp;


#5267827 Bvh player - blank!

Posted by WiredCat on 24 December 2015 - 02:30 PM

transpose it to get directx compilant matrix

#5267225 Just want to show you my project D:

Posted by WiredCat on 20 December 2015 - 03:51 PM

no, its a naval sim (pretends to be) i wont do a flight sim on android the steering of a plane is too difficult without keyboard.

#5267208 Just want to show you my project D:

Posted by WiredCat on 20 December 2015 - 02:39 PM

here: https://sites.google.com/site/customprog/wnb-dairy



or more or less this: (bare in mind music is there)

#5266755 call a java void from android ndk

Posted by WiredCat on 17 December 2015 - 03:27 AM

welp i understand that clearly but i just replied some nonsense topic should be closed after my third post btw.