Jump to content
  • Advertisement

ProjectOlle

Member
  • Content Count

    29
  • Joined

  • Last visited

Posts posted by ProjectOlle


  1. Hey guys!

    I got a problem with movement of my player in a RPG game, using the mouse to click to move, like any normal RTS game out there.

    So far I got this as the init for the player:
    playerPosition = Matrix.CreateTranslation(new Vector3(0, 0, 0));
    velocity = Matrix.Identity;
    acceleration = Vector3.Zero;
    target = Vector3.Zero;


    and this in the update function:

    if (newMouseState.LeftButton == ButtonState.Released && oldMouseState.LeftButton == ButtonState.Pressed)
    {
    target = new Vector3((mouse.X-mouseOriginalPosition.X), 0, (mouse.Y-mouseOriginalPosition.Y));

    }

    acceleration = playerPosition.Translation;
    acceleration -= target;

    if (acceleration.Length() >= 0.05f)
    {
    acceleration.Normalize();
    acceleration *= 0.05f;
    }
    velocity *= Matrix.CreateTranslation(acceleration);
    playerPosition *= velocity;


    The problem is that the player just starts moving in the direction of where I click but it never stops, and it wont change direction :S ... If I set the position of the player to be that of the mouse directly it functions fine (by teleporting the player so to speak)

    Any ideas of what Im doing wrong here? :S

  2. Okay I got it working :D turns out that http://blogs.msdn.co...studio-4-0.aspx is pretty awesome and pretty easy to use :D

    Now I have a different problem.

    Im working with the Kinect, so what I am doing right now is that I have a XAML project which I use to run my Kinect Game from a XNA 4.0 project. In the game I have an avatar I would like to control with the Kinect.

    In order to make the kinect function I needed to use another XAML project which I include in the first one, and display it as an additional window. So I got two windows running, one with my game and one with my Kinect, and that works fine.. Now all the tracking is done from the XAML project handling the Kinect, how on earth do I set my avatars values from the XAML project which does not have an instance in my XNA project? :o

    All is run from the original XAML project that creates an instance of my Game and run from there, and the App file turns on the Kinect project, so no where relevant does these two projects ever meet to create an instance of one in the other.. Any ideas?

    Can I export the values in an alternative file and then read it in the Game project or what the deuce to do? :o

  3. Uh and btw, yes its 4.0 I'm working with :) The solution seems useable enough, however It doesnst show how to add to the content and the content pipeline which I've done I my game :(

    Gonna give it a try but if anyone know of some way to implement an entire XNA project more or less directly I would send them a dancing monkey filled with joy for their amusement :D

  4. Hey Guys!

    I need to use XNA together with XAML, and it seems quite difficult.

    I've been following this tutorial http://petosky.net/node/13 and it seems fine, except that apparently between this was written and I've read it this step fails me.

    IntPtr handle = RenderPanel.Handle; new Thread(new ThreadStart(() => { game = new EditorGame(handle); game.Run(); })).Start();

    Apparently I'm missing a reference or the syntax has been changed from RenderPanel.Handle, cuz that isnt there anymore :o .. Anyone know an alternative, or where this handle can be accessed from now a days?


  5. Hey guys,

    I need to read an XML file in XNA 4.0.

    What Im doing is I am trying to make a Kinect game in XNA. As drivers I use these http://www.studentgu...y-tracking.aspx Which are pretty simple, and very useful.. However, in order to track a skeleton you need the method Nuitracker (Documentation new Nuitracker(string configuration)), this string configuration is meant to be a XML file. I got the file and all, and first I tried just adding it to the content and loading it by saying new NuiTracker("SampleConfig.XML") That did not work, It complained that it was the wrong format, so in the XML file I added <XnaContent>. Then it complained about assets, So I found a post that said i needed to include this in the file

    <Asset Type="Namespace.className"> Then I added that, and it gives me the Error: "There was an error while deserializing intermediate XML. Cannot find type "KinectTest.Game1"

    My namespace should be KinectTest, and the class name is the default one when creating a project Game1.

    Im not even sure what this error really means, please any help here? I need this badly and urgent for a project.!!

    Thanks in advance guys!

    Here is the full test code (Its VEEEERY basic ;))


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Audio;
    using Microsoft.Xna.Framework.Content;
    using Microsoft.Xna.Framework.GamerServices;
    using Microsoft.Xna.Framework.Graphics;
    using Microsoft.Xna.Framework.Input;
    using Microsoft.Xna.Framework.Media;
    using Nui.Vision;

    namespace KinectTest
    {
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;

    NuiUserTracker _skeleton;
    Vector3 cameraPosition;

    Matrix ViewMatrix;
    Matrix ProjectionMatrix;
    float aspectRatio;
    Model test;

    float headX;

    public Game1()
    {
    graphics = new GraphicsDeviceManager(this);
    Content.RootDirectory = "Content";

    }

    /// <summary>
    /// Allows the game to perform any initialization it needs to before starting to run.
    /// This is where it can query for any required services and load any non-graphic
    /// related content. Calling base.Initialize will enumerate through any components
    /// and initialize them as well.
    /// </summary>
    protected override void Initialize()
    {

    // TODO: Add your initialization logic here
    cameraPosition = new Vector3(250.0f, 100.0f, 0.0f);

    aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;

    ViewMatrix = Matrix.CreateLookAt(cameraPosition, new Vector3(0, 0, 0), Vector3.Up);
    ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(40.0f), aspectRatio, 10.0f, 10000.0f);

    base.Initialize();

    }

    /// <summary>
    /// LoadContent will be called once per game and is the place to load
    /// all of your content.
    /// </summary>
    protected override void LoadContent()
    {
    // Create a new SpriteBatch, which can be used to draw textures.
    spriteBatch = new SpriteBatch(GraphicsDevice);


    test = Content.Load<Model>("testSquare");

    // TODO: use this.Content to load your game content here
    }

    /// <summary>
    /// UnloadContent will be called once per game and is the place to unload
    /// all content.
    /// </summary>
    protected override void UnloadContent()
    {
    // TODO: Unload any non ContentManager content here
    }

    /// <summary>
    /// Allows the game to run logic such as updating the world,
    /// checking for collisions, gathering input, and playing audio.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Update(GameTime gameTime)
    {
    // Allows the game to exit
    if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
    this.Exit();

    _skeleton = new NuiUserTracker("SamplesConfig.xml");
    _skeleton.UsersUpdated += new NuiUserTracker.UserListUpdatedHandler(Skeleton_UsersUpdated);
    // TODO: Add your update logic here


    base.Update(gameTime);
    }

    /// <summary>
    /// This is called when the game should draw itself.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Draw(GameTime gameTime)
    {
    GraphicsDevice.Clear(Color.CornflowerBlue);

    // TODO: Add your drawing code here
    foreach (ModelMesh mesh in test.Meshes)
    {
    foreach (BasicEffect effect in mesh.Effects)
    {
    effect.World = Matrix.Identity * Matrix.CreateTranslation(new Vector3(0, headX, 0));
    effect.EnableDefaultLighting();
    effect.View = ViewMatrix;
    effect.Projection = ProjectionMatrix;
    }
    mesh.Draw();
    }

    base.Draw(gameTime);
    }
    public void Skeleton_UsersUpdated(object sender, NuiUserListEventArgs e)
    {

    foreach (var user in e.Users)
    {

    #region Get body parts coordinates

    float headX = user.Head.X;
    float headY = user.Head.Y;
    float headZ = user.Head.Z;

    float neckX = user.Neck.X;
    float neckY = user.Neck.Y;

    float leftShoulderX = user.LeftShoulder.X;
    float leftShoulderY = user.LeftShoulder.Y;

    float leftElbowX = user.LeftElbow.X;
    float leftElbowY = user.LeftElbow.Y;

    float leftHandX = user.LeftHand.X;
    float leftHandY = user.LeftHand.Y;

    float rightSholuderX = user.RightShoulder.X;
    float rightShoulderY = user.RightShoulder.Y;

    float rightElbowX = user.RightElbow.X;
    float rightElbowY = user.RightElbow.Y;

    float rightHandX = user.RightHand.X;
    float rightHandY = user.RightHand.Y;

    float waistX = user.Torso.X;
    float waistY = user.Torso.Y;

    float leftHipX = user.LeftHip.X;
    float leftHipY = user.LeftHip.Y;

    float leftKneeX = user.LeftKnee.X;
    float leftKneeY = user.LeftKnee.Y;

    float leftFootX = user.LeftFoot.X;
    float leftFootY = user.LeftFoot.Y;

    float rightHipX = user.RightHip.X;
    float rightHipY = user.RightHip.Y;

    float rightKneeX = user.RightKnee.X;
    float rightKneeY = user.RightKnee.Y;

    float rightFootX = user.RightFoot.X;
    float rightFootY = user.RightFoot.Y;

    #endregion


    }
    }
    }
    }




    and the XML file


    <XnaContent>
    <Asset Type="KinectTest.Game1">
    <OpenNI>
    <Licenses>
    <!-- Add licenses here
    <License vendor="vendor" key="key"/>
    -->
    </Licenses>
    <Log writeToConsole="false" writeToFile="false">
    <!-- 0 - Verbose, 1 - Info, 2 - Warning, 3 - Error (default) -->
    <LogLevel value="3"/>
    <Masks>
    <Mask name="ALL" on="true"/>
    </Masks>
    <Dumps>
    </Dumps>
    </Log>
    <ProductionNodes>
    <Node type="Depth" name="Depth1">
    <Configuration>
    <Mirror on="true"/>
    </Configuration>
    </Node>
    <Node type="Image" name="Image1" stopOnError="false">
    <Configuration>
    <Mirror on="true"/>
    </Configuration>
    </Node>
    <!--
    <Node type="Audio" name="Audio1"/>
    -->
    </ProductionNodes>
    </OpenNI>
    </Asset>
    </XnaContent>

  6. Hey guys!

    I have yet another small and hopefully easy to fix problem! :D

    I have different instances of the same class in a 3D game, these instances are three different types of towers, each tower got different textures depending on how upgraded and damaged they are.

    I figured out how to swap the texture from one to another with the effect.Texture BUT! when I have say two different towers of same type (so they use same model) and I change the texture of one of them at runtime, the texture for both of them will change :S .. Any way to avoid this? .. I really want to avoid using different models just to change the texture of a single tower :o

  7. FIXED!!

    Boy do I feel stupid now :P

    here is the solution:

    spriteBatch.Begin();
    Vector2 FontOrigin = spriteFont.MeasureString(text) / 2;
    spriteBatch.DrawString(spriteFont, yPos.ToString(), FontPos, Color.White, 0, FontOrigin, 1, SpriteEffects.None, 0.5f);

    spriteBatch.End();


    yPos is an int


  8. Well, if you really want just numbers and not other characters, that you could make 10 sprites (from 0-9) and draw those numbers.


    True but I want numbers from 0-1000 :P so thats a lot of images just for that :P

    I figured out the SpriteBatch.DrawString() method that almost solves my problem, now is there anyway to convert a int, float, double, to a string?? I tried casting to a char, and then a string but that wont work :(

  9. Hey guys!

    I want to have my 3D game, and in that game I want a simple HUD that displays things like your health and ammo etc. But I have no idea on how actually to "print" numbers to the screen ??

    I know all about using sprites and stuff like that, but it seems stupid to have a 100 sprites to have numbers from 1-100 :P

    I looked into some liberaries for HUDs but they are a little clumsy imo, and they tend to be very specific.. Anyone know of some methods in XNA that allow me to display variables on the screen or anything like that ? :)


  10. The problem is in the if statement.

    If i do:

    if (tileMap is WallTile) // <-- here it gets an error if there is nothing in this index.
    {
    do something
    }

    Also, is there anyway to remove a item and keep the list as is? I would like to have each index have specific values, [0] for ground, [1]&[2] for walls, [3]+ for objects so if i remove a wall i don't want the object in [3] moved to index [2].


    Hmm you could make a bool in your tileMap class that is true if it is a WallTile or another sensible work around, and check if tileMap.YourBool == true Then that should take care of that.

    If you has made it as a list I believe it will always shift the elements if you remove one, you should be able to remove an element from an Array though without messing with the rest of the order, but keep in mind you then would have an empty element in your Array (Not sure it if works like that but its worth trying using arrays instead ;) )


  11. Hey i have a list that contains data on fixed positions. Example [0] is ground, [1] to [2] are walls, [3] < are objects.

    Now i want to check if [1] or [2] exist to delete them when they do. A count would not work as the list could have [0] [3] and [4] set and then removing [1] would give me a exception.

    To be a little more clear what i want exactly is something like this:


    for (i = 1; i < totalLayers; i++)
    {
    if (tileMap.MapTiles Has something in it)
    {
    tileMap.MapTiles.RemoveAt(i);
    }
    }



    You could do two things either do


    for (i = 1; i < totalLayers; i++)
    {
    if (tileMap.MapTiles Has something in it)
    {
    tileMap.MapTiles.RemoveAt(i);
    break;
    }
    }


    or

    foreach(TileMap tileMap in whateverTheListIsCalled){
    if(tileMap Has Something in it){
    tileMap.Remove();
    break;
    }
    }


    The trick is to break the loop or you will go out of bounds of the index count, as if you got seven elements, you go through the entire list and the third element you remove. Now the fourth element is the third etc. so the seventh is now the sixth, so when you come to the seventh element that ofc. does not exist anymore you get an error.

    Hope it helps

  12. Hey Guys!

    Im making a tower-defense like game where I ofc. have towers that shoots at the enemies.

    I have no problem hitting my enemies, but when it comes to rotation the arrows so the tip is whats hits the enemies I have nothing but trouble.

    For hitting the enemies (this works) I use:

    boundingSphere = new BoundingSphere(position.Translation, 5);
    position *= velocity;

    acceleration = position.Translation;
    acceleration -= enemy.position.Translation;
    acceleration *= -0.5f;

    velocity *= Matrix.CreateTranslation(acceleration);

    Vector3 newVelocity = velocity.Translation;
    newVelocity.Normalize();
    newVelocity *= 2;
    velocity = Matrix.CreateTranslation(newVelocity);


    For rotating the arrow so it should hit correctly I use the formula: v1 DOT v2 = |v1| |v2| cosØ and as I understand it Acos in XNA returns in radians. Whenever a tower fires an arrow I makes sure that the velocity is set to shoot up in to the air to begin with, so the arrow is shot straight up and should move and rotate toward the enemy. Here is my rotation code:


    v1 = velocity.Translation;
    v2 = enemy.position.Translation;

    Vector2 xV1 = new Vector2(v1.Y, v1.Z);
    Vector2 xV2 = new Vector2(v2.Y, v2.Z);
    Vector2 yV1 = new Vector2(v1.X, v1.Z);
    Vector2 yV2 = new Vector2(v2.X, v2.Z);
    Vector2 zV1 = new Vector2(v1.X, v1.Y);
    Vector2 zV2 = new Vector2(v2.X, v2.Y);

    xV1.Normalize();
    xV2.Normalize();
    yV1.Normalize();
    yV2.Normalize();
    zV1.Normalize();
    zV2.Normalize();

    xRotation = (float)Math.Acos(Vector2.Dot(xV1, xV2));
    yRotation = (float)Math.Acos(Vector2.Dot(yV1, yV2));
    zRotation = (float)Math.Acos(Vector2.Dot(zV1, zV2));

    rotationMatrix = Matrix.CreateRotationX(xRotation) * Matrix.CreateRotationY(yRotation) * Matrix.CreateRotationZ(zRotation);



    Yes I choose to move all the calculations from 3D space to 2D space, I tried to rotate using an arbitary axis doing :


    arbitaryAxis = Vector3.Normalize(Vector3.Cross(v1, v2));
    rotationMatrix = Matrix.CreateFromAxisAngle(arbitaryAxis, (float)Math.Acos(Vector3.Dot(v1, v2)));


    But that works like poop as well :(
    Anyways, the rotations suck! :o It looks like poop, and it doesnt rotate correctly, any advise ? :)

    Thx guys!

  13. Hey guys, Im making a boid flocking algo, and it is pretty much functional

    You can see the basic of the flocking here (:


    if (flock.proximity < boidDistance && boidDistance < flock.vision)
    {
    flock.acceleration = flock.position.Translation;
    flock.acceleration -= flock[j].position.Translation;
    flock.acceleration *= (boidDistance / -0.1f);
    //If the acceleration is greater than the maxAcceleration allowed we normalize the vector in order to control the speed
    if (flock.acceleration.Length() >= flock.maxAcceleration)
    {
    flock.acceleration.Normalize();
    flock.acceleration *= flock.maxAcceleration;
    }
    //Adding the acceleration to the velocity.. well actually a Hyrda!, we multiply it!
    flock.velocity *= Matrix.CreateTranslation(flock.acceleration);
    }


    and then I want them to attack some different targets, for directing them in the right direction I say


    else if (!boundingSphere.Intersects(player.buildingList[1].boundingSphere))
    {
    behavior = Behavior.Flock;
    vision = 50;
    proximity = 15;
    maxAcceleration = 0.008f;
    acceleration = position.Translation;
    acceleration -= Target;
    acceleration *= (-0.0005f);
    if (acceleration.Length() >= 0.003f)
    {
    acceleration.Normalize();
    acceleration *= 0.003f;
    }
    velocity *= Matrix.CreateTranslation(acceleration);
    }


    Which is basically the same as before.. Now my real problem is when they reach their target their velocity is pretty high and they will pass fast through it and juggle back and forth like idiots :P..

    What I want is them to go to the buildings boundingsphere/box and do the stupid-bee thing ^^ you know hit its head against the window repeately :) .. any suggestions? Its really bugging me >_<

  14. Hey guys.. I sure post a lot in these times ;)

    Here I am again!

    Im making a tower-defense like game, and I got boids moving around, and a player that can put towers up that shot and kill the boids.. Only problem is the program sometimes crahses when a boid dies!.. I save all the boids in a common list so I do with the towers (that right now is called Obstecals) and the shots per tower is also listed...

    You can see the code here:


    for (int i = 0; i < positionList.Count; i++)
    {
    for (int oi = 0; oi < obstecalList.Count; oi++)
    {
    for (int x = 0; x < obstecalList[oi].shotList.Count; x++)
    {
    if (boundingSphereList.Intersects(obstecalList[oi].shotList[x].boundingSphere))
    {
    killBoid(i);
    continue;
    }
    }
    continue;
    }
    continue;
    }

    for(int i = 0; i < positionList.Count; i++){
    if (positionList.Translation.X <= -1000)
    {
    killBoid(i);
    continue;
    }
    }

    for (int i = 0; i < positionList.Count; i++)
    {
    if (player.boundingSphere.Intersects(boundingSphereList))
    {
    killBoid(i);
    continue;
    }

    }


    A boid will die when it is shot, reaches the end of the map, or collides with the player. The killBoid function deletes the boid from the positionList, velocityList and boundingSphereList and can be seen here.

    public void killBoid(int i)
    {
    positionList.Remove(positionList);
    velocityList.Remove(velocityList);
    boundingSphereList.Remove(boundingSphereList);
    }


    btw. I know that right now this code is somewhat messy, but im far from the cleaning up stage ;) It will come!

    The problem is apparently that when a boid gets killed the lists becomes shorter than they were before, and sometimes it will make a for-loop go out of bounds.. BUT! I don't understand why this happens, as I put a continue in to prevent this :S.. Shouldnt the continue make the program exit the loop as soon as it hits that ???? ...


  15. No worries. Its been a while since I used it, and I don't have it here anymore, but if I remember rightly the one thats called a tutorial has both the code and some step by step instructions on how to modify the first to manipulate the bones directly. The end result was that the dude's head looked to the side when the user presses a certain key. Its a bit tricky to get the animation sample itself to work in your own projects but its not too much hassle.


    Im worrying :P

    Still can't manage to have my own models to fit with the code :S.. Checked tons of turtorials of how to make skinned models etc. And all pretty much say the same, try it out.. and no cigar.. Keeps getting the same Error of "No skinningData tag" which means in my eyes the model either lacks animations, skeleton, bindpose / inverse binpose, or bone index.. which the models should have..

    I've failed in finding other usefull turtorials for this, and those vidoes Ive found around the web where people move individual bones, well they dont feel like explaining what they did >_< ... bah.. I really needs this bad for a project im doing. Any help would be more than welcome!

  16. Hey guys!

    I'm making a tower-defense like game and need some cooldown on the shots from the towers so they wont just spam out shots in more or less a straight line. Im still pretty new to XNA so could anyone tell me how I compare time ? ..

    I would like to do something like:
    Shoot(); // every 5 sec

    Thx in advance! :D

  17. Hey guys!

    I have previously loaded several texture in a 2D game for XNA 4.0 and I have also loaded several models in 3D.. But now I ran into a weird problem I really dont get.

    I have a boid, player and an obstecal class so far. The boid and player class share the same model, and obstecal has a different one. But when I load in the models it will only load the model for boid and player, if I change the model of the obstecal to load the same in Content.Load<Model>("") then it will load the model, meaning I can only have the same model in all instances :S which as I said.. is well.. weird :S ???

    Any ideas for what could cause this??

    I bring you the main code here:


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Audio;
    using Microsoft.Xna.Framework.Content;
    using Microsoft.Xna.Framework.GamerServices;
    using Microsoft.Xna.Framework.Graphics;
    using Microsoft.Xna.Framework.Input;
    using Microsoft.Xna.Framework.Media;

    namespace XNA3DTest
    {
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
    GraphicsDeviceManager graphics;

    Vector3 cameraPosition;
    Matrix ViewMatrix;
    Matrix Projection;

    Vector3 obstecalPosition = Vector3.Zero;

    Player player;
    Boid boid;
    Obstecal obstecal;

    float aspectRatio;

    Model model;
    Model obstecalModel;

    public Game1()
    {
    graphics = new GraphicsDeviceManager(this);
    Content.RootDirectory = "Content";

    }

    /// <summary>
    /// Allows the game to perform any initialization it needs to before starting to run.
    /// This is where it can query for any required services and load any non-graphic
    /// related content. Calling base.Initialize will enumerate through any components
    /// and initialize them as well.
    /// </summary>
    protected override void Initialize()
    {
    // TODO: Add your initialization logic here
    cameraPosition = new Vector3(200.0f, 30.0f, 50.0f);

    aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;

    ViewMatrix = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
    Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(40.0f), aspectRatio, 10.0f, 100000.0f);

    model = Content.Load<Model>("testSquare");
    obstecalModel = Content.Load<Model>("testPolygon");

    boid = new Boid(model);
    player = new Player(model);
    obstecal = new Obstecal(obstecalPosition, obstecalModel);

    base.Initialize();
    }

    /// <summary>
    /// LoadContent will be called once per game and is the place to load
    /// all of your content.
    /// </summary>
    protected override void LoadContent()
    {
    // Create a new SpriteBatch, which can be used to draw textures.
    // TODO: use this.Content to load your game content here
    }

    /// <summary>
    /// UnloadContent will be called once per game and is the place to unload
    /// all content.
    /// </summary>
    protected override void UnloadContent()
    {
    // TODO: Unload any non ContentManager content here
    }

    /// <summary>
    /// Allows the game to run logic such as updating the world,
    /// checking for collisions, gathering input, and playing audio.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Update(GameTime gameTime)
    {
    float moveFactorPerSecond = 400 * (float)gameTime.ElapsedGameTime.TotalMilliseconds / 1000;
    KeyboardState keyboard = Keyboard.GetState();
    // Allows the game to exit
    if (keyboard.IsKeyDown(Keys.Escape))
    this.Exit();

    if (keyboard.IsKeyDown(Keys.Space))
    boid = new Boid(model);
    if (boid.positionList.Count == 0)
    boid = new Boid(model);

    player.update();
    boid.update();

    for (int i = 0; i < boid.positionList.Count; i++)
    {
    boid.avoidPlayer(player, boid, i);
    if (player.boundingSphere.Intersects(boid.boundingSphereList))
    {
    boid.killBoid(i);
    }
    }
    // TODO: Add your update logic here

    base.Update(gameTime);
    }

    /// <summary>
    /// This is called when the game should draw itself.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Draw(GameTime gameTime)
    {
    GraphicsDevice.Clear(Color.CornflowerBlue);

    // TODO: Add your drawing code here
    boid.callDraw(model, ViewMatrix, Projection);
    player.Draw();
    obstecal.Draw();
    base.Draw(gameTime);
    }

    }
    }



    And Ive tried both loading the models in the init function and the loading function.. same thing happens


  18. There is a great example of how to do this on what is now the Microsoft App Hub. Its based on this sample:

    Skinned mesh sample

    and the part about manipulating bones is in this tutorial:

    Skinned mesh extensions tutorial

    Hope that helps.


    This is awesome :D This piece of code will surely help me out a lot thx man! :D

    Only wish there were more documentation in the code on what they did and why :P But thx a million times :D this is exactly what I need

    EDIT: Or am I a complete idiot, but it says it is a tutorial and that there is the complete code sample, which there is.. But is there truely a tutorial as such or just the code? O_o a tutorial of this would really be nice


  19. It's not surprising there's little information about controlling individual bones as, more commonly, animations for skinned meshes are created in a modeling program and imported into applications.

    I'm not familiar with XNA, or what you're importing from Maya. However, I imagine the principles of skinned mesh animation remain the same.

    First - If you're not familiar with the principles of skinned mesh animation, I'd suggest you do a bit of reading on that subject. It appears there is at least one skinned mesh example for XNA available.

    Second - Is your Maya model a skinned mesh, and are you importing skinweights, offset matrices, etc.?

    Third - It appears you're using a default shader (effect). You'll need a vertex shader for skinned mesh animation. It can be done on the CPU but that's a bit more complicated.

    Google words - "skinned mesh animation (programming)," "xna skinned mesh example," "xna mesh animation," etc.

    Thx a mill for your reply

    Yeah there is very little info on the subject >_<

    1. Reading sounds good ;) I never used models like this before or skinned mesh animations, one problem was I missed that term ;) so thx for that ^^

    2. Im importing everything, meshes, bones, skinweighs you name it.

    3. I am using the default shader, Dont really know any other, do you, or anyone else, know of any examples of a vertex shader as you talk about? Im a little lost on what it entails.

    But thx for the help its getting me one step closer to the solution :)
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!