# _WeirdCat_

Member

1022

1471 Excellent

• Rank
>^_^<

## Personal Information

• Website
• Role
3D Animator
3D Artist
Animator
Art Director
Artificial Intelligence
Artist
Audio Engineer
Character Artist
Composer
Concept Artist
Creative Director
DevOps
Environment Artist
Game Designer
Level Artist
Level Designer
Pixel Artist
Producer
Programmer
Quality Assurance
Sound Designer
Technical Artist
Technical Director
UI/UX Designer
Visual Effects Artist
Writer
• Interests
Programming

## Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

1. ## GLSL, Point Sprites, Geometry Shader problem

Maybe instead using glortho you should go for the shader approach, how can one use glortho and shaders anyway, that seems useless, and you put every sprite in range from -1..1 for both x and y Where -1,-1 is 0,0 position and 1,1 would be 800,600 Or was that 0,600 and 800,0 That depends....
2. ## Angular velocity and water physics

First of all define a boat hull, lets say you define it by triangles, now you cut those triangles with waterplanes to get the area that is under water, you list those triangles (newly created), then you calculate skin drag and form drag and apply that to rotation velocity, after that you need a damping function either way to cut the close to zero related problems and smoothly deaccelerate things for the simulation to run efficently. Now pay attention vec3 form_drag; vec3 skin_drag; float whole_sub_surf = 0.0; for (int i=0; i < submerged_tri_count; i++) //now iterate through form_percentage_coefff if (ACTUAL_FRAME[i].surface > 0.1) //do not coun't anything that is less than 10 cm^2 { whole_sub_surf = whole_sub_surf + ACTUAL_FRAME[i].surface; vec3 element_form_drag = vec3(0.0, 0.0, 0.0); //somehow i dont trust that compiler due to optimization will zero it vec3 element_skin_drag = vec3(0.0, 0.0, 0.0); vec3 cog2pC = vectorAB(pos + ROTATION_MAT * CENTER_OF_GRAVITY, ACTUAL_FRAME[i].pC); vec3 local_vel = vel + AngVel * cog2pC; vec3 vn = Normalize(local_vel); float vv = VectorLength(local_vel); float v2 = vv; vv = vv * vv; float form_percentage_coeff = absnf( acos(dot(ACTUAL_FRAME[i].normal, vn)) / float(pi) ); if (dot(ACTUAL_FRAME[i].normal, vn) <= 0.0) form_percentage_coeff = 0; //suction force element_form_drag = (-vn) * (form_percentage_coeff * (999.1026 * 0.5 * vv) * ACTUAL_FRAME[i].surface); //form drag float skin_percentage_coeff = absnf(1.0 - form_percentage_coeff); //due to float inaccuracy vec3 surf_n = Normal(ACTUAL_FRAME[i].V[0], ACTUAL_FRAME[i].V[1], ACTUAL_FRAME[i].V[2], true); float surf_choordlen = getTriangleChoordLength( -local_vel, surf_n, ACTUAL_FRAME[i].pC, ACTUAL_FRAME[i].V[0], ACTUAL_FRAME[i].V[1], ACTUAL_FRAME[i].V[2], true, ACTUAL_FRAME[i].pC); if (surf_choordlen > 20.0) surf_choordlen = 1.0; //calc reynolds number float Rn = ReynoldsNum(VectorLength(local_vel), surf_choordlen, 0.894); bool ah = false; if (absnf(Rn) <= 0.001 ) {Rn = 1.0; ah= true;} float CFRn = 1.328 / (sqrt(Rn)); if (ah) CFRn = 0.0; //float CFRn = 0.075 / (lg * lg); //1.328 / (sqrt(Rn));// vec3 Vfi = Normalize(ProjectVectorOnPlane(ACTUAL_FRAME[i].normal, -local_vel)); element_skin_drag = (-vn) * (CFRn * ((999.1026 * vv) / 2.0 ) * ACTUAL_FRAME[i].surface * skin_percentage_coeff); skin_drag = skin_drag + element_skin_drag; form_drag = form_drag + element_form_drag; cog2cob_vec = vectorAB(pos + ROTATION_MAT * CENTER_OF_GRAVITY, ACTUAL_FRAME[i].pC); ETorque = cog2cob_vec * ( element_skin_drag + element_form_drag ); elements_torque = elements_torque + ETorque; } drag_force = form_drag + skin_drag; result_force = gravity_force + buoyancy_force + drag_force + thrust_vec;// + rudder_force;// + drag_force + thrust_vec + rudder_force; mat4 inv_rot = ROTATION_MAT; inv_rot.Inverse(); vec3 local_torque = inv_rot * elements_torque; EAngVel = EAngAcc*dt; AngVel = AngVel + EAngVel; vec3 vLocalAngularMoment = (AngVel*dt)*RAD_TO_DEG; YPRangle.pitch(cos(vLocalAngularMoment.x*imopi), -sin(vLocalAngularMoment.x*imopi)); YPRangle.DoRotation(); YPRangle.yaw(cos(vLocalAngularMoment.y*imopi), sin(vLocalAngularMoment.y*imopi)); YPRangle.DoRotation(); YPRangle.roll(cos(vLocalAngularMoment.z*imopi), -sin(vLocalAngularMoment.z*imopi)); YPRangle.DoRotation(); float yawrate = 5.0*dt; YPRangle.yaw(cos(yawrate*imopi), sin(yawrate*imopi)); YPRangle.DoRotation(); ROTATION_MAT.LoadGLMatrix(YPRangle.AIR_MATRIX); BUO_COG = vectorAB(CENTER_OF_BUOYANCY, pos + ROTATION_MAT * CENTER_OF_GRAVITY); vec3 accel = result_force / mass; vel = vel + accel*dt; pos = pos + vel*dt; PC stands for pressure center point epsilon = 0.001; inline void damp( vec3 * ptr, float amount, float epsilon) { (*ptr) = (*ptr) - (*ptr)/amount; vec3 p = vec3(absnf<float>((*ptr).x),absnf<float>((*ptr).y),absnf<float>((*ptr).z)); if (IsNan(p.x)) p.x = 0.0; if (IsNan(p.y)) p.y = 0.0; if (IsNan(p.z)) p.z = 0.0; if ( (p.x > 0) && (p.x < epsilon) ) (*ptr).x = 0.0; if ( (p.y > 0) && (p.y < epsilon) ) (*ptr).y = 0.0; if ( (p.z > 0) && (p.z < epsilon) ) (*ptr).z = 0.0; } inline void damp( float * ptr, float amount, float epsilon) { (*ptr) = (*ptr) - (*ptr)/amount; if (IsNan((*ptr))) (*ptr) = 0.0; if ( (absnf<float>(*ptr) > 0) && (absnf<float>(*ptr) < epsilon) ) (*ptr) = 0.0; } //--------------------------------------------------------------------------- #ifndef aeroH #define aeroH //--------------------------------------------------------------------------- //Mix of crappyness //don't even think it is correct in 0.0001% #include <math.h> #include "DxcMath.h" const float AIR_STD_KINEMATIC_VISCOSITY = 1.460 * pow(10.0, -5.0); // m^2/s const float WATER_STD_KINEMATIC_VISCOSITY = 1.3083 * pow(10.0, -6.0); // m^2/s at temp = 10*C inline float ReynoldsNum(float V, float choord_len, float kinematic_viscosity_of_fluid) { return (V*choord_len) / kinematic_viscosity_of_fluid; } //0.894 inline vec3 FindTriangleAerodynamicCenter(vec3 A, vec3 B, vec3 C) { } inline float getChoordLength(vec3 velocity, vec3 surf_normal, vec3 pC, vec3 * verts, int vert_count, bool project, vec3 point_on_surf) { //Project velocity vector onto surface vec3 projected = Normalize(ProjectVectorOnPlane(surf_normal, velocity)); //find the biggest side and square it - this will ensure us that ray will always hit two sides float adst = -999.0; for (int i=0; i < vert_count; i++) { int next = i + 1; if (next == vert_count) next = 0; adst = Max(adst, n3ddistance(verts[i],verts[next])); } adst = adst*adst; //compute ray vec3 rA = pC - projected*adst; vec3 rB = pC + projected*adst; vec3 cp; for (int i=0; i < vert_count; i++) cp = cp + verts[i]; cp = cp / float(vert_count); vec3 n = surf_normal*1000.0; vec3 colp; //we compute center point to determine whenever a side face is at front or back to the center point (because i don't need to waste time and run math on paper i can just check that and use it for further processing) int cpside; for (int i=0; i < vert_count; i++) { int next = i + 1; if (next == vert_count) next = 0; vec3 normal = Normal(verts[i], verts[next], verts[next] + n, true); float dst = getplaneD(normal, verts[i]); //cpside will now determine the cpside = classifyapointagainstaplane(cp, normal, dst); // which side faces 'the inside' of polygon (always either front or back never on plane) - solid convex polygon if (cpside != isBack) //when center point is not behind side plane { normal = -normal; dst = getplaneD(normal, verts[i]); } colp = rA; if (SegmentPlaneIntersection(normal, dst, rA, rB, colp)) { //if ray and face normal 'look' (face) at each other if (dot(Normalize(vectorAB(rA,rB)), normal) < 0) rA = colp; else rB = colp; } } return n3ddistance(rA, rB); } inline float getTriangleChoordLength(vec3 vel, vec3 surf_n, vec3 pC, vec3 A, vec3 B, vec3 C, bool project, vec3 pop) { vec3 ahue[3]; ahue[0] = A; ahue[1] = B; ahue[2] = C; return getChoordLength(vel, surf_n, pC, ahue, 3, project, pop); } inline vec3 ShearStress(vec3 Force, float Area) { return Force / Area; } //1/ (pressure*v^2*Area) * ShearStress * dot(surf_normal, tangent_surf_dir) inline float SkinFrictionDrag( float dens, float V, float Area, float ShearStress, t3dpoint<double> surf_normal, t3dpoint<double> surf_tangent_relative_to_airflow) { return (dens*V*V*Area) * ShearStress * absnf(dot(surf_normal, surf_tangent_relative_to_airflow)); } inline float BodyDrag(float V, float Area, float fluidDens, t3dpoint<double> SurfNormal, t3dpoint<double> FluidFlowDir, bool front_only) { //now im not sure if its only the percentage of the rotation or if body is rotated the area increases //anyways im not increasing the area. float ratio = -dot(FluidFlowDir, SurfNormal); if(!front_only) ratio = absnf(ratio); return (0.5*(V*V)*fluidDens*Area*ratio); } #endif And heres a vid but keep in mind i applied rotation force and thrust force each frame so they are moving almost constantly https://youtu.be/7YXtG73KY_k
3. ## Strange performance differences and crashes on different systems

And﻿ some﻿﻿﻿ other guy has random crashes every few ﻿m﻿inutes that I cannot reproduce. that describes perfectly how faulty your code is, maybe reconsider rewriting
4. ## Projectile collision detection / line segment maths

Remember about float inacuraccy 1.0-1.0 can give you 0.0003 Itll be safe to check for close to zero numbers or close to any number with 0.001 digit Also when dealing with big numbers you'll need to translate them by some fixed point: i mean when dealing with lets say 60000.63738 the good idea would be to subtract 60000 so you end up with 0.63738 which will give you better accy
5. ## Adapting exiting desktop game to Android

Porting from dx to ogl is a pain, however there is another pain like handling system calls/events with different oses ao my best bet would be to port input handling, graphics initialization to sdl2. Another thing is permissions to access directories and resources, youd vetter for the start use fixed directory path where you put your files, another thing that youll have to face loading textures by your own or use sdl where x and y axis are negated. Not to mention youll have to find the correct path (best way to do is to execute ahstem call ls /storage/ and parse data you have received to find sdcard path or use /storage/emulated/0/ but depending on android platform you might be forced to install application to access specific data/packagename/files write/read permissions Networking differs too, handling time too From my xp i can say no you cant, you think you can but you cant unless you rooted the device and used make. And i highly dont recommend using java at all if you want to use c++, you only start app in java then call c++ code and thats all, no input handling or drawing once you started c++ code execution you contibhe with while loop till you want to exit application and habdle everythong from that, this will make you feel more like youre developing on windows without to care of threads spawning everywhere
6. ## Electricity in a tilemap with compute shader limitations

Could you draw on paper how actually you see this design of yours how power generators are attached to what. Because from what you already wrote i would store an array of connected devices per generator.
7. ## Serialize a vector of strings

First you need to open a file FILE * f = fopen("/mnt/sd_card/mybinstrvec.vtxt", ),"wb+"); Then at first the best would be to save vector size (how many strings you have) int vsize = int ( myvector.size() ); fwrite(&vsize, sizeof ( int ), 1, f); Then the best would be to convert std::string to * unsigned char but you could just put a loop and read uchar from each element of string then fwrite it but before that you should write the length of the string so you'll know when to finish updating the string. Then you fclose(f) And with opening that Read the size of vector to know how many string we will read FILE * f = fopen("/mnt/sd_card/mybinstrvec.vtxt", ),"rb"); Then for (int i=0; i < str_count; i++) { Read actual string length Either fread individually each char and update it to string or read a whole to pchar and create string from that } fclose(f);
8. ## Bone animation: calculate matrix of a child.

I dont quite get you, but i think you want to rotate spine by its own local axis. So first thing to do is that you place not rotated pelvis and not rotated spine in proper positions, then you get the vector from pelvis rotation pivot point to spine rotation pivot point. Then to actually rotate the spine along with pelvis rotation. You have rotation matrix of pelvis, and local rotation mattix of spine, now you translate spine so the rot pivot point of spine is at 0,0,0 then you apply spine rotmat then you translate back to original position then you should multiple vector computed earlier by pelvis rot mat then i think you combine those two matrices by multipkying them, its wuite harf to say cause it seems i deleted the code that actually did that and found something like this Where ship would be your pelvis and right boardside is your spine and ship is centered at 0,0,0 point and right boardside resides where it should for (int i=0; i < ship_count; i++) for (int j=0; j < ship[i]->boardside_cannon_cnt; j++) { vec3 rotpos = ship[i]->ROTATION_MAT * ship[i]->right_boardside[j].pos; Matrix44<float> wrld; wrld.TranslateP(rotpos + ship[i]->pos); MVP = (wrld * ACTUAL_VIEW) * ACTUAL_PROJECTION; COLOR_PICK_SHADER->SendMVPtoShader(MVP); box_model->DrawSimpleModel(COLOR_PICK_SHADER); }} I could twist something
9. ## Excavator Slingshot

It has nothing to the question but the only ezcavator with slibgshot is infiana jones with slibghost fighting off spiders rats and gorillaz
10. ## Projectile collision detection / line segment maths

Its quite straight forward, you move projectile over time and implement last_frame_pos with nowframepos vector which you test against each shape: whenever both points are on same sides then theres no collision, and if not you need to check for point on plane from ray. Then you test if the point lies inside polygon. As far as i remeber there was a code on gametutorials.net? Or something similar. Anyway there are many ways to implement this, one would be: template <class T> bool SegmentPlaneIntersection(t3dpoint<T> n, T d, t3dpoint<T> rA, t3dpoint<T> rB, t3dpoint<T> & res) { //t3dpoint<T> pop = poly.V[0]; // //t3dpoint<T> A = vectorAB(poly.V[0],poly.V[1]); //t3dpoint<T> B = vectorAB(poly.V[0],poly.V[poly.Count-1]); //t3dpoint<T> n = Normalize(A * B); t3dpoint<T> PointOnPlane; long double originDistance = (long double )d; // -1.0 * ((n.x * poly.V[0].x) + // (n.y * poly.V[0].y) + // (n.z * poly.V[0].z)); long double distance1 = ((n.x * rA.x) + (n.y * rA.y) + (n.z * rA.z)) + originDistance; long double distance2 = ((n.x * rB.x) + (n.y * rB.y) + (n.z * rB.z)) + originDistance; T clsnull = T(epsilona); if ( (absnf(distance1) <= clsnull) && (absnf(distance2) <= clsnull) ) return false; if (absnf(distance1) <= clsnull) { res = rA; return true; } if (absnf(distance2) <= clsnull) { res = rB; return true; } if (distance1 * distance2 > clsnull) //oryginalnie bylo >= return false; t3dpoint<T> vLineDir = Normalize(rB - rA); long double Numerator = -1.0 * (n.x * rA.x + n.y * rA.y + n.z * rA.z + originDistance); long double Denominator = ( (n.x * vLineDir.x) + (n.y * vLineDir.y) + (n.z * vLineDir.z) ); if( Denominator == 0.0) { PointOnPlane = rA; } else { long double dist = Numerator / Denominator; PointOnPlane = (rA + (vLineDir * T(dist))); } res = PointOnPlane; return true; } Now that function only returns point on plane and actually it can be done a bit easier (more readable code) but nvm Now the main goal was to gind if thenpoint is inside polygon, i remember that original code used the technique to find angles between points and check if they match or are greater than 2*pi*0.999999, i hovever calculate side planes and check whenever point lies on one side for all planes, thus it can lie on the edge of one side so youll have to take account on that, and it only states for convex shapes Oh here it is https://github.com/gametutorials/tutorials/blob/master/OpenGL/Camera%20World%20Collision/3DMath.cpp Search for intersectedpolygon function
11. ## Collision detection of two objects against a single bullet

For each visible bullet check for collisions if theres collision you add data to the stack then if theres another collision with same bullet you add new col info to the stack. In other words for each visible bullet check collision against all asteroids and do whatever you do there? Also i think using dynamic array for bullets is not the way one should ever do. Instead i would define a static array of bullets where the size is your predefined maximum if visible bullets (they surely wont exceed 100] where bullet class will hold bool visible, and you will check for which of new bullet index you want to use with int Find_first_free() { for (int i=0; i < BULLET_COUNT; i++) if (!BULLETS[i].visible) return i; return 0; }
12. ## Find infinity or a rect from set of 'halfspaces' 2d

Yeah i came up with same conclusion about parenthes of child subspaces etc. Thanks for info
13. ## Find infinity or a rect from set of 'halfspaces' 2d

First i need to define what halfspace for me is: a set of two lines one vertical and one horizontal [ they ofc are defined (A1, B1, C1) and (A2, B2, C2)] and a point at which those lines intersect) The available halfspace is always behind these two lines. But i need somehow to find areas where this set of halfspaces define (it can be a rect or just an halfspace with a intersection point - i meant that i cant define infinity (well actually i could because i anyway cut a space to some xy dimension so nothing that exceeds those values wont exist ok so from now one i need only to find rectangles that are defined by these halfspaces (the best would be all points. See image below i am trying to find blue rects. Hopefully one will understand what in trying to do if not tell me ill try to describe that more naturally
14. ## Voxel data to mesh data

Oh i see it now, however this should need another algorithm that merges cubes, what do you mean by wash rinse repeat)? Dividing space into smaller cubes than cell size seems a waste of data. I need some kind of inverse octree generation ;p where you merge these 8 into one. :)
15. ## Voxel data to mesh data

What do you mean to subdivide a cube into 8 smaller ones, not to mention that cube has 6 sides so wherr are additional 2? Where i subdivide that and what will be the result Let me show you sample pics lets say selected red cube is a pixel where data is now how do i subdivide that and where?