Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Applied Mathematics (hardcore).

  • 14-07-2001 6:05am
    #1
    Closed Accounts Posts: 218 ✭✭


    If you don't know that a "Quaternion" is, then stop reading (it's a maths yoke "discovered" by a certain Professor Hamilton in the 19th Century).
    This is WAYYY beyond LC Hons Maths kiddies...

    Excellent, so you do then? Firstly, I amn't a maths genius (by any stretch of even my own warped imagination). This stuff is pretty ****ing sobering. If I did ascribe to the aforementioned skill I wouldn't need help. Basically, I am trying to write a computer game involving 3d stuff(tm). This game happens to involve complex Newtonian physics(tm).

    Well, no actually. No gravity, no friction, it's actually pretty damned straightforward. PLEASE do not mention Einstein, no relativity here please (Science board, I would expect no less). The game we are trying to write is basically a multiplayer Elite clone. If you don't know what "Elite" is, then I suggest you do some research, rest assured it is nothing to do with "Elite" hax04 m45t045 (w0t h45 m4d 5k1ll5). Further information: http://hosted.quake.ie/void (about the project, not hax04s damnit!)

    Unfortunately, the webpage linked above has not been updated in a while. A chronological search of the Programming boards filtered by the username "Void" should reveal links to recent screenshots/updates (wah wah, we don't have time to update the site properly etc).

    Project Status:
    TCP/IP Multiplayer Architecture:
    Blah blah UDP comms.
    Dead reckoning (AKA Client-side prediction) ala Quakeworld (ala US Military SimNET project, yeah we robbed some of their code, nice.....).

    OpenGL Renderer
    Poxy 3D Graphics rendering thing (FPS sucks monkeys on a GeForce 2 GTS).
    2D Windowing system (yayyy!)
    All the stuff GUI programmers take for granted I coded myself, windows, checkboxes, listboxes, comboboxes, all the usual VB fare is fully functional).
    Multithreaded database access thingy (15 tier! Sorry, no, just 2 tier. What the **** does "tier" mean anyway? Whatever, it works.).
    Enterprise Level Design:
    Well, all you have to do is say "Enterprise" and all of a sudden it's a "professional" bit of code......
    Physics Engine
    This is pretty simple (Quaternions aside). As an example, the default physics function for a game object is listed below.

    AI FRAMEWORK - See above plea for help.
    Consider the following scenario. Two fighters are approaching each other. End of story. How do you code AI for this scenario? It's easy to think of the basics, but the mathematics is possibly the most savage thing I have ever come across. The problem lies with the heavy calculus. I can't handle it. Help please? This is what this post is all about.

    Basically, I have spent the last *three* years coding all this stuff. In all fairness, I did rob ridiculous amounts of code from various places. Robbing code is easy, integrating it into your own design is difficult. I scrapped the entire design recently and have embarked on the 3rd iteration of the project.

    Anyway, excuse the hyperbole, we are looking for people who are good at maths, with a tiny amount of programming skill (optional). Rewards are minimal but do include "I made this" and "I officially have mad skillz". I hope to start my first proper job getting paid to write computer games in August (dependent on IDA funding), so the last three years ****ing around with this stuff have not been in vain.


    CLARIFICATIONS:
    We're talking about C++ here.
    Standalone demo is ALMOST ready to go (you just can't do anything in it!! No AI!!!)
    We = Necrosoft INC. http://hosted.quake.ie/void
    Me = PJW. pjw@oceanfree.net
    Necrosoft = Some c*nt has already registered www.necrosoft.com, and it's a "portal site for the afterlife"? Mother of Jesus.

    Before anyone gets any ideas, my nick "Void" is the same as the project's: "Void". Funnily enough this is because I created the account to publicise the project about a year ago. I just haven't been bothered setting up a new account. And as for the origins of "Void", C++ (I was illumined whilst coding one fine day).

    Anyways,
    ADDENDUM: CHOICE SELECTION OF CODE (MEDIUM RARE)

    Warning: No you won't be able to compile this code, duhhhhh. It is supposed to serve as an example of interfacing into the Void object hierarchy. Notice the incredibly unprofessional coding style/variable naming convention. Quaternion dogs indeed!
    // DEFAULT OBJECT PHYSICAL RESOLUTION
    // etime = elapsed time in milliseconds
    void cGameObject::Update(float etime)
    {
    Quaternion temp;
       // temp = orientation rotated by rotation
       temp.mult(orientation, rotation);
       // interpolate between orientation and temp by an interval of etime
       orientation.QuatSlerp(&orientation, &temp, etime);
    		
       // standard Newtonian jazz
       velocity.x += (acceleration.x * etime);
       velocity.y += (acceleration.y * etime);
       velocity.z += (acceleration.z * etime);
    
       // likewise
       position.x += (velocity.x * etime) / 1000;
       position.y += (velocity.y * etime) / 1000;
       position.z += (velocity.z * etime) / 1000;
       
       // mad ridiculously complicated collision detection stuff (HERE BE DRAGONS!)
       CollisionUpdate();
    }
    
    
    // CODE TO DRAW "ELITE" STYLE RADAR
    static int RadarPerspectiveAngle = 20;
    static int RadarRotationAngle = 30;
    static float RadarMarkStep = 5000;
    static int RadarZoom = 1;
    
    void DrawRadar(Widget& wf) 
    {
    	int i;
    	
    	Point me = game.player->owner->position;
    	float passiveRadar = 10000; //Me->ship->radarPassiveDist;
    	float activeRadar = 100000; //Me->ship->radarActive? Me->ship->radarActiveDist : 100;
    	float rzoom = passiveRadar/RadarZoom;
    	float znear = rzoom*f_cos(RadarPerspectiveAngle*0.5f*fPI/180)/f_sin(RadarPerspectiveAngle*0.5f*fPI/180);
    	
    	// Setup Viewport
    	glViewport(0,0,400,400);
    
    	// Setup projection matrix
    	glMatrixMode(GL_PROJECTION);
    	glPushMatrix();
    	glLoadIdentity();
    	gluPerspective(RadarPerspectiveAngle,1,znear,znear+2*rzoom);
    
    	// Setup modelview matrix
    	glMatrixMode(GL_MODELVIEW);
    	glPushMatrix();
    	glLoadIdentity();
    	gluLookAt(0,0,-(znear+rzoom),  0,0,0,  0,znear,0);
    	glRotated(-RadarRotationAngle,1,0,0);
    
    	// Draw radar's mark lines
    	glColor3ub(56,59,166);
    	//glColor3f(.5f,.5f,.5f);
    	int num = int(rzoom/RadarMarkStep);
    	float edge = 0.3826834323651f; // sin(45./2.);
    	glLineWidth(2);
    	glBegin(GL_LINE_LOOP);
    		glVertex3d(-rzoom,0,-rzoom*edge);
    		glVertex3d(-rzoom,0,+rzoom*edge);
    		glVertex3d(-rzoom*edge,0,+rzoom);
    		glVertex3d(+rzoom*edge,0,+rzoom);
    		glVertex3d(+rzoom,0,+rzoom*edge);
    		glVertex3d(+rzoom,0,-rzoom*edge);
    		glVertex3d(+rzoom*edge,0,-rzoom);
    		glVertex3d(-rzoom*edge,0,-rzoom);
    	glEnd();
    	glColor3ub(122,127,220);
    	glLineWidth(1);
    	glBegin(GL_LINES);
    		for(i=-num; i <= num; i++) 
    		{
    			float range = lf(f_fabs(i*RadarMarkStep),0,rzoom,rzoom*edge,rzoom,rzoom,rzoom*edge);
    			if (i < 0) range = -range;
    			glVertex3f(i*RadarMarkStep,0,-range);
    			glVertex3f(i*RadarMarkStep,0,+range);
    		}
    
    		for(i=-num; i <= num; i++) 
    		{
    			float range = lf(f_fabs(i*RadarMarkStep),0,rzoom,rzoom*edge,rzoom,rzoom,rzoom*edge);
    			if (i < 0) range = -range;
    			glVertex3f(-range,0,i*RadarMarkStep);
    			glVertex3f(+range,0,i*RadarMarkStep);
    		}
    	glEnd();
    
    	// Draw ships in radar
    	Vector up = axeY;
    	Quaternion dogs;
    	dogs = game.player->owner->orientation;
    	Vector eye(0,33000, 55000);
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
    	gluLookAt(eye.x,eye.y,eye.z,0,0,0,up.x,up.y,up.z);
    
    	// Draw world items as points
    	glPointSize(12);
    	
    	cObject *temp = game.world.firstobject;
    	Vector relpos;
    	NormalVector locY = axeY;
    	dogs.Invert();
    	
    	while (temp)
    	{
    		if (temp->objtype >= typemissile)
    		{
    			relpos = temp->position - game.player->owner->position;
    			double dist =  relpos.size()* 1000;
    			relpos.scale(1000);
    			glColor3f(0,1,0);
    			relpos.Rotate(dogs);
    			
    			glBegin(GL_LINES);
    			glVertex3f(relpos.x, 0, relpos.z);
    			glVertex3f(relpos.x, relpos.y, relpos.z);
    			glEnd();			
    
    			glColor3f(1.0f, 0,0);
    			glPointSize(6.0f);
    			
    			glBegin(GL_POINTS);
    			glVertex3f(relpos.x, relpos.y, relpos.z);
    			glEnd();
    			//glVertex3fv(&(relpos.x));
    		}
    		temp = temp->next;
    	}
    
    	
    	// Restore projection matrix
    	glMatrixMode(GL_PROJECTION);
    	glPopMatrix();
    	// Restore modelview matrix
    	glMatrixMode(GL_MODELVIEW);
    	glPopMatrix();
    	// Restore viewport
    	
    	glViewport(0, 0, game.width, game.height);
    }
    
    // MISSILE HOMING CODE
    void cAIMissile::HomeIn()
    {
    float distancetotarget;
    Point relativeposition;
    
    	relativeposition = target->position - owner->position;
    	//game.Log("Target @ %f %f %f\n", relativeposition.x, relativeposition.y, relativeposition.z);
    
    	distancetotarget = relativeposition.size();
    	//game.Log("Targe @ %f km\n", distancetotarget);
    
    	if (distancetotarget > 100 || distancetotarget <0.005)
    	{
    		Detonate();
    	}
    	else
    	{
    		Vector vect1, vect2;
    		vect1 = relativeposition;
    		vect1.scale(1000);
    		vect2 = vect1;
    		vect2.norm(); vect2.scale(sqrt(100*M_PI*vect1.size()));
    		if(vect2.size() < 200)
    		{
    			vect2.norm(); vect2.scale(200);
    		}
    		vect2 = vect2 + target->velocity;
    		//Vect2 is now the velocity i WANT the missile to go.
    		vect2 = vect2 - owner->velocity; //acceleration required
    		if(vect2.size() > 200)
    		{
    			vect2.norm(); vect2.scale(200);
    		}//Cap Acceleration.
    		owner->acceleration = vect2;
    		FaceVector(vect2);
    	}
    }  
    

    [This message has been edited by Void (edited 14-07-2001).]

    [This message has been edited by Void (edited 14-07-2001).]


Comments

  • Closed Accounts Posts: 1,136 ✭✭✭Bob the Unlucky Octopus


    That sounds seriously interesting Void- and I wish you the very best of luck with the project. However, my impression is that this thread belongs in "Work" or "Technology"- I'll go with my gut instinct and move it to "Work" if that's ok- if you don't get a decent response there, WWman could move it to Technology/Programming if that suits.

    Again, the very best of luck with "Void"- let's all hope it's a smashing success smile.gif

    Bob the Unlucky Octopus


This discussion has been closed.
Advertisement