Skip to content

Instantly share code, notes, and snippets.

@hecomi
hecomi / wasavi.exrc
Created January 26, 2019 14:35
wasavi
map [noremap] ; :
map [noremap] J 10j
map [noremap] K 10k
map [noremap] H ^
map [noremap] L $
map [noremap] q <Nop>
map [noremap] > >>

本エントリは Unity Advent Calendar 2018 23 日目の記事になります。

[https://qiita.com/advent-calendar/2018/unity:embed:cite]

はじめに

ECS(Entity Component System)の概要は読んだり、勉強会で話を聞いてはいたのですが、自分では書いたことがなかったので勉強してやってみることにしました。既に ECS の概要などは様々なサイトで紹介されています。そのまま解説を書いても焼き増しになってしまうので、別のアプローチでの解説を考えたいと思い、本エントリでは実際に既存の MonoBehaviour でいったんモノを作ってから、それを元に ECS 対応をする、という形式を取ることにしました。その題材としてシンプルな Boids シミュレーションを作ってみます。

Boids とはクレイグ・レイノルズさんによって 1986 年に考案された魚や鳥等の群体の動きを模倣する手法です。

@hecomi
hecomi / GraphicsCardAndMonitors.cpp
Created December 5, 2018 14:06
GPU とつながってるモニタ調べるヤツ
#include <iostream>
#include <dxgi1_2.h>
#include <wrl/client.h>
#pragma comment(lib, "dxgi.lib")
using namespace Microsoft::WRL;
void OutputGraphicsInformation()
{
@hecomi
hecomi / RtlGetVersion.cpp
Last active October 14, 2021 17:08
Windows の OS のバージョン取得するヤツ
#include <iostream>
#include <Windows.h>
void OutputWindowsInformation()
{
const auto hModule = ::LoadLibrary(TEXT("ntdll.dll"));
if (!hModule) return;
if (const auto address = ::GetProcAddress(hModule, "RtlGetVersion"))
{
[
{
"backcolor": "#ffffff"
},
[
{
"y": 1.5,
"c": "#222222",
"t": "#222222",
"a": 6,
@hecomi
hecomi / rec.cpp
Created September 13, 2018 15:35
#include <iostream>
#include <memory>
#include <portaudio.h>
#include <sndfile.h>
void checkError(PaError code)
{
if (code == paNoError) { return; }
std::cout << Pa_GetErrorText(code) << std::endl;
...
var ray = new Ray();
ray.origin = gripTransform.position;
ray.direction = gripTransform.forward;
RaycastHit hit;
if (Physics.Raycast(ray, out hit, maxRayDistance, layerMask))
{
var rb = targetHit_.rigidbody;
var uwcWinObj =
rb.GetComponent<uWindowCapture.UwcWindowObject>() ??
...
[DllImport("user32")]
public static extern System.IntPtr GetActiveWindow();
...
var handle = GetActiveWindow();
var window = UwcManager.Find(handle);
if (window != null)
{
// hogehoge
}
@hecomi
hecomi / libjpeg-test.cpp
Last active June 11, 2018 00:01
libjpeg-turbo の速度を雑にテストしたやつ
#include <cstdio>
#include <iostream>
#include <fstream>
#include <chrono>
#include <memory>
#include <turbojpeg.h>
// https://tenshil.blogspot.com/2017/06/visualstudio-2015-error-lnk2019.html
FILE _iob[] = { *stdin, *stdout, *stderr };
extern "C" FILE * __cdecl __iob_func(void)
Shader "Custom/SurfaceShaderDefault"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo (RGB)", 2D) = "white" {}
_Glossiness("Smoothness", Range(0,1)) = 0.5
_Metallic("Metallic", Range(0,1)) = 0.0
}