Skip to content

Instantly share code, notes, and snippets.

View naruse's full-sized avatar

Juan Sebastian Muñoz naruse

  • Pencil Square Games
  • Canada
View GitHub Profile
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public Transform gunObj;
void Update() {
if (Input.GetMouseButton(0)) {
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit)) {
-*- mode: compilation; default-directory: "~/dev/OpenGL/Test73DOpenGL/" -*-
Compilation started at Mon Jun 1 13:49:42
make -k \
g++ -I/usr/local/include main.cpp Vertex.cpp Matrix.cpp Utils.cpp -o main -L/usr/local/lib -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo -lGLEW
Matrix.cpp:13:14: error: array type 'float [16]' is not assignable
result.m = Matrix::Identity();
~~~~~~~~ ^
1 error generated.
make: *** [all] Error 1
#include "Matrix.h"
float const Matrix::identityMatrix[] = {
1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1
};
Matrix Matrix::MultiplyMatrices(const Matrix* m1, const Matrix* m2) {
#include <iostream>
using namespace::std;
int width = -1;
int height = -1;
char** mineBoard;
int main(int argc, char* argv[]) {
while (width != 0 && height != 0) {
naruse@MacBook-Pro ~/dev/HexLang/hex/compiler (master)$:make compiler.out
gcc -Wno-implicit parser.o lex.yy.c parser.tab.c ast.o semantics.o vtable.o ../base/hashmap.o ../base/strbuf.o ../base/hash.o compiler.c -o compiler.out
parser.y:695:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
compiler.c:63:66: error: too many arguments to function call, expected 3, have 4
hex_semantics_check_stmt_group(vtable, stmt_group, scope_type, indent_level);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~
./semantics.h:32:1: note: 'hex_semantics_check_stmt_group' declared here
public List<Texture> GetTextures2D(Material mat) {
List<Texture> list = new List<Texture>();
int count = ShaderUtil.GetPropertyCount(mat.shader);
for(int i = 0; i < count; i++) {
if(ShaderUtil.GetPropertyType(mat.shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) {
if(ShaderUtil.GetTexDim(mat.shader, i) == ShaderUtil.ShaderPropertyTexDim.TexDim2D) {
list.Add(mat.GetTexture(ShaderUtil.GetPropertyName(mat.shader, i)));
}
}
}
public List<Texture> GetTextures2D(Material mat) {
List<Texture> list = new List<Texture>();
int count = ShaderUtil.GetPropertyCount(mat.shader);
for(var i = 0; i < count; i++) {
if(ShaderUtil.GetPropertyType(mat.shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) {
string propertyName = ShaderUtil.GetPropertyName(mat.shader, i);
if(propertyName != "_Cube") {
list.Add(mat.GetTexture(propertyName));
}
}
/*
Created by: Juan Sebastian Munoz Arango
[email protected]
2014
www.pencilsquaregames.com
Feel free to use it for your personal / commercial projects.
a mention of the source would be nice but if you dont feel like
its alright.
@naruse
naruse / gist:4edc15f7c389ea8f793b
Created September 10, 2014 14:57
LOD groups add on to work with pro draw call.
[MenuItem("FixLODRendeer")]
static void LODRendeer()
{
LODGroup[] lodgroups = (LODGroup[])GameObject.FindObjectsOfType(typeof(LODGroup));
//For every LOD group: get the current groups and get the renderer names..
foreach (LODGroup lodgroup in lodgroups)
{
SerializedObject obj = new SerializedObject(lodgroup);
@naruse
naruse / gist:7352864
Last active December 27, 2015 16:09
Want to adjust a Quad / Plane to the size of what the camera renders for playing a video ? heres how you doit
//Adjust the size of the transform to ocuppy the whole size of the camera being rendered
void Start () {
float distance = Vector3.Distance(Camera.main.transform.position, transform.position);
float sizeHeight = Mathf.Tan(Mathf.Deg2Rad * Camera.main.fieldOfView/2) * distance;
float radAngle = Camera.main.fieldOfView * Mathf.Deg2Rad;
float radHFOV = 2 * Mathf.Atan(Mathf.Tan(radAngle / 2) * Camera.main.aspect);
float hFOV = Mathf.Rad2Deg * radHFOV;