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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? life3d.java

?? 3D演示例子,初步認(rèn)識3D的繪制,編程. 適合初學(xué)者!
?? 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)    {

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久久久国产精品日日| 一区二区在线观看视频| 国产成人自拍高清视频在线免费播放| 蜜臀久久99精品久久久久久9| 天天色综合成人网| 午夜视频一区在线观看| 亚洲成va人在线观看| 亚洲综合激情小说| 五月天亚洲精品| 日韩专区在线视频| 久久国产精品区| 国产剧情av麻豆香蕉精品| 成人晚上爱看视频| 99久久免费视频.com| 91国产视频在线观看| 欧美女孩性生活视频| 欧美体内she精高潮| 91九色最新地址| 欧美日韩视频第一区| 日韩精品一区在线| 久久九九99视频| 亚洲欧洲av在线| 亚洲一二三四久久| 免费久久99精品国产| 高清不卡在线观看| 色婷婷综合久色| 69久久夜色精品国产69蝌蚪网| 日韩精品一区二区三区在线播放| 国产亚洲制服色| 一区二区三区欧美日| 国产在线精品一区二区| 色哟哟国产精品| 欧美日产在线观看| 国产精品久久三| 日韩精品欧美精品| 91视频www| 日韩欧美电影一二三| 欧美经典一区二区| 亚洲超丰满肉感bbw| 激情综合亚洲精品| 欧美日本精品一区二区三区| 久久精品一区二区| 日日夜夜免费精品| youjizz久久| 欧美一三区三区四区免费在线看 | 色国产精品一区在线观看| 欧美一区二区三区系列电影| 亚洲精品自拍动漫在线| 美国三级日本三级久久99| 欧美系列一区二区| 国产蜜臀av在线一区二区三区 | 国产精品沙发午睡系列990531| 亚洲黄色小说网站| av在线不卡免费看| 日韩欧美一区二区免费| 国产精品视频第一区| 老司机午夜精品99久久| 色噜噜狠狠成人网p站| 国产精品美女久久久久高潮| 丝袜美腿亚洲一区二区图片| 不卡视频一二三四| 亚洲国产精品ⅴa在线观看| 蜜桃av一区二区在线观看| 欧美日韩的一区二区| 一片黄亚洲嫩模| www.成人在线| 中文字幕中文字幕中文字幕亚洲无线| 琪琪久久久久日韩精品| 在线不卡的av| 亚洲一卡二卡三卡四卡 | 丁香另类激情小说| 久久久美女艺术照精彩视频福利播放| 亚洲成人先锋电影| 91麻豆精品国产自产在线观看一区 | 欧美国产丝袜视频| 男人的j进女人的j一区| 欧美日韩一本到| 亚洲美女精品一区| 成人av小说网| 久久久综合激的五月天| 精品一区二区三区免费| 欧美中文字幕不卡| 国产欧美一区二区精品性色| 亚洲最大成人综合| 成人午夜激情视频| 精品久久久久香蕉网| 国产真实乱偷精品视频免| 日韩精品一区二区三区在线观看| 日韩av一区二| 美日韩一级片在线观看| 久久婷婷一区二区三区| 欧洲av一区二区嗯嗯嗯啊| 久久国产精品99久久久久久老狼| 国产欧美一区二区三区在线老狼 | 亚洲精品久久嫩草网站秘色| 色欧美日韩亚洲| 精品一二线国产| gogo大胆日本视频一区| 亚洲乱码一区二区三区在线观看| 久久人人97超碰com| 亚洲成人手机在线| 色综合视频一区二区三区高清| 中文字幕在线观看一区| 国内精品写真在线观看 | 亚洲精品国产无套在线观| 91成人免费电影| 亚洲国产成人av网| 色婷婷亚洲一区二区三区| 五月激情六月综合| 欧美一区二区不卡视频| 国产激情视频一区二区在线观看| 国产视频不卡一区| 色老汉一区二区三区| 亚洲一区在线视频| 91传媒视频在线播放| 日韩av一级片| 国产日韩欧美综合一区| 91视频一区二区三区| 亚洲影视在线播放| 精品国产精品网麻豆系列| 国产suv精品一区二区三区| 中文字幕成人av| 91久久国产最好的精华液| 日本一道高清亚洲日美韩| 精品国产精品一区二区夜夜嗨| 成人免费福利片| 亚洲欧美色图小说| 欧美精品在欧美一区二区少妇| 老司机一区二区| 国产精品入口麻豆九色| 91在线视频免费观看| 亚洲激情中文1区| 久久一区二区三区四区| 99视频有精品| 丝袜诱惑制服诱惑色一区在线观看| 日韩视频在线一区二区| 成人精品视频.| 亚洲黄色av一区| 欧美手机在线视频| 国产福利一区二区三区| 亚洲精品水蜜桃| 精品久久国产97色综合| 99r国产精品| 免费成人在线观看| 中文字幕中文在线不卡住| 欧美老肥妇做.爰bbww| 国产真实乱子伦精品视频| 欧美精品一区二区三区视频| 国产大陆精品国产| 亚洲一区在线免费观看| 久久精品夜夜夜夜久久| 欧美亚洲一区三区| 国产成人高清在线| 天堂蜜桃一区二区三区| 国产精品久久久久久久岛一牛影视 | 国产精品高潮呻吟久久| 日韩视频一区二区三区在线播放| 成人精品国产免费网站| 免费在线观看精品| 亚洲人成人一区二区在线观看| 日韩欧美亚洲国产精品字幕久久久| 成人国产精品免费观看| 蜜臀av性久久久久蜜臀aⅴ四虎 | 国产1区2区3区精品美女| 天天综合日日夜夜精品| 国产精品久久久久久久久久免费看 | 欧美精品一二三区| 99精品视频一区| 美日韩黄色大片| 一区二区三区 在线观看视频| 国产欧美精品一区| 日韩欧美电影一区| 欧美美女视频在线观看| 色综合久久88色综合天天6 | 99re免费视频精品全部| 国产在线精品国自产拍免费| 亚洲美女淫视频| 国产亚洲精品免费| 欧美日韩一级黄| 欧美日韩视频专区在线播放| 色综合欧美在线视频区| 国产·精品毛片| 国产精品911| 六月丁香婷婷久久| 婷婷亚洲久悠悠色悠在线播放| 亚洲人精品午夜| 国产精品久久三区| 欧美激情一区二区三区不卡| 中文一区二区完整视频在线观看| 欧美本精品男人aⅴ天堂| 色天天综合久久久久综合片| 91亚洲精品一区二区乱码| 国产不卡在线播放| 99riav一区二区三区| 99久久免费国产| 色偷偷88欧美精品久久久| 91官网在线免费观看| 成人听书哪个软件好| jlzzjlzz欧美大全| 国产精品中文字幕欧美|