<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sindney</title>
	<atom:link href="http://sindney.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://sindney.com/blog</link>
	<description>Crazy shi* starts with single steps</description>
	<lastBuildDate>Sun, 21 Apr 2013 14:54:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Hello GLSL</title>
		<link>http://sindney.com/blog/posts/hello-glsl/</link>
		<comments>http://sindney.com/blog/posts/hello-glsl/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 14:54:46 +0000</pubDate>
		<dc:creator>sindney</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Chinese]]></category>
		<category><![CDATA[CPP]]></category>

		<guid isPermaLink="false">http://sindney.com/blog/?p=398</guid>
		<description><![CDATA[<p>关于GLSL在GLFW里的使用(windows平台，使用mingw)，我们的目标是使用着色器：</p> // vertex void main() { gl_Position = gl_Vertex; } //fragment void main(void) { gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); } <p>来绘制一个蓝色的矩形。</p> <p>由于sf里的GLEW编译好的版本是vc的，所以要用mingw自己再编译下。</p> <p>然后我们的main.cpp</p> #include &#60;GL/glew.h&#62; #include &#60;GL/glfw.h&#62; #include &#60;stdlib.h&#62; #include &#60;iostream&#62; #include &#60;fstream&#62; unsigned int shader_id; unsigned int shader_vp; unsigned int shader_fp; char* textFileRead(const char *fileName) { char* text; if (fileName != NULL) { [...]]]></description>
				<content:encoded><![CDATA[<p>关于GLSL在GLFW里的使用(windows平台，使用mingw)，我们的目标是使用着色器：</p>
<pre class="brush: c; gutter: true; first-line: 1">// vertex
void main()
{
    gl_Position = gl_Vertex;
}
//fragment
void main(void)
{
    gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
}</pre>
<p>来绘制一个蓝色的矩形。</p>
<p>由于sf里的GLEW编译好的版本是vc的，所以要用mingw自己再编译下。</p>
<p>然后我们的main.cpp</p>
<pre class="brush: c; gutter: true; first-line: 1">#include &lt;GL/glew.h&gt;
#include &lt;GL/glfw.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;iostream&gt;
#include &lt;fstream&gt;

unsigned int shader_id;
unsigned int shader_vp;
unsigned int shader_fp;

char* textFileRead(const char *fileName) 
{
    char* text;
    if (fileName != NULL) {
        FILE *file = fopen(fileName, "rt");
        if (file != NULL) {
            fseek(file, 0, SEEK_END);
            int count = ftell(file);
            rewind(file);
            if (count &gt; 0) {
                text = (char*)malloc(sizeof(char) * (count + 1));
                count = fread(text, sizeof(char), count, file);
                text[count] = '\0';
            }
            fclose(file);
        }
    }
    return text;
}

void createShader(const char *vsFile, const char *fsFile)
{
    shader_vp = glCreateShader(GL_VERTEX_SHADER);
    shader_fp = glCreateShader(GL_FRAGMENT_SHADER);

    const char *vsText = textFileRead(vsFile);
    const char *fsText = textFileRead(fsFile);

    glShaderSource(shader_vp, 1, &amp;vsText, 0);
    glShaderSource(shader_fp, 1, &amp;fsText, 0);

    glCompileShader(shader_vp);
    glCompileShader(shader_fp);

    shader_id = glCreateProgram();
    glAttachShader(shader_id, shader_fp);
    glAttachShader(shader_id, shader_vp);
    glLinkProgram(shader_id);
}

void freeShader()
{
	glDetachShader(shader_id, shader_fp);
    glDetachShader(shader_id, shader_vp);
    glDeleteShader(shader_fp);
    glDeleteShader(shader_vp);
    glDeleteShader(shader_id);
}

int main(void)
{
	int running = GL_TRUE;
	// Initialize GLFW
	if(!glfwInit()) exit(EXIT_FAILURE);
	// Setup OpenGL window properties
	glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE);
	// Open an OpenGL window
	if(!glfwOpenWindow(800,600,0,0,0,0,0,0,GLFW_WINDOW))
	{
		glfwTerminate();
		exit(EXIT_FAILURE);
	}
	glfwSetWindowTitle("Hello GLFW &amp; GLSL");
	// Init GLEW
	if(glewInit() != GLEW_OK) exit(EXIT_FAILURE);
	// Create Shader
	createShader("shader.vert", "shader.frag");
	// Main loop
	while(running)
	{
		// OpenGL rendering goes here...
		glClear(GL_COLOR_BUFFER_BIT);
		glShadeModel(GL_SMOOTH);
		glEnable(GL_CULL_FACE);
		glCullFace(GL_BACK);
		// Bind shader
		glUseProgram(shader_id);
		glBegin(GL_QUADS);
			glVertex2f(-0.5f, -0.5f);
			glVertex2f( 0.5f, -0.5f);
			glVertex2f( 0.5f,  0.5f);
			glVertex2f(-0.5f,  0.5f);
		glEnd();
		// Unbind shader
		glUseProgram(0);
		// Swap front and back rendering buffers
		glfwSwapBuffers();
		// Check if ESC key was pressed or window was closed
		running = !glfwGetKey(GLFW_KEY_ESC) &amp;&amp; glfwGetWindowParam(GLFW_OPENED);
	}
	// Close window and terminate GLFW
	glfwTerminate();
	// Free Shader
	freeShader();
	// Exit program
	exit(EXIT_SUCCESS);
}</pre>
<p>最后包含GLFW，GLEW(已用gcc编译好了)的打包在<a href="http://sindney.com/dl/Hello_GLFW_GLEW_GLSL.rar">这里</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://sindney.com/blog/posts/hello-glsl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nest3D 新的计划</title>
		<link>http://sindney.com/blog/posts/nest3d-future/</link>
		<comments>http://sindney.com/blog/posts/nest3d-future/#comments</comments>
		<pubDate>Tue, 19 Mar 2013 14:15:23 +0000</pubDate>
		<dc:creator>sindney</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Chinese]]></category>

		<guid isPermaLink="false">http://sindney.com/blog/?p=393</guid>
		<description><![CDATA[<p>前些日子一直想给引擎实现骨骼动画支持，当时选择md5作为解析模型目标，然后找到不少资料加上gara的例子，很快有了进展。</p> <p>但最后发现md5解析没问题，但是得到目标骨骼动画逻辑数据的部分，如果按md5的逻辑实现的话，会破坏已有的骨骼动画抽象部分，不利于骨骼动画部分通用。我们打算取消md5模型的解析计划，准备转向现在更“流行”的collada格式，看起来很不错，应用也比较广泛。不过在开始实现前，我打算将引擎mesh的geometry部分再重新修改下，取消之前的vertex,triangle类抽象，将其改为简单的数组来存储：triangleIndices，vertexPositions，vertexNormals，vertexTangents，vertexBinormals，uvs，uvIndices。可以提高数据向VertexBuffer3D/IndexBuffer3D上传时的cpu消耗，使引擎效率更高。</p> <p>这样，下一版本也就是1.4.2的发布版，会是geometry修改的效率提高版。</p> <p>而collada解析的支持会在1.4.2之后的发布版中实现。</p> <p>关注nest3d的朋友，在这里向大家倒个歉 T.T 引擎的更新一直比较慢。并且由于时间原因而且一些技术我们也是现学现用，所以开发效率比较低，不过为了引擎更加完美，我认为这些等待都是值得的 </p> <p>good day</p>]]></description>
				<content:encoded><![CDATA[<p>前些日子一直想给引擎实现骨骼动画支持，当时选择md5作为解析模型目标，然后找到不少资料加上gara的例子，很快有了进展。</p>
<p>但最后发现md5解析没问题，但是得到目标骨骼动画逻辑数据的部分，如果按md5的逻辑实现的话，会破坏已有的骨骼动画抽象部分，不利于骨骼动画部分通用。我们打算取消md5模型的解析计划，准备转向现在更“流行”的collada格式，看起来很不错，应用也比较广泛。不过在开始实现前，我打算将引擎mesh的geometry部分再重新修改下，取消之前的vertex,triangle类抽象，将其改为简单的数组来存储：triangleIndices，vertexPositions，vertexNormals，vertexTangents，vertexBinormals，uvs，uvIndices。可以提高数据向VertexBuffer3D/IndexBuffer3D上传时的cpu消耗，使引擎效率更高。</p>
<p>这样，下一版本也就是1.4.2的发布版，会是geometry修改的效率提高版。</p>
<p>而collada解析的支持会在1.4.2之后的发布版中实现。</p>
<p>关注nest3d的朋友，在这里向大家倒个歉 T.T 引擎的更新一直比较慢。并且由于时间原因而且一些技术我们也是现学现用，所以开发效率比较低，不过为了引擎更加完美，我认为这些等待都是值得的 <img src='http://sindney.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>good day</p>
]]></content:encoded>
			<wfw:commentRss>http://sindney.com/blog/posts/nest3d-future/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nest3D 1.4 发布</title>
		<link>http://sindney.com/blog/posts/nest3d-1-4-cn/</link>
		<comments>http://sindney.com/blog/posts/nest3d-1-4-cn/#comments</comments>
		<pubDate>Sun, 03 Feb 2013 02:36:02 +0000</pubDate>
		<dc:creator>sindney</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Chinese]]></category>

		<guid isPermaLink="false">http://sindney.com/blog/?p=388</guid>
		<description><![CDATA[<p>你好，我非常荣幸向大家介绍<a href="https://github.com/sindney/Nest3D">nest3d</a>的最新版本.</p> <p>你也许想先看些 <a href="http://sindney.com/project/nest3d/">demo</a> 吧 还有他们的 <a href="https://github.com/sindney/Nest3D/tree/master/examples">source</a>.</p> <p>在这个发行版里，我们引进一个新的非常灵活的 <a href="https://github.com/sindney/Nest3D/tree/master/src/nest/view/process">渲染流程</a> 的设计。</p> process0 = new ContainerProcess(camera1, container0); process0.meshProcess = new BasicMeshProcess(camera1); process0.color = 0xff000000; process1 = new ContainerProcess(camera, container1); process1.meshProcess = new BasicMeshProcess(camera); process1.color = 0xffffffff; view.processes.push(process0, process1); <p>我们可以很容易实现RTT(Render To Texture)效果。</p> process0.renderTarget.texture = material.diffuse.texture; <p>也很容易添加后期处理效果。</p> process0 = new ContainerProcess(camera, container); process0.meshProcess = new BasicMeshProcess(camera); process0.color = 0xff000000; var effect:RadialBlur [...]]]></description>
				<content:encoded><![CDATA[<p>你好，我非常荣幸向大家介绍<a href="https://github.com/sindney/Nest3D">nest3d</a>的最新版本.</p>
<p>你也许想先看些 <a href="http://sindney.com/project/nest3d/">demo</a> 吧 <img src='http://sindney.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  还有他们的 <a href="https://github.com/sindney/Nest3D/tree/master/examples">source</a>.</p>
<p>在这个发行版里，我们引进一个新的非常灵活的 <a href="https://github.com/sindney/Nest3D/tree/master/src/nest/view/process">渲染流程</a> 的设计。</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">process0 = new ContainerProcess(camera1, container0);
process0.meshProcess = new BasicMeshProcess(camera1);
process0.color = 0xff000000;

process1 = new ContainerProcess(camera, container1);
process1.meshProcess = new BasicMeshProcess(camera);
process1.color = 0xffffffff;

view.processes.push(process0, process1);</pre>
<p>我们可以很容易实现RTT(Render To Texture)效果。</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">process0.renderTarget.texture = material.diffuse.texture;</pre>
<p>也很容易添加后期处理效果。</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">process0 = new ContainerProcess(camera, container);
process0.meshProcess = new BasicMeshProcess(camera);
process0.color = 0xff000000;

var effect:RadialBlur = new RadialBlur(256, 256, 1, 10);
effect.comply();

view.processes.push(process0, effect);</pre>
<p>我们还改进了动画部分的设计，让其变得更容易使用&amp;理解&amp;创造。</p>
<p>我们有四种内置的动画关键帧，当然了，你一可以很容易由内置的interface来创造出你的关键帧。</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">// 这个例子，我们学习手动建立存放TransformKeyFrame列表的AnimationTrack。
var track:AnimationTrack = new AnimationTrack();
// 首先，我们给modifier赋值，这非常重要。
track.modifier = new TransformModifier();
// 我们将此track开始的时间改为1，相当于一个延迟效果。
track.start = 1;

mesh.tracks = new Vector.();
mesh.tracks.push(track);

// 新建关键帧，我们可以设置时间，所进行的变换（位置，旋转，缩放），然后将其加入到track中。
var keyFrame:TransformKeyFrame = new TransformKeyFrame();
keyFrame.time = 0;
keyFrame.position.x = 0;
keyFrame.scale.setTo(1, 1, 1);
track.addChild(keyFrame);

keyFrame = new TransformKeyFrame();
keyFrame.time = 1;
keyFrame.position.x = 100;
keyFrame.scale.setTo(1, 10, 1);
track.addChild(keyFrame);

keyFrame = new TransformKeyFrame();
keyFrame.time = 3;
keyFrame.position.x = -100;
keyFrame.scale.setTo(1, 10, 1);
track.addChild(keyFrame);

keyFrame = new TransformKeyFrame();
keyFrame.time = 4;
keyFrame.position.x = 0;
keyFrame.scale.setTo(1, 1, 1);
track.addChild(keyFrame);

// 最后，连接到我们的控制器就行了。
anim_controller = new AnimationController();
anim_controller.objects.push(mesh);
anim_controller.loops = int.MAX_VALUE;
anim_controller.restart();</pre>
<p>还有更多的特性，赶快去看看吧 <img src='http://sindney.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://sindney.com/blog/posts/nest3d-1-4-cn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nest3d 1.4 Released</title>
		<link>http://sindney.com/blog/posts/nest3d-1-4/</link>
		<comments>http://sindney.com/blog/posts/nest3d-1-4/#comments</comments>
		<pubDate>Sun, 03 Feb 2013 02:30:03 +0000</pubDate>
		<dc:creator>sindney</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[As3]]></category>

		<guid isPermaLink="false">http://sindney.com/blog/?p=386</guid>
		<description><![CDATA[<p>Hey all, i&#8217;m glad to announce the new release of <a href="https://github.com/sindney/Nest3D">nest3d</a>.</p> <p>You may want to check out some <a href="http://sindney.com/project/nest3d/">demos</a> first And feel free to grab it&#8217;s <a href="https://github.com/sindney/Nest3D/tree/master/examples">source</a>.</p> <p>In this release, we introduced a new design of <a href="https://github.com/sindney/Nest3D/tree/master/src/nest/view/process">render pipeline</a> which is flexible.</p> process0 = new ContainerProcess(camera1, container0); process0.meshProcess = new BasicMeshProcess(camera1); process0.color = 0xff000000; [...]]]></description>
				<content:encoded><![CDATA[<p>Hey all, i&#8217;m glad to announce the new release of <a href="https://github.com/sindney/Nest3D">nest3d</a>.</p>
<p>You may want to check out some <a href="http://sindney.com/project/nest3d/">demos</a> first <img src='http://sindney.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  And feel free to grab it&#8217;s <a href="https://github.com/sindney/Nest3D/tree/master/examples">source</a>.</p>
<p>In this release, we introduced a new design of <a href="https://github.com/sindney/Nest3D/tree/master/src/nest/view/process">render pipeline</a> which is flexible.</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">process0 = new ContainerProcess(camera1, container0);
process0.meshProcess = new BasicMeshProcess(camera1);
process0.color = 0xff000000;

process1 = new ContainerProcess(camera, container1);
process1.meshProcess = new BasicMeshProcess(camera);
process1.color = 0xffffffff;

view.processes.push(process0, process1);</pre>
<p>We can easily achieve RTT effect with it.</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">process0.renderTarget.texture = material.diffuse.texture;</pre>
<p>It&#8217;s easy to add post effects too.</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">process0 = new ContainerProcess(camera, container);
process0.meshProcess = new BasicMeshProcess(camera);
process0.color = 0xff000000;

var effect:RadialBlur = new RadialBlur(256, 256, 1, 10);
effect.comply();

view.processes.push(process0, effect);</pre>
<p>We&#8217;v improved animation part of our engine. Which makes it easy to use &amp; understand &amp; create.</p>
<p>We have 4 kind of animation keyframe in nest3d. Of course with the interface, you can easily create your own keyframes.</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">// Here, we'll learn to create an AnimationTrack that stores TransformKeyFrames.
var track:AnimationTrack = new AnimationTrack();
// First, we value it's modifier, it important.
track.modifier = new TransformModifier();
// We set track's start time to 1.
track.start = 1;

mesh.tracks = new Vector.&lt;AnimationTrack&gt;();
mesh.tracks.push(track);

// We create a new KeyFrame, then we can set it's time, position, rotation, scale value. Then we push it to our track.
var keyFrame:TransformKeyFrame = new TransformKeyFrame();
keyFrame.time = 0;
keyFrame.position.x = 0;
keyFrame.scale.setTo(1, 1, 1);
track.addChild(keyFrame);

keyFrame = new TransformKeyFrame();
keyFrame.time = 1;
keyFrame.position.x = 100;
keyFrame.scale.setTo(1, 10, 1);
track.addChild(keyFrame);

keyFrame = new TransformKeyFrame();
keyFrame.time = 3;
keyFrame.position.x = -100;
keyFrame.scale.setTo(1, 10, 1);
track.addChild(keyFrame);

keyFrame = new TransformKeyFrame();
keyFrame.time = 4;
keyFrame.position.x = 0;
keyFrame.scale.setTo(1, 1, 1);
track.addChild(keyFrame);

// At last, just link the mesh to our controller and we are done <img src='http://sindney.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> 
anim_controller = new AnimationController();
anim_controller.objects.push(mesh);
anim_controller.loops = int.MAX_VALUE;
anim_controller.restart();</pre>
<p>And there&#8217;s still more features, go and check it out <img src='http://sindney.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://sindney.com/blog/posts/nest3d-1-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ImageBox 1.1</title>
		<link>http://sindney.com/blog/posts/imagebox-1-1/</link>
		<comments>http://sindney.com/blog/posts/imagebox-1-1/#comments</comments>
		<pubDate>Sun, 25 Nov 2012 08:14:34 +0000</pubDate>
		<dc:creator>sindney</dc:creator>
				<category><![CDATA[CPP]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://sindney.com/blog/?p=375</guid>
		<description><![CDATA[<p>ImageBox is a batch image file converter.</p> <p>With the help of <a href="http://freeimage.sourceforge.net">FreeImage</a> library.</p> <p>He can transform jpg,png,bmp,tga,tif files with specific scale value.</p> <p></p> <p><a href="http://sindney.com/software/imagebox/">http://sindney.com/software/imagebox/</a></p>]]></description>
				<content:encoded><![CDATA[<p>ImageBox is a batch image file converter.</p>
<p>With the help of <a href="http://freeimage.sourceforge.net">FreeImage</a> library.</p>
<p>He can transform jpg,png,bmp,tga,tif files with specific scale value.</p>
<p><img class="alignnone" title="ImageBox" src="http://sindney.com/software/imagebox/imagebox.jpg" alt="" width="700" height="400" /></p>
<p><a href="http://sindney.com/software/imagebox/">http://sindney.com/software/imagebox/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sindney.com/blog/posts/imagebox-1-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>顶点数据（MeshData）</title>
		<link>http://sindney.com/blog/posts/meshdata-and-materia/</link>
		<comments>http://sindney.com/blog/posts/meshdata-and-materia/#comments</comments>
		<pubDate>Sun, 02 Sep 2012 10:28:26 +0000</pubDate>
		<dc:creator>skyfeiyun</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Chinese]]></category>

		<guid isPermaLink="false">http://sindney.com/blog/?p=366</guid>
		<description><![CDATA[<p>我们在设计Nest3D的渲染结构的时候，使用了比较轻巧灵活的结构，对于每个可以渲染的IMesh物体，都有data和material两个属性，其中data中存储着MeshData类型的模型顶点、uv、法线、三角形索引等信息，而material中则存储着贴图，光照等信息，你可以这样初始化一个红色的立方体：</p> var data:MeshData=PrimitiveFactory.createBox(100,100,100); var material:ColorMaterial=new ColorMaterial(0xff0000); material.update(); var cube:Mesh=new Mesh(data,material); <p>这样设计的一个好处就是，不同物体之间可以共享顶点信息或者材质信息，而Mesh只是引用这些数据，并将这些模型数据应用上自己的变换矩阵，因此，如果您需要创建1000个红色立方体，只需要这样：</p> var data:MeshData=PrimitiveFactory.createBox(100,100,100); var material:ColorMaterial=new ColorMaterial(0xff0000); material.update(); var cube:Mesh; for(var i:int=0;i&#60;1000；i++){ cube=new Mesh(data,material); } <p>所有物体均引用同一组顶点数据和材质数据，因此每个物体的创建只需要很少的额外的内存占用。</p> <p>那么如何通过程序创建一些基本物体呢？比如立方体，平面等等？很简单，我们提供了一个工厂类PrimitiveFactory，使用这个类可以创建各种您所需要的基本体，比如说立方体，平面和球。</p> <p>除了一些最基本的物体外，PrimitiveFactory还提供了放样建模（Loft）和旋转建模（Revolution）的功能，使用过3D编辑软件的同学就应该知道这两个建模功能在制作模型时使用得何等便利。在这里，你可以通过提供一个3D物体的截面图使用旋转建模功能（createPrimitiveByRevolution）建立一个任意形状的3D物体，也可以提供一个3D物体的横断面，并提供扫略的路径，使用放样建模函数（createPrimitiveByLoft）通过程序动态建模:)</p>]]></description>
				<content:encoded><![CDATA[<p>我们在设计Nest3D的渲染结构的时候，使用了比较轻巧灵活的结构，对于每个可以渲染的IMesh物体，都有data和material两个属性，其中data中存储着MeshData类型的模型顶点、uv、法线、三角形索引等信息，而material中则存储着贴图，光照等信息，你可以这样初始化一个红色的立方体：</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">var data:MeshData=PrimitiveFactory.createBox(100,100,100);
var material:ColorMaterial=new ColorMaterial(0xff0000);
material.update();
var cube:Mesh=new Mesh(data,material);</pre>
<p>这样设计的一个好处就是，不同物体之间可以共享顶点信息或者材质信息，而Mesh只是引用这些数据，并将这些模型数据应用上自己的变换矩阵，因此，如果您需要创建1000个红色立方体，只需要这样：</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">var data:MeshData=PrimitiveFactory.createBox(100,100,100);
var material:ColorMaterial=new ColorMaterial(0xff0000);
material.update();
var cube:Mesh;
for(var i:int=0;i&lt;1000；i++){
    cube=new Mesh(data,material);
}</pre>
<p>所有物体均引用同一组顶点数据和材质数据，因此每个物体的创建只需要很少的额外的内存占用。</p>
<p>那么如何通过程序创建一些基本物体呢？比如立方体，平面等等？很简单，我们提供了一个工厂类PrimitiveFactory，使用这个类可以创建各种您所需要的基本体，比如说立方体，平面和球。</p>
<p>除了一些最基本的物体外，PrimitiveFactory还提供了<strong>放样建模（Loft）</strong>和<strong>旋转建模（Revolution）</strong>的功能，使用过3D编辑软件的同学就应该知道这两个建模功能在制作模型时使用得何等便利。在这里，你可以通过提供一个3D物体的截面图使用旋转建模功能（<strong>createPrimitiveByRevolution</strong>）建立一个任意形状的3D物体，也可以提供一个3D物体的横断面，并提供扫略的路径，使用放样建模函数（<strong>createPrimitiveByLoft</strong>）通过程序动态建模:)</p>
]]></content:encoded>
			<wfw:commentRss>http://sindney.com/blog/posts/meshdata-and-materia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>透明及半透明物体的处理</title>
		<link>http://sindney.com/blog/posts/alphatest-cn/</link>
		<comments>http://sindney.com/blog/posts/alphatest-cn/#comments</comments>
		<pubDate>Tue, 28 Aug 2012 05:18:13 +0000</pubDate>
		<dc:creator>skyfeiyun</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Chinese]]></category>

		<guid isPermaLink="false">http://sindney.com/blog/?p=357</guid>
		<description><![CDATA[<p>全透明贴图的处理</p> <p>在3D场景中，经常会用到具有透明部分的物体以及具有半透明部分的物体，在这个部分，Nest3D也提供了方便的实现，如果您需要的是树叶这样的应用（贴图的一部分完全透明），那么不需要任何额外的操作，您即可得到正确的透明效果。</p> <p>全透明排序如何工作?</p> <p>透明排序的工作原理非常简单，并且易于控制，material.kill:Number这个属性即是用于正确的贴图处理，这里，我们使用alphaTest的方式通过AGAL代码提供像素级的精确全透明物体遮挡处理，kill属性介于0~1之间，表示一个阈值，当贴图某一部分的alpha值低于这个阈值时，它将被当做全透明像素而不会绘制，当kill为1时，任何alpha值小于1（非完全不透明物体）均会被当做完全透明的像素处理。</p> <p>更进一步，半透明物体</p> <p>有时候，您可能需要使用一个半透明的贴图，并且希望贴图能够与其他物体之间的混合达到较为完美的效果，这时候全透明像素的处理方式就不能够再使用了，相比一些其他引擎无法支持这样的应用场景，Nest3D同样提供了一个解决方案，首先，将需要做半透明处理的物体的kill参数设置为0（相当于关闭全透明处理），并将mesh:alphaTest属性设置为true（打开半透明测试），同时，使用AlphaManager作为场景渲染器替换BasicaManager：</p> EngineBase.manager = new AlphaManager(); mesh.alphaTest=true; <p>在这里，我们提供了高效的物体级alpha快速排序，从而基本解决了半透明效果的处理，但请注意，当两个半透明物体出现重叠相交情况的时候，半透明处理可能会导致错误的结果，如果有更好的处理方案，也欢迎大家留言告诉我们:)</p>]]></description>
				<content:encoded><![CDATA[<p><strong>全透明贴图的处理</strong></p>
<p>在3D场景中，经常会用到具有透明部分的物体以及具有半透明部分的物体，在这个部分，Nest3D也提供了方便的实现，如果您需要的是树叶这样的应用（贴图的一部分完全透明），那么不需要任何额外的操作，您即可得到正确的透明效果。</p>
<p><strong>全透明排序如何工作?</strong></p>
<p>透明排序的工作原理非常简单，并且易于控制，material.kill:Number这个属性即是用于正确的贴图处理，这里，我们使用alphaTest的方式通过AGAL代码提供像素级的精确全透明物体遮挡处理，kill属性介于0~1之间，表示一个阈值，当贴图某一部分的alpha值低于这个阈值时，它将被当做全透明像素而不会绘制，当kill为1时，任何alpha值小于1（非完全不透明物体）均会被当做完全透明的像素处理。</p>
<p><strong>更进一步，半透明物体</strong></p>
<p>有时候，您可能需要使用一个半透明的贴图，并且希望贴图能够与其他物体之间的混合达到较为完美的效果，这时候全透明像素的处理方式就不能够再使用了，相比一些其他引擎无法支持这样的应用场景，Nest3D同样提供了一个解决方案，首先，将需要做半透明处理的物体的kill参数设置为0（相当于关闭全透明处理），并将mesh:alphaTest属性设置为true（打开半透明测试），同时，使用AlphaManager作为场景渲染器替换BasicaManager：</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">EngineBase.manager =  new AlphaManager();
mesh.alphaTest=true;</pre>
<p>在这里，我们提供了高效的物体级alpha快速排序，从而基本解决了半透明效果的处理，但请注意，当两个半透明物体出现重叠相交情况的时候，半透明处理可能会导致错误的结果，如果有更好的处理方案，也欢迎大家留言告诉我们:)</p>
]]></content:encoded>
			<wfw:commentRss>http://sindney.com/blog/posts/alphatest-cn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting start with nest3d</title>
		<link>http://sindney.com/blog/posts/intro-nest3d-en/</link>
		<comments>http://sindney.com/blog/posts/intro-nest3d-en/#comments</comments>
		<pubDate>Mon, 27 Aug 2012 11:15:15 +0000</pubDate>
		<dc:creator>sindney</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[As3]]></category>

		<guid isPermaLink="false">http://sindney.com/blog/?p=346</guid>
		<description><![CDATA[<p>Hi, i&#8217;d like to show you how to initialize the engine.</p> <p>Make sure your version is 1.3，go and download it <a href="https://github.com/sindney/Nest3D/zipball/1.3">here</a>。</p> <p>And make sure your build target is greater than flash player 11.3</p> private var controller:CameraController; <p>CameraController is the bridge from user to the camera，he controls camera with mouse&#38;keyboard events，his keyboard event stores data to [...]]]></description>
				<content:encoded><![CDATA[<p>Hi, i&#8217;d like to show you how to initialize the engine.</p>
<p>Make sure your version is 1.3，go and download it <a href="https://github.com/sindney/Nest3D/zipball/1.3">here</a>。</p>
<p>And make sure your build target is greater than flash player 11.3</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">private var controller:CameraController;</pre>
<p>CameraController is the bridge from user to the camera，he controls camera with mouse&amp;keyboard events，his keyboard event stores data to a public array，so you can easily listen your own keyboard event as well.</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">public function HelloWorld() {
	stage.scaleMode = StageScaleMode.NO_SCALE;
	stage.align = StageAlign.TOP_LEFT;
	stage.frameRate = 60;

	EngineBase.stage = stage;
	EngineBase.stage3d = stage.stage3Ds[0];
	EngineBase.camera = new Camera3D();
	EngineBase.root = new Container3D();
	EngineBase.manager = new BasicManager();
	EngineBase.view = new ViewPort(800, 600);
	EngineBase.view.culling = new BasicCulling();
	addChild(EngineBase.view.diagram);

	controller = new CameraController();
	controller.mouseEnabled = true;
	controller.keyboardEnabled = true;
	controller.speed = 10;

	EngineBase.view.addEventListener(Event.CONTEXT3D_CREATE, onContext3DCreated);
}</pre>
<p>Let&#8217;s have a look at demo&#8217;s constructor. In order to initialize the engine, you&#8217;ll need to value those static methods in nest.control.EngineBase, then listen viewPort&#8217;s Context3D_Create event to initialize your 3d scene. Make sure you initialized the engine first then your scene.</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">private function onContext3DCreated(e:Event):void {
	stage.addEventListener(Event.RESIZE, onResize);
	stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);

	var data:MeshData = PrimitiveFactory.createBox();
	var material:ColorMaterial = new ColorMaterial(0xffffff);
	material.light = new AmbientLight();
	material.light.next = new DirectionalLight(0xffffff, -1, -1);
	material.update();

	var mesh:Mesh = new Mesh(data, material);
	EngineBase.root.addChild(mesh);

	EngineBase.camera.position.z = -200;
	EngineBase.camera.changed = true;
}</pre>
<p>Then we create our 3d scene.</p>
<p>We start from creating a colored box.</p>
<p>First, we need mesh&#8217;s vertex, triangle, uv &#8230; data, they are stored in MeshData.</p>
<p>Your can create one with PrimitiveFactory or you can generate one from nest.control.parsers.*</p>
<p>Then we dress our mesh with ColorMaterial, and we can setup material&#8217;s lights.</p>
<p>Material&#8217;s light is a linked list. The first one is an AmbientLight. And be aware of fragment constant&#8217;s limitions. Check n3d&#8217;s API for more help.</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">private function onEnterFrame(e:Event):void {
	controller.update();
	EngineBase.view.calculate();
}</pre>
<p>Finally we update our controller&amp;view and we are done! Enjoy!</p>
<p><a href="https://github.com/sindney/Nest3D/blob/master/examples/HelloWorld.as">Code</a><br />
<a href="https://github.com/sindney/Nest3D/raw/master/examples/HeadDemo.swf">Demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sindney.com/blog/posts/intro-nest3d-en/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>给Mesh穿上衣服</title>
		<link>http://sindney.com/blog/posts/dress-up-mesh-cn/</link>
		<comments>http://sindney.com/blog/posts/dress-up-mesh-cn/#comments</comments>
		<pubDate>Sun, 26 Aug 2012 08:49:27 +0000</pubDate>
		<dc:creator>sindney</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Chinese]]></category>

		<guid isPermaLink="false">http://sindney.com/blog/?p=341</guid>
		<description><![CDATA[<p>本节，我向大家介绍Mesh的衣服，Material。</p> <p>所有的材质集中在nest.view.materials.* 包下，包含：</p> <p>ColorMateiral, TextureMaterial, EnvMapMaterial, SkyBoxMaterial, LightmapMaterial, MovieMaterial</p> public function ColorMaterial(color:uint = 0xffffff, alpha:Number = 1) { <p>你只要提供你需要的颜色和透明度即可</p> <p>注意透明度要在场景里起作用，你得设置mesh的混合模式，并更换场景的Manager为AlphaManager进行透明排序，记得打开mesh.alphaTest参数，具体我会在以后的章节里提到。</p> <p>一般材质都提供光照，你可以通过material.light进行设置</p> <p>当你设置好你的材质后，需要调用material.update()函数来更新生成正确的供stage3d使用的资源。</p> public function TextureMaterial(diffuse:BitmapData, specular:BitmapData = null, glossiness:int = 10, normalmap:BitmapData = null) { <p>必须提供diffuse图像，然后specular和normalmap是可选项，glossiness是specular的参数。</p> <p>还有material.kill:Number选项，使用agal代码kill进行像素剔除，而material.kill的值就是到时候像素的透明度分量要减去的值（当kill后的参数小于零，像素就被剔除）</p> public function EnvMapMaterial(cubicmap:Vector.&#60;BitmapData&#62;, reflectivity:Number, diffuse:BitmapData, specular:BitmapData = null, glossiness:int = 10, normalmap:BitmapData = null) { <p>必须提供cubicmap（就是环境的六个面），和diffuse贴图，继承于TextureMaterial，reflectivity控制环境图和diffuse图所占的比例，应在1-0之间。</p> public function SkyBoxMaterial(cubicmap:Vector.&#60;BitmapData&#62;) [...]]]></description>
				<content:encoded><![CDATA[<p>本节，我向大家介绍Mesh的衣服，Material。</p>
<p>所有的材质集中在nest.view.materials.* 包下，包含：</p>
<p>ColorMateiral, TextureMaterial, EnvMapMaterial, SkyBoxMaterial, LightmapMaterial, MovieMaterial</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">public function ColorMaterial(color:uint = 0xffffff, alpha:Number = 1) {</pre>
<p>你只要提供你需要的颜色和透明度即可</p>
<p>注意透明度要在场景里起作用，你得设置mesh的混合模式，并更换场景的Manager为AlphaManager进行透明排序，记得打开mesh.alphaTest参数，具体我会在以后的章节里提到。</p>
<p>一般材质都提供光照，你可以通过material.light进行设置</p>
<p>当你设置好你的材质后，需要调用material.update()函数来更新生成正确的供stage3d使用的资源。</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">public function TextureMaterial(diffuse:BitmapData, specular:BitmapData = null, glossiness:int = 10, normalmap:BitmapData = null) {</pre>
<p>必须提供diffuse图像，然后specular和normalmap是可选项，glossiness是specular的参数。</p>
<p>还有material.kill:Number选项，使用agal代码kill进行像素剔除，而material.kill的值就是到时候像素的透明度分量要减去的值（当kill后的参数小于零，像素就被剔除）</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">public function EnvMapMaterial(cubicmap:Vector.&lt;BitmapData&gt;, reflectivity:Number, diffuse:BitmapData, specular:BitmapData = null, glossiness:int = 10, normalmap:BitmapData = null) {</pre>
<p>必须提供cubicmap（就是环境的六个面），和diffuse贴图，继承于TextureMaterial，reflectivity控制环境图和diffuse图所占的比例，应在1-0之间。</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">public function SkyBoxMaterial(cubicmap:Vector.&lt;BitmapData&gt;) {</pre>
<p>这是SkyBox对象专用的贴图，传入6张天空图即可。</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">public function LightMapMaterial(lightmap:BitmapData, diffuse:BitmapData, specular:BitmapData = null, glossiness:int = 10, normalmap:BitmapData = null) {</pre>
<p>传入lightmap和diffuse，到时渲染会将lightmap和结果叠加，常用于渲染预先烘培的阴影效果等。</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">public function MovieMaterial(specular:BitmapData = null, glossiness:int = 10) {</pre>
<p>通过material.frames传入序列位图，用material.frames控制当前帧的图像。</p>
<p>有</p>
<pre class="brush: actionscript3; gutter: true; first-line: 1">getFramesFromMovieClip(source:MovieClip, width:Number = 100, height:Number = 100):Vector.&lt;BitmapData&gt;
getFramesFromSpriteSheet(source:BitmapData, tileWidth:Number = 100, tileHeight:Number = 100, startIndex:int = 0, endIndex:int = int.MAX_VALUE):Vector.&lt;BitmapData&gt;</pre>
<p>方法来生成位图数组。</p>
<p>最后，你会注意到还有TextureResource和CubeTextureResource类，他们是用来存储位图信息的，并生成能让stage3d使用的对象。</p>
]]></content:encoded>
			<wfw:commentRss>http://sindney.com/blog/posts/dress-up-mesh-cn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>让Mesh动起来</title>
		<link>http://sindney.com/blog/posts/make-mesh-move-cn/</link>
		<comments>http://sindney.com/blog/posts/make-mesh-move-cn/#comments</comments>
		<pubDate>Sun, 26 Aug 2012 08:24:42 +0000</pubDate>
		<dc:creator>sindney</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Chinese]]></category>

		<guid isPermaLink="false">http://sindney.com/blog/?p=338</guid>
		<description><![CDATA[<p>这一节，我为大家介绍对Mesh的控制。</p> <p>Mesh继承于Object3D，实现了IMesh接口。</p> <p>用户可以用它来显示物体，对物体进行控制。</p> <p>基本控制：</p> <p>mesh.position:Vector3D</p> <p>mesh.rotation:Vector3D</p> <p>mesh.scale:Vector3D</p> <p>用这些进行基本移动旋转缩放，然后可以用 mesh.orientation 来设置旋转的存储方式。</p> <p>包含 轴角，四元数，欧拉角三种方式。</p> <p>我们还提供了nest.object.geom.Quaternion 静态类提供四元数的基本操作。</p> <p>当你修改了上面信息后，你可以标记mesh.changed = true，让mesh在渲染的时候再把这些信息写到矩阵里，或者用mesh.recompose()来立即写入。</p> <p>你也可以通过mesh.matrix:Matrix3D来控制Mesh的变换。</p> <p>mesh.worldMatix, invertWorldMatrix, invertMatrix都是用来运算的，再每一帧都会更新。</p> <p>Mesh还提供了translate()方法，让mesh按指定轴进行平移。</p>]]></description>
				<content:encoded><![CDATA[<p>这一节，我为大家介绍对Mesh的控制。</p>
<p>Mesh继承于Object3D，实现了IMesh接口。</p>
<p>用户可以用它来显示物体，对物体进行控制。</p>
<p>基本控制：</p>
<p>mesh.position:Vector3D</p>
<p>mesh.rotation:Vector3D</p>
<p>mesh.scale:Vector3D</p>
<p>用这些进行基本移动旋转缩放，然后可以用 mesh.orientation 来设置旋转的存储方式。</p>
<p>包含 轴角，四元数，欧拉角三种方式。</p>
<p>我们还提供了nest.object.geom.Quaternion 静态类提供四元数的基本操作。</p>
<p>当你修改了上面信息后，你可以标记mesh.changed = true，让mesh在渲染的时候再把这些信息写到矩阵里，或者用mesh.recompose()来立即写入。</p>
<p>你也可以通过mesh.matrix:Matrix3D来控制Mesh的变换。</p>
<p>mesh.worldMatix, invertWorldMatrix, invertMatrix都是用来运算的，再每一帧都会更新。</p>
<p>Mesh还提供了translate()方法，让mesh按指定轴进行平移。</p>
]]></content:encoded>
			<wfw:commentRss>http://sindney.com/blog/posts/make-mesh-move-cn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
