G'day,
We are new to sunburn (it is AWESOME), and wish to know how to draw 3D lines. Does the engine support this? Also, we are attempting to use Mod Tools to export .fbx files. Our first, was simply some text. It compiled, but did not appear in the engine.Second, we imported your windmill scene (what application did you guys use to make this by the way?) and then skewed it a little, duplicated some stuff, and added a sphere. This then would not compile because it had changed the texture paths. We got it compiling, but the textures are absent when the game is running.Any help would be good :)
Hi 2.0,
You can render 3D lines by submitting a vertex and index buffer containing the lines to the render manager. One of the RenderManager.SubmitRenderableObject overloads allows you to pass in custom buffers of any format and primitive type.
When exporting text from XSI did you triangulate the text first? I think this is needed for non mesh object types - triangulate converts these objects to a mesh, which is needed either by the FBX format or XNA. If the model did import correctly it might be that the object scale was too small.
When re-exporting the windmill what asset build errors did you receive (related to the textures)? I'll try the import / re-export here to see what happens.
Let me know if this helps!
Follow me on Twitter – development and personal tweetsAwesome XNA Videos – Lighting, Rendering, and game videos
Ok, regarding the line drawing, the RenderManagerSubmitRenderableObject(... function is gigantic. Most of what it wants is either not needed or just confuses me. Surely there is already some kind of primative drawing in sunburn somewhere? All I want is debug boxes and lines.
renderManager.SubmitRenderableObject( BoundingSphere, Effect, IndexBuffer, VertexBuffer, VertexDeclaration, indexStart, PrimitiveType.LineList, Primativecount, Vertexbase, Vertexcount, VertexStreamOffset, VertexStride, MatrixWorld, MatrixSkinbones[], CastShadows, ObjectLifeSpan.Scene);
We have been working with 3D for a short while, and toyed with 3 other engines, so there is much we are new to.
Ah, I didn't realize you were only rendering bounding boxes and similar objects. The render manager is definitely overkill for that, it renders lines with lighting, shadows, materials, and fog.
In this case it's much easier to render using BasicEffect, DrawUserPrimitives, and one of the XNA vertex structures. Here's the pseudo code (in your code make sure to only create objects (BasicEffect, VertexDeclaration, and vertex array) when first loading assets and to dispose when unloading assets):
int primitivecount = <number of primitives>; // two vertices for each primitive. VertexPositionColor[] vertices = new VertexPositionColor[primitivecount * 2]; BasicEffect effect = new BasicEffect(GraphicsDevice, null); // get the color from each vertex. effect.VertexColorEnabled = true; // disable specular. effect.SpecularPower = 0.0f; // fill verts for each rendered bounding box... example: vertices[0].Position = <vertex position in object space>; vertices[0].Color = <vertex color>; ... // setup the transforms. effect.World = <world transform of the current object, or pack the world positions into the vertex array and make this Matrix.Identity>; effect.View = sceneState.View; effect.Projection = sceneState.Projection; // tell the device about the vertex format. GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionColor.VertexElements); // begin rendering the effect. effect.Begin(); for (int p = 0; p < effect.CurrentTechnique.Passes.Count; p++) { EffectPass pass = effect.CurrentTechnique.Passes[p]; pass.Begin(); // draw the lines. GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, primitivecount); pass.End(); } effect.End();
The lines can be rendered after RenderManager.Render.
My mind has been folded like a taco with new info and concepts.
First I have to say, that sunburn not being a blatent hog of my code, and demanding that I use it, and only it, to render is WONDERFULL.
I skipped over and used good ol' XNA to render my lines in a similar mannar you described by having a look at http://msdn.microsoft.com/en-us/library/bb196414.aspx#ID4EBC, since I knew what I wanted.
After some issue with trying to use indices when they wer'nt needed, and not passing in fresh view, and projection matrices to my basic effect, I got the damn lines up! Thanks for your help! If we have anymore trouble with .fbx's and such, I think I'll post in a seperate thread for clarity.
Cool, that looks like a great article - I'm glad lines are working for your project now!
2.0 Studios:that sunburn not being a blatent hog of my code, and demanding that I use it, and only it, to render is WONDERFULL
Thanks! We definitely designed SunBurn so you can get started by simply loading a model, a light rig, adding them to SunBurn, and calling Render without having to worry about the underlying code, lighting / rendering theory, or anything. But to still let you enhance and modify how your project is rendered with your own code and shaders.
And most of SunBurn's underlying pieces are exposed, so further down the road your team can create custom renderers that still take full advantage of SunBurn's materials, lighting, and / or shadows.
Speaking of underlying pieces: SunBurn does contain a simplified LineRenderHelper, which is used by the editor. But the class is currently internal (not publicly visible), because we didn't realize people would find it helpful in their projects. We'll expose that class in the next SunBurn update so there is a quick and easy built-in way to render lines.
Hello John,
Can you point me to a code snippet or any information about this line renderer utility class?
Regards
Chen
SynapseGaming.LightingSystem.Core namespace, class LineRenderHelper
cool, thanks.