Skip to content

Instantly share code, notes, and snippets.

### Makefile ---
## Author: Kun Wang <ifreedom.cn@gmail.com>
## Version: $Id: Makefile,v 0.0 2011/03/23 10:57:42 ifreedom Exp $
## Keywords:
## X-URL:
all: src c1 c2 c3
src:
#define FILTER_PI (3.1415926535897932384626433832795)
#define FILTER_2PI (2.0 * 3.1415926535897932384626433832795)
#define FILTER_4PI (4.0 * 3.1415926535897932384626433832795)
#define FILTER_SET_PARAM_IMP(type) int filter_##type##_set_param(void *this,double val,int flags) { \
assert(this != NULL); \
switch(flags) { \
case FILTER_SET_WIDTH: \
(Filter_##type *)this->width = val; \
return 1; \
@nomadalex
nomadalex / EditorObjExporter.cs
Created September 7, 2011 03:03
Unity网格资源导出为*.Obj格式模型脚本, 将下面2个脚本保存在 Editor 文件夹中,然后选择一个网格对象,在 Custom 菜单中根据需要选择导出为 Obj 文件,文件将被保存在项目目录的 ExportedObj 文件夹中.
/*
Based on ObjExporter.cs, this "wrapper" lets you export to .OBJ directly from the editor menu.
This should be put in your "Editor"-folder. Use by selecting the objects you want to export, and select
the appropriate menu item from "Custom->Export". Exported models are put in a folder called
"ExportedObj" in the root of your Unity-project. Textures should also be copied and placed in the
same folder. */
using UnityEngine;
using UnityEditor;
@nomadalex
nomadalex / CreatePrefabFromSelected.cs
Created September 7, 2011 03:22
Unity中从目前选择对象创建预设(Prefab)脚本
using UnityEditor;
using UnityEngine;
using System.Collections;
class CreatePrefabFromSelected : ScriptableObject
{
const string menuTitle = "GameObject/Create Prefab From Selected";
/// <summary>
/// Creates a prefab from the selected game object.
@nomadalex
nomadalex / SplashScreen.cs
Created September 9, 2011 06:18
Unity淡入淡出脚本
using UnityEngine;
using System.Collections;
public class SplashScreen : MonoBehaviour
{
public string levelToLoad = ""; // this has to correspond to a level (file>build settings)
public Texture2D splashLogo; // the logo to splash;
public float fadeSpeed = 0.3f;
public float waitTime = 0.5f; // seconds to wait before fading out
public bool waitForInput = false; // if true, this acts as a "press any key to continue"
@nomadalex
nomadalex / prettify.lua
Created September 9, 2011 17:10 — forked from stevedonovan/prettify.lua
Script to convert Markdown source with code blocks into syntax-highlighted HTML.
-- translate Markdown with code blocks into HTML
-- with syntax highlighting.
-- If article.md was the source, Lua was the language and we
-- wanted a preview:
-- lua prettify.lua article lua preview
-- Without the last argument it will just write out the HTML body.
-- Languages supported are 'lua', 'cpp', 'java' and 'go
-- Indented code blocks may begin with an explicit @lang name line;
-- if you do this then mark every code block explicitly
-- e.g
@nomadalex
nomadalex / water.shader
Created October 26, 2011 06:10
Unity-水面效果的shader文件
Shader "FX/Water" {
Properties {
_WaveScale ("Wave scale", Range (0.02,0.15)) = 0.063
_ReflDistort ("Reflection distort", Range (0,1.5)) = 0.44
_RefrDistort ("Refraction distort", Range (0,1.5)) = 0.40
_RefrColor ("Refraction color", COLOR) = ( .34, .85, .92, 1)
_Fresnel ("Fresnel (A) ", 2D) = "gray" {}
_BumpMap ("Bumpmap (RGB) ", 2D) = "bump" {}
WaveSpeed ("Wave speed (map1 x,y; map2 x,y)", Vector) = (19,9,-16,-7)
_ReflectiveColor ("Reflective color (RGB) fresnel (A) ", 2D) = "" {}
@nomadalex
nomadalex / gist:1319913
Created October 27, 2011 15:35
hiless - LESS Syntax Highlighter
(function () {
//
// hiless - LESS Syntax Highlighter
//
// Copyright (c) 2010 Alexis Sellier
//
// All elements which match this will be syntax highlighted.
var selector = 'code';
@nomadalex
nomadalex / docked_menu_sinppet.js
Created October 27, 2011 15:59
sinppet for docked menu.
var menu = document.getElementById('menu');
var init = menu.offsetTop;
var docked;
window.onscroll = function () {
if (!docked && (menu.offsetTop - scrollTop() < 0)) {
menu.style.top = 0;
menu.style.position = 'fixed';
menu.className = 'docked';
docked = true;
@nomadalex
nomadalex / openni_motor.cpp
Created December 31, 2011 03:02
Easy way to work with Kinect's motor, through OpenNI.
// Here is easy way to work with Kinect's motor, through OpenNI. No other
// drivers or libraries is required.
// The code is following:
// OpenNI includes
#include <XnUSB.h>
// Standard includes
#include <stdio.h>
#include <time.h>
/**