Daily Archives

Articles indexed Saturday December 15 2012

Page 14/15 | < Previous Page | 10 11 12 13 14 15  | Next Page >

  • Scaling along an arbitrary axis (Dealing with non-uniform scale)

    - by Jon
    I'm trying to build my own little engine to get more familiar with the concepts of 3D programming. I have a transform class that on each frame it creates a Scaling Matrix (S), a Rotation Matrix from a Quaternion (R) and concatenates them together (S*R). Once i have SR, I insert the translation values into the bottom of the three columns. So i end up with a transformation matrix that looks like: [SR SR SR 0] [SR SR SR 0] [SR SR SR 0] [tx ty tz 1] This works perfectly in all cases except when rotating an object that has a non-uniform scale. For example a unit cube with ScaleX = 4, ScaleY = 2, ScaleZ = 1 will give me a rectangular box that is 4 times as wide as the depth and twice as high as the depth. If i then translate this around, the box stays the same and looks normal. The problem happens whenever I try to rotate this scaled box. The shape itself becomes distorted and it appears as though the Scale factors are affecting the object on the World X,Y,Z axis rather than the local X,Y,Z axis of the object. I've done some pretty extensive research through a variety of textbooks (Eberly, Moller/Hoffman, Phar etc) and there isn't a ton there to go off of. Online, most of the answers say to avoid non-uniform scaling which I understand the desire to avoid it, but I'd still like to figure out how to support it. The only thing I can think off is that when constructing a Scale Matrix: [sx 0 0 0] [0 sy 0 0] [0 0 sz 0] [0 0 0 1] This is scaling along the World Axis instead of the object's local Direction, Up and Right vectors or it's local Z, Y, X axis. Does anyone have any tips or ideas on how to handle construction a transformation matrix that allows for non-uniform scaling and rotation? Thanks!

    Read the article

  • Speed up content loading

    - by user1806687
    I am using WinForms Sample downloaded from microsoft website. The problem is, that the model loading time is quite long, using: contentBuilder.Add(ModelPath, ModelName, null, "ModelProcessor"); contentManager.Load<Model>(ModelName); even a simple model, such as a cube with no textures, takes 4+ seconds to load. Now, I am no expert on this, but is there anyway to decrease loading time? EDIT: I've gone thru the code and found out that calling contentBuilder.Build(); ,which comes right after contentBuilder.Add() method takes up most of the time.

    Read the article

  • Managing shots of the player

    - by Bitbridge
    I'm currently developing a 2D Jump'n'Run and the situation is the following: The player has different weapons he can collect and is then able to shoot the weapon's projectiles (laser, rockets, whatever). In my previous game (space shooter) I just had a manager class for all the weapon-shots, it stored them in a container and then updates and draws every single one. When the "shoot-event" occurred, the "ProjectileManager" was notified and it added the wanted projectile. The input for player action is handled in the player-class, so the player would have to know the manager to call the function of the manager. I also have a collisionManager, that checks for collisions between, for example, enemies and the projectiles and then notifies these objects. However, I somehow have the feeling, that I shouldn't use this approach and that there might be a better way to handle this. I know, the question is a bit vague, I'm pretty much just looking for input and ideas to improve my design.

    Read the article

  • XNA When to call LoadContent

    - by Peteyslatts
    I have an enum in my game that denotes the game state ie MainMenu, InGame, GameOver, Exit and I was wondering if it would be advisable to add a new one in for PrepGame - in which the game creates viewports for however many players there are, creates the battlefield etc. I feel like this is a good idea except for one thing: should I make a call back to LoadContent() in this state? I could just put a switch statement in the LoadContent for my currentGameState. If it equals PrepGame load things like the skybox, ship models, texures, HUD graphics etc. Or is it a good idea to create an Asset Manager class in the first call to LoadContent() and load everything then. I feel like both approaches have different benefits: faster, but more load times vs slower initial load time, but then all my objects are referencing the same variables so I only have to load each on once. Any help is greatly appreciated. Thanks, Peter

    Read the article

  • libGDX using Stage and Actor produces different camera angles on desktop and Android Phone

    - by Brandon
    libGDX using Stage and Actor produces different camera angles on desktop and Android Phone. Here are pictures demonstrating the problem: http://brandonyuh.minus.com/mFpdTSgN17VUq On the desktop version, the image takes up most all the screen. On the Android phone it only takes up a bit of the screen. Here's the code (not my actual project but I isolated the problem): package com.me.mygdxgame2; import com.badlogic.gdx.*; import com.badlogic.gdx.graphics.*; import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.graphics.g2d.*; import com.badlogic.gdx.scenes.scene2d.*; public class MyGdxGame2 implements ApplicationListener { private Stage stage; public void create() { stage = new Stage(); stage.addActor(new ActorHi()); } public void render() { Gdx.gl.glClearColor(0, 1, 0, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); stage.draw(); } public void dispose() {} public void resize(int width, int height) {} public void pause() {} public void resume() {} public class ActorHi extends Actor { private Sprite sprite; public ActorHi() { Texture texture = new Texture(Gdx.files.internal("data/hi.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); sprite = new Sprite(new TextureRegion(texture, 0, 0, 128, 128)); sprite.setBounds(0, 0, 300.0f, 300.0f); } public void draw(SpriteBatch batch, float parentAlpha) { sprite.draw(batch); } } } hi.png is included in the above link Thank you very much for answering my question. I've spent 3 days trying to figure it out.

    Read the article

  • How to simulate objects floating on water without a physics engine?

    - by user1075940
    In my game the water movement is done in a shader using Gerstner equations. The water movement looks realistic enough for a school project but I encounter serious problem when I wanted to do sailing on waves (similar to this). I managed to do collision with land by calculating quad's vertices and normals beneath ship, however same method can not be applied to water because XZ are displaced and Y is calculated in a shader :( How to approach this problem ? Is it possible to retrieve transformed grid from shader? Unfortunately no external physics libraries can be used.

    Read the article

< Previous Page | 10 11 12 13 14 15  | Next Page >