I have a little problem with my C# code which I would most appreciate help with. Using XNA, I have defined a GameComponent called ActorStaticMesh to handle the drawing of static meshes within my program. Right now I have to explicitly call my draw function so I can pass the view and projection matrices from my camera. In an ideal situation I would be able to render my mesh by overriding XNA's built in draw function but this provides me no way to pass the matrices required to properly render my model.
So I ask this question, how would I efficiently pass my camera's view matrix to my GameComponent so I could call the draw function implicitly instead of explicitly.
[code]// How I currently draw my model
teapot.Draw(gameTime, camera);
// Current draw function in ActorStaticMesh.cs
public void Draw(GameTime gameTime, FirstPersonCamera camera)
// desired draw function
public override void Draw(GameTime gameTime) [/code]
On a side note, does facepunch have syntax highlighting for C#?
Isn't there like.. a DrawableGameComponent?
[QUOTE=Robbis_1;17754681]Isn't there like.. a DrawableGameComponent?[/QUOTE]
That's what I'm using, my problem is with passing matrices to the draw function without them being sent via a function parameter.
I don't know if I understand this correct, but you have a camera and a bunch of meshes. You'd like to draw those meshes correctly depending on your where your camera is?
Never mind, I solved my problem by passing a reference to the camera in my class constructor. Only problem now is isolating the interface and forcing it to draw last because right now my model draws over it.
I'm pretty sure all the components have a DrawOrder variable.
Yeah, but I haven't got around to rewriting my UI code as a a component.
Sorry, you need to Log In to post a reply to this thread.