Projectile immediately intersecting with target I have a fairly simple and somewhat cookie cutter method for testCollisions (FYI BasicProjectile is a CCNode with a CCSprite member). for (BasicProjectile basicProjectile in self.projectiles) NSLog( "projectile sprite ",NSStringFromCGRect(basicProjectile.sprite.boundingBox)) NSLog( "destination sprite ",NSStringFromCGRect(basicProjectile.destination.sprite.boundingBox)) if (CGRectIntersectsRect(basicProjectile.sprite.boundingBox, basicProjectile.destination.sprite.boundingBox)) basicProjectile.destination setHealth (basicProjectile.destination.hp basicProjectile.damage) self.projectiles removeObject basicProjectile self removeChild basicProjectile cleanup YES Those NSLog statements output 2013 03 23 10 02 59.124 GridWars 25268 c07 projectile sprite 10, 10 , 20, 20 2013 03 23 10 02 59.124 GridWars 25268 c07 destination sprite 13.5, 34 , 27, 68 The main problem is that the collision immediately happens. It should take a few frames to travel from the source to the destination. So although the logic of setting the health works fine the sprite itself is never seen on the screen because the very second its fired it is removed. From what I understand about CGRectIntersectsRect those 2 points listed above do not intersect. Am I wrong are they intersecting? What can be causing these projectiles to immediately intersect with their target? BasicProjectile class (CCNODE superclass) (id)initWithSourceAndDestination (GameCharacters )Source destination (GameCharacters )Destination if (self super init ) self.damage 25 self.sprite CCSprite spriteWithFile "Projectile.png" self addChild self.sprite z 1000 self.source Source self.destination Destination return self GameCharacters would look similar to this except have health and mana properties. WizardHero Class, Method Fire basicProjectile.position self.position self.hostLayer addChild basicProjectile z 2021 Determine where we wish to shoot the projectile to int realX Are we shooting to the left or right? CGPoint diff ccpSub(basicProjectile.destination.position, basicProjectile.source.position) if (diff.x gt 0) realX (self.hostLayer.tileMap.mapSize.width self.hostLayer.tileMap.tileSize.width) (basicProjectile.contentSize.width 2) else realX (self.hostLayer.tileMap.mapSize.width self.hostLayer.tileMap.tileSize.width) (basicProjectile.contentSize.width 2) float ratio (float) diff.y (float) diff.x int realY ((realX basicProjectile.position.x) ratio) basicProjectile.position.y CGPoint realDest ccp(realX, realY) Determine the length of how far we're shooting int offRealX realX basicProjectile.position.x int offRealY realY basicProjectile.position.y float length sqrtf((offRealX offRealX) (offRealY offRealY)) float velocity 380 1 380pixels 1sec float realMoveDuration length velocity Move projectile to actual endpoint id actionMoveDone CCCallFuncN actionWithTarget self.hostLayer selector selector(projectileMoveFinished ) basicProjectile runAction CCSequence actionOne CCMoveTo actionWithDuration realMoveDuration position realDest two actionMoveDone self.hostLayer.projectiles addObject basicProjectile Basically here is the class structure Three main superclasses GameProjectiles CCNodes GameLevels CCNodes GameChars CCNodes Then the actual more specific classes (used on the GameLevels) BasicProjectile GameProjectiles Level1Layer GameLevels WizardHero GameCharacters RedEnemy GameCharacters


Recommended book for cocos2d? I'm an experienced programmer that recently got into iOS development by working through the big nerd ranch book by Aaron Hillegass and Joe Conway. I loved the way the book was structured in terms of typing in the code and doing the challenges. I'm interested in learning more about iOS gaming and cocos2d, but am a complete newbie in terms of game development design. There are a number of books on amazon on cocos2d, can anyone recommend one in particular?


Importance of scripting engine at Cocos2d Game Engine Each Game Engine is different and solves different problems in different ways, so the engine design does vary greatly from engine to engine (even though a lot of principles are shared from engine to engine). Cocos2D is a great product on it s own, but it doesn t expose engine functionality to a scripting Language like Lua, JavaScript etc. My Question How much important to integrate a Scripting Engine at Cocos2d?


How to use generic level editors with my arbitary code? I have a game, breakout clone. It has a Block class that contains CCSprite as a property. Usually I made levels by manually setting those blocks to positions. Here comes the question, how do I use generic level editors with my custom code? All editors work with CCSprites and not my class. How can I overcome that?


DPad style movement for AI without using A What is the easiest way to implement DPad style movement (No diagonal) for AI without using and A algorithm? I thought about having the enemy catch up to the player in the Y axis first then the X axis (or vice versa) but then it would be too easy to evade the enemy. If it matters I'm doing this in Objective C using Cocos2d. Any input would be appreciated.


I need some help with stopping individual sound effects in OALSimpleAudio I'm trying to find out how to stop a specific sound effect rather than having to stop all of them. I'm using OALSimpleAudio. I can't seem to find how to do it. simple google searches result in nothing, which means my searches are crap, it's REALLY easy to do and i'm ... stupid p, or it isn't possible. I hope you guys can help me. In the background i have a humming engine sound, but when the object takes damage, the humming sound is stopped, that's not what i want. case kStateTakingDamage CCLOG( "Ship taking damage") self playTakingDamageSound self.characterHealth self.characterHealth 1.0f action CCActionAnimate actionWithAnimation damageAnimation GameManager sharedGameManager stopSoundEffect break (void) playSoundEffect (NSString ) soundEffect self playSoundEffect soundEffect andLoop NO (void) playSoundEffect (NSString ) soundEffect andLoop (BOOL) loop OALSimpleAudio sharedInstance playEffect soundEffect loop loop (void) stopSoundEffect OALSimpleAudio sharedInstance stopAllEffects (id) isSoundPlaying TODO find out how this works


How to create fun and interactive menus with cocos2d? Possible Duplicate How to make animated buttons in a menu with Cocos2d? How do I make fun and interactive menus with cocos2d, all the tutorials are just for simple clickable menus. Can any one help me learn this? It would be see the menu flip or slide away, I know you can do this with scenes but how do I make this with just the menu? Let's say the menu is a bunch of cards and I want them to flip over like the sub menu is on the backside of the card, how would I do this? Or, make the Main menu slide in from the left, right, top or bottom side and then when a button is selected it slides away the same way and switch to a sub menu (settings, Score etc)? Anyone? David


Image drawing tools (that aren't Photoshop) that work in the sRGB colorspace I'm looking for a way to create sRGB raster images. Now, I could use Inkscape and just have it render to a raster format, but are there any image drawing tools other than Photoshop that work in sRGB? Here's what I want to be able to do more specifically. Let's say the image is all one color. I want to be able to pick color 0x808080, which is in the sRGB colorspace. I want the file to write an image where every pixel is 0x808080. And then, when I read it, I can tell OpenGL that it's sRGB color data, so it will treat the 0x808080 color has being from the sRGB colorspace. The important part is that, when I'm selecting colors in the tool, the colors I'm selecting are from the sRGB colorspace.


Recording Xbox controller button presses? I would like to generate some sort of log file of xbox gamepad events while playing an existing game on PC, such as Call of Duty. I am not developing a game necessarily, I just would like a static file of all button presses recorded during a session of gameplay. I am writing an application that will use this data as input. Can anyone recommend any software tools that could enable me to do this? Thanks in advance. I have Mac, Windows, and Ubuntu that I can use.


Tool to create a bitmap font from a true type font What tool do you use to convert ttf fonts to bitmap fonts? Following is a list of features I'm looking for. I'd be happy with any tool really, but one that had these features would be better. outputs power of 2 texture atlas parsible config file (so I don't have to use their rendering library) output kerning information cross platform a rendering library would be great if it lets me make the actual OpenGL calls. So what tool have you used? Were you happy with it?


Are bounding volumes created by artists? I'm interested in where in the tool chain bounding boxes are created. Are they made by the artists? In the modeling tool? How are they exported? Can Maya 3DS Max Blender ... mark geometry as bounding box? How does that work in Collada FBX?) Or is there a tool which calculates them? Are they calculated at run time? I basically know how bounding volumes work, but I'm a little bit confused on where to get them from.


Sprites saved in INA and AN format? I'm not sure if this is a suitable question but I found a game that had all it is sprites and stuff saved in INA and AN format and I got curious to know which program is it. Or is it some sort of compressing or alike and how it is usually done? Anyone know? Here is the content of one of the files http pastebin.com EzUsFvdG Here is a hex dump of the above file http pastebin.com CTErFBcS The above one is the AN file and the bellow one INA. Hex dump of a INA file which seems to be some sort of map or data file (I believe because of the layers info, etc?) http pastebin.com 2fWn8izR


What language and tools are good to start with for Linux game development? I would like to start learning about game development and I would like to do it using Linux. My main experience has been with Java and a bit of C , but that was for applications and not games. Now that I want to try with gaming, I'm wondering which IDE language should I use in Linux, whether I should go with C and compiling files manually at the beginning, or maybe continue with Java Eclipse, also I think I can use Eclipse with C , I have also started reading about Python... I was thinking in starting with the typical "Tetris" just to understand how a game works internally, and I think I can achieve that with all the previous options, but what do you recommend me or how have you started game developming under Linux?


What level editor is Phil Fish using in Indie Game The Movie? Does anyone know what program Phil Fish is using to edit models of levels? Or is it it something he built himself? I'm new to game development and was looking for something to design levels with besides my notebook.


What is a good tool for producing animated sprites? Has anyone come across a software package that allows you to build animations in a similar way to how you can in Flash (i.e. using techniques such as tweens amp bones amp easings, etc) and then have the result exported as a sprite sheet?


How is console game development done? I'm curious what the process is for development for a game console such as Wii, Playstation, or Xbox. Do I need to use some game engine and compile for each platform? What IDE is used? Any C IDE? Are all console games built in C ?


create terrain with some vertical cliffs, natural arcades, caves using octree I am about to start creating the first terrain. I would like to create a terrain with vertical cliffs, natural arcades and caves. For instance in one point the terrain might look like this. I want to discuss about how to store this information about the terrain. I think quadtree will not do the trick. From my understainding with quadtree perfectly vertical terrain is bound to be low quality in the vertical part, as you cannot subdivide it. So I thounght that octree should be the right tool. But I have a conceptual problem with octree. I cannot understand how to store the triangle data in a octree structure. Understanding how to store data in a quadtree is easy you subdivide the region in a lot of squares and you give a coordinate value to each vertex of the squares, then you just connect all the verticies with triangles. But what can you do when it comes to octtree? Which information should you store conceptually in the octree tree? I cannot guess the logic and the algorithm that lays behind a octtree terrain. Thank you


Static "LoD" hack opinions I've been playing with implementing dynamic level of detail for rendering a very large mesh in XNA. It occurred to me that (duh) the whole point of this is to generate small triangles close to the camera, and larger ones far away. Given that, rather than constantly modifying or swapping index buffers based on a feature's rendered size or distance from the camera, it would be a lot easier (and potentially quite a bit faster), to render a single "fan" or flat wedge frustum shaped planar mesh that is tessellated into small triangles close to the near or small end of the frustum and larger ones at the far end, sort of like this (overhead view) (Pardon the gap in the middle I drew one side and mirrored it) The triangle sizes are chosen so that all are approximately the same size when projected. Then, that mesh would be transformed to track the camera so that the Z axis (center vertical in this image) is always aligned with the view direction projected into the XZ plane. The vertex shader would then read terrain heights from a height texture and adjust the Y coordinate of the mesh to match a height field that defines the terrain. This eliminates the need for culling (since the mesh is generated to match the viewport dimensions) and the need to modify the index and or vertex buffers when drawing the terrain. Obviously this doesn't address terrain with overhangs, etc, but that could be handled to a certain extent by including a second mesh that defines a sort of "ceiling" via a different texture. The other LoD schemes I've seen aren't particularly difficult to implement and, in some cases, are a lot more flexible, but this seemed like a decent quick and dirty way to handle height map based terrain without getting into geometry manipulation. Has anyone tried this? Opinions?


3rd party terrain editor I am looking for a good application for generating 3d terrains (really allowing generation and then some user editing) . After a google search, I found many, but I need one that can export the entire terrain as a mesh. This, I was unable to find. (I need either a .obj .fbx or .3ds output) The size of the file that is written and the price of the program are not major factors in my decision.


Real world terrain import into UE4 I am trying to create a basic game in Unreal Engine 4.8.1 and I wish to have it set in the Dubai, UAE but i cannot find a way that will successfully use terrain data i have obtained (NASA Shuttle RADAR 90m) to create a 1 1 scale map in unreal without creating huge world spikes. Does anyone know a method that can import the data without creating terrain spikes?


anisotropic fog of war Here I am not talking about how to render fog of war, but how to model exploring of terrain in a more sophisticated way. In a straight forward approach, terrain explored by a game unit is simply represented by a circle whose radius is how far this unit can see. And visible area is just union of isometric circles. But I can tell that it is not the case in popular games. Please take a look at the following screenshot from League of Legends, for example. The sight of view is anisotropic. The shape of surrounding terrain is also taken in to account. Any idea how this can be done?


Heightmap based Terrain with a Road What's the best way to implement a detail feature, like a road, on a heightmap based terrain? Update It's a bit hard to see in the image, but the road descends from the top of the quarry to do its base.


How do I simplify terrain with tunnels or overhangs? I'm attempting to store vertex data in a quadtree with C , such that far away vertices can be combined to simplify the object and speed up rendering. This works well with a reasonably flat mesh, but what about terrain with overhangs or tunnels? How should I represent such a mesh in a quadtree? After the initial generation, each mesh is roughly 130,000 polygons and about 300 of these meshes are lined up to create the surface of a planetary body. A fully generated planet is upwards of 10,000,000 polygons before applying any culling to the individual meshes. Therefore, this second optimization is vital for the project. The rest of my confusion focuses around my inexperience with vertex data How do I properly loop through the vertex data to group them into specific quads? How do I conclude from vertex data what a quad's maximum size should be? How many quads should the quadtree include?


Rendering smooth ground I'm attempting to render terrain made out of a triangle mesh. The problem is that whenever I have a northwest gt southeast ramp in the terrain, I get this diamond pattern The issue is that at the top and bottom of the ramp, the terrain is more flat than at the middle, so if the ramp is aligned with the triangles, each triangle will have two light vertices (at the top and bottom), and one dark vertex (at the middle). How can I fix this effect? Subdividing the mesh helps, but doesn't fix it completely. Vertex shader uniform mat4 projection attribute vec3 position attribute vec3 normal attribute vec4 color varying vec3 f position varying vec3 f normal varying vec4 f color void main(void) gl Position projection position f color color f normal normal f position position Fragment shader varying vec3 f position varying vec3 f normal varying vec4 f color uniform vec3 light position void main(void) float light 0.5 0.5 abs(dot(normalize(f normal), normalize(light position f position))) gl FragColor vec4(light, light, light, 1) f color


What do sandbox games usually do when generating new terrains? I am trying to make a minecraft. In my game, when the player moves to the boundary, new chunks will be generated. What I do is creating new chunks in my main thread and generating a new VBO to store them. But I find that it's quite inefficient and you can obviously feel the FPS is decreasing. What do these kinds of games usually do when generating new terrains? Do they use multi threads or some specific efficient algorithms or compute shaders (I still don't know much about OpenGL)? I once tried to generate my new terrains in another thread. But I found I can't use GL operation to generate VBO in another thread. I am thinking about pre generated some VBOs in my main thread. Is that the right way? I want to know what most people do in this situation.


Black bars on 720p emulator? I'm making a game for Windows Phone 8 using XNA 4.0 in Visual Studio express 2012. I'm trying to add a background image to the game with a size of 1366x768 (as I believe WP8 only supports up to 720p). Everything stretches well on the other emulators (WVGA and WXGA) until I use the 720p emulator and I get black bars on the sides How can I fix this, or is this normal? This is all the code I have used so far GraphicsDeviceManager graphics SpriteBatch spriteBatch Texture2D Background public Game1() graphics new GraphicsDeviceManager(this) Content.RootDirectory "Content" graphics.SupportedOrientations DisplayOrientation.LandscapeLeft DisplayOrientation.LandscapeRight this.graphics.IsFullScreen true Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime TimeSpan.FromTicks(333333) Extend battery life under lock. InactiveSleepTime TimeSpan.FromSeconds(1) lt summary gt Allows the game to perform any initialization it needs to before starting to run. This is where it can query for any required services and load any non graphic related content. Calling base.Initialize will enumerate through any components and initialize them as well. lt summary gt protected override void Initialize() TODO Add your initialization logic here base.Initialize() lt summary gt LoadContent will be called once per game and is the place to load all of your content. lt summary gt protected override void LoadContent() Create a new SpriteBatch, which can be used to draw textures. spriteBatch new SpriteBatch(GraphicsDevice) Background Content.Load lt Texture2D gt ("SkyBackground") lt summary gt UnloadContent will be called once per game and is the place to unload all content. lt summary gt protected override void UnloadContent() TODO Unload any non ContentManager content here lt summary gt Allows the game to run logic such as updating the world, checking for collisions, gathering input, and playing audio. lt summary gt lt param name "gameTime" gt Provides a snapshot of timing values. lt param gt protected override void Update(GameTime gameTime) Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back ButtonState.Pressed) this.Exit() base.Update(gameTime) lt summary gt This is called when the game should draw itself. lt summary gt lt param name "gameTime" gt Provides a snapshot of timing values. lt param gt protected override void Draw(GameTime gameTime) GraphicsDevice.Clear(Color.CornflowerBlue) TODO Add your drawing code here spriteBatch.Begin() drawBackground() spriteBatch.End() base.Draw(gameTime) private void drawBackground() spriteBatch.Draw(Background, GraphicsDevice.Viewport.Bounds, Color.White)


Writing via content pipeline in Xbox game project I'm creating an Xbox application and I have this problem with the content pipeline. Loading .xnb files is not a problem but I can't seem to find any helpful tutorials on writing via the content pipeline. I want to write an XML whenever the user presses a custom made "save" button. I've searched the web for "saving game sate" etc. but so far I haven't found a solution for my case. So, summarized is there a way to write data (in XML format) via the content pipeline, if my Save() method is called? Cheerz


Confused about Content Pipeline I'm attempting to get my head around the XNA content pipeline, and how I can use it to simplify my game code. Specifically, I want to define sprites, sprite sheets, and animations as assets and have them automatically available to me in game code. At the end of the day, this is what I want to be able to do add a new file with .sprite extension to my content project call contentManager.Load lt Sprite gt ("NameOfSprite") and get back a Sprite instance My Sprite class looks like this public class Sprite public Texture2D Texture get ... public Rectangle? SourceRectangle get ... public Vector2 Origin get ... The purpose of the Origin property is not important it's specific to my game. The point is, I want it to be "packaged up" alongside the texture information. I've defined a SpriteData class as public sealed class SpriteData public string TextureFilename get set public Rectangle? SourceRectangle get set public Vector2 Origin get set And I've added a test.sprite file to my content project as lt ?xml version "1.0" encoding "utf 8" ? gt lt XnaContent xmlns data "MyNamespace" gt lt Asset Type "data SpriteData" gt lt TextureFilename gt Sprites Test.jpg lt TextureFilename gt lt SourceRectangle gt 0 5 20 25 lt SourceRectangle gt lt Origin gt 30 2 lt Origin gt lt Asset gt lt XnaContent gt I have defined a SpriteImporter as ContentImporter(".sprite", DisplayName "Sprite Importer", DefaultProcessor "SpriteProcessor") public class SpriteImporter ContentImporter lt SpriteData gt public override SpriteData Import(string filename, ContentImporterContext context) using (var xmlReader XmlReader.Create(filename)) return IntermediateSerializer.Deserialize lt SpriteData gt (xmlReader, filename) And a SpriteProcessor as ContentProcessor(DisplayName "Sprite Processor") public class SpriteProcessor ContentProcessor lt SpriteData, SpriteData gt public override SpriteData Process(SpriteData input, ContentProcessorContext context) var spritePath Path.GetDirectoryName(context.OutputFilename) var textureReference new ExternalReference lt Texture2DContent gt (input.TextureFilename) make sure the texture is built (not sure what else to do here) context.BuildAsset lt Texture2DContent, Texture2DContent gt (textureReference, string.Empty) return input Now I'm stuck. If I don't implement a content writer reader combination then I won't get a Sprite out of the content manager I'll get a SpriteData instead, which is not what I want. But my attempt to implement a SpriteWriter came up short. I have no idea how to get the texture information from the processor to the writer. Do I need to change the type from SpriteData to something else? Is there a sample anywhere that demonstrates how to do this end to end?


Client and Server game update speed I am working on a simple two player networked asteroids game using XNA and the Lidgren networking library. For this set up I have a Lidgren server maintaining what I want to be the true state of the game, and the XNA game is the Lidgren client. The client sends key inputs to the server, and the server process the key inputs against game logic, sending back updates. (This seemed like a better idea then sending local positions to the server.) The client also processes the key inputs on its own, so as to not have any visible lag, and then interpolates between the local position and remote position. Based on what I have been reading this is the correct way to smooth out a networked game. The only thing I don t get is what value to use as the time deltas. Currently every message the server sends it also sends a delta time update with it, which is time between the last update. The client then saves this delta time to use for its local position updates, so they can be using roughly the same time deltas to calculate position updates. I know the XNA game update gets called 60 times a second, so I set my server to update the game state at the same speed. This will probably only work as long as the game is working on a fixed time step and will probably cause problems if I want to change that in the future. The server sends updates to clients on another thread, which runs at 10 updates per second to cut down on bandwidth. I do not see noticeable lag in movement and over time if no user input is received the local and remote positions converge on each other as they should. I am also not currently calculating for any latency as I am trying to go one step at a time. So my question is should the XNA client be using its current game time to update the local game state and not being using time deltas sent by the server? If I should be using the clients time delta between updates how do I keep it in line with how fast the server is updating its game state?


How to animate a destruction of a model? I have a model (see image) and I am trying to animate a destruction. But it doesn't seem possible, since XNA is using only bones to animate. So my question is Which workflow should I use, to animate 4 independent objects (being one big model), which lie on top of each other? Regarding this model


Strange anomalies when using WinForms with XNA I haven't seen any questions related to my issue, and this leads me to believe I'm missing something minor, however The Problem I'm creating a game that is effectively launched from a windows form. Consider the following code. static void Main(string args) main new TestGame() The Game class. menu new Menu(main) The form. while (true) if (menu.ShowDialog() DialogResult.OK) if (menu.ShouldStartGame) main.RunGame( Some params ) else ExitGame() break This loop works fine. My issue lies in the form itself. Firstly, DialogResult does not trigger at all. When the result from menu.ShowDialog() is printed, its result is "Cancel" which is not the option set for the button (OK.) As well as this, picture boxes, the form background colour and other such controls do not work properly. And the form appears to have a UI style from Windows versions before or during XP. Is this a known issue or am I missing something?


Monogame Startup Memory Spike I am currently porting a game from WP7 using XNA to WP8.1 using MonoGame. I have been putting considerable effort into optimizing my game to be under the 185MB memory limit for low memory phones. I was making headway until I discovered a memory spike on startup. I continued to reduce the quality of my assets until the memory usage (while the game is running) is at about 140MB. However, on startup, the memory usage spikes to 205MB, sits there for about 10 seconds, and then drops to standard operating memory usage. It does this every time. Increasing or decreasing the asset sizes only changes how high the spike goes and the usage in general, but it does not change the 10 second delay at all. One idea I thought about was to delay the user with a longer splash screen, giving me time to load all the assets without blowing the hatch. But this seems to me like detracting from the user experience out of convenience. Any ideas? Has anyone else had this problem?


Creating refraction map problem I'm reading riemers tutorial on how to make a water effect and trying to translate it from xna 3 to xna 4. So far I figured out I have to create a shader in order to clip the planes for my refraction map. I'm new to hlsl and how to implement custom shaders into my program, so I am wondering what I am doing wrong here. float4x4 World float4x4 View float4x4 Projection float4 ClipPlane0 void vs(inout float4 position POSITION0, out float4 clipDistances TEXCOORD0) clipDistances.y 0 clipDistances.z 0 clipDistances.w 0 position mul(mul(mul(position, World), View), Projection) clipDistances.x dot(position, ClipPlane0) float4 ps(float4 clipDistances TEXCOORD0) COLOR0 clip(clipDistances) return float4(0, 0, 0, 0) TODO whatever other shading logic you want technique pass VertexShader compile vs 2 0 vs() PixelShader compile ps 2 0 ps() This is the fx file that I found on an xna forum just for reference. Major edit I was able to get the program running successfully but when I viewed the saved screenshot of the refraction map, nothing was clipped. public void DrawRefractionMap(Effect clipEffect, Camera camera, GraphicsDevice device) Plane refractionPlane CreatePlane(waterHeight 1.5f, new Vector3(0, 1, 0), camera, false) clipEffect.Parameters "ClipPlane0" .SetValue(new Vector4(refractionPlane.Normal, refractionPlane.D)) device.SetRenderTarget(refractionRenderTarget) device.Clear(ClearOptions.Target ClearOptions.DepthBuffer, Color.Black, 1, 0) foreach (EffectPass pass in clipEffect.CurrentTechnique.Passes) pass.Apply() DrawTerrain(clipEffect, camera, device) device.SetRenderTarget(null) refractionTexture (Texture2D)refractionRenderTarget FileStream stream File.OpenWrite("Screenshot33.png") refractionTexture.SaveAsJpeg(stream, refractionTexture.Width, refractionTexture.Height)


How can I properly rotate a 2D vector in the "flipped" XNA client space? In my 2d XNA game, because SpriteBatch treats world space as client space and has positive Y axis down and negative up, I've built my game's world space with that coordinate system too. However, I've hit a snag when I try to rotate a position around the origin using a matrix. var p1 new Vector2(95f, 40f) var m Matrix.CreateRotationZ(MathHelper.ToRadians(90)) var p2 Vector2.TransformNormal(p1, m) This results in p2.X 40 and p2.Y 95. If there's an object that is positioned relative to another object and that other object rotates, the child object gets swung around the parent object in the opposite direction because the matrix works in the positive Y axis up and negative down coordinate system. What's the best way to account for this? Negate the Y value before and after transforming? EDIT To get more detailed I am trying to do a transformation like this, where child rotates with parent I though I would be able to multiply the matrices from the child object up through each of its parents' transform matrices in order to get its final world position, scale, and rotation that can be passed to SpriteBatch.Draw. Unfortunately the combined translations and rotations don't work out properly with the inverted Y axis.


How to clip cut off text in a textbox? I'm writing a textbox class for my XNA game and I'm using SpriteFont to draw the text. It's only a single line textbox so when the text width exceeds the size of the rectangle box, it currently just keeps going. In Windows textboxes extra text is cut off so that you may only see half a letter. I'd like to emulate this with my custom control. However, I see no overload with SpriteBatch.DrawString that would allow for anything that could cut off text that didn't fit within certain bounds. Does anyone know of a method that would allow for this? I'm still quite new to the XNA API so I'm not sure what out there exists for this sort of thing.. Thanks


Dynamically Deformable Terrain In Game Engine I am looking for a game engine that is open to the public for free or at a payed price that allows for any reasonable way of doing deformable terrain over a network. The closest I have found to this is in udk where one can build a terrain in 3ds, cut it up, and import different chunks into udk, and fracture them. Unfortunately after a few hours work I discovered that this doesn't seem to work too well for what I am trying to do. Can anyone recommend a game engine, or even a rendering engine that supports this? Programming other features into a rendering engine is not an issue for me.


How do I use tiles and sprites together in an isometric scene? I'm trying to write a 2D isometric scene. Rendering order is complex, since both tilemaps and sprites are different concepts. Rendering one of the 2 before the other will draw the scene incorrectly. Tiles and Sprites both have some common data that can be used as render information. I thought of creating an extra object which simply holds the coordinates and texture data. However, this also meant having to couple a tile or sprite to a render info object. (something I haven't figured out). This adds complexity. However, I thought this way I could abstract over any renderable object. This tutorial defines tiles as any other sprite and then uses a topology algorithm to sort the scene every frame. I was actually thinking of using the pigeon hole algorithm by sorting the render info objects on their depth property. How is this usually done? I can't wrap my head around it. Bear in mind that I have no actual z depth to work with. Everything relies on the artificial depth from the x and y coordinates.


How to render Viva Pinata fur In the game Viva Pinata, cute virtual animals have color changing paper cut like furs. It didn't seem like using shell rendering because there are LOTS of animals in a scene and shell rendering each every one of them to render these furs sounded like a daunting process for a game. I tried to build 3d model with each triangle but that didn't seem like right solution either. I am out of my tricks in my pocket.


What are some of the more commonly used projectile rendering techniques? couldn't find a duplicate question (bit surprising to me) but anywho I'm starting to get near implementing the rendering of projectiles for my game. My question is what are some good techniques for efficiently rendering projectiles? I would like emphasis on techniques that leave room for the projectiles to be "rich" and dynamic (Cool to look at!) I'm also using DX11 for my rendering engine so bleeding edge techniques that can make use of that would be much appreciated too. Thanks!


What is the best PBR real time Fresnel function? I'm working on a physically based renderer, and I've come to a sort of crossroads regarding the Fresnel factor. I'm having trouble finding the best way to represent it. I know that Schlick's Fresnel approximation is based off IOR, but IORs can go up to 38.6 for a meta material, and 4.05 for a natural element, which will make representing these in a 0 1 image difficult and confusing. I also noticed that no one really uses IOR maps. I also read a paper on Unreal's PBR integration, and I discovered that they initially wanted to use a F0 of 0.4, for non metals. What would be the F0 for metals, in this case, and isn't the static value of 0.4 worth the limitations for that tiny bit of memory? I believe the F0 tends to the base color, as it becomes more metallic, but I'd like confirmation. Finally, there's reflectivity or specular, as is used in modern PBR equations. Is there a standard for this, in regard to getting an F0? It seems arbitrary is it a float value up to that directly maps to F0? I am not sure if there are any real reasons to not combine specular color and base color, as Unreal has done this, before. I can't think of a single real reason, even for more stylized implementations. What is the best PBR real time Fresnel function?


How to maintain char widths of non monospace fonts? Having a font via spritesheet (as PNG), the easiest way to render fonts from that is just showing chars as monospace, but as you can imagine, that looks not pretty with chars like l, i, and so on.. Is there a slick way to maintain the width of every char? I already thought of storing it into an extra file, telling the width of each char in pixels. Pro Fast rendering. Con That's one load of work for about 100 chars. I gave "counting" the pixel width of each char on rendering it a thought. Pro Once that algorithm does it's job there's no work with that afterwards. Con As there is pretty much font rendering going on each frame, this is plain bullshit performancewise. I'm open to suggestions and or known algorithms for this problem. EDIT TTF or some other real font is not an option, because they render wayy to pixelated on the small sizes needed. EDIT Thanks to lorenzo gatti, made simple marker pixels in the spritesheet like so Distance between these gets counted on startup of the game and the markers are replaced with transparent pixels. So no heavy additional logic in render which would slow down and startup time is not really slower than before, thanks!


How should I set camera in Blender for example to render a sprite which can be used in an isometric map? I am trying to render some 3D model in blender and use them as a texture sprite in a game which uses Apple s SpriteKit. I have an isometric map with tiles size 32 as width and 24 as height, Since I use same size tile whole over the map (isometric) I need to use an orthographic projection I think! please tell me if I am wrong but I was pretty sure! anyway... I am using Blender to render my sprites (3D models) but I can not set the camera direction to have the rendered image really fit with the map. The attached picture shows the problem, take a look at the building. I have also attached the geometric math that I have used to create my render script in Blender. I found out that if I use a 32,24 tile I need to look at from 29Deg 29Min 28Sec but it seems not alright as the iOS simulator shows! Can anyone help me on this? How do I have to prepare my sprite to fit well on my isometric map? Those who have experience with isometric map games are welcome to answer and I really appreciate it. Here is the code I wrote in python to render the 3D Model, I have also set the camera to Orthographic manually. import bpy cam bpy.data.objects "Camera" def look at(cam, point) loc camera cam.matrix world.to translation() direction point loc camera point the cameras ' Z' and use its 'Y' as up rot quat direction.to track quat(' Z', 'Y') assume we're using euler rotation cam.rotation euler rot quat.to euler() meshObj bpy.data.objects "plate" meshObj.rotation mode 'XYZ' meshObj.rotation euler (0,0,0) d meshObj.dimensions Finding maximum dim of the object objectScale 1 if d 1 gt d 2 objectScale d 1 16 elif d 2 gt d 1 objectScale d 2 16 cam.rotation mode 'XYZ' cam.location (20.416 objectScale,20.416 objectScale,20.416 objectScale) cam.rotation euler (0.7853,0.7853,0.5147) cam.rotation euler (0.7853,0.7853,0) look at(cam, meshObj.matrix world.to translation()) alamp bpy.data.objects "Lamp" alamp.location (17.416 objectScale 4,17.416 objectScale 4,20 objectScale 4) print("Scaling ",objectScale) bpy.context.scene.render.filepath " Users iman Documents Render ISOBUILDING.png" bpy.ops.render.render(write still True, use viewport True, scene "Camera )


When a Render Pass decides what textures it needs, how are shaders written? I am studying render graph architectures (I've seen the Frostbite presentation). A RenderPass has outputs (i.e. textures you draw to) and inputs. How are these inputs bound to the internal pipeline ? Lets say I have an AO Pass and it has Normals and Depth as the input. Do I just bind the texture to a register and that's it and sample it? What about the actual shaders (for drawing geometry) that also use textures?


What is a texture atlas? I've heard about this concept, but what is it?


Rendering models in isometric view How to setup the rendering and camera for isometric gameworld projection? And specifically how do i get the images exactly the right size? What angles to use to get the exact 2 1 isomtric view? Methods to set the camera on the right position? Options to set like anti alias off. I have tried many things, 45, 30, 35.264 degree angles. What i do is set the angle of the camera, then place the camera in front of the model then use dolly fov lens settings to get the left and right edge of the model lined up with the save frame. Then adjust camera height so the bottom lines up with the bottom of the save frame. But i keep getting jagged edges and not the isometric style 2 width one height.


iPhone GLSL shader dynamic branching issue I am trying to pass an array of vec3 as uniform and then iterate through them on each pixel. The size of array varies on situations so I can't make the loop with constant number of iterations. Here is the code precision highp float precision highp int varying vec4 v fragmentColor varying vec4 v pos uniform int u numberOfParticles const int numberOfAccumsToCapture 3 const float threshold 0.15 const float gooCoeff 1.19 uniform mat4 u MVPMatrix uniform vec3 u waterVertices 100 void main() vec4 finalColor vec4(0.0, 0.0, 0.0, 0.0) vec2 currPos v pos.xy float accum 0.0 vec3 normal vec3(0, 0, 0) for ( int i 0 i lt u numberOfParticles i ) vec2 dir2 u waterVertices i .xy currPos.xy vec3 dir3 vec3(dir2, 0.1) float q dot(dir2, dir2) accum u waterVertices i .z q float normalizeToEdge 1.0 (accum threshold) 2.0 if (normalizeToEdge lt 0.4) finalColor vec4( 0.1, normalizeToEdge 0.5, 0.9 normalizeToEdge 0.4, 1.0) if ( normalizeToEdge lt 0.2 ) finalColor vec4( 120.0 255.0, 245.0 255.0, 245.0 255.0, 1.0) float shade mix( 0.7, 1.0, normal.x) finalColor shade gl FragColor vec4(finalColor) The problem is here for ( int i 0 i lt u numberOfParticles i ) vec2 dir2 u waterVertices i .xy currPos.xy vec3 dir3 vec3(dir2, 0.1) float q dot(dir2, dir2) accum u waterVertices i .z q When I make the for loop like this for ( int i 0 i lt 2 i ) ... I get double the framerate even though u numberOfParticles is also 2 Making it like this for ( int i 0 i lt 100 i ) if (i u numberOfParticles) break ... gives no improvement. The only way I know to cope with this situation is to create multiple shaders. But The size of array may vary from 1 to 40 and making 40 different shaders just because of the for loop is stupid. Any help or ideas how to deal with this situation ?


OpenGL ES 2.0 Repository of Quality Shaders Could I kindly ask, to suggest me a repository of high quality OpenGL (OpenGL ES 2.0) vertex and fragment shaders, please? I am looking for pixel based ligting shaders (such as phong) and simmilar. It would be nice to see more of them, to be able to choose between quality vs shader performance.


2D day night mapping I'm looking for this kind of effect MINUS the lights and snow (Another problem). It needs to change depending on the time of year. Doesn't need snow or city lights. Now I'm pretty new to shaders (learnt them yesterday in my spare time) but so far I have achieved This moves across the screen display light on both sides. Now I'm completely lost, as to how I can make it seem like a light map I.E. it needs to be more square sharper (As it's going off the edges) amp have the bottom and top times of year.. I though maybe I could pass sphere mesh to the vertex? Or do something with the map normal. Or maybe use blending with two textures but I've looked around and it looks extremely difficult. Code I have so far Fragment Pixel shader attributes from vertex shader varying vec4 vColor varying vec2 vTexCoord our texture samplers uniform sampler2D u texture diffuse map uniform sampler2D u normals normal map values used for shading algorithm... uniform vec2 Resolution resolution of screen uniform vec3 LightPos light position, normalized uniform vec4 LightColor light RGBA alpha is intensity uniform vec4 AmbientColor ambient RGBA alpha is intensity uniform vec3 Falloff attenuation coefficients uniform float lightX X Position of light. Can also feed Y for times of the year. void main() RGBA of our diffuse color vec4 DiffuseColor texture2D(u texture, vTexCoord) RGB of our normal map vec3 NormalMap texture2D(u normals, vTexCoord).rgb int numberOfLights 3 vec3 lightPoses 3 vec3 lightDirections 3 LightX goes to 0, then back to 1. lightPoses 0 vec3(lightX 1.0, LightPos.y, LightPos.z) lightPoses 1 vec3(lightX, LightPos.y, LightPos.z) lightPoses 2 vec3(lightX 1.0, LightPos.y, LightPos.z) TODO Introduce one extra light for top and bottom. OR Figure out how to squash the Y. TODO Needs to be sharper light. vec3 Sum vec3(0.0) Go though both lights. for(int index 0 index lt numberOfLights index ) The delta position of light vec3 LightDir vec3(lightPoses index .xy (gl FragCoord.xy Resolution.xy), LightPos.z) Correct for aspect ratio LightDir.x LightDir.x (Resolution.x Resolution.y) Make it bigger. (smaller the value the bigger.) LightDir vec3(0.55, 0.4, 1.0) Determine distance (used for attenuation) BEFORE we normalize our LightDir float D length(LightDir) normalize our vectors vec3 N normalize(NormalMap 2.0 1.0) vec3 L normalize(LightDir) Pre multiply light color with intensity Then perform "N dot L" to determine our diffuse term vec3 Diffuse (LightColor.rgb LightColor.a) max(dot(N, L), 0.0) pre multiply ambient color with intensity vec3 Ambient AmbientColor.rgb AmbientColor.a Because there are more lights, take off total ambient power. Ambient vec3(1.0 float(numberOfLights)) Calculate attenuation (The amount of fade the light has.) float Attenuation 1.0 (Falloff.x (Falloff.y D) (Falloff.z D D)) the calculation which brings it all together vec3 Intensity Ambient Diffuse Attenuation vec3 FinalColor DiffuseColor.rgb Intensity Sum FinalColor gl FragColor vec4(Sum, DiffuseColor.a) Vertex Shader combined projection and view matrix uniform mat4 u projTrans "in" attributes from our SpriteBatch attribute vec4 a position attribute vec4 a color attribute vec2 a texCoord0 "out" varyings to our fragment shader varying vec4 vColor varying vec2 vTexCoord void main() vColor a color vTexCoord a texCoord0 gl Position u projTrans a position


2D HLSL World position I'm trying to get world position from my vertex shader to my pixel shader so that I can disable the shader once a preset X coordinate has been passed (no shading once I'm over X). Getting the screen position is not a problem so far but despite my best efforts to look after it and implement examples the calculations just don't return the preferred world positions I'm looking for. Update So got it to somewhat work, after compiling the shaders the output changes to such Could anyone explain why this happens? I should mention that I'm really new to HLSL, been only scripting so far. Edit Added matrices. world Matrix.Identity view Matrix.CreateScale(new Vector3(1, 0.75f, 0)) Matrix.CreateTranslation( playerpos.X, playerpos.Y, 1) projection Matrix.CreateOrthographicOffCenter(0, view.Width, view.Height, 0, 0, 1) Matrix halfPixelOffset Matrix.CreateTranslation( 0.5f, 0.5f, 0) projection halfPixelOffset projection lt code texture lightMask sampler mainSampler register(s0) sampler lightSampler sampler state Texture lightMask float4x4 World float4x4 View float4x4 Projection struct vs2ps float4 Pos POSITION0 float4 TexCd TEXCOORD0 float3 PosW TEXCOORD1 vs2ps VS(float4 Pos POSITION0,float4 TexCd TEXCOORD0) vs2ps Out Out.Pos mul(Pos, World View Projection) Out.TexCd TexCd Out.PosW mul(Pos, World) return Out float4 PixelShaderFunction(vs2ps input) COLOR0 float2 texCoord input.TexCd float4 screenPosition (input.PosW,1.0f) float4 lightColor tex2D(lightSampler, texCoord) float4 mainColor tex2D(mainSampler, texCoord) if(screenPosition.x lt 3500) return (mainColor lightColor) else return mainColor


Matcap and BRDF Shading I just would like to know what's the difference between the Matcap shaders used in ZBrush for example and the Bidirectional Radiance Distribution Function shader. Are there two techniques the same ? Is Matcap done using BRDF or are they different ?


vertex pixel shaders and "materials" What relationship is there, if any, of "materials" and vertex pixel shaders (or the "effects" that combine the latter two)? I have the impression that before the advent of HLSL, materials were explicitly handled by Direct3D or OpenGL. I also have the impression that with HLSL, many prior effects are now handled directly (and generically) via the rendering pipeline in vertex pixel shaders. In other words, I hae the impression that materials are often little more than what DirectX would call an "Effect." If so, this means that many models that specify materials would be transformed by a content pipeline into an "Effect". Is this correct? Where can I get a little more history info that either corroborates or corrects the impression I have?


What are the pros and cons of HLSL vs GLSL vs cg? What are the pros cons of the three?


DirectX 11, using Tessellation Geometry shader in a single pass Before all, sorry for my poor english ! With DirectX 11, i'm trying to create a random map full with GPU. Using Hull shader stage, I'm managing LOD with tessellation. Using Domain shader stage, I'm generating the map (based on perlin noise). Now my goal, is to compute normals in the geometry shader (normal on vertex). For that, I must use vertex adjency, like geometry is capable of. But here is the problem... For tessellation, my primitives must be D3D11 PRIMITIVE TOPOLOGY 3 CONTROL POINT PATCHLIST. But for geometry shader with 6 vertex (triangle primitive and adjency), I must use D3D11 PRIMITIVE TOPOLOGY TRIANGLELIST ADJ. Think I'm missing something... It must be possible to tessellate and use the results in the geometry shader... However, it's working with 3 points, but I cannot use the 3 others (they are 0.0, 0.0, 0.0).... Thank you in advance for any help )


Wrap texels between desired values I'm using a basic pixel shader here uniform sampler2D texture uniform float pixel threshold void main() float factor 1.0 (pixel threshold 0.001) vec2 pos floor(gl TexCoord 0 .xy factor 0.5) factor gl FragColor texture2D(texture, pos) gl Color It works great in my game. But on a new enemy it doesn't. This enemy is different because it uses a texture atlas one big texture holding more frames than just the character. The sampling gets messed up because factorapproaches 0 so does the xy coord therefore sampling some pixels outside of the character's sheet. Likewise when pixel threshold gets small, the xy coord goes outside of the character's spot in the texture. Clamping is not the solution because we want it to wrap around. I've tried many ways of wrapping but not seem to offer the desired effect of the original. I tried using 4 uniforms left,top,width,height and passing in the masking values used when drawing the sprite from the spritesheet. vector2 size mySprite.getSize() float left mySprite.getTextureRect().left size.x float top mySprite.getTextureRect().top size.y float width mySprite.getTextureRect().width size.x float height mySprite.getTextureRect().height size.y myShader.setUniformf("left", left) ... myShader.setUniformf("height", height) How can I have the pixel blur shader stay within the texel ranges provided by the uniform? Thanks.


HLSL's Tex2D for GLSL? I am trying to port a HLSL shader to GLSL. I'm just not quite sure how to convert this line outA Input.Color.a tex2D(s, Input.TexCoord.xy float2( 4.0 pxSz.x blurSize,0)).a 0.05 It's mostly the Tex2D I'm having trouble with. In GLSL, it seems to work differently. I'm porting a horizontal blur texture al tex sampler2D s sampler state texture lt al tex gt int tWidth int tHeight float blurSize 5.0 float4 ps main(VS OUTPUT Input) COLOR0 float2 pxSz float2(1.0 tWidth,1.0 tHeight) float4 outC 0 float outA 0 outA Input.Color.a tex2D(s, Input.TexCoord.xy float2( 4.0 pxSz.x blurSize,0)).a 0.05 outA Input.Color.a tex2D(s, Input.TexCoord.xy float2( 3.0 pxSz.x blurSize,0)).a 0.09 outA Input.Color.a tex2D(s, Input.TexCoord.xy float2( 2.0 pxSz.x blurSize,0)).a 0.12 outA Input.Color.a tex2D(s, Input.TexCoord.xy float2( pxSz.x blurSize,0)).a 0.15 outA Input.Color.a tex2D(s, Input.TexCoord.xy float2(0,0)).a 0.16 outA Input.Color.a tex2D(s, Input.TexCoord.xy float2(pxSz.x blurSize,0)).a 0.15 outA Input.Color.a tex2D(s, Input.TexCoord.xy float2(2.0 pxSz.x blurSize,0)).a 0.12 outA Input.Color.a tex2D(s, Input.TexCoord.xy float2(3.0 pxSz.x blurSize,0)).a 0.09 outA Input.Color.a tex2D(s, Input.TexCoord.xy float2(4.0 pxSz.x blurSize,0)).a 0.05 outC.a outA return outC Thanks


How can I find all connected objects of the same type recursively? In my game, when a user selects an object of some type, I'd like to search for all other objects of the same type that are connected to that first one. For example, if the user selects a object of type 2, I want to check the object next to that one to see if it is also of type 2 and so on in all directions (up, down, left and right, et cetera) until there are no more objects of that type connected. Does anyone know how I could do something like this? You can assume I have access to the set of connections from any given object.


Body lost a velocity component when hitting a wall I am creating a Breakout game using Box2D (of LibGdx if anyone interest). Everything works well until when the ball hits the wall when moving with a very small angle. Please look at the image for details I tried to set the wall friction to 0 and restitution to 1, as well as the ball's friction and restitution, but it still move along the wall (I have no World Gravity). This also happens to the vertical wall if the angle is small enough, it will lose X velocity. How can I move the ball the way I expected? If there is no friction, what caused the problem? EDIT In case of LibGdx only, this is a fix World.setVelocityThreshold(float threshold) I set it to 0.1f, and it helped. If you encounter problem, maybe 0 can help, but it is unrecommended..


LibGDX sound playing problem I'm making a game and I want to play sounds in it. I have AssetManager which loads the sounds and I made a class which has playSound(String sound) method. This method calls the get() method of the assets manager with the string, creates Sound type file and calls it's play() method. The code public void playSound(String sound) Sound file gameRenderer.assetsManager.get("sfx sounds " sound ".wav") file.play() It works fine. But then I noticed there is a log that occurs every time the sound is played AUDIO OUTPUT FLAG FAST denied by client I also noticed a small "tick" sound in the end of the sound every time it's played in the game. I read about it and from what I've learned it has something to so with sample rate. I tried many types of sounds (44KHz, 48KHz, and lower values too) but it doesn't stop printing that log. I couldn't find a solution anywhere. If it really has something to do with sample rate, does it mean I need to have different types of file of the same sound (With every sample rate)? If it does, my game would be heavy... I'm using Nexus 5. Thanks!


Using libraries in libgdx This is the first time I'm using libgdx and I've got one problem. I am confused by the web of dependencies and the number of projects and I'm not sure how and mostly where to add a third party library I want to use. It should work both for desktop and android. How is this done?


LibGDX buttons bounds are wrong I am making a simple gui in libgdx and run into this problem when you click on the button it's bounds (?) are wrong since if I click under it, the game registers it as a click. On the other end, if I click it at the top it won't get the click. It seems like the bounds are a bit under the button. I tried to set manually but nothing. Also i tried changing sizes. Looked here too this is almost the same but no answer.. tabl new Table() stage new Stage() tabl.setSize(stage.getWidth() 2, stage.getHeight() 2) tabl.defaults().size(500, 40) g game Gdx.input.setInputProcessor(stage) skin new Skin() TextureAtlas te new TextureAtlas(Gdx.files.internal("uiskin.atlas")) skin.addRegions(te) skin.add("default font", new BitmapFont()) skin.load(Gdx.files.internal("uiskin.json")) Pixmap r new Pixmap(100,100,Format.RGBA8888) r.setColor(0xff0000ff) r.fillRectangle(1, 1, 13, 13) Texture s new Texture(r) SpriteDrawable s1 new SpriteDrawable(new Sprite(s)) TextButton gam new TextButton("new games",skin) gam.addListener(new InputListener() Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) TODO Auto generated method stub g.setScreen(null) new Logger("e").setLevel(10) return true ) super.getS LabelStyle tt new LabelStyle(new BitmapFont(), Color.BLUE) Label l new Label("d",tt) tabl.add(gam) tabl.setDebug(true) stage.addActor(tabl)


Tween animation with Universal Tween Engine LIbGDX Let me preface by saying that I'm new to libgdx... I have an animation that I'm currently drawing to the screen using game.batch.draw(flyAnimation2.getKeyFrame(elapsedTime, true), 200,200,0, 0, 124, 90, 1.0f, 1.0f, 90) Where flyAnimation2 is Animation flyAnimation2 This works correctly. I now want to use UniversalTweenEngine to tween it from one side of the screen to the other. I can't find any decent documentation on how to achieve this affect using an Animation. Any help would be appreciated!!


Making a border around a translucent shape in LibGdx The recommended method for making a border around a shape using LibGdx is to draw a larger version of the shape to serve as the border, then draw the shape over the larger image. shapeRenderer.setColor(borderColor) shapeRenderer.circle(x, y, radius borderWidth) shapeRenderer.setColor(shapeColor) shapeRenderer.circle(x, y, radius) This works well most of the time, but if you want shapeColor to have any opacity less than 1, it fails. The problem is that you can see the borderColor through the shape, and the colors are blended. Is there anyway to fix this issue?


Statemachine to behaviour tree? Background I was able to convert simple statemachines like this... Into a BT looking like this (Notation describtion)... root sequence After another playAnimation name idle sequence walks? Breaks current sequence if false playAnimation name walk sequence runs? playAnimation name run Goal But how do we convert more complex multi layered animation states into a behaviour tree ? How would such a BT look like ? The difficult parts here are transistions between the different states, something i couldnt solve in an BT. Question Is it possible to convert every statemachine into a behaviour tree ? What does the theory says and how does it look like in practice ?


let me know how to save an integer for game stage level? I am trying to make a game which there are many stages. For example, If users are done stage 3 of the game, and then turn off the game, they can play the game at stage 3 anytimes. simply, I tried to make this logic, so when you press space bar, the level goes up. However, after turning off and on, lev will start at 0. I guess when program are ruining every single times, the lev is initialized 0. I tried to use preference. please let me know solutions.. AppPreferences.java public class AppPreferences private static final String PREFS NAME "Adventure" private static final String PREF LEVEL "Level" private Preferences preferences protected Preferences getPrefs() if (preferences null) preferences Gdx.app.getPreferences(PREFS NAME) return preferences public void setPrefLevel(int level) getPrefs().putInteger(PREF LEVEL,level) getPrefs().flush() public int getPrefLevel() return getPrefs().getInteger(PREF LEVEL) PlayScreen.java public class PlayScreen implements Screen int lev 0 public void render(float delta) if(Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) advanture.getPreferences().setPrefLevel(i) System.out.println(advanture.getPreferences().getPrefLevel() "!!!!!!!!!") i


Box2dMapObjectParser isometric map bodies have wrong position and size I'm using Box2dMapObjectParser to load Tiled objects layer onto my IsometricTiledMapRenderer'ed TiledMap. It works OK with a UnitScale of 1 but the position is wrong and some shapes have weird rotation and size. Map in Tiled Map in game I've found another similar question but the answer is unfortunately far from being clear, at least to me. Relevant code mParser.load(mWorld, mMap) mRenderer new IsometricTiledMapRenderer(mMap, mParser.getUnitScale()) Notice the 'Ellipse' is not drawn at all, the Rectangle is way off and Polygons Polylines are just not positioned right. Did anyone experience the same issue and or have any idea how to fix this?


How should I use Monte Carlo method to simulate some police cars that keep patroling in a tile based map? I have a tile map (isometric) and I have some police cars that they patrol all the time on the map, there is some building and other cars in map too so they are considered as constraints in my shortest path algorithm (below). I use to randomly select some target for each police car and use A algorithm to find the path to the randomly selected destination tile and this cycles over and over. because cars should move all the time! (except those that gamer should control) The problem is police cars routes are correlated and they do not just traverse the area randomly, for instance, they do not usually cover a same area or they do not repeat their own route so my implementation based on some random destination point wasn t a good idea and the result was not satisfying. Take a look at the following picture, it shows how randomly selecting the destinations worked for me, obviously, it is a dumb patroling for sure, even a cockroache could do better! Suddenly, I remembered Monte Carlo Method and I thought it would solve my problem, because it exactly does what I wanted to do, However may be I should use Zobrist Hashing since it is tile base in nature. Does anyone has any idea how should I use this kind of methods? Question in Brief How can I use Zobrist Hashing or Monte Carlo method to set destinations points for my patroling car (like police car)? If anyone knows another way to implement a patrolling method, he she is very welcome to post an answer, I am not sure if Zobrist Hashing is the best and worth to implement. First Edit (added following paragraph) I need to distribute the cars and their destination points in a homogeneous manner. Every kind of solution that get me close to a good pattern could be my answer, of course there is a lot of methods to do so, but I dont have any clue.


How do I implement group formations in a 3D RTS? I managed to get pathfinding work for a single unit, and I managed to avoid agent agent collision, but now I need to be able to send a group of agents to some location. This is my set up so far Waypoint pathfinding The minimum distance between two nodes is a little bigger than the biggest bounding sphere radius allowed for an agent. Agents avoid collisions with other agents by doing some steering behaviour I based on clearpath So now I need to send my agents somewhere in group. I have read some posts saying that some way to do it is to create a group leader and give the other units offsets to his position. But then the problem is, what if the group formation cannot be achieved? e.g. you want to form a rectangle, but at the target position there is a structure nearby which prevents you from creating a rectangle setup.


A Algorithm for Tactical RPGs? I'm messing around with writing a really poor tactical RPG in C . So far I have a 2D tile map and just got the A algorithm working based on the pseudocode in the wikipedia. But real tactical RPGs don't just find the best path on a flat plane and move there. They typically have limited move ranges and must climb up or down. If you've ever played Final Fantasy Tactics these would be affected by the Move and Jump stats. This is where I get lost. How do I alter the A algorithm so that it finds the best path toward a target, but the path is only so many tiles long? How should I take height differences and jump stats into account? How do I implement jumping over a gap? If it helps, right now my map is represented by a Vector of Tile objects. Each tile has pointers to the North, South, East, and West tile, which are set to a nullptr if no tile exists there, such as along the edge of the map or if a tile is set to non passable.


Shortest path to a road I have a road network and a vehicle that is current off the roads. I want to find the shortest path to any road. An obvious solution is to run a pathfinding algorithm between the current vehicle location and all the points on the road, but that's hardly scalable. I am curious to know if there is an algorithm out there that I could use to maximize the performance of this operation.


Pointy top hexagonal A pathfinding I'm trying to create a game with a hex based map with the points at the top. I have most of it working, however the path finding is being a little awkward. The heuristic I'm using is called Euclidean I believe and is like so var dx Number destinationNode.c node.c var dy Number destinationNode.r node.r return Math.sqrt((dx dx) (dy dy)) Node is the node the unit is currently on, c is the node's column number and r is its row number. I'm using these as a simpler x and y coords. I'm trying to limit the unit to 3 hex moves in one round, so initially I thought it'd be as simple as IF returned heuristic lt 3 unit can move to that hex, however it's not working out quite like that. As you can see in the pic above, the bottom right selected hex with the "1 9 3.162277" is moveable to in 3 moves, however the hex with "9 1 3.162277" on the far right would need 4 moves to reach it. Can anyone offer any advice on how to make this work? EDIT My problem was being caused because I was using a Cartesian coordinate system and was just staggering every other Y coord. Fixed this by making the Y axis go down at a 60 degree angle. Thanks to amitp for the links that showed me what I was doing wrong.


UE4 Navmesh precision I'm trying to make my very tiny man pathfind his way through a map of a school but the navmash won't recognize some of the hallways cause they are very narrow like this. So as you can see the man can fit but the navmesh says no so can anyone help and keep in mind that i am very new to unreal engine so please make your explanation easy to understand.


What is the most appropriate path finding solution for a very large proceduraly generated environment? I have been reading quite a bit in order to make the following choice which path finding solution should one implement in a game where the world proceduraly generated, of really large dimensions? Here is how I see the main solutions and their pros cons 1) grid based path finding this is the only option that would not require any pre processing, which fits well. However, as the world expands, memory used grows exponentially up to insane levels. This can be handled in terms of processing paths, trough solutions such as the Block A or Subgoal A algorithms. However, the memory usage is the problem difficult to circumvent 2) navmesh this would be lovely to have, due to its precision, fast path calculation and low memory usage. However, it can take an obscene pre processing time. 3) visibility graph this option also needs high pre processing time, although it can be lessened by the use of fast pre processing algorithms. Then, path calculation is generally fast too. But memory usage can get even more insane than grid based depending on the configuration of the procedural world. So, what would be best approach (others not present in this list are also welcome) for such a situation? Are there techniques or tricks that can be used to handle procedural infinite like worlds? Suggestions, ideas and references are all welcome. EDIT Just to give more details, one should see the application I am talking about as a very very large office level, where rooms are generated prodecuraly. The algorithm works like the following. First, rooms are placed. Next, walls. Then the doors and later the furniture obstacles that go in each room. So, the environment can get really huge and with lots of objects, since new rooms are generated once the players approaches the boundary of the already generated area. It means that there will be not large open areas without obstacles.


Use pathfinding algorithm in a navmesh with several endpoints I need to implement a pathfinding algorithm in a navmesh with several endpoints, and I would like to find the path to the closest endpoint. I suppose that Dijkstra algorithm is the best solution for that but it needs some adaptation. Is someone could help me please ?


How to adapt pathfinding algorithms to restricted movement? Imagine car like movement where entities cannot turn on a dime. Say, for the sake of discussion, that when at speed they can turn 90 degrees per second. This would in many cases change the optimal path and therefore the pathfinding. It may even make 'usual' paths entirely impossible to traverse. Are there any pathfinding algorithms or movement planning algorithms that can keep this in mind, or are there simple ways to adapt the popular ones?


How can I implement caching into my Rectangular Symmetry Reduction pathfinding algorithm? I have a working implementation of Rectangular Symmetry Reduction (see here and here for more information on RSR). I'm interested in further improving performance over raw A by implementing caching of paths. My assumptions are as follows We're working on a 4 connect square grid The Destination position is more important than the start position. Because RSR is made possible via contiguous rectangular regions, the fastest path between two points in the same region is likely to be the same (but not always) It's at this point that I get stuck I'm unsure how best to use those assumptions and the information generated by a path calculation to better future path calculations. I've considered storing the path cost from the final waypoint (that is, where the resultant path leaves the first rectangle), but as far as I've been able to consider, that is only useful if I have the path cost from every other potential waypoint on the rectangle's edge so good if you've got a lot of rectangular rooms separated by doors (few open edges), less so if you're pathing around wide open fields with a few scattered rocks (many open edges). Essentially, my intuition is that going that route would potentially necessitate a lot of pathfinding before caching could provide any returns, so I'm looking for someone else's opinion on whether I'm on the right track, or if I'm missing a simpler way of implementing a performance boosting caching algorithm. Thoughts? I'm more than happy to discuss more of what I understand of the algorithm or share specific code if requested.


MMO Some NPCs controlled clientside? I'm making an online game and considering whether to handle certain NPCs clientside. Is this common? For example I play Elder Scrolls Online and it seems basic townspeople NPC locations aren't quite synced up with my friends. I guess it makes sense if they're only wandering around in a set area for that to be handled clientside right? So my question is, should I go with this method, or are there any good reasons why I shouldn't? Any examples of games that do, so I can see how they handle it?.


Node.js MMO process and or map division I am in the phase of designing a mmo browser based game (certainly not massive, but all connected players are in the same universe), and I am struggling with finding a good solution to the problem of distributing players across processes. I'm using node.js with socket.io. I have read this helpful article, but I would like some advice since I am also concerned with different processes. Solution 1 Tie a process to a map location (like a map cell), connect players to the process corresponding to their location. When a player performs an action, transmit it to all other players in this process. When a player moves away, he will eventually have to connect to another process (automatically). Pros Easier to implement Cons Must divide map into zones Player reconnection when moving into a different zone is probably annoying If one zone process is always busy (has players in it), it doesn't really load balance, unless I split the zone which may not be always viable There shouldn't be any visible borders Solution 1b Same as 1, but connect processes of bordering cells, so that players on the other side of the border are visible and such. Maybe even let them interact. Solution 2 Spawn processes on demand, unrelated to a location. Have one special process to keep track of all connected player handles, their location, and the process they're connected to. Then when a player performs an action, the process finds all other nearby players (from the special player process location tracking node), and instructs their matching processes to relay the action. Pros Easy load balancing spawn more processes Avoids player reconnecting borders between zones Cons Harder to implement and test Additional steps of finding players, and relaying event action to another process If the player location process tracking process fails, all other fail too I would like to hear if I'm missing something, or completely off track.


How do you design a record replay system for a frequently changing game? I'm working in a free MMORPG and I have a problem. I'm (with other people) developing a video recording system for the game. The idea is basically we record all the packages sent amp received with timestamps, plus some local data from the client, and then dump it in a file. For playing the video, we just emulate everything that's on the file. We also have an option to export the video to avi with ffmpeg. The problem is when we change between versions of the game, it is hard to maintain backwards compatibility for the video (commands added removed, function changes, etc). Is there a good way to handle this problem? instead of having a bunch of different players and choose the right one for each version of the video file? It would be helpful to know how does other games handle this situation. Thanks for the help, sorry for my english.


Recommended RPG game that can be used to learn game Modding? I would like to learn game development via game modding. RPG MMORPG is one of my favorite genres. Could someone recommend me a good and recent ( I would like to play the game as well) game to learn game modding. Something with the likes of Neverwinternights 2. Thank you very much for the responses. Appreciate it.


What are some alternative options for saving level data for a game like Hurtworld? For a multiplayer building crafting game like Hurtworld (where the player can build structures on the map), what are some alternative options or example data structures for saving the world data on the server? Level data including Grid of squares that foundations can be built on, with a flag to indicate whether the square is empty or already has a foundation Walls etc which have been built on the foundations, and multiple floors above Windows doors which can be built on window frames door frames Furniture machines which can be placed on foundations floors Other dynamic world data such as trees, animals, chests with items, etc I feel like it's too much data to store in a database. Am I wrong? If it can be stored in a database, how can I get my head around the data structure I would need to set up? Is there some simplified example? Can each square in the world grid be represented by 1 row in the database? And should there be a new row for each structure built on a square, with that row referencing the square structure that it was built on?


How should I collect user behavior data in an MMO? In an MMO, and I'm trying to collect data about user behaviors for the purpose of tweaking the game rules to achieve maximum user satisfaction. Clearly one way to do it is to hand roll specific things into an application, much like one might use Console.WriteLine() to view the contents of a variable, or the StopWatch() class to see how long something takes to execute. But you can use a profiler in lieu of StopWatch, and you can use a debugger in lieu of WriteLine. How should I collect my data? Are there generalized techniques for instrumenting an application to observe user behavior, or some form of code instrumentation technique? Also, I'm only interested in collection techniques you can assume that I already know how to transmit, store and analyze said data.


Is there a way to make a dynamic world such as a MMORPG horizontally scalable? Imagine a open world of 500 players with data changing as fast as 20 updates player second. Last time I worked in a similar MMORPG, it used SQL, so obvioulsy it couldn't query the DB all the time. Instead, it loaded all players from the DB to memory as C objects and used them. That is, it scaled vertically. Would it be possible to make that server horizontally scalable instead? Is there a database designed to support that amount of updates concurrently?


How do I create a big multiplayer world in UDK? I want to create a big multiplayer world in UDK and I'm having a few difficulties. I created the biggest terrain possible but then any terrain related action I do takes forever. However, I've seen videos of people make same size terrain and working without a problem. My pc is strong enough, so maybe someone can tell me what I'm doing wrong. I want to make it even bigger then the biggest terrain size, so I was thinking of doing level streaming but then I read that streaming is working server side which means if I have a player on every terrain all terrains will still be loaded and I want to save as much memory possible so it will work well online. Thanks for any help you can give.


Client Server MMOG data structures sync when joining playing After reading a few articles on MMOG architecture, there is still one point on which I cannot find much information it has to do with how you keep in sync server data on the client, when you join, and while you play. A pretty vague question, I agree. Let me refine it Let's say we have an MMOG virtual world subdivided into geographical cells. A player in a cell is mostly interested in what happens in the cell itself, and all the surrounding cells, not more. When joining the game for the first time, the only thing we can do is send some sort of "database dump" of the interesting cells to the client. When playing, I guess it would be very inefficient to do the same thing regularly. I imagine the best thing to do is to send "deltas" to the client, which would allow keeping the local database in sync. Now let's say the player moves, and arrives in another cell. Surrounding cells change, and for all the new cells the player subscribes, the same technique as used when joining the game has to be used some sort of "database dump". This mechanic of joining moving in a cell based MMOG virtual world interests me, and I was wondering if there were tried and tested techniques in this domain. Thanks!


game state update structure and distribution in MMO? I'm developing an MMO, which has to maintain a global game state. Now I want to distribute the updates, which the players make to this state, to players which can see those updates (area of interest etc.) Is there a common structure format for these updates and for a global game state? Like, every action a player sends to the server has to include a type, the coordinates etc. And are the updates, which gets distributed from the server to the players in the same format or are they different? Also should I include timestamps or use the receive time from the server to check which action came first and which sencond etc.? And what should I send back to the player if he send an invalid action?


2d Circle different ARC's Collision detection I've read about the way to detect collision between 2 circles or circle and line using trigonometry. But now I would like be able to detect which part of the circle arcs I'm hitting. For example I divided my circle to 4 different sized arcs. I would like to know which arc gets hit, 1, 2, 3, or 4? See image What is the best collision detection algorithm for this? Or what is this called?


LWJGL Collision Detection I cannot find LWJGL collision detection with a camera and walls. Like making it to where you can not walk through walls and other different shaped rectangular prisms and cubes. How do I set up LWJGL collision?


Calculating the intersection of a fast moving circle and a line Inside of my game, I am in need of a way to test the collision between a line segment and a fast moving circle. I would say I need a line v capsule collision however the problem is I need the collision point. None of the existing formulas I can find can do quite what I need. I have tried line x line intersection and just moving the lines by the radius of the capsule sort of work however then the collision point found around the edges is off. Additionally, I can't find a way to work back from the collision point to the point that the circle first collided at. Above is sort of a picture of what I am hoping to achieve. The green capsule represents the circle's path. So really the problem here is finding that collision point because a yes or no answer is trivial here. There are formulas for ray capsule or box capsule however none of them will get me this collision point. Does anyone have any ideas on how I can figure this out?


How can I properly detect my cars collisions using hitboxes? I have created two car objects and their current speed is represented as the len variable. This is the code Under Blue Car Collision Event if (place meeting(x,y,obj CarRed)) Checking Collision len 0 Current speed if (len lt obj carRed.len) Blue Car's current speed is greater than Red's myHP obj carRed.len 2 So I copied the code to the other object and replaced Red with Blue. When the Red car crashes into the Blue car, the Blue car takes damage because the Red car is traveling faster than the Blue car. But when the Blue car crashes into the Red car, the Red car won't take any damage. Later, I thought about using a Hitbox and have it as a parent for both cars, but I don't know if it would mess up the collisions, and I don't know how to tell the hitbox that it's been created by Blue Car, or by Red Car. I don't know if I should make a new hitbox for each car or one for both.


Is there algorithm for boxcasting or thickray casting? I am not sure what the correct name is called but here is my problem I have implemented a casting ray function that works as expected. However, because I am using a loose grid structure, (ie, objects that overlap multiple grids are only put into one grid), the ray cast may miss certain objects. What I need, I think is a box casting where I need to get every grid the box hits from its initial position to final position. Does anyone have such algorithm? Or pointing out to a solution to this problem, thanks! This pic from N tutorials is a nice summary of this problem My ray cast implementation only hit the blue cells but as you can see, it may miss certain objects. They are only put into the grid where the x is. Just to add I will be using this in a heated loop and so I have the additional requirement that this must be done efficiently. EDIT this picture illustrates why I think a box casting would work for loose grid (The box must be bigger than the objects contained in the grid.)


What data should a generic collision detection system gather? I'm working on a relatively generic 2D AABB collision detection system for a game engine, and I've re written it more times than I'd like to admit, due to not calculating or recording specific details of each collision. Right now, this is what I'm collecting Collision time as a fraction of an update cycle in the game loop. Location of the collision. ID of the colliding object. Each object has a Set that holds this data for each collision (I'm working with a component entity system) so other systems can use the recorded data. The problem I just ran into was that I needed to know which side of the object the collision takes place on. What other values or points of interest should I calculate or record, per collision? What do you look for in a standard collision detection system?


Collisions between players in multiplayer racing game I'm creating a simple racing game (spaceships, no gravity) using p2.js, phaser and node.js. What I have done Client receives world state from server extrapolate other players based on latest velocity position from server check if client side prediction was correct if no apply position from server and process inputs that server was not aware of. fixed physics step Server receives inputs from clients and apply fixed physics step sends world state to each client Now I'm struggling with collisions between players. Colliding player is jumping all time during collision. I think it's because client side prediction is not calculating similar results to the server. Server doesn't know all inputs from player (lag). Player doesn't have the same position of colliding player as the server (lag). Combining this two makes the client to resolve collision different than the server and when world state arrives player has to make a big correction.


Game Maker 8.0 Can I simulate any collision event within the step event of an object including the "other" reference? Let's say I have two objects. One is "obj wall" and the other is "obj player". For the sake of argument, let us assume that I cannot just add a collision event to obj wall (I truly cannot due to limitations embedded within the nature of the project itself). Is there a function or block that allows one to write a collision event within obj wall's step event? I know there are various collision detection functions, but what I need is one that acts identically to the collision event and allows me to access the "other" property. If this is not possible, are there any suitable alternatives (such as a function that detects collision and returns the instance id of an object colliding the wall)? My primary issue here is that I want to be able to use collision in one instance of an object without having to have the collision event added. I'd prefer it to be as close as possible to the collision event so as to avoid unnecessary extra checks.


2D destructable terrain with collisions in MMO Task What I want is to create destructable terrain (like in Worms) and collisions with this terrain (with calculated normals) that will be fast enough to work on server machine. Basically lets say that I want to make Worms Online (I don't really) using model CLIENT SERVER, not peer2peer. Approaches I read about People in other threads were suggesting using bitmaps and perpixel collisions, but is it fast enough to handle i.e. 100 games simultaneously? Another approach is using vectors to track outline of terrain, but it seems also really CPU heavy and I didn't find any good example of that. So guys what is your proposal?


Create bullet physics rigid body along the vertices of a blender model I am working on my first 3D game, for iphone, and I am using Blender to create models, Cocos3D game engine and Bullet for physics simulation. I am trying to learn the use of physics engine. What I have done I have created a small model in blender which contains a Cube (default blender cube) at the origin and a UVSphere hovering exactly on top of this cube (without touching the cube) I saved the file to get MyModel.blend. Then I used File gt Export gt PVRGeoPOD (.pod .h .cpp) in Blender to export the model to .pod format to use along with Cocos3D. In the coding side, I added necessary bullet files to my Cocos3D template project in XCode. I am also using a bullet objective C wrapper. (void) initializeScene physicsWorld CC3PhysicsWorld alloc init physicsWorld setGravity 0 y 9.8 z 0 Setup camera, lamp etc. .......... ........... Add models created in blender to scene self addContentFromPODFile "MyModel.pod" Create OpenGL ES buffers self createGLBuffers get models CC3MeshNode cubeNode (CC3MeshNode ) self getNodeNamed "Cube" CC3MeshNode sphereNode (CC3MeshNode ) self getNodeNamed "Sphere" Those boring grey colors.. cubeNode setColor ccc3(255, 255, 0) sphereNode setColor ccc3(255, 0, 0) float cVertexData (float )((CC3VertexArrayMesh )cubeNode.mesh).vertexLocations.vertices int cVertexCount (CC3VertexArrayMesh )cubeNode.mesh).vertexLocations.vertexCount btTriangleMesh cTriangleMesh new btTriangleMesh() for (int i 0 i lt cVertexCount 3 i 3) printf(" n f", cVertexData i ) printf(" n f", cVertexData i 1 ) printf(" n f", cVertexData i 2 ) Trying to create a triangle mesh that curresponds the cube in 3D space. int offset 0 for (int i 0 i lt (cVertexCount 3) i ) unsigned int index1 offset unsigned int index2 offset 6 unsigned int index3 offset 12 cTriangleMesh gt addTriangle( btVector3(cVertexData index1 , cVertexData index1 1 , cVertexData index1 2 ), btVector3(cVertexData index2 , cVertexData index2 1 , cVertexData index2 2 ), btVector3(cVertexData index3 , cVertexData index3 1 , cVertexData index3 2 )) offset 18 self releaseRedundantData Create a collision shape from triangle mesh btBvhTriangleMeshShape cTriMeshShape new btBvhTriangleMeshShape(cTriangleMesh,true) btCollisionShape sphereShape new btSphereShape(1) Create physics objects gTriMeshObject physicsWorld createPhysicsObjectTrimesh cubeNode shape cTriMeshShape mass 0 restitution 1.0 position cubeNode.location sphereObject physicsWorld createPhysicsObject sphereNode shape sphereShape mass 1 restitution 0.1 position sphereNode.location sphereObject.rigidBody gt setDamping(0.1,0.8) When I run the sphere and cube shows up fine. I expect the sphere object to fall directly on top of the cube, since I have given it a mass of 1 and the physics world gravity is given as 9.8 in y direction. But What is happening the spere rotates around cube three or times and then just jumps out of the scene. Then I know I have some basic misunderstanding about the whole process. So my question is, how can I create a physics collision shape which corresponds to the shape of a particular mesh model. I may need complex shapes than cube and sphere, but before going into them I want to understand the concepts.


SDL Multiple keyboard support I am making a game with multiplayer split screen mode using SDL. Basically, I like the idea of having each player plug in his own keyboard to the PC, set custom controls via options and being able to play it with controls that he likes. However, there's a problem. This code gets the keyboard event SDL Event event SDL PollEvent( amp event) SDL Event has member SDL KeyboardEvent key, which has member Uint8 which. In short event.key.which According to this, it should represent keyboard device index, however, I've tried connecting three keyboards to my PC and press the buttons at the same time and the result wasn't satisfying they all had same keyboard indexes. Is there a solution to this? Or am I missing something?


How does this background scrolling code work? I'm glad that this code does exactly what I wanted it to do...But I can't make sense of it although I wrote it from scratch myself. What I wanted to do was create an infinitely scrolling background. What I figured I'd need to do was have it draw the entire background twice so that the second one comes in after the first one, and when the first one gets to the end it starts over behind the second one, and it would loop like this forever. However, after I wrote the code to make it scroll and tested it, it scrolls infinitely by just having the code draw the background once... I have the function to draw the background like so... void drawBackground(int xStart,int yStart,SDL Rect clip) int x,y for(y yStart y lt SCREENH y y TILEH) for(x xStart x lt SCREENW x x TILEW) drawClip(x,y,background, amp clip 45 ) And then I use the function like this to scroll the background... bgX 1 if(bgX SCREENW) bgX 0 bgY 1 if(bgY SCREENH) bgY 0 drawBackground(bgX, bgY, bgClip) It works perfectly...I just don't understand what makes it loop around with no gaps.


How do I access the pixels of an SDL 2 texture? How exactly can one get to the RGBA pixel arrays of SDL 2.0 textures? Does the texture need to be specially initialized and locked down?


Where can I get correct pitch parameter for SDL RenderReadPixels function in SDL2? I have a texture created with SDL TEXTUREACCESS TARGET access and I want to get all its pixels with SDL RenderReadPixels() function. One of the function parameters is pitch and I don't really know where can I can get it. Texture is created with dimensions of a previously created surface, but function call with surface gt pitch as pitch parameter generates EXC BAD ACCESS. Texture and surface dimensions are 800x600, and surface gt pitch returns 3200, which is strange for me, because I thought that pitch is the width of the texture in memory and expected surface gt pitch to be something like 1024.


Memory leak around SDL FreeSurface When I call my tile engine function, the amount of memory my program uses begins to spike at about 80 90 megabytes per second. The memory use continues to go up until the program crashes. The function is below. After tinkering with it, I figured out that I could reduce this bricking to about 15 megabytes per second if I called SDL FreeSurface every time I ran the function. But this confused me, because I thought that you are only supposed to use SDL FreeSurface when the program exits so that the images don't continue to occupy the memory. if I don't call SDL FreeSurface before I blit the tiles, do the previously blitted tiles continue to exist? If I don't how do I fix the aforementioned bug? The edit I made to bring the memory bricking down to 15 megabytes per second is commented out. SDL Surface loadedTile NULL SDL Surface modelIMAGE NULL void enviroment blitTiles(SDL Surface windowENVIRO, int tileAmount, int tileType , int tileXenviro, int tileYenviro, bool quitTiles) HDcounter 1 if(loadedTile ! NULL) SDL FreeSurface(loadedTile) loadedTile IBFobjectENVIRO.loadIMG("tileClipSheet.png") for(int tiles 0 tiles lt tileAmount tiles ) switch(tileType tiles ) Black square (unpassable) case 1 IBFobjectENVIRO.blitIMG(tileXenviro 75, tileYenviro, windowENVIRO, loadedTile, 0, 0, 75, 75) HDcounter 1 forbiddenX HDcounter tileXenviro 75 forbiddenY HDcounter tileYenviro forbiddenSpriteWidth HDcounter 75 forbiddenSpriteHeight HDcounter 75 forbiddenSpriteDepth HDcounter 75 break Grey square case 2 IBFobjectENVIRO.blitIMG(tileXenviro 75, tileYenviro, windowENVIRO, loadedTile, 75, 0, 75, 75) break Brown square case 3 IBFobjectENVIRO.blitIMG(tileXenviro 75, tileYenviro, windowENVIRO, loadedTile, 150, 0, 75, 75) break Invisible square (unpassable) case 4 IBFobjectENVIRO.blitIMG(tileXenviro 75, tileYenviro, windowENVIRO, loadedTile, 225, 0, 75, 75) HDcounter 1 forbiddenX HDcounter tileXenviro 75 forbiddenY HDcounter tileYenviro forbiddenSpriteWidth HDcounter 75 forbiddenSpriteHeight HDcounter 75 forbiddenSpriteDepth HDcounter 75 break tileXenviro 75 if(tileXenviro gt level1ObjectENVIRO.level1Width) tileYenviro 75 tileXenviro tileXenviro level1ObjectENVIRO.level1Width if(quitTiles true) SDL FreeSurface(loadedTile)


Render two images to an SDL window I want to create a menu for an SDL game, so I load an Image to an SDL Window as the background, then I try to load the next image which will be a button but it doesn't display the button to the window, it just displays the background. I'm a newbie so perhaps it is an obvious mistake. Here's what I got include lt stdio.h gt define SDL MAIN HANDLED include "SDL.h" int main(int argc, char argv ) int a 1 SDL Event event SDL Window window SDL Surface background surface SDL Texture background texture SDL Renderer background renderer SDL Surface button surface SDL Texture button texture SDL Renderer button renderer SDL Rect button pos button pos.h 65 button pos.w 320 button pos.x 0 button pos.y 0 SDL Init(SDL INIT VIDEO) window SDL CreateWindow( "Cosmic Racing", SDL WINDOWPOS CENTERED, SDL WINDOWPOS CENTERED, 320, 568, SDL WINDOW OPENGL ) background renderer SDL CreateRenderer(window, 1, 0) background surface SDL LoadBMP("Background.bmp") background texture SDL CreateTextureFromSurface(background renderer, background surface) SDL RenderCopy(background renderer, background texture, NULL, NULL) SDL RenderPresent(background renderer) button renderer SDL CreateRenderer(window, 1, 0) button surface SDL LoadBMP("Play.bmp") button texture SDL CreateTextureFromSurface(button renderer, button surface) SDL RenderCopy(button renderer, button texture, amp button pos, NULL) SDL RenderPresent(button renderer) while(a) SDL PollEvent( amp event) if(event.type SDL QUIT) a 0 SDL DestroyTexture(button texture) SDL FreeSurface(button surface) SDL DestroyRenderer(button renderer) SDL DestroyTexture(background texture) SDL FreeSurface(background surface) SDL DestroyRenderer(background renderer) SDL DestroyWindow(window) SDL Quit() return 0 BTW if you find additional mistakes please tell me. Thank you )


How do I modify textures in SDL with direct pixel access? I'm trying to use SDL LockTexture and SDL UnlockTexture for directly editing pixels in a texture. I'm using SDL 2.0. Setting the pixel value using the following code doesn't modify the texture void pixels int pitch SDL LockTexture(mytexture, NULL, amp pixels, amp pitch) Set pixel 100,100 to blue ((uint32 t )pixels) 100 100 255 SDL UnlockTexture(mytexture)


Are SDL games trivially portable from Linux to Windows? I have a small game made with SDL2 and I want to port it to Windows. Would I hav eto write a lot of ifdefs to port it or will the very same code work on Windows and Linux? Or is it more complicated? Sorry if these are silly questions. I couldn't find existing resources on porting SDL games between desktop systems and I've never done this before!