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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:33:34+00:00 2026-05-23T18:33:34+00:00

I’m trying to create a custom class to hold three vertex positions that define

  • 0

I’m trying to create a custom class to hold three vertex positions that define a triangle to draw and subdivide. The problem I’m running into is how to make sure I return the correct values.

here’s the code that I have so far:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Icosahedron_Test
{
    class TriXYZ
    {
        Vector3 vertex1;
        Vector3 vertex2;
        Vector3 vertex3;
        int depth;
        float material; // float because the material can be part grass / part dirt or part sand / part rock, etc...  for blending

        public TriXYZ(Vector3 pos1, Vector3 pos2, Vector3 pos3, int tDepth)
        {
            vertex1 = pos1;
            vertex2 = pos2;
            vertex3 = pos3;
            depth = tDepth;
        }

        public TriXYZ(Vector3 pos1, Vector3 pos2, Vector3 pos3, int tDepth, float tMaterial)
        {
            vertex1 = pos1;
            vertex2 = pos2;
            vertex3 = pos3;
            depth = tDepth;
            material = tMaterial;
        }

        public Vector3 Vertex1(TriXYZ triangle)
        {
            return vertex1;
        }
        public Vector3 Vertex2(TriXYZ triangle)
        {
            return vertex2;
        }
        public Vector3 Vertex3(TriXYZ triangle)
        {
           return vertex3;
        }
        public int Depth(TriXYZ triangle)
        {
            return depth;
        }
        public Vector3 Midpoint(Vector3 pos1, Vector3 pos2, int tDepth)
        {
            Vector3 midpoint;  // returned midpoint between the two inputted vectors

            //PLACEHOLDER

            return midpoint;
        }

    }
}

I create a new Triangle element like this:

new TriXYZ(pos1, pos2, pos3, depth); // the depth will deal with LOD later on

so, in order to get the value for the vertex positions, I’m calling the class like this:

vertex1 = TriXYZ.Vertex1(verticiesList[listPos]);

My issue is that I’m not sure if it’s working, and I’m not entirely sure how to check it at this point, because there’s not enough here to actually make the program run. Does the theory behind this seem like it would work?

Also, as a side note, I’m an amateur programmer, so if there are any glaring issues with this that are going against coding standards, feel free to point them out to me ^^

  • 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-23T18:33:34+00:00Added an answer on May 23, 2026 at 6:33 pm

    I’m assuming what you want are getters for those vertex variables.

    This is because you should not try to make those functions static (from the way you’re trying to call them), do the following instead:

    public Vector3 Vertex1()
    {
        return vertex1;
    }
    public Vector3 Vertex2()
    {
        return vertex2;
    }
    public Vector3 Vertex3()
    {
        return vertex3;
    }
    

    If what you really want are getters, then I’d recommend getting a more explicit name like GetVertex1, or even better, put it as a property like so:

    public Vector3 Vertex1 { get; private set; }
    

    So, what exactly is a property? It’s just a nicer way to get or set data.

    Here, we specify public to be the access level of the vertex, so that Vertex1 can be accessed publicly (you can get the value of the vertex outside of the class). Like so:

    Vector3 vertex = triangle.Vertex1;
    

    In this particular situation, you may or may not want other people from outside of the class to change the vertex. If you don’t want them to change it, you specify the setter of the property to be private, so that you can only change Vertex1‘s value within the class.

    You’d use it this way:

    TriXYZ myTriangle = new TriXYZ(pos1, pos2, pos3, depth);
    Vector3 vertex1 = myTriangle.Vertex1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from

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.