Author Topic: Several Different Targets.  (Read 6539 times)

Offline votemike

  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
on: June 16, 2008, 05:55:52 AM
Has anyone added code so that instead of just the one target .png there at several different patterns on show all at once?



Offline UndCon

  • Support Admin
  • *
  • Posts: 566
  • Karma: +11/-3
    • View Profile
    • UndCon
Reply #1 on: June 16, 2008, 06:53:18 AM
I changed a few features in the code but I dind't finish this one off...

Just put your images in an array

Loop thru the images for as many targets you need and assign an image to a specific target

make sure you have some code to handle problems that can occur like: out of images, nonexistent image, to many targets/to few images (use 1 as default)


kinda simple actually...



Offline tillydevine

  • *
  • Posts: 22
  • Karma: +0/-1
    • View Profile
Reply #2 on: June 16, 2008, 09:33:49 PM
Um, simple to whom? I dont know how to do it and been wanting this for a LONG time. Could some of you smart people tweak the code to allow this so us 'simple' people can use it?



Offline UndCon

  • Support Admin
  • *
  • Posts: 566
  • Karma: +11/-3
    • View Profile
    • UndCon
Reply #3 on: June 17, 2008, 03:13:12 AM
I'n not trying to be rude or anything - pls don't get this wrong...

It is simple programming, assuming you know about that of course

An array with the images is needed and you have to loop thru each target and assing an image as you go

That part is simple programming - but if you don't know much about it I understand it can be difficult to do so.

I'm afraid I cannot help you out atm - but I'll try to as soon as I get some spare time



Offline votemike

  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Reply #4 on: June 17, 2008, 05:01:17 AM
Where does the image for the target get called?
I have found in WiiDesktopVR.cs there is the line 'String textureFilename = "target.png";'
But I think that it is in CrosshairCursor.cs that I need to change the code to get different target images as there is a counter couting through the number of circleSegments.



Offline UndCon

  • Support Admin
  • *
  • Posts: 566
  • Karma: +11/-3
    • View Profile
    • UndCon
Reply #5 on: June 17, 2008, 08:25:06 AM
The target-image is named Target.png and if you replace that one with another image you can have this result like I did



I'll try to make an array of images when I get home from work...



Offline tillydevine

  • *
  • Posts: 22
  • Karma: +0/-1
    • View Profile
Reply #6 on: June 17, 2008, 08:17:58 PM
Yep, we get that part. I think the post was refuring to having different targets at once. Thankyou. (PS the stars are pretty!)



Offline UndCon

  • Support Admin
  • *
  • Posts: 566
  • Karma: +11/-3
    • View Profile
    • UndCon
Reply #7 on: June 19, 2008, 01:48:43 PM
Thank you - I also liked the stars...

here you have the image i made:
http://undcon.com/mods/wiimote/target.png

It is actually easier to put the images in an listArray

with the stringArray it requires more code to cycle between the images

with an listArray you can use myArray.Next to move to the next position in the array
« Last Edit: June 20, 2008, 03:23:36 AM by UndCon »



Offline tillydevine

  • *
  • Posts: 22
  • Karma: +0/-1
    • View Profile
Reply #8 on: June 19, 2008, 08:45:05 PM


This is what I have done before. It's inside the human body (based on Fantastic Voyage film) and the bloodcells and person are a replaced .png target. Still, I can only have the one pic and not different ones at once.

It's kind of a weird game concept. The illusion is awesome and Johny's code is flawless.



Offline kalbster

  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Reply #9 on: September 21, 2008, 10:00:22 PM
Some code to help.
Code: [Select]
Texture[] TextureArray = new Texture[10];

        private void LoadTexture()
        {
            //MessageBox.Show("LoadTexture");
           
            try
            {
                int currentrow = 1;
                for (int i = 0; i <= numTargets; i++)
                {
                    texture = TextureLoader.FromFile(device, System.Windows.Forms.Application.StartupPath + "\\images\\" + currentrow.ToString() + ".jpg");
                    TextureArray[i] = texture;
                    currentrow++;
                }

           
            }
            catch
            {
                // We must be running from within Visual Studio. Relocate the
                // current directory and try again.
                System.IO.Directory.SetCurrentDirectory(
                   System.Windows.Forms.Application.StartupPath + @"\..\..\");

                texture = TextureLoader.FromFile(device, textureFilename);
            }

            device.SamplerState[0].MinFilter = TextureFilter.Linear;
            device.SamplerState[0].MagFilter = TextureFilter.Linear;
        }


            if (showTargets)//draw targets
            {

.
.
.            for (int i = 0; i < numTargets; i++)
                {
                   
     
                    device.SetTexture(0, TextureArray[i]);
                    device.Transform.World = Matrix.Scaling(targetSizes[i]);
                    device.Transform.World *= Matrix.Translation(targetPositions[i]);
                    device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                    device.SetTexture(0, null);
                }



}