2013年5月25日 星期六

Three.js 如何loading blender obj mtl檔

在blender export obj檔
會產生.obj .mtl

在利用three.js load

var loader = new THREE.OBJMTLLoader();
                                loader.addEventListener( 'load', function ( event ) {

                                        var object = event.content;

                                        object.position.y = 0;
                                        scene.add( object );

                                });
                                loader.load( 'obj/male02/monkey.obj', 'obj/male02/monkey.mtl' );


2013年3月24日 星期日

Compiler(1)


第一章

Programming languages are notations for describing computations to people
and to machines.
It first must be translated into a form in which it can be executed by a computer.
The software systems that do this translation are called compilers.

a compiler is a program that can read a program in one lan­
guage - the source language - and translate it into an equivalent program in
another language - the target language.


f we open up this box
a little, we see that there are two parts to this mapping: analysis and synthesis .The analysis part
is often called the front end of the compiler; the synthesis part is the back end. 

2013年3月20日 星期三

OpenCL筆記

OpenCL主要分成四個部份

Platform model -- device 和 host

Execution model -- kernel如何在device上執行

Memory model -- abstract memory hierarchy

Programming model -- 定義concurrency model如何map 到physical hardware


(1) Initialize platforms

clGetPlatformIDs(...,...,...);

(2)Initialize devices

clGetDeviceIDs(...,...,...,...,...);

(3) Create a context

clCreateContext(...,...,...,...,...,...,...);

(4) Create a command queue

clCreateCommandQueue(...);

(5) Create device buffers

clCreateBuffer(...);

(6) Write host data to device buffers

clEnqueueWriteBuffer(...);

(7) Create and compile the program

clCreateProgramWithSource(...);

clBuildProgram(...);

(8) Create the kernel

clCreateKernel(...);

(9) Set kernel arguments

clSetKernelArg(...);

(10) Configure the work-item structure

size_t globalWorkSize[1];

globalWorkSize[0]=2048;

(11) Enqueue the kernel for execution

clEnqueueNDRangeKernel(...);

(12) Read output results to host

clEnqueueReadBuffer(...);

(13) Release OpenCL Resources

clRealeaseKernel(...);
clRealeaseProgram(...);
...







2013年3月13日 星期三

物件導向(1)


#include <stdio.h> → include interface ↔ 沒有include implementation
int main()
{
printf(“Hello World!\n”); → 第一個引數format string

return 0;
}

preprocessing(macro) → compiling → linking (才需要知道implementation 函式庫)
static dynamic

posix (portable operation system interface)
包含各種platform的實作

#include <stdio.h>
int stk[100]; → scope的問題 加上static解決問題
int sp = -1;
void push(int x) → 兩個stack 的問題 float double型別的stack問題
{            沒有encapsulation的問題
stk[++sp]=x;
}
int pop()
{
return stk[sp--];
}

ADT(Abstract Data Type)= Data + Operators(用來manipulate Data操作)

C++克服C的地方
encapsulation
inheritance(reuse)
polymorphism(switch)

資料庫(3)


DB2 & SQL

每種query language 都有DDL and DML
a base table is “real” table實體存在
a view is a “virtual” table

2013年3月5日 星期二

OpenCL(1) vector add



//vector add 副程式  類似glsl中 fragment shader 和vertex shader呼叫方式


const char* programSource =
"__kernel                 \n"
"void vecadd(__global int *A,\n"
"            __global int *B,\n"
"            __global int *C) \n"
"{\n"

"   // Get the work-item unique ID                \n"
"   int idx = get_global_id(0);                   \n"
"\n"
"   // Add the corresponding locations of        \n"
"   // 'A' and 'B', and store the result in 'C'. \n"
"   C[idx] = A[idx] + B[idx];\n"
"}\n"
;



main主程式
...
kernel = clCreateKernel(program, "vecadd", &status);    //inline 方式call vecadd
...


Compile方法

g++ vectoradd.c -I/usr/local/cuda-5.0/include -L/usr/local/cuda-5.0/lib64 -lOpenCL

資料庫(2)


第二章 Data Model

Data Model:A set of concepts to describe the structure of a database, and certain constraints that the database should obey.

Components of Data Model
1.Structures
2.Operations
3.Integrity Constraints

Data Model為了將資料抽象化,storage detail隱藏

Relational Data Model
Hierarchical Data Model
Network Data Model

Primary Key:滿足uniquenessminimalitycandidate key
Foreign key:a foreign key is an attribute of relation R2 whose values are refer to the primary key of some relation R1.