Skip to content

Instantly share code, notes, and snippets.

@edom18
edom18 / EventDispatcher.cs
Created July 4, 2018 02:43
イベントディスパッチャサンプル
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// イベントデリゲートタイプ
/// </summary>
/// <param name="args">引数</param>
public delegate void EventListener<T>(T args);
/// <summary>
@edom18
edom18 / MouseCameraController.cs
Created June 5, 2018 03:01
マウスでカメラ操作を行うスクリプト
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseCameraController : MonoBehaviour
{
[SerializeField]
private float _speed = 0.1f;
[SerializeField]
@edom18
edom18 / ceternalTriangle.cs
Created June 5, 2018 00:48
円の外接三角形の頂点計算
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
[SerializeField]
private float _radius = 1f;
private Vector3 _center = Vector3.zero;
@edom18
edom18 / Fade.shader
Created May 11, 2018 00:50
UnityでVR開発していてフェードを簡単に行いたい場合の処理
private void OnRenderImage(RenderTexture src, RenderTexture dest)
{
_fadeMaterial.SetPass(0);
GL.PushMatrix();
GL.LoadOrtho();
GL.Color(_fadeMaterial.color); // Update内などでこのcolorを変更する想定
GL.Begin(GL.QUADS);
GL.Vertex3(-1f, -1f, 1f);
GL.Vertex3(-1f, 1f, 1f);
GL.Vertex3( 1f, 1f, 1f);
@edom18
edom18 / Unity-C#
Last active June 16, 2019 23:55
直交座標から極座標への変換メモ ref: https://qiita.com/edo_m18/items/5d61f19512fb05f48501
private void Convert(Color[] colors, int width, int height)
{
int halfWidth = width / 2;
int halfHeight = height / 2;
Texture2D tex = new Texture2D(width, height);
Color[] newColors = new Color[colors.Length];
GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
quad.name = "PolarCoord";
@edom18
edom18 / file0.cs
Last active September 8, 2017 16:01
[ゲームAI] ファジー理論 ref: http://qiita.com/edo_m18/items/6f66d7510c31e0a57cd7
float temperature = 30.5f;
float cold = Cold(temperature);
float warm = Warm(temperature);
float hot = Hot(temperature);
@edom18
edom18 / file0.cs
Created June 16, 2017 10:39
[Unity] TransformクラスのTransform****系メソッドのメモ ref: http://qiita.com/edo_m18/items/d2f2f0555b5cb5bcff67
// ----------------------------------------------------------------------------
// TransformPoint
// 意味: 通常のモデル行列を掛けたポイントを得る
Vector3 point = Vector3.one;
Vector3 newPoint1 = transform.TransformPoint(point);
Vector4 v = new Vector4(point.x, point.y, point.z, 1f);
Vector3 newPoint2 = transform.localToWorldMatrix * v;
// ----------------------------------------------------------------------------
@edom18
edom18 / file0.txt
Created March 12, 2017 07:15
[Unity] 深度バッファから法線を復元しようとしてうまくいかなかった話 ref: http://qiita.com/edo_m18/items/86029fd6c18a52ad4f3d
Shader "Custom/DepthNormal" {
SubShader {
Tags { "RenderType"="Transparent" "Queue"="Transparent+10" }
LOD 200
Pass
{
CGPROGRAM
#include "UnityCG.cginc"
@edom18
edom18 / LU分解を行う
Last active February 1, 2017 05:19
[数学] 最小二乗平面をプログラムで求める ref: http://qiita.com/edo_m18/items/82659d6b1b122e80f645
float[] LUDecomposition(float[,] aMatrix, float[] b)
{
// 行列数(Vector3データの解析なので3x3行列)
int N = aMatrix.GetLength(0);
// L行列(零行列に初期化)
float[,] lMatrix = new float[N, N];
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
@edom18
edom18 / file0.txt
Created January 25, 2017 23:19
[数学] LU分解法をプログラムで書いてみた ref: http://qiita.com/edo_m18/items/1d67532bed4a083cddb3
\begin{bmatrix}
l_{00} & 0 & 0 \\
l_{10} & l_{11} & 0 \\
l_{20} & l_{21} & l_{22}
\end{bmatrix}