XNA Creators Club Online
Page 1 of 1 (6 items)
Sort Posts: Previous Next

[Help] Few questions.

Last post 11/15/2009 12:10 AM by Daniel Hanson. 5 replies.
  • 11/14/2009 3:14 AM

    [Help] Few questions.

    Hi I have a few questions.

    How would I load more than one mesh at startup. Kinda like I have a few mesh's in a folder. Can I just load everything in that folder?

    Im wondering how would I go about placing one of them mesh's where the mouse clicked.

    And can I apply a texture to a mesh by clicking it?

    Thanks,
               Anthony
  • 11/14/2009 9:12 AM In reply to

    Re: [Help] Few questions.

    Yes, you can load many meshes at startup.  Simply place what you want to load into the content folder and use multiple lines of  Content.Load<Mode>("  file name ");

    To place a mesh where the mouse is clicked is a little tricky, because the mesh exists in 3d space and the mouse click in 2d space.    Go over to the education section and look for the "Picking" example.  It will show you how to catch your mouse clicks and translate mouse coordinates into your 3d world space.  Once you get the X and Y coordinates, you'll need to determine how far into the scene you want to place the model to create your "Z" value.  Then, just use those XYZ values as the .Translation vector of your model's world matrix.

    Yes, you can apply a texture to a mesh by clicking it.  You will need to detect the mouse click, have the texture loaded & ready, then either send it to your own custom shader via an effectparameter or through the built in BasicEffect.  You'll need to check the XNA helpfile & read up on BasicEffect's use of textures a bit as I don't know its syntax off the top of my head.

    Byron
    ..shaders make you feel... powerful, or very very stupid.
    http://drjbn.spaces.live.com/
  • 11/14/2009 3:44 PM In reply to

    Re: [Help] Few questions.

    Hmm I will look into the other answers Thanks, but I don't think you got what I meant on the first one. Like if I wanted to drop a new mesh then restart is it possible to load that one too without adding any code for that mesh?
  • 11/14/2009 6:52 PM In reply to

    Re: [Help] Few questions.

    'fraid I may still not quite know what you're asking about the second mesh.

    Like if I wanted to drop a new mesh then restart is it possible to load that one too without adding any code for that mesh?

    I'm a bit confused on "drop a new mesh" and "restart".    Are you asking if you have one mesh loaded into a Model variable, replace that mesh with another?  If so, yes, but it would require code.

    Best,
    Byron
    ..shaders make you feel... powerful, or very very stupid.
    http://drjbn.spaces.live.com/
  • 11/14/2009 11:15 PM In reply to

    Re: [Help] Few questions.

    Lets see is there a way to load every mesh in a folder even if one was added or removed?
  • 11/15/2009 12:10 AM In reply to

    Re: [Help] Few questions.

    You should be able to call Directory.GetFiles() on your Content directory and then load each file you find there. Use Path.Join(StorageContainer.TitleLocation, "Content") to access your Content directory.
    Previously known as "Rainault".
    Twitter - me, Jade Vault Games
    Announcing ASCII Quest, a Roguelike under development for Xbox LIVE Indie Games
Page 1 of 1 (6 items) Previous Next