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 181405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:45:28+00:00 2026-05-11T14:45:28+00:00

I have a cuboid who’s dimensions are imported from XML so i need to

  • 0

I have a cuboid who’s dimensions are imported from XML so i need to be sure that no matter what the size of the model, the camera can always see all of it. This is for preview purposes. I’ll likely render a caption over the top showing the scale for clarity.

I think i need some function which will tell me whether the ModelVisual3D fits inside the bounds of the FieldOfView of the camera or maybe the ViewPort3D itself.

So far i have the static callback (the dimension properties are DependencyPropertys) when dimensions properties change define as below. It’s pretty crude at the moment but you get the idea I’m looking at. The commented out section shows roughly what kind of logic I’m looking for

    private static void OnCubeDimensionsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)     {         if (!valueSemaphore)         {             //while(mainModel.WillClip(mainCamera))             //{             //     mainCamera.FieldOfView--;             //}              valueSemaphore = true;             double propertyValue = 0.0;             Product3D p = d as Product3D;              switch (e.Property.Name)             {                 case 'CubeHeight':                     propertyValue = (double.Parse(e.NewValue.ToString()) / 100) * 8;                     p.CubeHeight = propertyValue;                     break;                 case 'CubeWidth':                     propertyValue = (double.Parse(e.NewValue.ToString()) / 100) * 5.3;                     p.CubeWidth = propertyValue;                     break;                 case 'CubeDepth':                     propertyValue = (double.Parse(e.NewValue.ToString()) / 100) * 2.6;                     p.CubeDepth = propertyValue;                     break;             }             valueSemaphore = false;         }     } 

If anyone knows what should go where the commented-out section is I’d be eternally grateful.
Thanks in advance.

  • 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. 2026-05-11T14:45:29+00:00Added an answer on May 11, 2026 at 2:45 pm

    What you need to get hold of is the extent of the 2D projection of the cube on the view plane. You can then do a simple check on the min and max X & Y values to see whether the whole of the cube is visible.

    Adding a tolerance factor to the extent will take care of any rounding errors.

    I’ve copied what looks to be the relevant section of code from here. You can then set the size of the viewport accordingly.

    public static Rect Get2DBoundingBox(ModelVisual3D mv3d) {     bool bOK;      Matrix3D m = MathUtils.TryWorldToViewportTransform(vpv, out bOK);      bool bFirst = true;         Rect r = new Rect();      if (mv3d.Content is GeometryModel3D)     {         GeometryModel3D gm3d = (GeometryModel3D) mv3d.Content;          if (gm3d.Geometry is MeshGeometry3D)         {             MeshGeometry3D mg3d = (MeshGeometry3D)gm3d.Geometry;              foreach (Point3D p3d in mg3d.Positions)             {                 Point3D pb = m.Transform(p3d);                 Point p2d = new Point(pb.X, pb.Y);                 if (bFirst)                 {                     r = new Rect(p2d, new Size(1, 1));                     bFirst = false;                 }                 else                 {                     r.Union(p2d);                 }             }         }     } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 236k
  • Answers 236k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I don't think it's worth not duplicating the code here-… May 13, 2026 at 6:25 am
  • Editorial Team
    Editorial Team added an answer Try this (VS2008 and target framework == 2.0): static void… May 13, 2026 at 6:25 am
  • Editorial Team
    Editorial Team added an answer $("Edit").click(function(){ This should be: $("#Edit").click(function(){ And if you have that… May 13, 2026 at 6:25 am

Related Questions

I have a cuboid who's dimensions are imported from XML so i need to
I have a number of cuboids whose positions and sizes are given with minimum
We've gotten a homework assignment in Java, which relates to inheritance. I don't have
I've seen on StackOverflow and googling around that the most used way to get
I have a web-service that I will be deploying to dev, staging and production.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.