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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:49:44+00:00 2026-05-23T23:49:44+00:00

I’ve been trying to set up a triangle class that contains three Vector3’s and

  • 0

I’ve been trying to set up a triangle class that contains three Vector3’s and an integer.

Here’s the class constructor: (not sure that’s the right term, I’m an amateur)

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 material1; // float for first material value amount (in %)  deals with blending
        float material2; // float for second material value amount (in %)  deals with blending

        Vector3 vValue;  // place holder for vertex properties "set"
        int dValue;  // place holder for depth properties "set"

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

This is how I’m setting up the property:

public Vector3 GetVertex1
{
    get { return vertex1; }
    set { vertex1 = vValue; }
}

And this is how I’m calling the property from another class:

Vector3 cVertex1;
TriXYZ cTriangle = triangleList[listPos];   // triangleList is a TriXYZ[] array
.
.
.

cVertex1 = cTriangle.GetVertex1;

The error I am getting is:

Cannot implicitly convert type 'Microsoft.Xna.Framework.Vector3' to 'Icosahedron_Test.TriXYZ'

I understand what this error usually means, essentially that I am trying to assign a string to an integer or something like that. What I don’t understand is why I am seeing the error here. the variable cVertex1 is a Vector3 variable, and the return value of vertex1 is also a Vector3 variable.

Can anyone see why I am running into this problem?

Here’s teh full code for the TriXyZ class and the Icosahdron class that I’ve developed so far:

TriXYZ:

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 material1; // float for first material value amount (in %)  deals with blending
    float material2; // float for second material value amount (in %)  deals with blending

    Vector3 vValue;  // place holder for vertex properties "set"
    int dValue;  // place holder for depth properties "set"

    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 tMaterial1, float tMaterial2)
    {
        vertex1 = pos1;
        vertex2 = pos2;
        vertex3 = pos3;
        depth = tDepth;
        material1 = tMaterial1;
        material2 = tMaterial2;
    }

    // public access to triangle data, read-write

    public Vector3 GetVertex1
    {
        get { return vertex1; }
        set { vertex1 = vValue; }
    }
    public Vector3 GetVertex2
    {
        get { return vertex2; }
        set { vertex2 = vValue; }
    }
    public Vector3 GetVertex3
    {
        get { return vertex3; }
        set { vertex3 = vValue; }
    }
    public int GetDepth
    {
        get { return depth; }
        set { depth = dValue; }
    }



    public Vector3 Midpoint(Vector3 pos1, Vector3 pos2, int tDepth)
    {
        Vector3 midpoint;  // returned midpoint between the two inputted vectors

        //PLACEHOLDER

        return midpoint;
    }

}
}

and ICOSAHDRON:

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 Icosahedron
{
    int radius;  // radius of the planet
    int refinement;  // number of times to refine the traingles
    int faces = 20;
    Vector3[] basePositions; // Vertex points for three defining rectangles
    TriXYZ[] vertices;  // Vertex points for triangles which define the spherical surface

    public Icosahedron(int tRadius, int tRefinement, TriXYZ[] tVertices)
    {
        radius = tRadius;
        refinement = tRefinement;
        vertices = tVertices;
    }

    protected void Initialize()
    {
        double t = radius*((1+Math.Sqrt(5))/2);

        Vector3[] basePositions = 
        {
            //First Rectangle
            Vector3.Normalize(new Vector3(-radius, (float)t, 0)),
            Vector3.Normalize(new Vector3(radius, (float)t, 0)),
            Vector3.Normalize(new Vector3(-radius, (float)-t, 0)),
            Vector3.Normalize(new Vector3(radius, (float)-t, 0)),

            //Seconds Rectangle
            Vector3.Normalize(new Vector3(0, -radius, (float)t)),
            Vector3.Normalize(new Vector3(0, radius, (float)t)),
            Vector3.Normalize(new Vector3(0, -radius, (float)-t)),
            Vector3.Normalize(new Vector3(0, radius, (float)-t)),

            //Third Rectangle
            Vector3.Normalize(new Vector3((float)t, 0, -radius)),
            Vector3.Normalize(new Vector3((float)t, 0, radius)),
            Vector3.Normalize(new Vector3((float)-t, 0, -radius)),
            Vector3.Normalize(new Vector3((float)-t, 0, radius))
        };

        TriXYZ[] vertices =
        {
            new TriXYZ(basePositions[0], basePositions[11], basePositions[5], 1),
            new TriXYZ(basePositions[0], basePositions[5], basePositions[1], 1),
            new TriXYZ(basePositions[0], basePositions[1], basePositions[7], 1),
            new TriXYZ(basePositions[0], basePositions[7], basePositions[10], 1),
            new TriXYZ(basePositions[0], basePositions[10], basePositions[11], 1),

            new TriXYZ(basePositions[1], basePositions[5], basePositions[9], 1),
            new TriXYZ(basePositions[5], basePositions[11], basePositions[4], 1),
            new TriXYZ(basePositions[11], basePositions[10], basePositions[2], 1),
            new TriXYZ(basePositions[10], basePositions[7], basePositions[6], 1),
            new TriXYZ(basePositions[7], basePositions[1], basePositions[8], 1),

            new TriXYZ(basePositions[3], basePositions[9], basePositions[4], 1),
            new TriXYZ(basePositions[3], basePositions[4], basePositions[2], 1),
            new TriXYZ(basePositions[3], basePositions[2], basePositions[6], 1),
            new TriXYZ(basePositions[3], basePositions[6], basePositions[8], 1),
            new TriXYZ(basePositions[3], basePositions[8], basePositions[9], 1),

            new TriXYZ(basePositions[4], basePositions[9], basePositions[5], 1),
            new TriXYZ(basePositions[2], basePositions[4], basePositions[11], 1),
            new TriXYZ(basePositions[6], basePositions[2], basePositions[10], 1),
            new TriXYZ(basePositions[8], basePositions[6], basePositions[7], 1),
            new TriXYZ(basePositions[9], basePositions[8], basePositions[1], 1),

        };
    }

    private TriXYZ[] Refinement(TriXYZ[] rVertices, int rRefinement)
    {
        TriXYZ[] tVertices;  // Temp list of triangles

        int cDepth = 1; // current depth integer

        TriXYZ vertex1; // position of first vertex of base triangle
        TriXYZ vertex2; // position of second vertex of base triangle
        TriXYZ vertex3; // position of third vertex of base triangle
        int tDepth; // depth of the current triangle

        TriXYZ mid1; // position of first midpoint
        TriXYZ mid2; // position of second midpoint
        TriXYZ mid3; // position of third midpoint

        int listPos = 0; // base list position integer
        int nListPos = 0; // new list position integer

        int cRefine = 1; // current refinement iteration

        while(cRefine < rRefinement)  // loop until the icosphere has been refined the inputted number of times
        {
            tVertices = null;

            foreach (TriXYZ i in rVertices)
            {
                TriXYZ cTriangle = tVertices[listPos];

                vertex1 = cTriangle.GetVertex1;
                vertex2 = cTriangle.GetVertex2;
                vertex3 = cTriangle.GetVertex3;
                tDepth = tVertices[listPos].GetDepth;

                mid1 = TriXYZ.Midpoint(vertex1, vertex2, tDepth);
                mid2 = TriXYZ.Midpoint(vertex1, vertex2, tDepth);
                mid3 = TriXYZ.Midpoint(vertex1, vertex2, tDepth);
            }
        }

        return rVertices;
    }

}
}
  • 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-23T23:49:45+00:00Added an answer on May 23, 2026 at 11:49 pm

    You declare GetVertex1 like so:

    public Vector3 GetVertex1
    

    This is fine assumign that’s what you want. However in the isocahedron class in the Refinement method you have the following snippets:

        TriXYZ vertex1; // position of first vertex of base triangle
        TriXYZ vertex2; // position of second vertex of base triangle
        TriXYZ vertex3; // position of third vertex of base triangle
        ...
        ...
        vertex1 = cTriangle.GetVertex1;
        vertex2 = cTriangle.GetVertex2;
        vertex3 = cTriangle.GetVertex3;
    

    So this is then trying to set vertex1 to be a Vector3 when it is declared as a TriXYZ.

    Work out what types things should be and you should be sorted. 🙂

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

Sidebar

Related Questions

No related questions found

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.