Or is there a different way in place for inherited entities to update and i'm just missing it?
| Welcome | |
|---|---|
| Welcome to xnaquickstart
You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today! |
|
Moderators: Coordinators, Developers
lordikon wrote:Yes, but the rendering would ideally still be done through the render component.
Think of it in an Object Oriented way. The sky could be there, but maybe you find a reason not to render it. If you have a SkyDome component then the sky would exist, but if you don't give it a RenderComponent then it wouldn't render.
This is similar to how you make cameras. Any object can become a camera just by giving it that component.
A skydome is really just a model, like any other, it just uses a different shader. I'm not sure how to change the shader as I haven't learned how the graphics system works. But if you figure that out, then all the skydome component would need to do is rotate itself.
On a side note: I see no way to be selective about which meshes of an imported model you wish to load using StaticModel. Am I missing it or is this functionality just not in there yet?
Why would you only want to load specific meshes in a model? Wouldn't you just separate an model into separate models when you export it?
- Terrain, is an entity, with a render and physics component.
public RenderComponent(BaseEntity parent, string modelPath, string materialPath)
: base(parent)
{
LoadModel(modelPath);
LoadMaterial(materialPath);
}
public RenderComponent(BaseEntity parent, StaticModel model, string materialPath)
: base(parent)
{
LoadModel(modelPath);
LoadMaterial(materialPath);
}
// create an entity
BaseEntity newEntity = new BaseEntity(this.game, position, Matrix.Identity, 2.0f);
// load the model and material path (or material object?)
StaticModel myCubeModel = this.Game.ModelLoader.LoadStaticModel("Models/unit_cube", myMaterial);
// create a new render component and pass it the entity
RenderComponent newRenderComponent = new RenderComponent(newEntity, myCubeModel);
// create a physics component and pass it the entity, physicsscene, shape and scale
PhysicsComponent newPhysComponent = new PhysicsComponent(newEntity, this.game.SceneManager.PhysicsScene, ShapeType.Box, 10.0f);
// add the actor
this.game.SceneManager.AddActor(newPhysComponent.PhysicsActor);
// add the entity
this.game.SceneManager.AddEntity(newEntity); // Add the entity to the scene manager
// create an entity
BaseEntity newEntity = new BaseEntity(this.game, position, Matrix.Identity, 2.0f);
// create a terrain model. Terrain inherits from StaticModel
Terrain newTerrain = new Terrain(this.game, LOD.High);
newTerrain.ElevationStrength = 25;
newTerrain.InitTerrainTextures("./Textures/grass", "./Textures/rock", "./Textures/sand");
if (this.game.Settings.GraphicsLevel >= GraphicsLevel.High)
{
newTerrain.InitTerrainNormalsTextures("./Textures/grassNormal", "./Textures/rockNormal", "./Textures/sandNormal");
}
newTerrain.Initialize("./Images/Heightmaps/gcanyon", "./Images/Terrainmaps/gcanyonTerrain", 4, 25, this.game.SceneManager.PhysicsScene);
// create a new render component and pass it the entity, model
RenderComponent newRenderComponent = new RenderComponent(newEntity, newTerrain);
// create a physics component for the terrain
PhysicsComponent terrainPhysicsComp = new PhysicsComponent(newTerrain, this.game.SceneManager.PhysicsScene,
newTerrain.heightData, newTerrain.ScaleFactor);
newTerrain.SetupLODS();
// add the actor
this.game.SceneManager.AddActor(terrainPhysicsComp.PhysicsActor);
// add the terrain ENTITY (not model) to the scene
this.game.SceneManager.AddEntity(newEntity);
BaseEntity myEntity = new BaseEntity();
Material myMaterial = game.Content.Load<Material>("Material/grass");
StaticModel myCube = game.ModelLoader.LoadStaticModel(modelPath, myMaterial);
RenderComponent myRenderComponent = new RenderComponent(myEntity, myCube);
PhysicsComponent myPhysicsComponent = new PhysicsComponent(myEntity);
SceneMgr.addActor(myPhysicsComponent.PhysicsActor);
SceneMgr.addEntity(myEntity);
BaseEntity myEntity = new BaseEntity();
Material myMaterial = game.Content.Load<Material>("Material/grass");
Terrain myTerrain = new Terrain(myMaterial); // terrain extends staticmodel
RenderComponent myRenderComponent = new RenderComponent(myEntity, myTerrain);
PhysicsComponent myPhysicsComponent = new PhysicsComponent(myEntity);
SceneMgr.addActor(myPhysicsComponent.PhysicsActor);
SceneMgr.addEntity(myEntity);
Users browsing this forum: No registered users and 0 guests