2d

C# XNA 2D trail effect optimization

无人久伴 提交于 2019-12-07 15:24:25
问题 Currently as a trail effect in my game I have for every 5 frames a translucent texture copy of a sprite is added to a List<> of trails. The alpha values of these trails is decremented every frame and a draw function iterates through the list and draws each texture. Once they hit 0 alpha they are removed from the List<>. The result is a nice little trail effect behind moving entities. The problem is for about 100+ entities, the frame rate begins to drop drastically. All trail textures come

OpenGL rotating a 2D texture

∥☆過路亽.° 提交于 2019-12-07 15:07:09
问题 UPDATE See bottom for update. I've been looking alot around the internet and I have found a few tutorials that explain what I'm trying to achieve but I can't get it to work, either the tutorial is incomplete or not applicable on my code. I'm trying something as simple as rotating a 2D image around its origin (center). I use xStart, xEnd, yStart and yEnd to flip the texture which are either 0 or 1. This is what the code looks like GameRectangle dest = destination; Vector2 position = dest

How to write a 2D vector into a binary file?

放肆的年华 提交于 2019-12-07 12:38:26
everyone! I have a 2D vector filled with unsigned chars. Now I want to save its contents into a binary file: std::vector<std::vector<unsigned char> > v2D(1920, std::vector<unsigned char>(1080)); // Populate the 2D vector here ..... FILE* fpOut; // Open for write if ( (err = fopen_s( &fpOut, "e:\\test.dat", "wb")) !=0 ) { return; } // Write the composite file size_t nCount = 1920 * 1080 * sizeof(unsigned char); int nWritten = fwrite((char *)&v2D[0][0], sizeof(unsigned char), nCount, fpOut); // Close file fclose(fpOut); But, when I read test.dat, fill in a new 2D vector, and compare its entries

spatial data / compute metrics on neighbors in R

谁说我不能喝 提交于 2019-12-07 11:58:50
问题 I have the 2D spatial data in the form (xBin, yBin, value). e.g.: DT = data.table(x=c(rep(1,3),rep(2,3),rep(3,3)),y=rep(c(1,2,3),3),value=100*c(1:9)) For each bin I want to compute the sum of variable "value" over all neighboring bins. A bin is considered a neighbor if both of its indices - x and y are within one unit from the current bin e.g. for x=2, y=2, I want to compute valueNeighbors(x=2,y=2) = value(x=1,y=1)+value(1,2)+value(1,3) +value(2,1)+value(2,3) +value(3,1)+value(3,2)+value(3,3)

Java 2D Image resize ignoring bicubic/bilinear interpolation rendering hints (OS X + linux)

女生的网名这么多〃 提交于 2019-12-07 11:30:28
问题 I'm trying to create thumbnails for uploaded images in a JRuby/Rails app using the Image Voodoo plugin - the problem is the resized thumbnails look like... ass. It seems that the code to generate the thumbnails is absolutely doing everything correctly to set the interpolation rendering hint to "bicubic", but it isn't honoring them on our dev environment (OS X), or on the production web server (Linux). I've extracted out the code to generate the thumbnails, rewritten it as a straight Java app

Android 2D游戏引擎AndEngine配置环境

左心房为你撑大大i 提交于 2019-12-07 11:15:39
Android 2D游戏引擎AndEngine配置环境 1 . 2 配置环境 在任何编程中,都需要一些软件或者硬件的支持。否则,没有硬件软件是不可能存在的,而想要编写对应语言的的程序,这需要对应语言库和编译器等的支持。所以在开 AndEngine 的游戏也需要这些东西,而我们需要的环境都有那些呢?本节内容就将解密 AndEngine 环境的配置本文选自 Android 2D游戏引擎AndEngine快速入门教程 。 1 . 2 . 1 环境要求 编写 AndEngine 需要一定的编程环境才可以完成编写。而为了调试,需要用到相应的设备才可以正常调试。这一小节就来讲一下需要编程环境。本书中需要的软件和硬件设备如下 本文选自 Android 2D游戏引擎AndEngine快速入门教程 。 q 一台计算机:计算机中安装的系统必须是 Windows XP 、 Windows Vista 、 Windows 7 、 Windows 8 、 Linux (例如 Ubuntu )和 Mac OS 10.5.8 中的一种,或者这些类型系统中的最新版。 q Java SDK :需要的 JDK 必须为 JDK 6 以上的版本。 q Eclipse 编辑工具。 q AndEngine 和 AndEnginePhysicsBox2DExtension 项目文件。 q 包含 ADT 的 Android

NGUI创建Camera参数为Simple 2D的UI UI对象的结构UI Root(2D)

天大地大妈咪最大 提交于 2019-12-07 10:23:44
NGUI创建Camera参数为Simple 2D的UI UI对象的结构UI Root(2D) 使用 NGUI 创建的 Camera 参数为 Simple 2D 的 UI ,会在游戏的场景中生成 1 个名为 UI Root(2D) 的游戏对象,且此对象下还包含了 3 个其它对象: Camera 、 Anchor 和 Panel ,如图 1-4 所示。本小节会分别介绍这 4 个游戏对象 本文选自 NGUI从入门到实战 。 图 1-4 在 Hierarchy 视图里查看新创建的 UI 游戏对象 1.4.1 UI Root(2D) 此游戏对象将负责控制 UI 控件的大小。在 Hierarchy 视图里选中 UI Root(2D) 对象,然后在 Inspector 视图里查看此游戏对象上的组件,如图 1-5 所示。 图 1-5 在 Inspector 视图里查看 UI Root(2D) 对象的各组件 Transform 组件在 Unity 的游戏对象上很常见,或者说所有的游戏对象上都有此组件,很平常就不做介绍了。而 UIRoot(Script) 组件是此游戏对象所特有的,其属性和介绍如下 本文选自 NGUI从入门到实战 : q Scaling Style :可以用于修改 UI 控件的缩放样式。 提示:此属性下有 3 个可选的参数: PixelPerfect 、 FixedSize 和

AngularJs ng-repeat 2D array in table, each subarray one column

心已入冬 提交于 2019-12-07 08:00:56
问题 I have an array and I need to put that array in table. $scope.testArr=[ {'first':[ { 'value':'1_1', 'rolle':'one1' }, { 'value':'2_1', 'rolle':'two1' }, { 'value':'3_1', 'rolle':'three1'} ] }, {'second': [ { 'value':'1_2', 'rolle':'one2' }, { 'value':'2_2', 'rolle':'two2' }, { 'value':'3_2', 'rolle':'three2' } ] } ]; Resulting table should have 4 columns, each subarray should be one(or two) column(s). Like this: one1 | 1_1 | one2 | 1-2 two1 | 2_1 | two2 | 2_2 three1|3_1 | three2|3_2 So far I

Normalized Device Coordinates

回眸只為那壹抹淺笑 提交于 2019-12-07 06:32:12
问题 I'm writing a library that deals with 2D graphical shapes. I'm just wondering why should my coordinate system range from [-1, 1] for both the x and y axis instead of [0, width] for x and [0, height] for y ? I went for the latter system because I felt it was straight forward to implement. 回答1: From Jim Blinn's A Trip Down The Graphics Pipeline , p. 138. Let's start with what might at first seem the simplest transformation: normalized device coordinates to pixel space. The transform is s_x * X

Memory issues with two dimensional array

大城市里の小女人 提交于 2019-12-07 05:38:25
Following this nice example I found, I was trying to create a function that dynamically generates a 2D grid (two dimensional array) of int values. It works fairly well the first couple of times you change the values but if crashes after that. I guess the part where memory is freed doesn't work as it should. void testApp::generate2DGrid() { int i, j = 0; // Delete previous 2D array // (happens when previous value for cols and rows is 0) if((numRowsPrev != 0) && (numColumnsPrev != 0)) { for (i = 0; i < numRowsPrev; i++) { delete [ ] Arr2D[i]; } } // Create a 2D array Arr2D = new int *