
fguihen
Avatar/Signature-
Posts
251 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by fguihen
-
i have to draw 10 circles on a form, all with the same diameter. they cannot overlap. the formula to see if they overlap is: SquareRoot( Squared(A.x -B.x) + Squared(A.y - B.y)) what i cant figure out is a system that will allow me to check each new circle against the previous ones, to see if they overlap, and if they do , to generate new random co-ordinates and re check. any ideas anyone?
-
i have a cartesian point. i want to insert it into an arrayList of cartesian points. before i insert it, i want to make sure it doesnt already exist. how would you go about this?
-
i cant use that way im afraid. you see im using my own draw method within a thread so that i can use buttons like pause to stop my simulation. without the thread , they wont work, and to use a thread, i cant use onPaint, so i cant get a graphics objet from the OnPaint Method. any other ideas?
-
I am using a Graphics object from the CreateGraphics object!? why is this bad? i dont know how to get a graphics object any other way. heres how im doing it: Graphics e = this.CreateGraphics(); this.DrawToScreen(e); can you advise me of a better way?
-
im fairly sure that im not calling the on paint method from any other thread. i only set up one thread and this is the only place the my "draw " method is being called from. i have overriden the forms OnPaint, and "OnPaintBackground" methods but still no joy.
-
i have overridden the onPaint method, and incorporated doubble buffering and i still have a flicker in my app. im drawing everything through my own draw method, and i am calling this through a thread. i cant get rid of the flicker, but i can reduce it if i play around with the sleep duration of the thread. any ideas anyone?
-
i have a number of point objects in an arraylist. is there any way that i can do something like arraylist a = new arraylist(); Point p = new point; p.x = 10; p.y = 23; a.add(p);// p is now at index 0 of the array list //////////////////////////// //this is the part i cannot do int num = a[0].x; as you can see i need to access the x property of point p, which is in the arraylist. how can this be done?
-
i have an array list of Points ( not the # point class,but one i wrote myself. i want to sort them by the x value. the array will get very long and have many tens of thousands of elements . i have been trying to implement a quick sort algorithm but have had little success. can anyone here show me a basic quick sort in c#, or another simple sort. thanks
-
if i dont put in invalidate then the simulation im drawing to the pannel wont ever get updated. you see , each time the paint method for the pannel is called, the charachters move on a position and then they are drawn to the panel in their new position. thanks anyway
-
i have a panel on a form onto which im drawing a little moving simulation. i had this working perfectly , flicker free on the form, but when i tried to put it on the panel it is terrible. i have overridden the panel_OnPaint() method to this: private void Pannel_Paint(object sender, System.Windows.Forms.PaintEventArgs g) {//top walls g.Graphics.FillRectangle(Brushes.Cyan,1,1,this.Width,this.Height); foreach (Wall w in this.walls) { w.DrawWall(g.Graphics); } crowd.DrawToScreen(g.Graphics); panel1.Invalidate(); } i have the doubble buffering set up here SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); i have overridden the onPaintBackground() to do nothing. i have tried overriding and leaving the form1_onPaint() but still the same problem happens. any ideas on what i can do now?
-
i am writing an application that simulates a crowd moving through a building. it is done using windows forms and GDI. i may need to pause it on and off and i cant figure out how to do this. i know it could be done using threads but im unsure how. the program is all run from the main form, with all classes being called from here.any ideas on how i might sort this?
-
what does the math.abs function do??
-
ok for a simple example, lets say i have two numbers, x=10, y=2. i want to check if z=5 is between theese ranges. if(x>z && y < z) { //z is in the range } now this will fail if x is smaller than y, even though z would still be in the range. i have to do this with points. i have a point. i have to check if this point is between 4 other points. before anyone starts, im not asking to find if two lines intersect, i can do that already. my problem is that my algorithm checks if infinite lines intersect, and i have to then check if the intersection point found by my program is within the range of both line segments. as you can see this would lead to quite a large if statement. also, as you can see if the line is sloped funny ( x is before y) then the algorithm wont detect a collision. i tried swapping points but its hard to call if one line is bigger or smaller than another. anyone got any ideas?
-
i am creating a simulation with many people in it. there is a person class. each person has to be in an array for tests performed. what i want to do is create a new person each time i click a button. i dont know how to create an object without hard coding it. any ideas? im using c#
-
i am passing the ArrayList Persons to the person class so that each person can check to see if any of the rest of the persons are coliding. Person is a class i wrote to define a person in a game.its only very basic right now but im stepping through it and i can see that the sphereCenter for the current object is always the same as the sphereCenter for the object the current object is checking its position against. here is the code. i have the hash code comparison here to check if the current person is being compared to itself. dont know if this is the correct solution. it seems like something to do with the dot net framework that i dont understand. foreach (Person p in Persons) { if(this.GetHashCode() == p.GetHashCode()) { //break; int d = 90; Persons.Remove(p); } float a = this.sphereCenter.X - p.sphereCenter.X; float b = this.sphereCenter.Y - p.sphereCenter.Y; float c = this.sphereCenter.Z - p.sphereCenter.Z; float distance =(float) Math.Sqrt(a*a + b*b + c*c); if (distance > this.meshRadius*2) { int i =0;//they are not overlapped; } if ( distance == this.meshRadius*2) { int j = 1;//they are just touching; } if(distance < this.meshRadius*2) { int k = 2;//they are overlapped this.sphereCenter.Z +=2; p.sphereCenter.Z += 0; }
-
thank you very much for your help. your a real asset to the forum. thanks for all the replies
-
minB and maxB are DirectX.Direct3D.Vector3 objects. obj[] is an array containing Vector3 objects. the entire c++ method i need to translate to c# is below. thanks : void CalcAABBFromOBB(const D3DXVECTOR3 *obb,D3DXVECTOR3 *minB,D3DXVECTOR3 *maxB) { assert(minB); assert(maxB); assert(obb); minB->x=maxB->x=obb[0].x; minB->y=maxB->y=obb[0].y; minB->z=maxB->z=obb[0].z; for (int i=1;i<8;i++) { if (obb.x < minB->x) minB->x=obb.x; if (obb.x > maxB->x) maxB->x=obb.x; if (obb.y < minB->y) minB->y=obb.y; if (obb.y > maxB->y) maxB->y=obb.y; if (obb.z < minB->z) minB->z=obb.z; if (obb.z > maxB->z) maxB->z=obb.z; } }
-
minB->x=maxB->x=obb[0].x; i need to know how to phrase the above line in c#. also, does anyone know what the assert() method does?
-
ok. i have gotten some answers to this on other boards but its all in c++ and older directX ( Not directX9 & c#, which is all i know).my problem is i have a charachter. at the moment he is in a room. when he hits a wall ( or before) he is going to turn to avoid the colission. the problem is keeping the charachter always facing the direction that he/she is travelling. i am viewing the scene from a fixed position over head. the only things i have to work with is my current position, my last position and the fact that the charachter can not move along the y axis ( i am not giving the ability to jump).can anyone help with this, in as simple a way as possible, using directX 9 ( and hopefully c#)? thanks all
-
ok, i have a tcpip client connecting to the server. i can send small files (below 17152 bytes in size). when my method has sent over 17152 bytes, i get the error "unable to write data to transport connection". here is my method. what it does is recieves a string which is an entire email. it breaks the email up into 128 byte bundles, and sends each bundle to the server, as specified in the SMTP spec. there doesnt seem to be a problem with the method, as i have stepped through it many times. its just the connection that causes the IO error after the 17152 bytes for no apparent reason. public void WriteData(string line)//send out data to server { int totalLength = line.Length; byte[] outMessage; int n = 0; string s= ""; while(n < totalLength) { outStream = ClientConnection.GetStream(); if(line.Length >=128) { outMessage = new byte [128]; n += 128; } else { outMessage = new byte [line.Length]; n += line.Length; } for(int j = 0; j < outMessage.Length ;j++) { outMessage[j] = (byte)line[0]; line = line.Remove(0,1);//removes the charachter form the string as it is already sent } //outMessage = encoder.GetBytes(line); try { outStream.Write(outMessage,0,outMessage.Length); } catch(System.IO.IOException e) { s = e.Message; } //outStream.Flush(); } } any help would be greatly appriciated. thanks
-
im trying to read in a stream of unknown length through a networkStream, but the problem is with a network stream, you gota say how much data you want to read in. im afraid i dont know, and theres no method like stream.ReadToEnd(). i tried casting the network stream as a streamReader, which has a ReadToEnd() method, but it just throws an IO exception. any ideas how to get around this problem?
-
detecting the color of a pixel, for colossion detect
fguihen replied to fguihen's topic in Graphics and Multimedia
no , the bot is supposed to work by itself to avoid objects . i dont think color detection is the way though. if i can find a way to make the bot start turning left or right when an object(wall or other bot) comes within my bots field of vision ( maby the width of the bot*3 in front of the bot). hope this is a little clearer -
allowing bot to detect objects in its field of vision
fguihen replied to fguihen's topic in Graphics and Multimedia
what i mean by avoining objects is like when your walking across a room, and theres a table in your way , when you get within a certain distance of it you start to move either left or right to avoid bumbing into the table, but your still avoiding other objects such as people as you avoid the table. i want to be able to avoid walls, objects and other people by continually adjusting my position left or right. does this make it clearer? its a bit hard to describe -
hi. i have a bot that is moving around between obstacles and other bots. has anyone got an algorithm or ideas on how to do this. the walls and objects are just red rectangles. the bots are just moving yellow circles. i cant do something to detect difference in color, as this requires objects to be touching, but i want my bot to avoid objects before it gets near t