changing body type without change of center of mass I have an box2d project with some bodies in it, which move around without any user interaction. But if the user selects one of the bodies, he should be able to move it around just like he wants to. To keep it short, I want to change the type of the body to "kinematic" while the user controls it and back to "dynamic" afterwards. If I do so the rotation center of the body changes with the change of the type. How can I reset this? The body's fixture is created of a single b2PolygonShape, with its vertices set via SetAsArray(). Greetings philipp EDIT So I looked around about setting the local center of bodies. what brought me to this solution var md new b2MassData() this.body.GetMassData( md ) this.body.SetType( b2body.b2 kinematicBody ) this.body.SetMassData( md ) that did not work, so I had a look at the source and found that SetMassData() always returns if the body is not "dynamic". So I tried this var md new b2MassData() this. body.GetMassData( md ) this. body.SetType( b2Body.b2 kinematicBody ) this. body.m sweep.localCenter.Set( md.center.x, md.center.y ) what actually is modifying the private data of the body. But it works and no errors appear, but can I really do this without the risk of breaking the application, or in other words, under which circumstances could this solution might cause errors? n.b. I am using box2dweb of the latest release. Greetings philipp


web based networked game physics efficiency I am writing a web based game, using websockets. its pretty simple, two players shooting at each other with bullets that have acceleration from a starting point at an angle. The client side (frontend in web dev terms) uses phaser.io with p2js for physics. However after reading this post, i believe that it's smarter to do some of the physics for the players on the server side. Such as collision detections, and update the player positions at regular intervals to keep the two players at sync. Now i have two questions if i use the Box2d javascript port on nodejs on the server side to simulate server side physics, than is it just as efficient as using the native c one? seeing as from what i have read so far it seems the js ports aren't that well maintained, and they are js ported on the other hand the js codes might be easier to deal with than the c ones. using p2js on the client side and using box2d on the server. The server being authoritative, and sends regular updates (once every second) as to the actual positions of the players. will the physics simulation be in sync (atleast to the user)? Theoretically i don't see any reason for it to not, given that both user has the exact same latency (this is assumed for sake of simplicity).


Include Box2D libraries to a cocos2d project (iOS) I have a problem including box2D to my cocos2d project. I've tried different ways to do it with no success. This is what I've done I downloaded Box2D (Box2D v2.2.1) to my project directory. Dragged the Box2D directory (which includes Box2D.h, Collision, Common, Dynamics, Rope) to my Xcode project (from Finder to Xcode) Then I added include "Box2D.h" to my .h file and got many errors... Here is where I started my research P I went to Project Settings and edited the attribute Header Search Paths (contained in the Search Paths section) specifying the path of Box2D. At this point, I builded the project and I got less errors. After that, I renamed my .m file to .mm (I think this is because Box2D is written in C and with this, the compiler can treat it as it is). Still got errors. Then I tried changing the attribute Always Search User Paths (contained in Project Settings Search Paths) from YES to NO. Still got errors. As my last option I tried changing the attribute Compile Sources As (contained in Project Settings LLVM GCC 4.2 Language) from According to File Type to Objective C . By now I'm frustrated xD. I have 203 errors and most of them are in the .h files contained in the Box2d engine. b2Timer.h Expected ' ', ',', ' ', 'asm' or 'attribute' before 'b2Timer' b2Distance.h Expected specifier qualifier list before 'b2DistanceProxy' b2Math.h Cfloat No such file or directory And so on... Thanks!!!


Error in destroying object in Box2D LibGDX I'm trying to delete an object when a collision happens. I have put the following code in the render method of the object so it would be outside of the physics calculations. public void render(SpriteBatch spriteBatch) some other code... body.setActive(false) body.getWorld().destroyBody(body) But I'm getting an run time error which crashes the JVM and shows, AL lib alc cleanup 1 device not closed Assertion failed! Program C Program Files Java jre6 bin javaw.exe File var lib hudson jobs libgdx git workspace gdx jni Box2D Dynamics b2World.cpp, Line 133 Expression m bodyCount 0 Can anyone help me here?


box2d resize bodies arround point I have a compound object, consisting of a b2Body, vector graphics and a list polygons which describe the b2body's shapes. This object has its own transformation matrix to centralize the storage of transformations. So far everything is working quiet fine, even scaling works, but not if i scale around a point. In the initialization phase of the object it is scaled around a point. This happens in this order transform the main matrix transform the vector graphics and the polygons recreate the b2Body After this function ran, the shapes and all the graphics are exactly where they should be, BUT after the first steps of the b2World the graphical stuff moves away from the body. When I ran the debugger I found out that the position of the body is 0 0 the red dot shows the center of scaling. the first image shows the basic setup and the second the final position of the graphics. This distance stays constant for the rest of the simulation. If I set the position via myBody.SetPosition( sx, sy ) the whole scenario just plays a bit more distant for the origin. Any Idea how to fix this? EDIT I came deeper down to the problem and it lies in the fact that i must not scale the transform matrix for the b2body shapes around the center, but set the b2body's position back to the point after scaling. But how can I calculate that point? EDIT 2 I came ever deeper down to it, even solved it, but this is a slow solution and i hope that there is somebody who understands what formula I need. assuming to have a set polygons relative to an origin as basis shapes for a b2body scaling the whole object around a certain point is done in the following steps i scale everything around the center except the polygons i create a clone of the polygons matrix i scale this clone around the point i calculate dx, dy as difference of clone.tx original.tx and clone.ty original.ty i scale the original polygon matrix NOT around the point i recreate the body i create the fixture i set the position of the body to dx and dy done! So what i an interested in is a formula for dx and dy without cloning matrices, scaling the clone around a point, getting dx and dy and finally scale the vertex matrix.


Calculate the rest length of a box2d distance joint Given the length of a distance joint along with its frequency and the mass of the bodies involved, is it possible to determine the final rest length? I'm only interested in the vertical axis if that makes the formula simpler. E.g. Imagine the simple case of a dynamic body of mass 1 sitting vertically atop another similar body and attached via a distance joint with length 1 and frequency 1 and gravity 10. What would the rest length be? I.e. What would the final distance be between those two bodies? I'm currently just trial and error fudging the frequency values I need in my game but I really need a formula to compute this as every time I change the masses, I have to re fudge everything. Thanks.


Handling player background movements in 2D games Suppose you have your animated character controlled by the player and a 2D world (like the old 2D side scrolling games). When the user presses right on the keyboard, the background is moved to the right. If the path is always horizontal, this is simple to do (incrementation decrementation of the x coordinate). But suppose that the path is instead a polygonal chain. My questions are How do you move the background? How do you move the background if the game objects are managed with a physics engine like box2D? Note. What I wanted to ask is, how do you move a 2D character in a side scroller? For example, consider the following path A B C' D' C D You start from A, move horizontally to B, then move diagonally to C, then move horizontally to D OR, from B, jump on C' and continue till D' and so on.


box2d prismatic joint friction I know it is possible to add friction to rev joints by enabling motor and adding maxMotorTorque. I want the same for prism joint but only maxMotorSpeed option is available which didn't quite work for me. Is there another way?


Where would I update a graphical representation of a b2Body in Box2D's solver? Hey i'm trying to make a class called BodyRep Which is supposed to use SFML too sync a graphical representation and Box2D Bodies orientation location. To do this i plan to ovveride some Box2D function so that it does it's original steps, plus one extra to update the graphical representaions orientation based on the new Body orientation. However I found this is not as easy as it seems as my class must be a descendent of another class that does the actual updates to the bodies in the World, so it CAN ovveride the function. On top of that, I know there is a ton of itterating in Box2D's solver, and i don't want my graphical reps. being updated if they don't have to yet.... So... What CLASS should I Descend from and what FUNCTION should I ovveride? if you have any other ideas on how i could accomplish my goal of syncronization between SFML and Box2D bodies, feel free to suggest them! )


box2d raycast filter category I am trying to filter a category in my ray casting (jBox2D within libGDX), which should return the closest object that does not belong to the category LEVEL0. I've tried a plethora of approaches, but none of them seem to work. This post, for example, instructed me to do so private static class RayCast implements RayCastCallback Fixture f Vector2 point float fraction public RayCast() this.fraction 1f Override public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) if (fixture.getFilterData().categoryBits Corpo.LEVEL0) return 1f if (fraction lt this.fraction) this.f fixture this.point point this.fraction fraction return 1f Yet, it ignores the LEVEL0 bodies only sometimes, and sometimes ignores other bodies as well (though it seems to work on most cases, it fails frequently enough to be unacceptable). I've tried a few other solutions, including returning 1 in the first if (which should mean ignore this collision), return this.fraction always, instead of 1, but nothing works this, in fact, seems to be a very common problem, as the internet is filled with a variety of workarounds, none of them working for me. I think my library is updated, or at least is the version that is included in the latest libGDX (which, according to my quick research, is the actual latest). I've posted this same question here, but I'm not sure about the official forum's activity, so I decided to ask here too, just in case. Whichever website gives the answer first, I shall copy it to the other.


How can I generate vertex data from an SVG? I am trying out the Phaser game engine, and am interested in making a vector graphics game (simple black and white like Asteroids), but I want to use vector graphics instead of raster PNGs. I was looking at this example, which looks like what I want to do... Where I am stuck is, say I draw a simple Asteroids style ship in Illustrator, consisting of 3 connected lines. How do I export that data into an array of vertices that would work with the setPolygon() method in Phaser Box2d?


box2d's ApplyForce works wrong after cocos2d x's replaceScene i'm practicing making a breakout game, using cocos2d x 3.x and box2d, referencing here. i create a ball in the scene's init function and apply force. when ball hits bottom wall, if i touch screen then the game restart current scene. after restart the scene, the ball's velocity is not same with the first ball's one. it's slower. i can't find what's wrong in my code. i need help. here are my code, creating a ball and restart scene. void GameScene CreateBall() create ball texture ball Sprite create("ball.png") ball gt setPosition(Point(100,100)) ball gt setTag(1) this gt addChild(ball) create ball body b2BodyDef ballBodyDef ballBodyDef.type b2 dynamicBody ballBodyDef.position.Set(100 PTM RATIO, 100 PTM RATIO) ballBodyDef.userData ball b2Body ballBody world gt CreateBody( amp ballBodyDef) create circle shape b2CircleShape circle circle.m radius 26.0 PTM RATIO create shape definition and add to body b2FixtureDef ballShapeDef ballShapeDef.shape amp circle ballShapeDef.density 1.0f ballShapeDef.friction 0.0f ballShapeDef.restitution 1.0f ballFixture ballBody gt CreateFixture( amp ballShapeDef) b2Vec2 force b2Vec2(1500,1500) ballBody gt ApplyForce(force, ballBodyDef.position) in here apply force bool GameScene onTouchBegan(Touch touch, Event event) if(gameOver) Director getInstance() gt replaceScene(GameScene createScene()) return true


Farseer Friend Foe Collision cannot push foes but friends we are using Farseer in our project and I try to find a setup to achieve the following quite complicated collision behavior Friendly Units can push each other aside. However, the push should be a "soft push", so that multiple units can squeeze through narrow gaps. Enemy Units should not be pushed. Ever. Moving units colliding with enemies should stop dead. Additionally, I have some other type of collider, lets call them "Wall" ). Neither friends nor foes should ever be able to stand inside a wall. Whether two objects are considered "enemies" can change dynamically during the game. The state is always symmetric (If Bob is an enemy of Alan, then Alan is always an enemy of Bob) but we have more than two factions (up to 16). (Basically, its a similar collision behavior like Starcraft, except that friendly units can temporarily squeeze through navmesh gaps.. much like in Age of Empire..) Actually, I got a quite elaborated solution so far. It has some problems, but kind of gets most of my wishlist done.. Well, most of the time. Here is what I did.. Lets first start with the setup without any walls (because that's what is working better ) I have 2 bodies for each unit. One dynamic the other kinematic. the dynamic body has two equal fixtures. One sensor (to soft push friends), the other a normal fixture (this is what I apply forces from outside game code). The kinematic body has one normal fixture. (This body is to dead stop on enemies) I hooked a BeforeCollision callback to the normal fixture of the dynamic sensor. This filters out all collisions except with the kinematic body of enemies. This way, the dynamic body can not push enemies. Another BeforeCollision filter on the kinematic body just excludes collisions with the sensor fixture of our own dynamic body. Now, after every world update, I run through all the dynamic bodies I will copy the new position into the kinematic body. For each touching contact of the sensor with another dynamic body, I will manually calculate a separating force and apply these to both dynamic bodies. Everything clear so far? To summarize Dynamic fixture moved by game code, stops dead colliding with kinematic body of enemies. Sensor register friends and I calculate push forces by hand. Kinematic body is synched every frame to the dynamic body. Now the problem Walls. I need to enforce that no Body ever ends up inside a wall. More precise, the center point of any body must not be inside any Wall shape (the circle can and should overlap with the wall, only the center point is interesting). I tried several ideas to achieve this but running out of steam here. The currently best solution I could come up with The dynamic body gets yet another circle fixture that is extremely small, like 0.001 meter. This one has a CCD on and a collision group that only allows collision with walls (which are in their own category) Walls are all fixtures of a static body. This approach works as long as no "teleporting" of units is involved. Lets say Alan is being teleported on a spot overlapping with Bob. Now, Alan's kinematic body will push Bob's dynamic body and vice versa. Everything is fine. But if Bob was standing right next to a wall, Farseer will still move Bob slightly into the wall, since the resolver need to resolve the unmovable kinematic body of Alan and the unmovable wall. Yet another post update loop through all bodies that scans all units whether they are inside walls and manually resolve their positions is way beyond our performance limits. I briefly thought about some solution involving two separate Farseer worlds, but my head starts to spin trying to figure out which body position need to be copied where and when... I haven't looked into joints yet, but my gut feeling is that they don't really help here. Except with a third body? Do I really need 3 bodies per unit? ( Any ideas?


Unwanted begincontact callbacks at high velocity I'm having some issues with jump detection due to begincontact. I have a player entity made of 2 bodies, and it looks something like this Note how the circle below (a body connected via a revolute joint) is not quite as wide as the rectangle. This means that when the player is up against a wall, there is no contact between the circle and the wall. However, if the player collides with a wall at high velocity, begincontact registers a contact between the circle and the wall. Is there any way around this?


how to apply force impulse perpendicular to the moving direction in box2d How can i apply or impulse to an object perpendicular to its moving direction in a top down game. Like if object is moving up, i press left or right, then force or impulse should be applied to left or right direction(object can be at any angle).


Libgdx import bin xml json from physics editor I'm using Libgdx. I did a simple json file in Physics Body Editor and I don't have any idea how could I import it into my physic world in libgdx. Any idea will be appreciated. P.S Sorry if there are question with the same subject, I didn't find any of them.


Getting Bodies to go "Super Fast" in Box2D I am making a breakout game in Android using the LibGDX version of Box2D. I have a ball that I am applying a force to with the following code... getBody().applyForceToCenter( 10000000000.0f, 10000000000.0f) This makes the ball move properly, but it never seems to gain a lot of speed (and I want to make it go super fast). I tried adding an accelerate method where I applied the force 40 times, but again it doesn't seem to move that fast. What is a good way to make a Body go "Super fast" in Box2D? If there is acceleration I would like it to be as short as possible. I tried adding the following.... World.setVelocityThreshold(1000000.0f) But now the ball doesn't seem to "bounce" off walls, do I need to raise my restitution or something?


Why set the position of both b2Body and Box2DSprite? In a game, we add a body for each sprite, the method is createBodyAtLocation (CGPoint) forSprite (Box2DSprite )sprite In which we create the body and we attach it to the sprite in parameter sprite.body body Then we set the position of the body, but later on in the code, in the update method, we also set the position of the sprite to the same position as the body. I was wondering Why are we doing it twice? As we already set the position of the body in the world, and we made a link between the two with sprite.body?


How to tell if a fixture is being squeezed by two other fixtures in Box2D? Let's say I had a ground fixture, a player box, and a kinematic block moving up and down. If the player stands under the block, weird things happen. I want to simply play an event where the player dies. How can I detect when the player box is crushed by the block moving down on it?


Explain the difference between extrapolation and interpolation http www.unagames.com blog daniele 2010 06 fixed time step implementation box2d here there are two algorithms of smoothing in case of fixed time step physics simulation. I don't understand the formula of interpolation state currentState alpha previousState (1 alpha) And also I don't understand the comparison figure. Please explaing what is the meaning of multiplying current state with alpha and summing with previous state with 1 alpha.


Cocos2d Box2d Problem, Follow doesn't work in the physical world bool TestImageLoaderScene init() if (!Scene init()) return false bgLayer Layer create() this gt addChild(bgLayer) BasicRUBELayer init() playerNode new PlayerNode playerNode gt addSprite() playerNode gt addBodyToWorld(m world) playerNode gt addCircularFixtureToBody(0.2f) this gt addChild(playerNode) bgLayer gt runAction(Follow create(playerNode)) return true bgLayer is the layer that contains the background. The background has a static body and is 3500 x 2700 in size. PlayerNode is an arbitrary class created to manage sprites and bodies together, and inherits node. class PlayerNode public cocos2d Node public void addSprite() void addBodyToWorld(b2World world) void addCircularFixtureToBody(float radius) void createFixture(b2Shape shape) cocos2d Sprite getTextureSprite() return playerTexture protected cocos2d Sprite playerTexture b2Body playerBody Any idea why it is not working? I am making a top down view type game, and the phenomenon of not following the player's movement is very fatal. please answer me. bad engilsh so sorry...


In Box2D, how can I SetTransform of a body without getting an IsLocked assertion error? I've created a bullet body and stored a reference to it in herobody bDef.type b2 dynamicBody bDef.position.Set(herobody gt GetPosition().x, herobody gt GetPosition().y) b world gt CreateBody( amp bDef) b2FixtureDef fixturebDef b2CircleShape circlebShape circlebShape.m radius 0.05 fixturebDef.shape amp circlebShape b gt CreateFixture( amp fixturebDef) I'm trying to change the current position of the bullet. I tried to use SetTransform but I get an error Assertion failed (IsLocked() false) during world gt step in my update method. This doesn't work. Causes the above assertion. b gt SetTransform( b2Vec2( herobody gt GetPosition().x, herobody gt GetPosition().y ), 0 ) This works, but doesn't set position directly. b gt ApplyLinearImpulse(b2Vec2(5, 0), b gt GetWorldCenter(),true) How do I do this correctly?


in box2d how to decrease joint's reaction force? I'm trying to make a game like cut the rope and meet some problems. when I create a float bubble and connect with a rope(a sets of bodies connected with revoluteJoint), the rope will become longer and when I destroy the bubble,rope gives a a big reaction force to candy, so how to decrease this reaction force? to simulate bubble's floating, I did this class Bubble extends PhyObject override function draw() void if(this.combined) this.getBody().SetLinearVelocity(velocity) velocity new b2Vec2(0, 3.5) other code class Main public function loop() getAllPhyObject().forEach(function(phyObj) phyobj.draw() ) so if bubble was combined with candy ,It "float". I think maybe I can do this pseudo code if(bubble is connected with rope) dynamic adjust bubble's linear velocity with rope's reaction force but I just cannot figure out how to dynamic adjust bubble's linear velocity.and is there a simpler way to solve this problem? thanks! update finally I solved my problem,so I write it down and hope it help to you. below code is grab from b2BuoyancyController and it works in my case. buoyancy private function float() void if (bodies.length lt 1) return var body b2Body bodies 0 if(body.IsAwake() false) Buoyancy force is just a function of position, so unlike most forces, it is safe to ignore sleeping bodes return var normal b2Vec2 new b2Vec2(0, 1) var offset Number 20 var density Number 2 var velocity b2Vec2 new b2Vec2(0, 0) var linearDrag Number 2 var angularDrag Number 1 var gravity b2Vec2 toolkit.world.GetGravity().Copy() var areac b2Vec2 new b2Vec2() var massc b2Vec2 new b2Vec2() var area Number 0.0 var mass Number 0.0 for(var fixture b2Fixture body.GetFixtureList() fixture fixture fixture.GetNext()) var sc b2Vec2 new b2Vec2() var sarea Number fixture.GetShape().ComputeSubmergedArea(normal, offset, body.GetTransform(), sc) area sarea areac.x sarea sc.x areac.y sarea sc.y var shapeDensity Number 1 mass sarea shapeDensity massc.x sarea sc.x shapeDensity massc.y sarea sc.y shapeDensity areac.x area areac.y area massc.x mass massc.y mass if(area lt Number.MIN VALUE) return Buoyancy var buoyancyForce b2Vec2 gravity.GetNegative() buoyancyForce.Multiply(density area) body.ApplyForce(buoyancyForce,massc) Linear drag var dragForce b2Vec2 body.GetLinearVelocityFromWorldPoint(areac) dragForce.Subtract(velocity) dragForce.Multiply( linearDrag area) body.ApplyForce(dragForce, areac) tmpForce if(candy.bodies.length gt 0) TODO !!!!! var tmpForce b2Vec2 candy.bodies 0 .GetLinearVelocity() body.SetLinearVelocity(tmpForce) tmpForce.x 0 tmpForce.Subtract(velocity) tmpForce.Multiply( linearDrag area) body.ApplyForce(tmpForce, areac) Angular drag TODO Something that makes more physical sense? body.ApplyTorque( body.GetInertia() body.GetMass() area body.GetAngularVelocity() angularDrag) tips use force instated of impulse and changing linear velocity.


How to create an extensible rope in Box2D? Let's say I'm trying to create a ninja lowering himself down a rope, or pulling himself back up, all whilst he might be swinging from side to side or hit by objects. Basically like http ninja.frozenfractal.com but with Box2D instead of hacky JavaScript. Ideally I would like to use a rope joint in Box2D that allows me to change the length after construction. The standard Box2D RopeJoint doesn't offer that functionality. I've considered a PulleyJoint, connecting the other end of the "pulley" to an invisible kinematic body that I can control to change the length, but PulleyJoint is more like a rod than a rope it constrains maximum length, but unlike RopeJoint it constrains the minimum as well. Re creating a RopeJoint every frame using a new length is rather inefficient, and I'm not even sure it would work properly in the simulation. I could create a "chain" of bodies connected by RotationJoints but that is also less efficient, and less robust. I also wouldn't be able to change the length arbitrarily, but only by adding and removing a whole number of links, and it's not obvious how I would connect the remainder without violating existing joints. This sounds like something that should be straightforward to do. Am I overlooking something? Update I don't care whether the rope is "deformable", i.e. whether it actually behaves like a rope, or whether it collides with other geometry. Just a straight rope will do. I can do graphical gimmicks while rendering they don't need to exist inside the physics engine. I just want something a RopeJoint whose length I can change at will.


Best way to allow a user to Control Body in Box2D I am working on a simple game and I am deciding how I should let users interact with the world. I really have 2 options, 1.) When the user moves an object I apply a force to the body 2.) With each move iteration I "move" the body by setting position. Which is "better" or am I looking at this wrong entirely and should I be doing something different? Also, does it matter if I want to keep the object stationary when it is hit by another body (I am assuming this means I will need to use static body which leads me back to 2)? Thanks


Problem with sensor in box2d I have two bodies one green static sensor (spikes) and one orange dynamic body (brick). I have bullet and it's a dynamic body too, but with bullet flag set. My problem is that when the bullet is moving left to right, it sometimes hits the orange brick instead of the spikes and it flies away. There is code to remove the bullet when it hits spikes. How can I make sure it hits the spikes first?


Store and create game objects at positions along terrain I have a circular character that rolls down terrain like that shown in the picture below. The terrain is created from an array holding 1000 points. The ground is drawn one screen width infront and one screen width behind. So as the character moves, edges are created infront and edges are removed behind. My problem is, I want to create box2d bodies at certain locations along the path and need a way to store these creator methods or objects. I need some way to store a position at which they are created and some pointer to a function to create them, once the character is in range. I guess this would be an array of some sort that is checked each time the ground is updated and then if in range, the function is executed and removed from the array. But I'm not sure if its even possible to store pointers to functions with parameters included... any help is much appreciated!


Why is Euler integration sometimes preferred over RK4 even if RK4 is more accurate? Some high quality engines such as Box2d uses the Simplistic Euler integrator instead for RK4 when Eumplectic Euler commits a global error of the order of t whereas, RK4 has t 4 error? RK4 is not that hard to do, right? Why would a physics engine use Euler over RK4 hence sacrificing accuracy ?


Box2D Do these simple objects need to be in the simulation? I would like to get input from the community regarding how best to represent simple objects in a Box2D based simulation. Some background Without going into too much detail, think of a top down game with a character and some 'food'. You can picture PacMan trade even. Suppose I will simulate the character and the walls to be Box2D so the guy cannot leave the maze and I get collision feed back etc. My question Should the 'food' be part of the Box2D simulation? My thoughts The food doesn't need to be in the simulation because.. It doesn't move. As soon as the character collides with the food it is removed from the game. It should not apply any force to the guy, or anything, ever. Nor should anything ever need to apply force to it. It's extra computation that isn't necessary. The food could be in the simulation because.. I am already using Box2D. Box2D can handle the collision events for me. Again, Box2D can handle the collision events for me I don't really want to check for collisions myself. Box2D should let the food 'sleep' so it won't be much extra computation, correct? What do you guys think? Do the benefits outweigh the costs here? Are there other pros cons I'm missing? I look forward to getting feedback.


box2d tween what am I missing I have a Box2D project and I want to tween an kinematic body from position A, to position B. The tween function, got it from this blog function easeInOut(t , b, c, d ) if ( ( t d 2 ) lt 1) return c 2 t t t t b return c 2 ( (t 2 ) t t t 2 ) b where t is the current value, b the start, c the end and d the total amount of frames (in my case). I am using the method introduced by this lesson of todd's b2d tutorials to move the body by setting its linear Velocity so here is relevant update code of the sprite if( moveData.current moveData.total ) this. body.SetLinearVelocity( new b2Vec2() ) return var t easeNone( moveData.current, 0, 1, moveData.total ) var step moveData.length moveData.total t var dir moveData.direction.Copy() this is the line that I think might be corrected dir.Multiply( t moveData.length fps moveData.total ) var bodyPosition this. body.GetWorldCenter() var idealPosition bodyPosition.Copy() idealPosition.Add( dir ) idealPosition.Subtract( bodyPosition.Copy() ) moveData.current this. body.SetLinearVelocity( idealPosition ) moveData is an Object that holds the global values of the tween, namely current frame (int), total frames (int), the length of the total distance to travel (float) the direction vector (targetposition bodyposition) (b2Vec2) and the start of the tween (bodyposition) (b2Vec2) Goal is to tween the body based on a fixed amount of frames in moveData.total frames. The value of t is always between 0 and 1 and the only thing that is not working correctly is the resulting distance the body travels. I need to calculate the multiplier for the direction vector. What am I missing to make it work?? Greetings philipp


What is inertia in a physics engine? Inertia seems to be useful in a physics engine, so useful that even in Box2DLite, a demo of Box2D it hasn't been omitted. See this Body class from Box2DLite struct Body Body() void Set(const Vec2 amp w, float m) void AddForce(const Vec2 amp f) force f Vec2 position float rotation Vec2 velocity float angularVelocity Vec2 force float torque Vec2 width float friction float mass, invMass float I, invI inertia and reverse inertia In the implementation of the class, inertia is set as the mass multipled by something I mass (width.x width.x width.y width.y) 12.0f invI 1.0f I What does this formula means ? I understood from wikipedia that Inertia is how much something doesn't want to move but there's not much formulas in this article. Why is it useful in a physics engine ? How is it used in the context of a collision ? Is it compared to other bodies ?


Make player to always move along the terrain I'm working on a 2D platformer side scroller game. I am giving high impulse to player, the player starts moving and if it hits a slope on terrain, it gets a vertical movement and starts to fly over (Box2D physics). What I need is that the player should always be on the terrain and move along the ground. I would like to know if it's possible using Box2D engine.


How do I avoid Race Conditions in UnrealScript? I'm trying to create a pseudo turn based battle system in the Unreal Engine (think Final Fantasy style). I'm trying to avoid the Enemies and the players attacking while another animation is in progress. I thought the most simple solution is to have a flag somewhere that the player controllers check before starting an animation, and set it to a value before they start, and then reset it when they've finished. However, I could see this leading to race conditions if two controllers (AI or player) try to access the variable at the same time, then both start their animations. If I was writing this in Java I'd obviously use synchronized methods, but I haven't come across anything like that in UnrealScript. Is there another way to avoid this? Its probably not the end of the world, as its a pretty unlikely occurance, but I'd like to try and avoid it completely if possible.


How reimport a package in UDK with command line? sometimes ago, I saw a command to re import a UDK package content without opening the UDK Editor. (Especially, it was used for reimporting a Flash package in a scaleform tutorial, but it doesn't matter now ) It's very useful, because every time I change my .swf file, I should open the heavy UDK and just press re import. So, can anyone give me that solution again ?


Get Final output from UDK ( sorry for my bad english in advance D ) I'm trying to get a .exe setup output, from my UDK !( with my own maps and scripts which I made within MyGame) I tried UnrealFrontEnd! But It made a setup , that after installation I can see my .udk maps, my packages and etc. But It's not a real output that I can show to my customers. I don't want, other can use my resources ! So... How can I get a binary like output from UDK as a real Game Output ? ( like what we see in all commercial games ) Is there any option in frontend that I missed ?


Changing State in PlayerControler from PlayerInput In my player input I wanna change the the "State" of my player controller but I have some trouble to do it my player input is declared like that class ResistancePlayerInput extends PlayerInput within ResistancePlayerController config(ResistancePlayerInput) and in my playerControler I have that class ResistancePlayerController extends GamePlayerController var name PreviousState DefaultProperties CameraClass class 'ResistanceCamera' Telling the player controller to use your custom camera script InputClass class'ResistanceGame.ResistancePlayerInput' DefaultFOV 90.f Telling the player controller what the default field of view (FOV) should be simulated event PostBeginPlay() Super.PostBeginPlay() auto state Walking event BeginState(name PreviousStateName) Pawn.GroundSpeed 200 log("Player Walking") state Running extends Walking event BeginState(name PreviousStateName) Pawn.GroundSpeed 350 log("Player Running") state Sprinting extends Walking event BeginState(name PreviousStateName) Pawn.GroundSpeed 800 log("Player Sprinting") I have tried to use PCOwner.GotoState() and ResistancePlayerController(PCOwner).GotoState() but won't work. I have also tried a simple GotoState, and nothing happen how can I call GotoState for the PC Class from my player input ?


How are the Unreal Development Kit (UDK) and Unreal Engine 4 (UE4) related? I'm thinking of learning Unreal Engine 4, but it costs money, and I want to try and keep costs as low as possible while I'm learning. In contrast, the Unreal Development Kit is free. How similar are the two? If I learn UDK first, how easily can I transition to UE4?


Do UDK mutators only apply on local games? I have developed a pretty simple mutator. It works exactly as intended on a local game against bots, but it doesn't work (nor do any of the stock mutators) on a listen server. Is this to be expected of UDK (May Beta Release by the way)?


Unreal Engine Scaleform How do I capture a button click event? I'm new to Unreal Development. In a nutshell, how do I create a button, install it in a basic game, and capture the button click event?


Valve Source Engine UDK and CUDA Do any games use the GPU for more game tasks than just rendering, as a way to reduce the game's load on the CPU? I'm most interested in games which use either Valve's Source engine or the UDK. Is it possible effective to even do such a thing?


SetBase with a KActor descendant does not appear to function I have a KActor descendant, which is a carging shot, kind of like in R Type. When it starts charging, I do projectile.SetBase(Pawn) in the PlayerController where it is spawned. I've checked in the debugger, and its base is in face the pawn. But it does not move with the pawn. I have done this before, where I base KActors on a moving entity, and it moved with them. I must have done something differently, but I can't figure out what it was. Looking at the old code, I just did SetBase like I am now. Any ideas where I might be going wrong?


Why might a Projectile hitting a KActor only call HitWall, and not ProcessTouch? I have a Projectile subclass that seems to work fine. It travels, does Explode(), etc. But when it hits one of our KActors, I get a HitWall event but not a ProcessTouch event. So my question is, why would a colliding actor trigger HitWall, but not ProcessTouch?


UDK Checking actor type in projectile ProcessTouch So, to be brief, I'm trying to teleport a pawn when it's struck by a projectile (or damaged by any weapon in my game.) Right now, I'm trying to just call Pawn.SetLocation in the projectile's ProcessTouch. That's a problem because ProcessTouch will hit any actor, not just a pawn. Additionally, any attempts to check the ProcessTouch's "Actor Other" throws errors. I've tried a bunch of solutions (including making a event TakeDamage in the Pawn controller class,) but to no avail. simulated function ProcessTouch(Actor Other, Vector HitLocation, Vector HitNormal) if (Other ! Instigator) This is where the Other.TakeDamage goes if we are using a traditional gun. if (Other Pawn) Other.SetLocation(0,0,0) Destroy This code complains that Pawn's a bad expression. How else should I check actor type here?


UnrealEngine how to create pirate boat tutorial I fount an Unity tutorial how to crate pirate boat, but I still can't find any sources (links, videos) how to create it using UE. Kind of this. So when you use character controller it can jump, run and etc, but with a boat you should smoothly running trough the waves with some bouncing effects. So I try to find tutorial that describe how to create this pirate boat. So the question not about model, so I can even use a cube that I can move through waves.


What exactly is the difference between Unreal Development Kit and Uunreal Engine 4? I want to start learning game development and I would obviously come across this tool. So every where I went people mentioned Unreal Engine 4 to be a viable choice, I've tried a bit of Unity and now I want to try Unreal. Only issue I came across UDK and UE4, I downloaded UDK which turns out to be different from tutorials and I can't seem to find any info on that and besides I could only run the software once because after the first time it starts a game, I re installed UDK I still get the issue, but anyways that's a different topic, what I want to know is whether UDK and UE4 are different and if they are, where do i get UE4, becauuse when I down UE4 (from https www.unrealengine.com dashboard), it downloads a game launcher and no development tool. In case they are same, why is my version of UDK different fr


UDK, can you add your own effects? I'm new to game development and am curious to know if you can add your own cg effects? Like if I wanted to add fog to my game and UDK didn't support that, is that possible? What kind of coding does one do, in a engine like UDK?


How can tell if a player has performed some action in UDK? For simplicity, let's say that I want bots to kill me when I enter a room without greeting them. So in this case I would need to store, somewhere, the variable didGreet, which should be changed when I send the message "Hello." Then, when any pawn sees me, he will check the didGreet variable and if this was false he would start firing at me. I've heard that this should be done using the GameInfo class, but unfortunately I don't know how to create, access and change variables there. How can I accomplish this?


How to detect the device type in UnrealScript? How can I recognize if the player device is an iPad or an iPhone? Now I can do it by checking the viewport size. But I think is just a tricky way, is there any other, more standard way?


How do I make game server for UDK game? I'm new in UDK and I'm starting to develop online multiplayer games. There is a one problem, I couldn't find any tutorials about how to make a game server using udk. I suppose, that it uses unreal script. But that's about all I know about it. So I'd really like for some help.


3D Game Engine comparable to UDK that's not GPL'd Are there any good, free 3D game engines similar to UDK that are under open source licenses without copyleft provisions?


Is it possible to use a spherical collision component in UDK? I have an object in UDK, which has a SkeletalMesh. At certain times in the game, I want this object to continue rendering the SkeletalMesh, but I'd like it to use spherical collision temporarily. After reading a bunch about PrimitiveComponents, my understanding is that UDK supports cylindrical and box like collision, but not spherical without using a static mesh. EDIT What I have now is a StaticMesh with a material that makes it invisible. I've added a StaticMeshComponent to my Pawns. I can shut off the Pawn's collision, and turn on the StaticMesh collision. But it doesn't respond to impulses. I figure I'm missing something in how you turn on the RigidBody thingy. CylinderComponent.SetActorCollision(false, false) SetPhysics(PHYS RigidBody) RBCollisionComponent.SetStaticMesh(RBCollisionMesh) RBCollisionComponent.AddImpulse(InImpulse) RBCollisionComponent.WakeRigidBody()


How to make a gaussian blur effect in UDK I want to make a plane shape (surface) that have a gaussian blur applied to it and this plane is transperant, so all objects behind it looks like they are having a gaussian blur effect.


UDK Problem with Touching Actors In my game I am trying to see all touching actors of a particular DynamicSMActor and it does return only two Actors as touching Actors Water Volume and Player Pawn. It is ignoring all the other DynamicSMActors that are touching. I actually tried different values for collision type, Blocking type, etc,. No success. Any help is really appreciated.


UDK deferred rendering? I plan to use UDK on PC to create commercial game. Can I use deferred rendering in UDK? Or it's only available with expensive UE3 license?


Using Canvas instead of Scaleform in UDK I'm working with Unreal Script, and I need to use Canvas instead of Scaleform to create a HUD. I've extended the game type from UTGame, and used bUseClassicHUD in the Default Properties section, but the default Scaleform HUD continues to appear. I know for certain that I have everything configured properly to load and run the scripts, but this one line just doesn't seem to have any effect. DefaultProperties Disable the scaleform (flash) HUD in the UTGame bUseClassicHUD true Initial score value nScore 0 Initial time value m gameTimer 30.0 Is there something else I need to include? I've done a reinstall (I'm using the July 2013 build), but to no avail.


How do you set event after a pawn takes damage? How can I set event after bot pawn takes damage in UDK? (possibly in Kismet?) I need to do something similar to this http www.youtube.com watch?v gjRf5lTcWLY


Field of view settings for first person shooter Are there any industry standards for setting the field of view (FOV) for FPS games or is it solely based on trial and error? Are there any guidelines for choosing the correct value?


GLM Camera attached to model moves in opposite direction from the model I have been working on a component based engine with nested game objects each with there own transformation's. Each game object calculates its position in the world based on its parents world transformation multipled by there own local one (ModelsWorldTransform ParentsWorldTransform LocalTransform). This all works great until I attach the camera component to a model and in this scenario, as the model the camera is attached to moves away from the origin, the camera moves in the opposite direction to the movement whitest still seeming like it is in the correct position according to its mat4. All local transformations are stored in a mat4 rather then three vec3's for position, rotation and scale to save on calculations each update having to generate new mat4's. Transformation Component Update Code m world transformation m local transformation If we have a parent object if (m parent transform component) m world transformation m parent transform component gt GetWorldTransformation() m world transformation Camers position buffer being updated BufferData.view m transformation component gt GetWorldTransformation() m camera buffer gt SetData() I'm not sure what i'm missing, if anyone has any sugestions that would be apreatiated.


Realistic Camera Screen Shake from Explosion I'd like to shake the camera around a bit during an explosion, and I've tried a few different functions for rocking it around, and nothing seems to really give that 'wow, what a bang!' type feeling that I'm looking for. I've tried some arbitrary relatively high frequency sine wave patterns with a bit of linear attenuation, as well as a square wave type pattern. I've tried moving just one axis, two, and all three (although the dolly effect was barely noticeable in that case). Does anyone know of a good camera shaking pattern?


Field of view or resolution? I'm new to CG and I'm building a ray tracer. I don't quite understand how to set camera parameters and film(pixel plane) parameters. Say I want to get an image of 400x300 resolution. I can set an fov, and then the distance between the film and camera can be calculated. If that's true, a high resolution and a "reasonable" fov, e.g 80 degree, will result in a large distance. Does that makes the object small on the final image? And I feel like people like to determine resolution at first, in order to get an expected image size. To avoid distortion of objects(fish eye), the fov cannot be too large. So how do I get close look of an object on a high resolution image? I think the rasterization way is different from ray tracing one since I can project an object into NDC(normalized device coordinate) to make it big, but what about ray tracers?


How to make camera rotation independent from frame rate? I multiply the mouse movement by a given number to get camera rotation of a desired speed. But it only works at 60 FPS. When I don't limit the frame rate I get around 350 FPS and the camera rotation is significantly too slow. In my calculation, I already consider the frame time. rotateCamera(ivec2 deltaMouse, float deltaTime, float sensitivity) apply multipliers deltaMouse deltaTime deltaMouse sensitivity rotate camera by deltaMouse ... Is this approach wrong? Why isn't the mouse movement independent from the frame rate in my code? How to achieve that?


Unity 5 Camera Functions Usage Error How to use functions like ScreenToRayPoint() in Camera class? I have used this code Ray ray camera.ScreenPointToRay(Input.mousePosition) and it says Component.camera is obsolete, instead using GetComponent() Then I tried these Camera cam GetComponent lt Camera gt () Ray ray cam.ScreenToRayPoint(Input.mousePosition) and it says Camera doesn't contain a definition of ScreenPointToRay and no extension method 'ScreenPointToRay' accepting a first argument of type 'Camera' could be found.


VR Camera and Hands height Using the Oculus Rift S, I just added OVRCameraRig and LocalAvatar or OVRPlayerController and when I press play I feel like I'm not as high as I want in my vision and hands, I change the position of Y of objets to make it more higher, but it affects to everything, my guardian setup floor goes more high too and it does not match with my floor. What can I do to solve this? What should I change or modify?


What would be a good game making engine supporting Vector images? I want to create a simple platforming game, in which you are a square in a wonderful world. I would like this game to be able to be played in browsers. Basically I am searching for something similar to "Flixel", but with the following features Support Vector Graphics Allow zooming rotating objects without producing huge amounts of lag as soon as you are using more objects. (Because I want to rotate the map around the player) So in other words, preferably zoom the viewport camera instead of the objects themselves. Does an engine like that exist?


Blueprint For Switching Between Cameras In The Unreal Engine So basically I have a scene in the Unreal Engine which has multiple cameras within it, the cameras are intentionally static as the application should behave more like a viewing gallery than a game. As the application is intended for mobile devices, the idea is that when a person touches the screen of their device, the rendering switches from the present camera to another one to show a different image. I have attempted to implement this action in the level blueprint with the following blueprint design Closer up Obviously in the scene there are three camera actors which must be switched between with the first camera viewed through being the 1st CameraActor hence the connection of the EventBeginPlay variable to the Set View Target With Blend variable that the 1st camera actor is connected to. When the Play button is pressed, the scene viewed from the first camera is rendered to the screen as desired however when the left mouse button is clicked equating to touch input on mobile devices, the scene does not switch to the second camera and the question is why?


Camera rotation in 4D What practical choices do I have in order to rotate a camera in 4D space? I would like to make it as intuitive as possible. A camera in 3D space can be represented by a point where it is located the forward vector (movement using the w and s buttons) the left (movement using the a and d buttons) the up vector (eg. space and ctrl ) In 4D space, the an additional axis is added the fourth axis vector (eg. q and e ) All of the vectors remain orthogonal to eachother. So the movement is trivial.


Calculations for a camera system I am building an interactive application in Starling for which a camera system is required. Since there is no existing camera system in flash and the addons for starling do not meet our requirements, I am writing my own. Basically, it moves and scales all assets depending on the position of the camera. However, I am having trouble with zooming towards a specific point on the screen. Every object has a pivotpoint in the topleft corner so it scales relative to the topleft corner. For all kinds of reasons, I cannot change the pivotpoint of the objects. To compensate for this, the camera needs to move towards the point we want to zoom towards on the x y plane, but I cannot figure out how much it should move. Are there any known formulas for this? How do I calculate how the camera should move? EDIT I can actually move the pivotpoint to the center of the assets if that makes it much easier. EDIT This method is used on each sprite to update its position var zPos Number Number(this.z Game.cameraZ) var scale Number Game.focalLength (Game.focalLength zPos) var correctedScale Number scale (1 (Game.focalLength (Game.focalLength this.z))) this.scaleX this.scaleY correctedScale this.x Game.cameraX scale this.defaultX scale this.y Game.cameraY scale this.defaultY scale


Swaying Camera when Walking You can see the effect in many games. The camera sways or wiggles a bit while walking to make the movement feel more realistic. I have implemented a camera in my game. (Who'd have thunk it?) So is there a common approach to build this swaying effect in?


Rotate camera around offset to player position (third person shooter view) I'm trying to rotate my camera 'next to' the player object so that the player is not in the way of the screen centered reticle. What I am trying to achieve is something like the targetting system of Fortnite, GTA 5 or Red Dead Redemption (or most third person shooters), where the camera player are offset slightly so that you can see directly in front of them. My code so far allows me to rotate the camera about the player (object here) and it follows the player's position. I cannot figure out how to offset it. public void update(final GameObject object) this.newMouseX Input.getMouseX() this.newMouseY Input.getMouseY() final float dx (float) (this.newMouseX this.oldMouseX) final float dy (float) (this.newMouseY this.oldMouseY) Rotate the camera on mouse move this.verticalAngle dy this.mouseSensitivity this.horizontalAngle dx this.mouseSensitivity Distances from side view final float horizontalDistance (float) (this.distance Math.cos(Math.toRadians(this.verticalAngle))) final float verticalDistance (float) (this.distance Math.sin(Math.toRadians(this.verticalAngle))) Distances from top view final float xOffset (float) (horizontalDistance Math.sin(Math.toRadians( this.horizontalAngle))) final float zOffset (float) (horizontalDistance Math.cos(Math.toRadians( this.horizontalAngle))) this.position.set(object.getPosition().getX() xOffset, object.getPosition().getY() verticalDistance VERT OFFSET, object.getPosition().getZ() zOffset) this.rotation.set( this.verticalAngle, this.horizontalAngle, 0) this.oldMouseX this.newMouseX this.oldMouseY this.newMouseY This is the sort of thing I'm trying to achieve


Camera Aligned To Sphere Surface I am writing a planet renderer and have come across a problem that is really limiting the usability of the program. When I am on the planet (anywhere but the north pole) I cannot rotate the camera to the left or to the right as I would if I was on a flat plane. Instead I can only move as if I were aligned to a regular flat plane. This gives me awkward viewing as seen here This limits me to only really looking straight ahead of the camera and straight behind the camera. I drew this to try to illustrate the problem Will setting the up vector of the camera to be the the point on the sphere where I am located normalized alleviate this problem? I am at a dead end here and any ideas would be greatly appreciated. Thanks.


Ortbit camera rotation multiplication order with quaternions? So I switched my camera to use quaternions and the first thing I noticed is that things started to 'roll' even though I'm not using any roll values. I looked it up and I found that people suggest that using rotation horizontal rotation vertical solves the issues instead of rotation rotation horizontal vertical which I thought was the more intuitive thing from doing matrix multiplication. The explanations I read as to why one works and the other doesn't were pretty vague and unclear. My question is why does it work this way? what's wrong with 'rotation h v ? Sample code float Horizontal 0 float Vertical 0 if (Keys 'W' Key Held) Camera gt Position Camera gt Forward() CamMovSpeed DeltaTime if (Keys 'S' Key Held) Camera gt Position Camera gt Forward() CamMovSpeed DeltaTime if (Keys 'A' Key Held) Camera gt Position Camera gt Right() CamMovSpeed DeltaTime if (Keys 'D' Key Held) Camera gt Position Camera gt Right() CamMovSpeed DeltaTime if (Keys 'E' Key Held) Camera gt Position vec Up CamMovSpeed DeltaTime if (Keys 'F' Key Held) Camera gt Position vec Up CamMovSpeed DeltaTime mouse int dx Mouse gt x Mouse gt LastX Mouse gt LastX Mouse gt x int dy Mouse gt LastY Mouse gt y Mouse gt LastY Mouse gt y if (Mouse gt MMB Key Held) pan Camera gt Position (Camera gt Up() dy Camera gt Right() dx) SpeedMul 2 DeltaTime if (Mouse gt RMB Key Held) orbit Horizontal dx SpeedMul 10 DeltaTime Vertical dy SpeedMul 10 DeltaTime if (Mouse gt Wheel) zoom Camera gt Position Camera gt Forward() Mouse gt Wheel SpeedMul 10 DeltaTime if (Horizontal ! 0 Vertical ! 0) quat QVertical(vec Right, Vertical) quat QHorizontal(vec Up, Horizontal) Camera gt Rotation QHorizontal Camera gt Rotation QVertical this works Camera gt Rotation Camera gt Rotation QHorizontal QVertical this doesn't Camera gt Rotation.Normalize()


Orthographic camera and z axis in 3D isometric view game I'm working on a game in Away3d. I'm using an orthographic camera and I'm attempting to simulate an isometric view (the camera has a 37 angle and the y axis is up down, x axis is left right, and z axis is orthographic). I hit a snag in understanding how to handle the z axis of the NPC's relative to the player so that, for example, when the player is below an NPC in Y coordinates, it doesn't appear to be "under" the NPC, but "besides in front" the NPC, as currently all the 3D models in this scene are Z axis coordinate 0. My common sense says that there should be a relation in the sense that if the Y axis coordinates of the NPC is lower than the Y axis coordinates of the player, then the z axis coordinates should update following an allegory is so that the apparent view of the NPC relative to the player is that the NPC is "behind" the player. But as I said, because all the z axis are zero for all the models, the players' apparent position is "under" the NPC, as opposed to "in front" of the NPC.


How to convert screen space to world space? I have a shader that should do raymarching. But I have problems converting the fragment's position to a worldspace coordinate. This is my vertex shader VertexShaderOutput VS(VertexShaderInput input) VertexShaderOutput output output.Position float4(input.Position.xy 2,0.0, 1.0) float4 worldPos output.Position output.WorldPos mul(worldPos, InverseViewProjection) output.UV input.UV return output input.Position in this case is a quad from 0.5 to 0.5, hence why I multiply it by 2. In my pixel shader, I want to get the ray start position from output.WorldPos. However, the shader outputs WorldPos as this x 118.943700000, y 25.704420000, z 23.763410000 This is wrong, because the camera is at around x 3846 y 810 z 734 What am I doing wrong? I expected a world position, but it seems to be a screen space position? Here is how I create my matrices (DirectX SimpleMath) View Matrix CreateLookAt(WorldPosition, target, up) Projection Matrix CreatePerspectiveFieldOfView(fov, w (float)h, n, f) ViewProjection View Projection ViewProjection.Invert(InverseViewProjection) Projection.Invert(InverseProjection) View.Invert(InverseView) The game renders perfectly fine, So I am certain The View Projection Matrices are not wrong.


FPS like mouse look camera WinAPI problem I have a problem with implementing mouse look camera movement, like in FPS games. For me common solution is Process WM MOUSEMOVE event in WndProc Calculate delta movement from the window's center using event's lParam Rotate camera Return cursor back to window's center using SetCursorPos The problem is when SetCursorPos is called, another WM MOUSEMOVE event is being fired. So camera rotates back. What is the common way to create such type of camera on Windows platform (using WinAPI)? I know that in WM MOSEMOVE I can check is mouse.x windowCenter.x and if it is do nothing, but it's a hack from my point of view. Is there any "non hacky" way to achieve the goal?


What are some common FOV for third person games? I am trying to decide on a field of view (FOV) for a third person game and I really don't know where to start. It would be very helpful to have some points of reference from recent TPS games and the FOV they use by default. The trouble is many third person games (or at least those I have tried) do not have any settings or information about what their default FOV is. I have had a look at Uncharted 4, Hitman (2016), The Division and GTA 5 but cannot find information about their FOV anywhere. I understand that each game is different and the type of gameplay will determine the FOV choice here, but it would be very useful for me to have some existing examples as a starting point. Is there any good place to find this out?


Realistic Camera Screen Shake from Explosion I'd like to shake the camera around a bit during an explosion, and I've tried a few different functions for rocking it around, and nothing seems to really give that 'wow, what a bang!' type feeling that I'm looking for. I've tried some arbitrary relatively high frequency sine wave patterns with a bit of linear attenuation, as well as a square wave type pattern. I've tried moving just one axis, two, and all three (although the dolly effect was barely noticeable in that case). Does anyone know of a good camera shaking pattern?


What is the term for making an object transparent when it blocks the player's view? In many games if your camera gets too close to certain objects, or the object starts to block your screen, the game turns it transparent so you can still see. What is the name for this effect? It is not occlusion culling. The model does not reduce its polygons, it simply just gets transparent so that you can look through it.


Camera LookAt position with fixed screen position I have a perspective "lookAt type" camera. I'm trying to compute specific focus point of the camera, which should be placed in the middle of the screen I also have a custom 3d point in world space, margin values in screen space and camera's tilt as inputs. I want to compute lookAt point, amp camera distance with restriction, that input world space point has to be visible in the middle of the free screen space area (not affected by margin values) and it has to have a given tilt. I'm able to compute this in 2D, but I'm lost in 3D. Any idea how to achieve this? Here's a sketch of the problem, red and blue area's are margin values of 0.5f in both x and y direction.


How do I properly implement zooming in my game? I'm trying to implement a zoom feature but I have a problem. I am zooming in and out a camera with a pinch gesture, I update the camera each time in the render, but my sprites keep their original position and don't change with the zoom in or zoom out. The Libraries are from libgdx. What am I missing? private void zoomIn() ((OrthographicCamera)this.stage.getCamera()).zoom .01 public boolean pinch(Vector2 arg0, Vector2 arg1, Vector2 arg2, Vector2 arg3) TODO Auto generated method stub zoomIn() return false public void render(float arg0) this.gl.glClear(GL10.GL DEPTH BUFFER BIT GL10.GL COLOR BUFFER BIT) ((OrthographicCamera)this.stage.getCamera()).update() this.stage.draw() public boolean touchDown(int arg0, int arg1, int arg2) this.stage.toStageCoordinates(arg0, arg1, point) Actor actor this.stage.hit(point.x, point.y) if(actor instanceof Group) ((LevelSelect)((Group) actor).getActors().get(0)).touched() return true Zoom In Zoom Out


What does it mean to "strafe" the camera? I'm looking at a tutorial in which both the terms camera moving and "strafing" are used. I looked onto dictionary.com and found strafe verb (used with object) 1. to attack (ground troops or installations) by airplanes with machine gun fire. 2. Slang . to reprimand viciously. noun 3. a strafing attack. WTF??? I'm not a native english speaker.


FlxSprite ignore camera follow in flixel I am using flixel v2.5 and am using FlxG.camera.follow to get the camera to follow the player. I have a background FlxSprite that I don't want to move with the camera. Is there a way I can set this FlxSprite to stay in the same place on the screen? I would also like to have a GUI HUD that stays fixed to the screen, and was thinking I could do this the same way.


How to avoid gimbal lock in Unreal Engine (c )? I created an orbit camera (sometimes called turntable camera similar to the one with the "use UE3 orbit controls" setting in a static mesh view). I attached the camera to a USpringArmComponent with a TargetArmLength set to 400. In the tick function, I rotate the arm with this simple method Simple, clamped version FRotator Rotation CameraSpringArm gt GetComponentRotation() Rotation.Yaw CameraInput.X CameraRotationSpeed Rotation.Pitch FMath Clamp(Rotation.Pitch CameraInput.Y CameraRotationSpeed, 85.0f, 85.0f) CameraSpringArm gt SetRelativeRotation(Rotation) I had to clamp the pitch to hide the gimbal lock problem. But this prevent users to rotate completely around objects. I don't understand why the Z rotation (the yaw) occurs on the world z axis ( FVector UpVector which is (0, 0, 1)) and not on the local z axis. It turns out that this is exactly what I want. I tried to solve this gimbal lock problem with this other method Taken from https answers.unrealengine.com questions 232923 how can i avoid gimbal lock in code.html FRotator RotationDelta(CameraInput.Y CameraRotationSpeed, CameraInput.X CameraRotationSpeed, 0.f) FTransform NewTransform CameraSpringArm gt GetComponentTransform() NewTransform.ConcatenateRotation(RotationDelta.Quaternion()) NewTransform.NormalizeRotation() CameraSpringArm gt SetWorldTransform(NewTransform) It works, but this time, the Z rotation (yaw) occurs on the local Z axis. How can I change it to rotate around the world Z axis, and the local Y axis, without gimbal lock? I tried this hybrid solution, but the gimbal lock is still there Hybrid FRotator RotationDelta(CameraInput.Y CameraRotationSpeed, 0.f, 0.f) FTransform Transform CameraSpringArm gt GetComponentTransform() FRotator Rotation CameraSpringArm gt GetComponentRotation() Rotation.Yaw CameraInput.X CameraRotationSpeed Transform.SetRotation(Rotation.Quaternion()) Transform.ConcatenateRotation(RotationDelta.Quaternion()) Transform.NormalizeRotation() CameraSpringArm gt SetWorldTransform(Transform) I did solve this problem (a long time ago) in OpenGL using quaternions, so I tried this version Quaternion FRotator Rotator CameraSpringArm gt GetComponentRotation() FQuat Quaternion Rotator.Quaternion() Rotate around the world Z axis Quaternion FQuat(FVector UpVector, FMath DegreesToRadians(CameraInput.X CameraRotationSpeed)) Rotate around the local Y axis Quaternion FQuat(Rotation.RotateVector(FVector RightVector), FMath DegreesToRadians(CameraInput.Y CameraRotationSpeed)) CameraSpringArm gt SetRelativeTransform(Quaternion) But this does not work. I also tried this Quaternion transform FTransform Transform CameraSpringArm gt GetComponentTransform() Transform.ConcatenateRotation(FQuat(FVector UpVector, FMath DegreesToRadians(CameraInput.X CameraRotationSpeed))) Transform.ConcatenateRotation(FQuat(Rotation.RotateVector(FVector RightVector), FMath DegreesToRadians(CameraInput.Y CameraRotationSpeed))) Transform.NormalizeRotation() CameraSpringArm gt SetWorldTransform(Transform) without success.


Strange 3D game engine camera with X,Y,Zoom instead of X,Y,Z I'm using a 3D game engine, that uses a 4x4 matrix to modify the camera projection, in this format r r r x r r r y r r r z zoom Strangely though, the camera does not respond to the Z translation parameter, and so you're forced to use X, Y, Zoom to move the camera around. Technically this is plausible for isometric style games such as Age Of Empires III. But this is a 3D engine, and so why would they have designed the camera to ignore Z and respond only to zoom? Am I missing something here? I've tried every method of setting the camera and it really seems to ignore Z. So currently I have to resort to moving the main object in the scene graph instead of moving the camera in relation to the objects. My question Do you have any idea why the engine would use such a scheme? Is it common? Why? Or does it seem like I'm missing something and the SetProjection(Matrix) function is broken and somehow ignores the Z translation in the matrix? (unlikely, but possible) Anyhow, what are the workarounds? Is moving objects around the only way? Edit I'm sorry I cannot reveal much about the engine because we're in a binding contract. It's a locally developed engine (Australia) written in managed C used for data visualizations. Edit The default mode of the engine is orthographic, although I've switched it into perspective mode. Its probably more effective to use X, Y, Zoom in orthographic mode, but I need to use perspective mode to render everyday objects as well.


Simulating a real camera's perspective projection I'm trying to simulate a real camera's perspective projection of straight, parallel lines running along the ground (one point perspective) by mapping the real world 3D coordinates of the lines to 2D screen coordinates. Suppose the camera's tilt angle is known, is there a way to calculate the slopes coordinates expression of these lines projected on to the 2D plane? Which parameters of the camera are needed? My understanding is that when the camera is tilted, the vanishing point is effectively shifted. But does tilting the camera cause the same changes in the perspective of the lines as moving the camera lower to the ground (closer to the lines)?


Field of view settings for first person shooter Are there any industry standards for setting the field of view (FOV) for FPS games or is it solely based on trial and error? Are there any guidelines for choosing the correct value?


Perfect FPS camera angle I am making a multiplayer FPS and I am in search of some helpful tips on the perfect FPS camera angle. Because it is a multiplayer, I am making a full body model holding the gun, I find, however, that some of the gun positions (when held naturally) seem awkward when placing the camera on the position of the characters eyes. Moving the camera has other consequences, for example, when moving the camera to a more appropriate fps position, when looking at your feet, it seems that your head is too far right, as your point of view is past your left foot.. Any expert advice?


Render a 3D scene in multiple windows extended panoramic view Is there any resource location on how to view a 3D scene from an application or a game on multiple windows or monitors? Each window should continue drawing from where the neighbouring one left off (in the end, the result should be a mosaic of the scene). My idea is to use a camera for each window and have a reference position and orientation for a meta camera object that is used to correctly offset the other cameras (e.g. like in the above figure where the render targets of the two cameras reproduce the star when stitched together). Since there are quite some elements to consider (window specs, viewport properties, position orientation of each render camera), what is the correct way to update the individual cameras considering the position and orientation of the central, meta camera? I currently cannot make the cameras present the scene contiguously (and I am reluctant in working out the transformations without checking whether this is the actual way of doing things).


Camera that follows a target with sub pixel movement As the title says, I have a character that moves at sub pixel movement (no, I can't change this, because this sub pixel movement happens when I normalize the vector during diagonal movements, otherwise it would move faster) and the camera follows it. The problem as you can see from this video, is that the textures of the various tiles kinda go crazy https files.catbox.moe ve6t0h.webm This is my camera CameraPos target.Position Movement Matrix mPosition Matrix.CreateTranslation( CameraPos.X, CameraPos.Y, 0) CameraOffset CenterOfScreen target.Origin Matrix mOffset Matrix.CreateTranslation((CameraOffset.X Game1.Scale.X), (CameraOffset.Y Game1.Scale.Y), 0) var zoom Matrix.CreateScale(new Vector3(Game1.Scale.X, Game1.Scale.Y, 1)) Transform mPosition mOffset zoom target.Position is the Position of my character, it can be sub pixel. Movement is the movement of the mouse in relation to my character, also can be sub pixel. The Sampler.State I'm using is PointClamp, I really don't want to use the linear one, I don't want blurriness. I've already tried truncating rounding the position values in the camera, but the result is a very annoyingly shaky camera which I don't want. Please help, this is driving me crazy.


Zooming versus panning in a 3D FPS fly camera Imagine you have a strategy game, and it's rendered in openGL, in 3D. You have an overview of the map and the camera is currently looking at the direction of the ground at some angle (but is not limited to this angle). Like the standard view in the CIV games. You now do one of the two actions A) You move the camera along its line of sight towards the ground (forward). B) You scale the whole scene by a factor 1. If I understand these actions correctly, both situations should have exactly the same visual result, zooming in. The player shouldn't really be able to tell which of the two has happened. My questions is, firstly, am I right to assume this? If no, what is the observable difference? If yes, which mechanic should be used? Note that I am thinking about this in regards of use in a level editor. Thinking about it a little further, the difference should become visible if player moves the camera after the action the camera in the scaled version would move at an apparently slower speed, right? Would there be any other side effects? Which behavior would be expected by the player user? If you assume an FPS fly camera (one that yaws and tilts, but does not roll), is there any scenario where the scaling method would be preferred?


Camera type for puzzle game like tetris I can't find what is the name of the camera type. Sided camera view seems logical but not correct thought


Restrict camera movements I'm making a game with target (orbit camera). I want to limit camera movements when in room. So that camera don't go through walls when moving around target and along the ground. What are common approaches? Any good links with tutorials? I use Unity3D, nevertheless I'm good with a general solution to the problem


Scale aware adaptive camera zooming I would like to implement an interactive zoom on a 3d object with mouse wheel.A naive approach is simple where you just scale camera marix Z poistion or modify FOV.But I would like the zoom scaling to be aware to the scale of the object and adapt its speed to it accordingly.It is standard behavior of CAD programs like Maya and 3d max.In this demo the zoom scaling is performed by exponential grow of the value but it would still be the same for models with radius of 10 units and 100000 units.I am sure eventually I will probably roll my own solution but I am interested to know if there are some industry standard techniques for this kind of interactivity. Also I am sorry if this is not an appropriate place to ask.I thought game devs should have some experience in this area.


Relationship between Camera's view size, screen resolution and objects scale I've had this question since a long time ago and wanted to know the relationship between how an object is viewed through the camera depending on the resolution of the device, the camera's view size and the object scale, so for example let's say i have a 100x100 square in the middle of the screen, the camera is looking directly at it and let's say the square takes 10 of a specific screen, if i wanted it to keep that relationship with the screen do i have to change the square size depending on the screen size?, change the camera's width and height? or change the resolution of the game? in short, how does the resolution and the camera's widht and height affect the scale and proportions of the objects of the screen?


Camera view projection issue I made a simple OpenGL program but I can figure out why the camera is not working, here it's a little fragment of the Camera class public Matrix4f getView() initializes the view matrix return new Matrix4f().lookAt( new Vector3f(0f, 0f, 1f), camera position at 0,0,1 new Vector3f(0f, 0f, 0f), camera target at 0,0,0 new Vector3f(0f, 1f, 0f)) up axis set to "worldUp" (0,1,0) public Matrix4f getProjection() return new Matrix4f().perspective( (float) Math.toRadians(fieldOfView), the fov has a value between 0f and 180f, by default I set it to 90 viewportAspectRatio, the aspect ratio is equal to 1024 960 (screen height screen width)... even if I've not understood what is it... 0.1f, 1000f) I've not really understood what near and far planes are... public Matrix4f getMatrix() with this function I obtain the final camera matrix return getView().mul(getProjection()) And it's how I handle the camera Matrix in GLSL, created using camera.getMatrix() gl Position camera model vec4(position, 1.0) Without the camera all is fine here's the program running using gl Position model vec4(position, 1.0) (Yeah, it's a cube) But using the camera in the way I showed you before, increasing the FOV, I get this Could anyone look at my code and tell me where I'm wrong? I would be really happy... D


Camera LookAt position with fixed screen position I have a perspective "lookAt type" camera. I'm trying to compute specific focus point of the camera, which should be placed in the middle of the screen I also have a custom 3d point in world space, margin values in screen space and camera's tilt as inputs. I want to compute lookAt point, amp camera distance with restriction, that input world space point has to be visible in the middle of the free screen space area (not affected by margin values) and it has to have a given tilt. I'm able to compute this in 2D, but I'm lost in 3D. Any idea how to achieve this? Here's a sketch of the problem, red and blue area's are margin values of 0.5f in both x and y direction.


About the cameras in the original Metal Gear Solid for PSX Since I first played MGS on the PSX I have been wondering about this. To my understanding, MGS loads the geometry of the 'room' where you are and lets you move through it by using semi fixed cameras that can follow you to a certain degree until your character gets in the range of another camera, and then seems to transition from the last angle of the previous camera to the initial angle of the current camera. However, since this game does not seem to have a great deal of reverse engineering done, I wonder if anybody has replicated this scheme on any game (stealth or not) to study it. As far as I know, the only one I have found with a similar approach is Resident Evil Code Veronica, which switched from pre rendered backgrounds to 3D but restricted the cameras available, as in the previous installments, giving the cameras certain degree of freedom in following the player (but less than MGS since RECV is about being afraid, not being stealthy). I know I am asking a questio too broad and risk to be tagged as such... but it's been a lot of time since MGS got out and I still wonder about if anybody has more concrete answers to my guess about how MGS works.


How do I create a bounding frustum from a view projection matrix? Given a left handed Projection matrix, a left handed View matrix, a ViewProj matrix of View Projection How do I create a bounding Frustum comprised of near, far, left, right and top, bottom planes? The only example I could find on Google (Tutorial 16 Frustum Culling) seems to not work for example, if the math is used as given, the near plane's distance is a negative. This places the near plane behind the camera...


Field of view or resolution? I'm new to CG and I'm building a ray tracer. I don't quite understand how to set camera parameters and film(pixel plane) parameters. Say I want to get an image of 400x300 resolution. I can set an fov, and then the distance between the film and camera can be calculated. If that's true, a high resolution and a "reasonable" fov, e.g 80 degree, will result in a large distance. Does that makes the object small on the final image? And I feel like people like to determine resolution at first, in order to get an expected image size. To avoid distortion of objects(fish eye), the fov cannot be too large. So how do I get close look of an object on a high resolution image? I think the rasterization way is different from ray tracing one since I can project an object into NDC(normalized device coordinate) to make it big, but what about ray tracers?


Understanding how to go from a scene to what's actually rendered to screen in OpenGL? I want something that explains step by step how, after setting up a simple scene I can go from that 'world' space, to what's finally rendered on my screen (ie, actually implement something). I need the resource to clearly show how to derive and set up both orthographic and perspective projection matrices... basically I want to thoroughly understand what's going on behind the scenes and not plug in random things without knowing what they do. I've found lots of half explanations, presentation slides, walls of text, etc that aren't really doing much for me. I have a basic understanding of linear algebra matrix transforms, and a rough idea of what's going on when you go from model space screen, but not enough to actually implement it in code.


In UE4, how do I turn my character's body together with the camera? I made a simple punch animation in Blender and exported it into Unreal Engine 4. In game, the character appeared from a 3rd person perspective, but I made it look like first person by adjusting the camera. Now, whenever I turn the camera in game, I can look around at different parts of the character's body. (For example, if I turn right I can see shoulder of my character, and if I am facing the front I can see just the wrists.) Whenever I turn the camera and run the punch animation, it looks weird because the character model isn't aligned with the camera. How can I make the body turn together with the camera, so my animation looks right?


How does time dependent camera rotation with a mouse work? The commonly used equation for camera rotation with a mouse does not involve time. This make sense since higher frame rates have smaller changes in mouse position and vise versa so it all evens out. If time slows down or speeds up, however, camera rotation from the mouse does not adjust accordingly. Just as you move slower when time is slowed, logically I also want rotating to be slower. One option is to multiply the change in position of the mouse with the same multiplier I'm using on time, but shouldn't it be possible to have change in rotation and change in time in the same equation, independent from framerate?


Camera rotation in 4D What practical choices do I have in order to rotate a camera in 4D space? I would like to make it as intuitive as possible. A camera in 3D space can be represented by a point where it is located the forward vector (movement using the w and s buttons) the left (movement using the a and d buttons) the up vector (eg. space and ctrl ) In 4D space, the an additional axis is added the fourth axis vector (eg. q and e ) All of the vectors remain orthogonal to eachother. So the movement is trivial.


Looking for online resources to understand game camera properties What are some good online resources to understand game camera properties, such as fov, aspect ratio and more?


Orthographic camera and z axis in 3D isometric view game I'm working on a game in Away3d. I'm using an orthographic camera and I'm attempting to simulate an isometric view (the camera has a 37 angle and the y axis is up down, x axis is left right, and z axis is orthographic). I hit a snag in understanding how to handle the z axis of the NPC's relative to the player so that, for example, when the player is below an NPC in Y coordinates, it doesn't appear to be "under" the NPC, but "besides in front" the NPC, as currently all the 3D models in this scene are Z axis coordinate 0. My common sense says that there should be a relation in the sense that if the Y axis coordinates of the NPC is lower than the Y axis coordinates of the player, then the z axis coordinates should update following an allegory is so that the apparent view of the NPC relative to the player is that the NPC is "behind" the player. But as I said, because all the z axis are zero for all the models, the players' apparent position is "under" the NPC, as opposed to "in front" of the NPC.


FPS games don't they have unrealistic one eyed view? What are the causes? I have played many fps games, and noticed that the camera perspective is similar to the 'one eyed view' of the surroundings. It does not feel like bilinear. Is it because of the single flat view of the screen? Or is it the problem that can be fixed by some research? PS If you want, try to roam around with only one eye open.


What am I missing for this flycam to work correctly? Through reverse engineering, I've found an instruction to inject on which allows me to obtain the XYZ coordinates of the camera, as well as pitch and yaw. Thus, I have the following camX (Plane) Value is a float ranging from negative to positive camY (Plane) Value is a float ranging from negative to positive camZ (Up Down) Value is a float ranging from negative to positive camH (Horizontal Yaw) Value is a float in degrees from 180 to 180 camV (Vertical Pitch) Value is a float in degrees clamped to 89 to 89 I've written a script in Lua which allows me to bind directions (forward, backward, left, right, up, and down) to keys (W, A, S, D, Q, and E) however, those simply add subtract to from XYZ values along with a speed modifier, meaning if I'm facing forward and moving forward, everything is fine. Turning 180 degress with the mouse, though, effectively means back is forward, left is right, etc. What I'm looking to achieve is having those directional keys apply to wherever I'm aiming the mouse pointer. So, forward is always where I'm facing, etc. I've been piecing together the necessity of sin cos for calculations related to this however, I'm apparently in over my head with understanding everything I'm reading watching. I've found a number of calculations for this based on degrees, radians, converting degrees to radians, etc., but I'm just completely lost as nothing I've tried has panned out (even though I think I understand what I'm reading). I've ascertained that, where applicable, respective games have sin cos values stored somewhere in memory which I could use in lieu of calculating those values myself, but I'm honestly not sure what those values look like to seek out in the first place...or exactly what I need to do to make the calculations myself. They're probably staring me right in the face in nearby memory or on the stack as I trace through code, but I simply don't know. Are there multiple ways to calculate the appropriate angles via sin cos? Can I use some combination of the 5 values I listed above, along with a speed modifier and Lua's math. methods (math.rad, math.sin, math.cos), to get this flycam to work properly? Thank you for any guidance you can provide!


How the game engine handles camera view in DirectX I am quite confused with how the game engine handles camera view in DirectX. I know all the matrix stuffs, but where the projection matrix goes finally seems rarely mentioned. I looked up in the sample project by microsoft https msdn.microsoft.com en us windows uwp gaming tutorial create your first metro style directx game in the GameRenderer CreateWindowSizeDependentResources() method, the projection process is implemented XMFLOAT4X4 orientation m deviceResources gt GetOrientationTransform3D() ConstantBufferChangeOnResize changesOnResize XMStoreFloat4x4( amp changesOnResize.projection, XMMatrixMultiply( XMMatrixTranspose(m game gt GameCamera() gt Projection()), XMMatrixTranspose(XMLoadFloat4x4( amp orientation)) ) ) d3dContext gt UpdateSubresource( m constantBufferChangeOnResize.Get(), 0, nullptr, amp changesOnResize, 0, 0 ) However I can't figure out what the UpdateSubresources method has anything to do with projection (yet such projection in the UpdateSubresources method exists in some other samples I found). But wouldn't it be absurd to change the entire buffer every frame for projection? Isn't the data in the buffer in world view coordinates? The vertex shader seems also take the task of projection PixelShaderInput output (PixelShaderInput)0 output.position mul(mul(mul(input.position, world), view), projection) I do think this one is more plausible for the task. So the questions are Which one exactly is the process of projection, and how does it come along in two places? If it happens in UpdateSubresources, what should I do with dynamic buffer? If it happens in the shader, where does the world, view, projection matrics come from? How should I use it with SharpDX


How to avoid gimbal lock I am trying to write code with rotates an object. I implemented it as Rotation about X axis is given by the amount of change in y coordinates of a mouse and Rotation about Y axis is given by the amount of change in x coordinates of a mouse. This method is simple and work fine until on the the axis coincides with Z axis, in short a gimble lock occurs. How can I utilize the rotation arount Z axis to avoid gimbal lock.


XNA Placing a "field of view" rectangle on a minimap I'm building a top view 3ed person shooter. I have a HUD and in the HUD I have a minimap. I'm trying to draw on this minimap a rectangle which shows me my "visual field", meaning i see on the minimap which part of the map I'm currently seeing. I've nearly achieved this, except for a scaling problem. Here's my code float distX ScreenWidth Tools.MapToCamera(Camera.pos.X, Camera.pos.Y).X float distY ScreenHeight Tools.MapToCamera(Camera.pos.X, Camera.pos.Y).Y Vector2 topLeft new Vector2((calcX((Camera.pos.X distX) (Bg.Width Tools.minimap.Width) Tools.minimap.X)), (calcY((Camera.pos.Y distY) (Bg.Height Tools.minimap.Height) Tools.minimap.Y))) Vector2 rightBottom new Vector2 ((calcX((Camera.pos.X distX) (Bg.Width Tools.minimap.Width) Tools.minimap.X)), (calcY((Camera.pos.Y distY) (Bg.Height Tools.minimap.Height) Tools.minimap.Y))) Tools.DrawLine(topLeft, new Vector2 (rightBottom.X, topLeft.Y), Color.WhiteSmoke) Tools.DrawLine(topLeft, new Vector2 (topLeft.X, rightBottom.Y), Color.WhiteSmoke) Tools.DrawLine(new Vector2 (topLeft.X, rightBottom.Y), rightBottom, Color.WhiteSmoke) Tools.DrawLine(new Vector2 (rightBottom.X, topLeft.Y), rightBottom, Color.WhiteSmoke) ScreenWidth ScreenHeight are the current PreferredBackBuffer sizes. Bg means BackGround, contains height width, etc. of the map. calcX(float num) multiplies num by the current scale of the HUD. HUD scale is measured by hudScale ScreenWidth hudWidth calcY float calcY(float y) return y hudScale (ScreenHeight (hudHeight hudScale)) internal static V2 MapToCamera(float X,float Y) return new V2(X (Tools.w Bg.Width), Y (Tools.h Bg.Height)) public static void DrawLine(V2 start, V2 end, Color clr) sb.Draw(pointTex,start, null, clr,(float)Math.Atan2(end.X start.X, start.Y end.Y), new V2(0.5f, 1), new V2(1, (start end).Length()), SpriteEffects.None,0) pointTex new Texture2D(gd, 1, 1) (Color set White) These are all the functions in use. The end result is a rectangular frame around my position on the minimap. It follows me and i'm mostly in it's center. The problem is, this rectangle comes out about twice larger than it should be. Anyone care to help me with this? P.S I don't use any scaling on the map or the other sprites. Scaling is done only on the HUD and it's objects. Although, I use a zoom factor for my Camera class. Thanks in advance.


How to set "near" value properly? Usually, the camera's near value is set to sth like 0.1f. However, this (assuming 1.0f 1 metre) makes everything that's closer than 10 cm from the camera invisible. On the other hand, when working with big open terrains too small near value results in this (yes, that's a sandy coast and water P) instead of this (Apparently, when the difference in distance between too objects is too small, you get artifacts. Something to do with precision, I guess, and apparently the precision is dependent on the near camera value.) My question is is it possible to set near value to something like 0.001f and not get the above artifacts?


Realistic Camera Screen Shake from Explosion I'd like to shake the camera around a bit during an explosion, and I've tried a few different functions for rocking it around, and nothing seems to really give that 'wow, what a bang!' type feeling that I'm looking for. I've tried some arbitrary relatively high frequency sine wave patterns with a bit of linear attenuation, as well as a square wave type pattern. I've tried moving just one axis, two, and all three (although the dolly effect was barely noticeable in that case). Does anyone know of a good camera shaking pattern?


Restrict camera movements I'm making a game with target (orbit camera). I want to limit camera movements when in room. So that camera don't go through walls when moving around target and along the ground. What are common approaches? Any good links with tutorials? I use Unity3D, nevertheless I'm good with a general solution to the problem


Calculations for a camera system I am building an interactive application in Starling for which a camera system is required. Since there is no existing camera system in flash and the addons for starling do not meet our requirements, I am writing my own. Basically, it moves and scales all assets depending on the position of the camera. However, I am having trouble with zooming towards a specific point on the screen. Every object has a pivotpoint in the topleft corner so it scales relative to the topleft corner. For all kinds of reasons, I cannot change the pivotpoint of the objects. To compensate for this, the camera needs to move towards the point we want to zoom towards on the x y plane, but I cannot figure out how much it should move. Are there any known formulas for this? How do I calculate how the camera should move? EDIT I can actually move the pivotpoint to the center of the assets if that makes it much easier. EDIT This method is used on each sprite to update its position var zPos Number Number(this.z Game.cameraZ) var scale Number Game.focalLength (Game.focalLength zPos) var correctedScale Number scale (1 (Game.focalLength (Game.focalLength this.z))) this.scaleX this.scaleY correctedScale this.x Game.cameraX scale this.defaultX scale this.y Game.cameraY scale this.defaultY scale


Static Camera on Endless Runner I am developing a mobile game in ue4. For this project, I need to have a "static" camera so that the player can move within the frame not affecting camera location and rotation. But as this is an endless scroller I also need to have the camera move at a constant pace limiting the player's area of movement. Does anyone know how to do this?


Camera view projection issue I made a simple OpenGL program but I can figure out why the camera is not working, here it's a little fragment of the Camera class public Matrix4f getView() initializes the view matrix return new Matrix4f().lookAt( new Vector3f(0f, 0f, 1f), camera position at 0,0,1 new Vector3f(0f, 0f, 0f), camera target at 0,0,0 new Vector3f(0f, 1f, 0f)) up axis set to "worldUp" (0,1,0) public Matrix4f getProjection() return new Matrix4f().perspective( (float) Math.toRadians(fieldOfView), the fov has a value between 0f and 180f, by default I set it to 90 viewportAspectRatio, the aspect ratio is equal to 1024 960 (screen height screen width)... even if I've not understood what is it... 0.1f, 1000f) I've not really understood what near and far planes are... public Matrix4f getMatrix() with this function I obtain the final camera matrix return getView().mul(getProjection()) And it's how I handle the camera Matrix in GLSL, created using camera.getMatrix() gl Position camera model vec4(position, 1.0) Without the camera all is fine here's the program running using gl Position model vec4(position, 1.0) (Yeah, it's a cube) But using the camera in the way I showed you before, increasing the FOV, I get this Could anyone look at my code and tell me where I'm wrong? I would be really happy... D


Why does this work? camera rotation from screen space I do not understand the math behind the linked function or why it works. I would like to know this. https sidvind.com wiki Yaw, pitch, roll camera void Camera motion(int x,int y) theta x 200 Adjust this to control the sensitivity phi y 200 target.x cos(theta) sin(phi) target.y cos(phi) target.z sin(theta) sin(phi)


What game systems exist which uses camera input? The group and I is in the middle of a semester project where we are currently researching on which game systems are using camera as input or as an interactive medium? We would like some help listing some of the game systems which uses camera input, as it seems hard to find other examples. Currently we know that webcam browser games uses camera input (Newgrounds webcam games), as well as the xbox kinect. I know this questions seems rather vague, though I still hope some people is capable of helping.