Author Topic: Darwinbots replacement/clone  (Read 18398 times)

Offline peterb

  • Bot Destroyer
  • ***
  • Posts: 148
    • View Profile
Darwinbots replacement/clone
« Reply #45 on: April 20, 2010, 05:00:10 AM »
Quote from: Numsgil
Quote from: peterb
Well i've done neither, so i will slowly learn it i guess.

Word of warning: if you've never done any OpenGL/XNA/DirectX before, and don't have a real good understanding of how graphics cards work...  Well, it's going to be difficult.  You're pretty close to the metal.  Basically video cards don't know how to draw anything but triangles.  So for drawing circles you have to either tessellate it (divide it up into triangles) or draw a square with a circle texture.  And there are a lot of ways to do something, only some of which are fast.

Did you see the GDI link I posted at the bottom of my last post?  It's built right in to .NET and I think it'll save you a lot of effort.  It's based more on the "draw circle at x,y pixel position" paradigm you might be used to.

I've seen the GDI sample, they remind me of the pen up and pen down commands of logo, which i never was a fan of..
I've been thinking too to use sprites for circles, that way no calculations..hmm
but they need to rotate as well, and scale not sure if that is something a graphic card does do fast.
Would it be better to scale, or to have multiple sprites of different sizes ?

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Darwinbots replacement/clone
« Reply #46 on: April 20, 2010, 08:56:26 AM »
Quote from: peterb
I've seen the GDI sample, they remind me of the pen up and pen down commands of logo, which i never was a fan of..
I've been thinking too to use sprites for circles, that way no calculations..hmm
but they need to rotate as well, and scale not sure if that is something a graphic card does do fast.
Would it be better to scale, or to have multiple sprites of different sizes ?

Yes, they use transformation matrices to handle scale, rotation, and translation of triangles.  Once the triangles are placed in screen space, they get their texture sampled and applied.

Textures/sprites have the advantage that they require fewer pixels.  But they'll get pixelated if you zoom in too close.  Using triangles will mean the edges won't be smooth, but will look more like a n-gon (eg: octagon) when you zoom in.

Offline peterb

  • Bot Destroyer
  • ***
  • Posts: 148
    • View Profile
Darwinbots replacement/clone
« Reply #47 on: April 20, 2010, 02:19:43 PM »
Quote from: Numsgil
Quote from: peterb
I've seen the GDI sample, they remind me of the pen up and pen down commands of logo, which i never was a fan of..
I've been thinking too to use sprites for circles, that way no calculations..hmm
but they need to rotate as well, and scale not sure if that is something a graphic card does do fast.
Would it be better to scale, or to have multiple sprites of different sizes ?

Yes, they use transformation matrices to handle scale, rotation, and translation of triangles.  Once the triangles are placed in screen space, they get their texture sampled and applied.

Textures/sprites have the advantage that they require fewer pixels.  But they'll get pixelated if you zoom in too close.  Using triangles will mean the edges won't be smooth, but will look more like a n-gon (eg: octagon) when you zoom in.

HMM

GL_Line_Loop

thinking of something fast to create n sides (its slow to do all with cos and sin) ,
basicly a quarter of a circle, or even maybe 1/8 is enough to get all X,Y positions ... hmm thinking fast routines no (zero) divisions and re-using values, and arrays.


Offline peterb

  • Bot Destroyer
  • ***
  • Posts: 148
    • View Profile
Darwinbots replacement/clone
« Reply #48 on: April 20, 2010, 04:39:27 PM »
Numsqil what do you think of this :

idea for openGL

The more precize the circles are, the less circles you have to draw since the viewscreen is zoomed in..
So .. ideas get more complex, but also you dont have to draw anything outside the current viewscreen (speeding things up).
I'm not sure if the program needs to know what is inside the viewscreen (vb.net could be aware of that).
So a circle routine has to be aware of the zoom scale.


 for some simple math testing for this i'd like to have a... simple language to draw.. duh.

hmmm i'm beginning to wonder if c++ might be more easy for this all together, as might tackle to many problems at once.

Offline Houshalter

  • Bot Destroyer
  • ***
  • Posts: 312
    • View Profile
Darwinbots replacement/clone
« Reply #49 on: April 20, 2010, 06:03:08 PM »
Quote from: peterb
I've seen the GDI sample, they remind me of the pen up and pen down commands of logo, which i never was a fan of..
You mean turtle graphics? Whats wrong with them?

Offline peterb

  • Bot Destroyer
  • ***
  • Posts: 148
    • View Profile
Darwinbots replacement/clone
« Reply #50 on: April 20, 2010, 06:30:44 PM »
Quote from: Houshalter
Quote from: peterb
I've seen the GDI sample, they remind me of the pen up and pen down commands of logo, which i never was a fan of..
You mean turtle graphics? Whats wrong with them?


I had to learn logo at school while i had at home an MSX in those days (which was graphically way more advanced).
It might be something else too, i never like penwidth or patern fills, i like 32bit collors when they where available.

ANYWAY i found something COOL

Its called BASIC4GL   (google for their wiki space and download it from there, the main site seams to be offline).
A basic compiler with openGL language support, the basic isnt as advanced as vb6 or vb.net, but it does do fast openGL...
So now i can experimenting drawing in OpenGL before i write somekind .net program to get familiar with openGL.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Darwinbots replacement/clone
« Reply #51 on: April 20, 2010, 09:09:37 PM »
Quote from: peterb
HMM

GL_Line_Loop

thinking of something fast to create n sides (its slow to do all with cos and sin) ,
basicly a quarter of a circle, or even maybe 1/8 is enough to get all X,Y positions ... hmm thinking fast routines no (zero) divisions and re-using values, and arrays.

Yeah, you'll want to use a line loop probably.  You can bake the vertices into a display list.  That's being pretty old-school but it's fairly easy to set up vs. the speed you'd get.

Quote from: peterb
Numsqil what do you think of this :

idea for openGL

The more precize the circles are, the less circles you have to draw since the viewscreen is zoomed in..
So .. ideas get more complex, but also you dont have to draw anything outside the current viewscreen (speeding things up).
I'm not sure if the program needs to know what is inside the viewscreen (vb.net could be aware of that).
So a circle routine has to be aware of the zoom scale.

That's how I'd do it using the fixed function pipeline in OpenGL (as opposed to shaders) for highest quality graphics.  But it's a bit of an effort to code up.

Quote
for some simple math testing for this i'd like to have a... simple language to draw.. duh.

hmmm i'm beginning to wonder if c++ might be more easy for this all together, as might tackle to many problems at once.

Did you get Tao working?  I found it very easy to use.  The only hard part was adding the Tao graphics control to a winform (hard as in tricky to navigate through all the menues and everything).   You can probably steal one of the NeHe tutorials as a starting point.  I think the C# source code for them uses Tao.

Offline peterb

  • Bot Destroyer
  • ***
  • Posts: 148
    • View Profile
Darwinbots replacement/clone
« Reply #52 on: April 21, 2010, 04:36:05 AM »
Quote from: Numsgil
Quote from: peterb
HMM

GL_Line_Loop

thinking of something fast to create n sides (its slow to do all with cos and sin) ,
basicly a quarter of a circle, or even maybe 1/8 is enough to get all X,Y positions ... hmm thinking fast routines no (zero) divisions and re-using values, and arrays.

Yeah, you'll want to use a line loop probably.  You can bake the vertices into a display list.  That's being pretty old-school but it's fairly easy to set up vs. the speed you'd get.

Quote from: peterb
Numsqil what do you think of this :

idea for openGL

The more precize the circles are, the less circles you have to draw since the viewscreen is zoomed in..
So .. ideas get more complex, but also you dont have to draw anything outside the current viewscreen (speeding things up).
I'm not sure if the program needs to know what is inside the viewscreen (vb.net could be aware of that).
So a circle routine has to be aware of the zoom scale.

That's how I'd do it using the fixed function pipeline in OpenGL (as opposed to shaders) for highest quality graphics.  But it's a bit of an effort to code up.

Quote
for some simple math testing for this i'd like to have a... simple language to draw.. duh.

hmmm i'm beginning to wonder if c++ might be more easy for this all together, as might tackle to many problems at once.

Did you get Tao working?  I found it very easy to use.  The only hard part was adding the Tao graphics control to a winform (hard as in tricky to navigate through all the menues and everything).   You can probably steal one of the NeHe tutorials as a starting point.  I think the C# source code for them uses Tao.


I first need to get a bit known with openGL so i first will play with that other basic variant, since it understands native opengl commands
Later i will use TAO,... yep i allready been reading about that part seamed complex to me too, how to get it into a form/picturebox ..first openGL it is.


OH BTW just woke up with another speed improvement idea (not sure if it is allready used)
We only need to calculate with sin / cos after a colission, we dont have to do it each time.
.. and apparently opengl does understand movement to (matrix movements, and matrix turns)....