亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? life3d.java

?? 3D演示例子,初步認識3D的繪制,編程. 適合初學者!
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/******************************************************************************//** *	@file	Life3D.java *	@brief	Implements a 3D version of Conway's "game of life". * *	Copyright (C) 2004 Superscape plc * *	This file is intended for use as a code example, and *	may be used, modified, or distributed in source or *	object code form, without restriction, as long as *	this copyright notice is preserved. * *	The code and information is provided "as-is" without *	warranty of any kind, either expressed or implied. *//******************************************************************************/package com.superscape.m3g.wtksamples.life3d;import javax.microedition.midlet.MIDlet;import javax.microedition.midlet.MIDletStateChangeException;import javax.microedition.lcdui.*;import java.util.Random;import java.util.Timer;import java.util.TimerTask;import javax.microedition.m3g.*;/** * 	Life3D Midlet - implements a 3D version of Conway's "game of life". * *	The "game of life" is an interesting system discovered by John Conway in 1968. *	This is a generalization of that system to 3D. * *	The game grid is divided into cubical cells, each of which can be alive or dead. *	A live cell is indicated by a cube at that position; a dead cell is vacant. * *	At each generation, the number of living neighbours for each cell is counted, and *	the state of the cell in the next generation is determined by that count. Each has *	26 possible neighbors (including ones that are diagonal in one or more directions), *	and if a live cell has fewer than 4 live neighbors, it dies of loneliness. If it has *	more than 5 live neighbors, it dies of overcrowding. A vacant cell will have a new *	cell created inside it if it has exactly 4 live neighbors. * *	This apparently simple rule, when applied to all the cells simultaneously, leads *	to surprisingly complex behavior. Certain patterns of cells are stable, some die *	out, some flip between two or more configurations, and some actually progress through *	the grid in an ordered manner (these are called "gliders"). * *	Although the grid starts in a random state, we have added the most interesting patterns *	we have found to a pattern library, which can be accessed from the keyboard. * *	Keys: *		0: Pause generation *		1: Full speed (1 generation per frame) *		2: Increase generation speed *		3: Decrease generation speed *		4: Load previous pattern in library *		5: Load next pattern in library *		*: Load random pattern * *	If a pattern dies out completely, then the game restarts with a random pattern again. */public class Life3D extends MIDlet implements CommandListener{    /**     * 	Default constructor.     *     *  This just sets up a canvas and attaches it to the display. The actual     *	initialization happens in startApp.     */    public Life3D()    {		// Set up the user interface.        myDisplay = Display.getDisplay(this);        myCanvas = new CallbackCanvas(this);        myCanvas.setCommandListener(this);        myCanvas.addCommand(exitCommand);    }    /**     *	This initializes the game state, and generates a M3G world programmatically.     */    public void startApp() throws MIDletStateChangeException    {    	// Catch excpetions here before they go too far.        try        {        	// Create a new M3G world.			myWorld = new World();			// In this world, we have a root group which will contain everything else			// and which is tilted 15 degrees towards the camera.			Group rootGroup2 = new Group();			myWorld.addChild(rootGroup2);			rootGroup2.setOrientation(15.0f,1.0f,0.0f,0.0f);			// Under this, we have a second group which will be the one we rotate			// to get an all-round view of the game grid.			rootGroup = new Group();			rootGroup2.addChild(rootGroup);			// We now create a parallel camera - parallel projection is faster than			// perspective, and since we are rendering 512 separate objects that's a			// saving worth having.			Camera myCamera = new Camera();			myWorld.addChild(myCamera);			myWorld.setActiveCamera(myCamera);			myCamera.setParallel(CUBESIZE*1.5f, 1.0f, -CUBESIZE, CUBESIZE);			// This is geometry data for the shape that represents a single cell - a cube. 			// It consists of 6 triangle strips, one for each face, each of which			// has 2 triangles (and therefore 4 vertices). We will set the vertex			// colors so that the colors of the sides are different from each other.						// This data is shared by all the cells in the grid, rather than each having			// its own copy. This keeps memory overhead down.			int[][] aaStripLengths = {{4}, {4}, {4}, {4}, {4}, {4}};			// These are the vertex positions			short[] aPos =			{				// Front				-1, -1,  1,	// B				 1, -1,  1,	// C				-1,  1,  1,	// A				 1,  1,  1,	// D				// Bottom				-1, -1, -1,	// F				 1, -1, -1,	// G				-1, -1,  1,	// B				 1, -1,  1,	// C				// Top				-1,  1,  1,	// A				 1,  1,  1,	// D				-1,  1, -1,	// E				 1,  1, -1,	// H				// Right				 1,  1,  1,	// D				 1, -1,  1,	// C				 1,  1, -1,	// H				 1, -1, -1,	// G				// Left				-1, -1,  1,	// B				-1,  1,  1,	// A				-1, -1, -1,	// F				-1,  1, -1,	// E				// Back				 1, -1, -1,	// G				-1, -1, -1,	// F				 1,  1, -1,	// H				-1,  1, -1	// E			};			// These are the colors for the vertices			byte[] aCol =			{				// Front				-1, 0, 0,				-1, 0, 0,				-1, 0, 0,				-1, 0, 0,				// Bottom				 0, -1, 0,				 0, -1, 0,				 0, -1, 0,				 0, -1, 0,				// Top				 0,  0, -1,				 0,  0, -1,				 0,  0, -1,				 0,  0, -1,				// Right				-1, -1,  0,				-1, -1,  0,				-1, -1,  0,				-1, -1,  0,				// Left				-1,  0, -1,				-1,  0, -1,				-1,  0, -1,				-1,  0, -1,				// Back				 0, -1, -1,				 0, -1, -1,				 0, -1, -1,				 0, -1, -1,			};			// Calculate the number of submeshes and vertices directly from the sizes			// of the arrays. This prevents us getting a mismatch if we decide to change			// the cells to a different shape later.			int cSubmeshes = aaStripLengths.length;			int cVertices = aPos.length/3;			// We will share a default appearance between all the faces on the cube. Each			// face is a separate "submesh" - it can have a separate appearance if we wish.			Appearance app = new Appearance();			// We need to specify an appearance and the submesh data for each face.			Appearance[] appa = new Appearance[cSubmeshes];			IndexBuffer[] iba = new IndexBuffer[cSubmeshes];			int startIndex=0;			for(int i=0;i<cSubmeshes;i++)			{				// We use the same apppearance for each.				appa[i]=app;				// And we create a new triangle strip array for each submesh.				// The start index for each one just follows on from previous submeshes.				iba[i] = new TriangleStripArray(startIndex, aaStripLengths[i]);				for(int j=0; j<aaStripLengths[i].length;j++)					startIndex+=aaStripLengths[i][j];			}			// Now we create a new vertex buffer that contains all the above information			VertexBuffer vertexBuffer = new VertexBuffer();			vertexBuffer.setDefaultColor(0xFFFFFFFF); // white			{				// Copy the vertex positions into a VertexArray object				VertexArray vaPos = new VertexArray(cVertices, 3, 2);				vaPos.set(0, cVertices, aPos);				vertexBuffer.setPositions(vaPos, 0.40f, null);			}			{				// Copy the vertex colors into a VertexArray object				VertexArray vaCols = new VertexArray(cVertices, 3, 1);				vaCols.set(0, cVertices, aCol);				vertexBuffer.setColors(vaCols);			}			// Create all the cells, in a random state.			// The X, Y and Z positions of the cells range from -CUBESIZE/2 to +CUBESIZE/2 units.			// They are all children of the rootGroup object.			cells = new Mesh[NUMCELLS];			nextState = new byte[NUMCELLS];			currentState = new byte[NUMCELLS];			rand = new Random();			int index = 0;			for(int i=0; i<CUBESIZE; i++)			{				float x = (i*2 - CUBESIZE) * 0.5f;				for(int j=0; j<CUBESIZE; j++)				{					float y = (j*2 - CUBESIZE) * 0.5f;					for(int k=0; k<CUBESIZE; k++)					{						float z = (k*2 - CUBESIZE) * 0.5f;						Mesh m = new Mesh(vertexBuffer, iba, appa);						m.setTranslation(x,y,z);						rootGroup.addChild(m);						// This test gives a 1 in 4 chance of being alive at the start				    	currentState[index]=(rand.nextInt()>0x40000000)?(byte)1:(byte)0;						cells[index++] = m;					}				}			}			// Attach to display	        myDisplay.setCurrent(myCanvas);			// Force a repaint so that we get the update loop started.            myCanvas.repaint();        }        catch(Exception e)        {            e.printStackTrace();        }    }    /**     *	If cell[i] is alive, this increments the "live neighbor" count	 *	on all the neighboring cells. This is more efficient than counting	 *	the neighboring cells for each cell, because there are likely to be	 *	fewer live cells than dead cells.	 *	 *	The cube wraps around, so that the neighbor to the right of a cell	 *	in the last row is in fact in the first row. The same happens with 	 *	columns and planes. We speed things up here by using bit operations	 *	to effect this wrapping (which is why CUBESIZE must be a power of 2)	 *	and we also unroll the loop.     */    public void updateNeighbours(int i)    {		if(currentState[i]!=0)		{	    	int ix0 = (i-STEPX)&MASKX;	    	int iy0 = (i-STEPY)&MASKY;	    	int iz0 = (i-STEPZ)&MASKZ;	    	int ix1 = (i)&MASKX;	    	int iy1 = (i)&MASKY;	    	int iz1 = (i)&MASKZ;	    	int ix2 = (i+STEPX)&MASKX;	    	int iy2 = (i+STEPY)&MASKY;	    	int iz2 = (i+STEPZ)&MASKZ;			++nextState[ix0|iy0|iz0];			++nextState[ix0|iy0|iz1];			++nextState[ix0|iy0|iz2];			++nextState[ix0|iy1|iz0];			++nextState[ix0|iy1|iz1];			++nextState[ix0|iy1|iz2];			++nextState[ix0|iy2|iz0];			++nextState[ix0|iy2|iz1];			++nextState[ix0|iy2|iz2];			++nextState[ix1|iy0|iz0];			++nextState[ix1|iy0|iz1];			++nextState[ix1|iy0|iz2];			++nextState[ix1|iy1|iz0];	//!		++nextState[ix1|iy1|iz1];			++nextState[ix1|iy1|iz2];			++nextState[ix1|iy2|iz0];			++nextState[ix1|iy2|iz1];			++nextState[ix1|iy2|iz2];	   		++nextState[ix2|iy0|iz0];			++nextState[ix2|iy0|iz1];			++nextState[ix2|iy0|iz2];			++nextState[ix2|iy1|iz0];			++nextState[ix2|iy1|iz1];			++nextState[ix2|iy1|iz2];			++nextState[ix2|iy2|iz0];			++nextState[ix2|iy2|iz1];			++nextState[ix2|iy2|iz2];		}    }    /**     *	Works out current alive/dead state based on neighbour count.     *	If a cell is alive, it will die of loneliness if it has at fewer than     *	minSurvive neighbors, but if it has more than maxSurvive neighbors it     *	will die of overcrowding. If a cell has between minBirth and maxBirth     *	neighbours, and it is currently dead, a new cell is born in that position.     */    public void updateState(int i)    {    	byte count = nextState[i];    	nextState[i]=0;		if(currentState[i]==0)		{        	currentState[i]=(count>=minBirth && count<=maxBirth)?(byte)1:(byte)0;  		}        else        {        	currentState[i]=(count>=minSurvive && count<=maxSurvive)?(byte)1:(byte)0;        }		// After calculating the new state, set the appropriate rendering enable for the		// cell object in the world, so we can see it. We take advantage of this test to		// count the current live population, too.		if(currentState[i]!=0)		{	        cells[i].setRenderingEnable(true);	        ++population;	 	}		else	        cells[i].setRenderingEnable(false);    }    /**     * On pause, simply shut everything down.     */    public void pauseApp()    {        myRefreshTask.cancel();	myRefreshTask = null;	// Release resources.	myWorld = null;    }    /**     * On exit, simply shut everything down     */    public void destroyApp(boolean unconditional) throws MIDletStateChangeException    {        myRefreshTimer.cancel();        myRefreshTimer = null;        myRefreshTask = null;		// Release resources.        myWorld = null;		myCanvas = null;    }    /**     *	MIDlet paint method.     *     * 	This is called back from the inner Canvas class. It renders the current state of the     *	cells, then updates them and schedules another update.     */    public void paint(Graphics g)    {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
5566中文字幕一区二区电影| 伊人夜夜躁av伊人久久| 国产精品嫩草99a| 亚洲第一会所有码转帖| 成人久久18免费网站麻豆| 欧美日韩免费电影| 国产精品久久久久久久久晋中| 日韩av一级片| 91丨porny丨首页| 久久久亚洲高清| 日韩激情一二三区| 91免费在线看| 欧美国产精品v| 激情文学综合丁香| 91精品国产综合久久久久久| 一区二区三区四区不卡在线| 不卡的av网站| 国产精品欧美综合在线| 国内精品伊人久久久久影院对白| 7777精品伊人久久久大香线蕉经典版下载 | 成人午夜激情片| 精品久久久久久无| 日韩av网站在线观看| 欧美日韩一级二级三级| 亚洲自拍偷拍av| 色婷婷综合中文久久一本| 中文字幕一区二区三区av| 国产xxx精品视频大全| 久久久久久久综合| 国产呦萝稀缺另类资源| 欧美tk—视频vk| 蓝色福利精品导航| 精品国产麻豆免费人成网站| 麻豆极品一区二区三区| 精品黑人一区二区三区久久| 久久99九九99精品| 久久久久综合网| 国产精品影视网| 欧美激情在线一区二区三区| 风间由美中文字幕在线看视频国产欧美| 久久久精品免费网站| 国产精品一区二区三区网站| 中文字幕欧美日韩一区| av一区二区不卡| 一区二区在线免费观看| 欧美日韩一级二级| 国产主播一区二区三区| 国产精品私人自拍| 一本久久a久久免费精品不卡| 亚洲情趣在线观看| 欧美手机在线视频| 人禽交欧美网站| 国产婷婷色一区二区三区四区 | 91福利在线免费观看| 午夜国产精品一区| 精品人在线二区三区| 成人亚洲一区二区一| 亚洲精品日韩一| 欧美精品亚洲一区二区在线播放| 美女被吸乳得到大胸91| 国产拍欧美日韩视频二区| 99久久精品久久久久久清纯| 午夜精品久久久久影视| 欧美精品一区二区久久婷婷| 99视频精品全部免费在线| 亚洲高清免费观看高清完整版在线观看| 91精品欧美久久久久久动漫 | 国产亚洲欧美日韩日本| 一本大道久久a久久精二百| 青青草国产成人av片免费| 国产日韩欧美在线一区| 色婷婷国产精品久久包臀| 美国毛片一区二区三区| 中文字幕中文字幕在线一区 | 91在线免费视频观看| 亚洲mv在线观看| 国产精品视频yy9299一区| 欧美日韩黄色一区二区| 国产aⅴ综合色| 日本伊人色综合网| 亚洲视频免费看| www日韩大片| 欧美日韩三级一区二区| 不卡在线观看av| 麻豆精品国产传媒mv男同| 亚洲欧洲av一区二区三区久久| 91麻豆精品国产自产在线 | 国产精华液一区二区三区| 亚洲丶国产丶欧美一区二区三区| 久久婷婷一区二区三区| 欧美撒尿777hd撒尿| hitomi一区二区三区精品| 国产在线国偷精品免费看| 日韩精品电影一区亚洲| 亚洲码国产岛国毛片在线| 久久久九九九九| 欧美一级片免费看| 欧美精品久久99久久在免费线| 色综合久久精品| 成人国产视频在线观看| 国产精品一二三区| 久久国产精品99精品国产| 日韩国产高清在线| 日韩中文字幕区一区有砖一区| 亚洲最色的网站| 亚洲三级免费电影| 中文字幕亚洲一区二区va在线| 国产亚洲va综合人人澡精品| 欧美va在线播放| 欧美mv日韩mv国产网站app| 91精品婷婷国产综合久久竹菊| 欧美剧在线免费观看网站| 日本高清视频一区二区| 91在线免费播放| 日本久久电影网| 在线一区二区三区四区| 91九色最新地址| 欧美主播一区二区三区| 欧美日韩中文国产| 日韩一级视频免费观看在线| 日韩免费观看高清完整版在线观看| 9191精品国产综合久久久久久| 欧美美女喷水视频| 日韩女同互慰一区二区| 久久伊人蜜桃av一区二区| www国产精品av| 欧美激情一区二区三区四区| 国产精品久久精品日日| 亚洲欧美日韩国产综合在线| 亚洲精品第1页| 日韩一区欧美二区| 蜜桃av一区二区在线观看| 国产在线视视频有精品| 国产麻豆一精品一av一免费| 波多野结衣亚洲一区| 欧美自拍丝袜亚洲| 精品免费99久久| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 香蕉久久夜色精品国产使用方法 | 一区二区三区在线观看国产| 亚洲成a人v欧美综合天堂| 免费观看在线综合| 国产大陆亚洲精品国产| 9久草视频在线视频精品| 欧美性三三影院| 精品成人一区二区三区四区| 国产精品久久久久久久久动漫| 亚洲成人动漫一区| 国产精品中文字幕日韩精品 | 成人h动漫精品一区二区| 色狠狠桃花综合| 精品久久一区二区三区| 亚洲视频在线观看三级| 理论电影国产精品| 97se亚洲国产综合自在线不卡| 欧美色综合网站| 久久精品在线观看| 亚洲成a人在线观看| 国产一区二区三区免费在线观看| 97se亚洲国产综合在线| 欧美成人女星排名| 亚洲激情综合网| 国产一区二区在线看| 日本韩国一区二区三区| 久久综合网色—综合色88| 亚洲一区影音先锋| 国产精品18久久久久| 欧美日韩免费观看一区三区| 欧美国产激情二区三区| 日韩中文字幕91| 色婷婷激情久久| 国产日韩欧美精品一区| 日韩福利电影在线观看| 一本一道久久a久久精品| 久久日韩粉嫩一区二区三区| 亚洲国产一区二区视频| 91在线一区二区| 国产精品免费看片| 国产一区二区三区久久久| 欧美美女一区二区在线观看| 亚洲另类在线视频| 成人一区二区三区视频在线观看| 日韩女优av电影在线观看| 亚洲6080在线| 欧美手机在线视频| 亚洲综合一二三区| 日本丰满少妇一区二区三区| 国产农村妇女毛片精品久久麻豆 | 欧美电影免费提供在线观看| 亚洲成人激情av| 欧美视频中文字幕| 亚洲一区在线观看免费观看电影高清| 成人手机电影网| 日本一区二区三区高清不卡| 经典三级视频一区| 欧美大片在线观看一区二区| 美女任你摸久久| 精品久久久久久久人人人人传媒 | 欧美成人激情免费网| 五月天亚洲婷婷|