Sponsors of Wiimoteproject.com
IRGreat.com
Wiimote Project » Forum » Wiimote Projects » Wiimote Desktop VR/Head Tracking » Several Different Targets.
Pages: [1]
  Print  
Author Topic: Several Different Targets.  (Read 2010 times)
0 Members and 1 Guest are viewing this topic.
*
Karma: +0/-0
Posts: 9
Offline Offline
View Profile
« on: June 16, 2008, 06: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?
Logged
Support Admin
*
Karma: +11/-2
Posts: 563
Offline Offline
View Profile
« Reply #1 on: June 16, 2008, 07: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...
Logged

*
Karma: +0/-1
Posts: 22
Offline Offline
View Profile Email
« Reply #2 on: June 16, 2008, 10: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?
Logged
Support Admin
*
Karma: +11/-2
Posts: 563
Offline Offline
View Profile
« Reply #3 on: June 17, 2008, 04: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
Logged

*
Karma: +0/-0
Posts: 9
Offline Offline
View Profile
« Reply #4 on: June 17, 2008, 06: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.
Logged
Support Admin
*
Karma: +11/-2
Posts: 563
Offline Offline
View Profile
« Reply #5 on: June 17, 2008, 09: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...
Logged

*
Karma: +0/-1
Posts: 22
Offline Offline
View Profile Email
« Reply #6 on: June 17, 2008, 09: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!)
Logged
Support Admin
*
Karma: +11/-2
Posts: 563
Offline Offline
View Profile
« Reply #7 on: June 19, 2008, 02: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, 04:23:36 AM by UndCon » Logged

*
Karma: +0/-1
Posts: 22
Offline Offline
View Profile Email
« Reply #8 on: June 19, 2008, 09: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.
Logged
*
Karma: +0/-0
Posts: 2
Offline Offline
View Profile Email
« Reply #9 on: September 21, 2008, 11:00:22 PM »

Some code to help.
Code:
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);
                }



}

Logged
Pages: [1]
  Print  
 
Jump to:  

TinyPortal v.1.0.6 beta 2 © Bloc
Clicky Web Analytics