Author Topic: Change grid  (Read 43747 times)

Offline javiasi

  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
on: January 21, 2008, 06:59:02 AM
Hi! I'm trying to change the grid by a bitmap image (a pic), but I don't know how to do it.

I supose that I can change it into the DirectX SDK like I was trying to apply textures to a 3D model, but I need to know witch program I should use.

Any suggestions ???

Greetings from Spain

btw great work Johnny, you're the best  ;D



Offline Spiffy

  • *
  • Posts: 3
  • Karma: +1/-0
    • View Profile
Reply #1 on: January 31, 2008, 04:29:46 AM
Yeah i was wondering the same. I wanted a group of images what i could scale and rotate and do what was done on the grid then use some gesture to move to the next image. What would be the best way to do something like this.

Thanks guys and well done Johnny on a great idea. Well impressed

Thanks again
Rob



Offline vadali

  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Reply #2 on: February 10, 2008, 03:13:16 PM
Hey,
I haven't really looked at the code, and I dont know DirectX API yet, but iam sure there's alot about 2d transformation there, which is what you are looking for (just a quick google gave me this tutorial http://www.euclideanspace.com/software/games/twod/index.htm).

I found this article, which explains how to display, rotate and scale (and iam sure translating will be really easy too): http://blogs.msdn.com/coding4fun/archive/2007/03/29/1991785.aspx ,in the Drawing section it shows how to scale and rotate, and just before it shows how to make a bitmap.

I didnt go over the grid code yet, though it most likely will already contatin a precalculated angle of rotation (which is also easily calculated, given two points and a little high school trigo), and also the scale factor most likely is calculated, so just go over it, and let me know what did you manage to make!

after thursday passes, and my last final with it for this semester, ill start digging in the code!

let me know if you managed to progress man, this sounds awesome!

Vadali



Offline vadali

  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Reply #3 on: February 10, 2008, 06:10:45 PM
Alright... I absolutely couldn't resist and downloaded the code.. :D

in class AffineTransformSolver you have a method called computeAngle and distance, and basically
Code: [Select]
float scale = distance(x3, x4, y3, y4) / distance(x1, x2, y1, y2);
float theta = computeAngle((x4 - x3), (y4 - y3)) - computeAngle((x2 - x1), (y2 - y1));

basically, I found that WiiMultipointGrid class has a method render, where it draws the lines of the grid, I think that would be a good place to start.
combine this with the tutorial on my last post, and iam sure it will be easily done!

ill sign off for now, time to bed..

Vadali



Offline cdougw

  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Reply #4 on: March 12, 2008, 02:08:36 AM
Hey Vadali can u please please please tell me the code to have a different image for the grid system.  I did look at the tutorial in your post but i am a complete noob in this area so i don't really know what I'm doing :D But I really would appreciate you (or anybody else) helping me out!

Thanks.
Doug.



Offline vadali

  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Reply #5 on: March 12, 2008, 06:49:50 AM
Hey Doug,
Ill hopefully go over the code this weekend, and then give you some pointers.

Until I do that, I suggest you to try to make a simple application in c# that just displays an image on the screen. Once you managed to do that, try to read again http://blogs.msdn.com/coding4fun/archive/2007/03/29/1991785.aspx, and attempt to make the picture rotate and rescale (focus on the Drawing section).

If you manage to do all that, integrating this into the wiimote's code will be the simplest thing, and ill help you with it as well.

Have a great day,
Vadali



Offline NoahGrey

  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Reply #6 on: March 17, 2008, 04:22:54 PM
Hey Vidali.

I just read that you might be working on the code to change the grid. Any luck with the code yet?

Hope you managed to work it out! We could really use it, I know I do!



Offline vadali

  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Reply #7 on: March 18, 2008, 02:57:20 AM
Hi all,
I managed to get a picture into a box within the grid!  :D
Ill post the code later today, since Iam at work right now.

I tried to make a picture for each box within the grid, but there are still some problems with that..
Anyone here knows some Direct3D? Its not as intuitive as I thought it was..

Good day,
Vadali



Offline vadali

  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Reply #8 on: March 18, 2008, 07:59:44 AM
Hey,

Alright, so I asked my friend to go on my computer at home and send me the source here.. :)
I cleaned it a bit, but since I have no compiler to test it in here, I hope I didnt mess it up. If it doesnt work, let me know.

Basically what I have done, was to make a texture with the image, assign it to a box within the grid, then run it through the same transformation that the grid goes through.

This is my first time ever writing anything (or even looking at) c# code AND Direct3D, so in that sense iam a complete noob, and any feedbacks would be appreciated.

I have tried to put another texture on a different box, but when i try to use both boxs, the program runs really ridiculously slow (I have no clue why). The code for that is commented, so if anyone knows some Direct3d, iam sure you could make much more sense out of it.

I included in the zip only the WiiMultipointGrid.cs, so you should overwrite your own with it, compile and run it.
My changes begin with "//Vadali :", so you can easily see what i have touched.

Let me know how you like it,
Vadali



Offline cdougw

  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Reply #9 on: March 18, 2008, 08:36:27 AM
So how do i get the image up there?   do i just put it in the folder and call it something?



Offline vadali

  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Reply #10 on: March 18, 2008, 08:41:44 AM
Hey,

open the code, in line 281 put in the location of your image file.

remember to put "\\" (twice!) instead of "\" (once),
so if your image is in your temp directory in c drive, write this: "C:\\temp\\imagename.jpg"

Vadali



Offline cdougw

  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Reply #11 on: March 18, 2008, 08:54:38 AM
Yep did that.. didnt work.  :-[



Offline cdougw

  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Reply #12 on: March 18, 2008, 08:57:17 AM
And i did push 'I' to display image.



Offline vadali

  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Reply #13 on: March 18, 2008, 09:02:11 AM
hehehe, did you try to press 'I' again?  ;D
its on by default, so you might have disabled that..

Anyhow, do you see the grid at all? the image should be really small on the bottom left box of the grid, so you should zoom in on that box.

unfortunately, its not my computer here, so i cant see whats up, i might have even messed the code up because I cleaned it a bit without checking.

Vadali



Offline cdougw

  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Reply #14 on: March 18, 2008, 09:09:16 AM
yehh its absolutely not there.  Its probably my fault, screwed something up...