0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

cscの作法 その579

Last updated at Posted at 2025-04-16

概要

cscの作法、調べてみた。
OpenRCF v2.8、見つけたので、windows11で、MSbuildしてみた。
練習問題やってみた。

練習問題

プリミティブを作れ。

写真

image.png

サンプルコード

using System;
using System.Windows;
using OpenRCF;
using Vector = OpenRCF.Vector;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;

    class Traiangle {
		private float radius = 0.2f;
		public Vector Position = new Vector(3);
		public RotationMatrix Rotate = new RotationMatrix();
		public Color Color = new Color();
		public float SizeX = 0.5f,
			SizeY = 0.5f;
		public float Radius {
			get {
				return radius;
			}
			set {
				radius = value;
			}
		}
		public Traiangle(float sizeX = 0.5f, float sizeY = 0.5f) {
			SizeX = sizeX;
			SizeY = sizeY;
			Radius = sizeX;
		}
		private float[][] Vertex = new float[3][];
		private static class BaseVertex {
			public static float[][] Vertex = new float[3][];
			static BaseVertex() {
				Vertex[0] = new float[3] { -0.5f,  0.3f, 0 };
				Vertex[1] = new float[3] { -0.5f, -0.5f, 0 };
				Vertex[2] = new float[3] {  0.3f, -0.5f, 0 };
			}
		}
		public void Draw() {
			VertexUpdate();
			Color.EnableBodyColor();
			DrawVertex(PrimitiveType.Polygon);
		}
		private void DrawVertex(PrimitiveType primitiveType) {
			GL.Begin(primitiveType);
			GL.Normal3(Rotate[0, 2], Rotate[1, 2], Rotate[2, 2]);
			for (int i = 0; i < Vertex.GetLength(0); i++)
			{
				GL.Vertex3(Vertex[i]);
			}
			GL.End();
		}
		private void VertexUpdate() {
			float[] vector = new float[3];
			for (int i = 0; i < Vertex.GetLength(0); i++)
			{
				vector[0] = SizeX * BaseVertex.Vertex[i][0];
				vector[1] = SizeY * BaseVertex.Vertex[i][1];
				vector[2] = 0;
				Vertex[i] = Position.Plus(Rotate * vector);
			}
		}
	}

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?