Jump to content
  • Advertisement
Sign in to follow this  
Say

load an x file but without using it

This topic is 4769 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i would to load some .x mesh file in m game but i want use them when i need. What is the way?

Share this post


Link to post
Share on other sites
Advertisement
While rendering a mesh obviously requires that the mesh data is loaded, rendering and loading still are separate steps. So yes, load the mesh when you start your app/level/section/whatever and render it afterwards when needed.

Share this post


Link to post
Share on other sites
Hi there, just to add to the answers :)
I would like to mention that normally you would have an Init() method/function and normally you would only instantiate the objects you want to use when you want to use them.

so

[source lang = c++]
//the following method/s only gets called once. Instantiating the entity/body.
void Init()
{
// initialize the objects... maybe have a small list of related entities/bodies.
}

//the following method/s gets called each frame
void Update()
{
// update your objects, like their positions textures or whatever
}

void Render()
{
// render your objects
}



Sorry if this seems a little condescending. It was not meant to. Just as a help towards other people that might want some more information on how a simple structure would work.

Share this post


Link to post
Share on other sites
Yes but if i call this fuction
mesh = Mesh.FromFile("pathxfile.x", MeshFlags.SystemMemory, device, out materials);

does it just to load the mesh or prepare it do rendering?

Share this post


Link to post
Share on other sites
Hi there Say,

[Mesh.FromFile()]
"Loads a mesh from a .x file."
This means that it only loads the specified file. It's kinda like giving a variable a value in a very loose sense. What you do with the value is totally up to you, or when you want to use this.

Share this post


Link to post
Share on other sites
Quote:
Original post by Say
Yes but if i call this fuction
mesh = Mesh.FromFile("pathxfile.x", MeshFlags.SystemMemory, device, out materials);

does it just to load the mesh or prepare it do rendering?

That fragment will *only* load the data into memory, technically by virtue of being loaded it is also prepared for rendering as well.

It's not until you use DrawSubset() (or the MDX equivalent) that it'll appear on your screen.

There are lots of tools, including a couple I've developed, that use D3DX to load data in manipulate either using custom algorithms or those exposed via D3DX and then save it back to the file. Never is it actually displayed on the screen.

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!