Page 4 of 4 FirstFirst ... 234
Results 31 to 34 of 34
  1. #31
    Join Date
    Jan 2004
    Location
    Kemptville, Ontario
    Posts
    6,242
    Nothing to report. Been watching the XNA videos and I am in the process of reorganizing my code. I knew I would have to do this and now is the time.
    I have figured out what the internet is. You know what they say about an infinite number of monkeys hitting keys at random on an infinite number of typewriters for an infinite amount of time? Well the internet is like that. There is some big cosmic alien running that experiment here in order to find the answer to some big question or to create the greatest piece of literature known to the universe. From what I have seen so far I am sorry to say they are going to be greatly disappointed.

  2. #32
    Join Date
    Jan 2004
    Location
    Kemptville, Ontario
    Posts
    6,242
    Curious about something and I have looked around.

    I have the following function that generates a random Vector3. I use it for scaling but it can be used for other things.
    Code:
        public Vector3 RandomVector3(float MinX, float MaxX, float MinY, float MaxY, float MinZ, float MaxZ)
        {
            float X = Random.Range(MinX, MaxX);
            float Y = Random.Range(MinY, MaxY);
            float Z = Random.Range(MinZ, MaxZ);
    
            return new Vector3(X, Y, Z);
        }
    and I call like
    Code:
    transform.localScale = RandomVector3(1f, 5f, 3f, 5f, 2f, 6f);
    Very simple stuff. The question is though I would like float MinY, float MaxY, float MinZ, float MaxZ to be optional and if not there then default to float MinX, float MaxX. I would use this to scale evenly on all axis.

    I have been reading up and haven't seen anything clear on this. I haven't got to it in the XNA so if there is a video just point to it.
    I have figured out what the internet is. You know what they say about an infinite number of monkeys hitting keys at random on an infinite number of typewriters for an infinite amount of time? Well the internet is like that. There is some big cosmic alien running that experiment here in order to find the answer to some big question or to create the greatest piece of literature known to the universe. From what I have seen so far I am sorry to say they are going to be greatly disappointed.

  3. #33
    Join Date
    Dec 2002
    Location
    Virginia Beach, VA
    Posts
    861
    Hey Ben give some thought to just passing in two Vector3's into your RandomVector3() method. One to hold the Min values and the 2nd to hold the Max values. Cheers mate.

  4. #34
    Join Date
    Jan 2004
    Location
    Kemptville, Ontario
    Posts
    6,242
    Thanks that didn't even occur to me. I think it is cleaner. Now I can do just this.
    Code:
            transform.localScale = RandomVector3(new Vector3(1, 2, 4), new Vector3(5, 6, 7));
            transform.Rotate(RandomVector3(new Vector3(0, 90, 180), new Vector3(90, 180, 270)), Space.Self);
    to call this
    Code:
        public Vector3 RandomVector3(Vector3 Min, Vector3 Max)
        {
            float X = Random.Range(Min.x, Max.x);
            float Y = Random.Range(Min.y, Max.y);
            float Z = Random.Range(Min.z, Max.z);
    
            return new Vector3(X, Y, Z);
        }
    To get me random positions and scales.

    Another baby step on the long road.
    Last edited by benmcl; 02-06-2010 at 04:44 AM.
    I have figured out what the internet is. You know what they say about an infinite number of monkeys hitting keys at random on an infinite number of typewriters for an infinite amount of time? Well the internet is like that. There is some big cosmic alien running that experiment here in order to find the answer to some big question or to create the greatest piece of literature known to the universe. From what I have seen so far I am sorry to say they are going to be greatly disappointed.

Page 4 of 4 FirstFirst ... 234

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •