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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:17:21+00:00 2026-05-27T06:17:21+00:00

I can paint Model3DGroup in the color i want by using Material material =

  • 0

I can paint Model3DGroup in the color i want by using

Material material = new DiffuseMaterial(new SolidColorBrush(Colors.White));
GeometryModel3D model = new GeometryModel3D(mesh, material);

(following this tutorial)

to set the color of GeometryModel3D i include in the Model3DGroup.

I have an application where I have to place a map on a terrain in 3D (terrain is completely flat), the map is not an image, and I have detailed data of the points of the shapes I want to draw, and I also have DrawingVisual objects of all the shapes that I want to project on the 3D surface. In 2D mode, I draw them on a custom canvas (derived from Canvas) where I add them using

myCanvas.addVisualChild(item);
myCanvas.addLogicvalChild(item);

My question is how to “paint” or draw shapes and lines etc on 3D items? These shapes do not cover the terrain fully. I have tried using Viewport2DVisual3D class and tried placing a canvas on a 3D surface (a simple canvas with a button) using the following code:

Canvas testCanvas = new Canvas();
testCanvas.Background = Brushes.Green;
Button b1 = new Button();
b1.Content = "Hello there";
Canvas.SetTop(b1, 50);
Canvas.SetLeft(b1, 50);
Canvas.SetZIndex(b1, 2);
testCanvas.Children.Add(b1);

testVisual3d.Visual = testCanvas; // testVisual3d is a Viewport2DVisual3D declared in xaml

But the problem is that I am not able to figure out how the Canvas or any Visual “fills” the Viewport2DVisual3D class because:

  1. The button filled the canvas completely.
  2. Empty areas of the canvas (Canvas.SetTop(b1, 50)) is not visible.
  3. I have no idea idea about the size of the canvas related to the size of Viewport2DVisual3D object because the button always fills the object completely.

Also i cannot use Viewport2DVisual3D everywhere, as I also have to create models of buildings etc. when I am projecting the map to a 3D terrain, so I’ll have to paint areas of a building model (which will be a Model3DGroup) differently to give a realistic effects, but if i manage to project the map on a Viewport2DVisual3D, it’ll solve lots of problems as i’ll be able to directly project all the shapes including grid on the Viewport2DVisual3D object or terrain.

I am using .NET 4.0 and C#.

Please help.

Update

Using this code solves the initial problem of canvas size and space:

Canvas testCanvas = new Canvas();
testCanvas.Background = Brushes.Green;
Button b1 = new Button();
b1.Width = 120;
b1.Height = 25;

testCanvas.Width = 200;
testCanvas.Height = 200;

b1.Content = "Hello there";
Canvas.SetTop(b1, 50);
Canvas.SetLeft(b1, 50);
Canvas.SetZIndex(b1, 2);
testCanvas.Children.Add(b1);

testVisual3d.Visual = testCanvas;

The size of Viewport2DVisual3D is

Positions="0,0,0 0,0,30 30,0,30 30,0,0"

And the canvas resizes to fit the boundaries of the Viewport2DVisual3D, but will it work with a class derived from Canvas in which shapes have directly been added using Canvas.AddVisualChild and Canvas.AddLogicalChild, i am yet to try that.

And also the original question of painting on the Model3DGroup remains, how to do it?

  • 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-05-27T06:17:21+00:00Added an answer on May 27, 2026 at 6:17 am

    After a bit of experimenting, i have the answer, simple way is to set the color of each triangle while defining the mesh. In WPF, what is needed is to set the Material color when combining the triangle (MeshGeometry3D) and material while defining a new GeometryModel3D.

    (from this tutorial)

    Material material = new DiffuseMaterial(
            new SolidColorBrush(Colors.DarkKhaki)); //Set color here
        GeometryModel3D model = new GeometryModel3D(
            mesh, material);
    

    I am a beginner of 3D and I have not yet explored the concept of materials.

    If someone knows another way, please post here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Visual Editor to paint my Swing GUI. Can I dynamically build
How Paint .NET can draw so fast using C#? Sample: The ellipse perimeter is
How I can paint an arbitrary day with red color and bold font, and
I know I can override paint to change the text color in a labelfield,
//I want to paint a ball in a animation //I can't seem to find
Particular in my case, I want to paint a line to a QGraphicsScene using
I'm trying to drawText on a Canvas using Paint and I can't seem to
I'm writing a program to generate some wild visuals. So far I can paint
how can I paint all rows in a datagrid with the value of field
I'm trying to understand how I can paint simple graphics in x86 protected mode

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.