So far so good. I have got scenes easily loading and I have started using the new Digital Rune mathematics libraries to control the scenes main camera (soon to add multiple camera support with the ability to switch).
I now want to add the Digital Rune physics in replace of the default collision system in sunburn. I understand this requires components but I can't find much information on them. How would I tie in a 3rd party physics library to sunburn and gain access to the options in the editor?
I need to be able to provide every physics object in the scene with the correct physics materials and have a global component that can manage the interactions between these objects.
How do I add components to individual scene objects and correctly design the main simulation component?
Finally I seem to be having a strange issue with lightmapping. I'm sure it's just me doing something wrong but this is what my test scene looks like without lightmapping:
And here it is with lightmapping:
I have seen the lightmapping example and the baked lighting is far superior to what I seem to be getting.
Hi Darren,
It's probably a good idea to learn component design with a smaller goal in mind. As an example: first experiment with creating a number of different components that increasingly get more involved.
Components like:
My latest blog post is an excellent place to get started, it covers the component system and provides a number of example components.
To learn more about custom managers (system-level components) make sure to check out SunBurn 1.3.2's Custom Renderer kit. While the rendering is not designed for 2.0 the manager class and the documentation in the kit explains how to create custom managers that plug into SunBurn (both 1.3.2 and 2.0).
From the screen shot it looks like all of the objects are dynamic? If so this is causing the problem, dynamic objects cannot be light mapped.
Let me know if this helps!
Follow me on Twitter – development and personal tweetsAwesome XNA Videos – Lighting, Rendering, and game videos
Arrgghh yes. I kept reading about dynamic objects in the lightmapping lighting page and for some odd reason I came to the conclusion they all needed to be dynamic. That's an easy fix then thanks.
About the components. I read the blog post but I was still confused as to how to associate the components to scene entities and that was why I asked. I'll take your advice to start small but mainly I just need to understand how the components are added to the entities in the first place.
Sorry if it's really obvious. If it is to do with the serialization then that is something that is new to me (I haven't ever really looked into it properly to understand it).
Thanks for the help.
You can add components to entities, scene objects, and lights with the following code:
MyComponent component = new MyComponent();sceneobject.Components.AddWithDependencies(component);
That's just what I needed thanks. I presume then that you could iterate through all the entities within a pre-determined entity group and add the component. So I could have a group of objects in the editor called "Collectors" or something and then I could find the group and iteratively add the component to all entities within the group?
Sorry for the 21 questions. Just want to make sure I understand correctly. I still can't find the Components object in the API :S
Okay after giving it a shot I think I understand it a lot better although currently I have the following as an example.
ISceneEntityGroup crateGroup = scene.EntityGroups.Find(group => group.Name.Equals("Crates"));foreach (ISceneEntity crate in crateGroup.Entities){ crate.Components.AddWithDependencies(new SpinEntityComponent());}
Inside the SpinEntityComponent I override the OnUpdate method and attempt to spin the model. I put a breakpoint in the method but it is never called. Are there any steps I'm missing?
Of course! Setting them to Dynamic. Working perfectly now.
Also if you want to find specific objects by name you can use:
ISceneEntity entity;sceneInterface.ObjectManager.Find<ISceneEntity>("name", out entity);if(entity != null) entity.Components.AddWithDependencies(new SpinEntityComponent());
Please note this assumes the objects are already in the ObjectManager (via submitting the containing scene, or the objects individually).
I was just looking at that in fact :)
I'm starting to feel much more comfortable with everything and I owe you a big thanks. I appreciate all the patience you've shown me. I'm super excited to start making some components. So many possibilities :D
JohnK "bobthecbuilder": Hi Darren, Also if you want to find specific objects by name you can use: ISceneEntity entity;sceneInterface.ObjectManager.Find<ISceneEntity>("name", out entity);if(entity != null) entity.Components.AddWithDependencies(new SpinEntityComponent()); Please note this assumes the objects are already in the ObjectManager (via submitting the containing scene, or the objects individually). Let me know if this helps!
John, by the way, I don't think you actually verify a SceneObject's name is unique inside ObjectManager: how do you decide which to return in case several SceneEntity or SceneObject instances share the same name?
Thanks
Philippe
Hi Philippe,
If there are multiple dynamic objects with the same name the scenegraph will always return the last dynamic object submitted with that name.
Please note: like object events and components, Find<T>("name") only interacts with dynamic objects.
Back to my use of components to incorporate a seperate physics engine would that mean that even static objects (still in the physics simulation) would need to be marked dynamic?
This would mean lightmapping would be reduced even though the object will never move.
Will the OnInitialize method not even be called for non-dynamic scene objects?
Just did a check and found that by doing the search more manually like my other post you can add components to non-dynamic objects but they won't call the update method. At least they still call the initialize method which is what I was hoping for.
I think you've already found the answer, but just to clarify:
Yes, components can be added to static objects, used as data storage, and initialized, but they will not receive update and collision events.