Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8507487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:53:08+00:00 2026-06-11T02:53:08+00:00

Here is what I have: a custom DrawableGameComponent , containing children in which I

  • 0

Here is what I have: a custom DrawableGameComponent, containing children in which I call some DrawUserPrimitve. Each of the child can contain children etc.
I store in each component a list of the vertices describing its shape, and a Matrix to store its relative position (and eventually transformation).
So before I “DrawUserPrimitive“, I need to “apply” a matrix. This matrix must be the multiplication of the component’s transformations and of its parent and its parent’s parents etc.

This system allow me to keep the component’s variable independant and if I understood correctly, that’s the way to go.

To do so I saw the BasicEffect object in XNA, with which I can apply some matrices. So I am trying to multiply the basicEffect.World with my component.Transformation (Matrix)

So I should continue to inquire but for now it does not give me the results I was waiting for. I wonder if I chose the good way to do this. I see 2 systems for the same results:

  1. How I am currently doing, a bit like having a fixed pencil but moving your sheet of paper
  2. or adding a loop going through all my vertices just before drawing to modify these accordingly to the transformations expected. A bit like moving the pencil instead of the paper.

Some code for illustration’s sake:

public void override Draw(GameTime gameTime){

    Game.basicEffect.World *= Transformation;

    foreach(var child in this.Children){
        child.Draw(gameTime);
    }

    Game.basicEffect.World *= Matrix.Invert(Transformation);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:53:10+00:00Added an answer on June 11, 2026 at 2:53 am

    Thanks to @nico-schertler ‘s comment I was able to make it.

    Having a Matrix stack storing the current state of your “pencil” is the solution. But there was something I was missing:

    Each time you go deeper in the object hierarchy (ex: the arm of a robot) you multiply the new Matrix by the current one and put the resulting one on the stack. Therefore the stack always have (on top of itself) the Matrix which must be used to draw. When you are done with this object and go back to its parent, just pop once and you retrieve the Matrix to use for it.
    (I was stacking each Matrix and then everytime recalculating the resulting Matrix to use.)

    Remark: be careful to the order you multiplications. Matrices’ multiplication are not commutative! Always multiply your child matrix by the current one.

    internal void HandleDraw(GameTime gameTime)
    {
        Draw(gameTime);
    
        if (Children.Count > 0)
        {
            // draw children
            foreach (Control child in Children.Values.OfType<Control>())
            {
                if (child.Visible)
                {
                    Engine.CurrentTransformation.Push(Matrix.Multiply(
                        child.Transformation,
                        Engine.CurrentTransformation.Peek()
                    ));
    
                    child.HandleDraw(gameTime);
    
                    Engine.CurrentTransformation.Pop();
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my aproach: I have a custom ListView containing a custom Adapter containing two
Here's what I have: Custom-made C# CMS where the content is stored in a
I have a custom CMS here entitled phpVMS, and I want to exclude a
I have a custom content type create in visual studio 2010: custom http://img204.imageshack.us/img204/439/customf.jpg Here
Here's the setup. I have a custom UIScrollView as a subview of PrimeView. The
Here is my custom class that I have that represents a triangle. I'm trying
Here is my page: http://budclarychevy.com/custom/parts-specials-test My aim is to have the images clickable and
I'm have a weird issue here. I have a UITableView using custom UITableViewCells. Everything
This may be have a better name than custom tab completion, but here's the
I have a Tab that has a custom layout which contains a TextView .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.