texts: Why are faces being drawn like this with my custom shader?

texts:
I've been writing a custom surface shader which allows for vertex colors (with alphas) to be set programmatically. From test runs of the shader itself, it works perfectly fine, and I am able to set the color of vertices programmatically. Unfortunately, I ran into some other issues. Currently, the shader is rendering mesh faces quite strangely, and I cannot figure out why:

The shader code itself currently looks like this:

Shader "Custom/VertexColorSurface" {
    Properties {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" { }
    }

    SubShader {
        Tags { "RenderType"="Cutout" }

        CGPROGRAM
        #pragma surface surf Lambert alpha
        #pragma target 3.0

        struct Input {
            float2 uv_MainTex;
            float4 color : COLOR;
        };

        sampler2D _MainTex;
        fixed4 _Color;

        void surf(Input IN, inout SurfaceOutput OUT) {
            OUT.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb * _Color.rgb * IN.color.rgb;
            OUT.Alpha = tex2D(_MainTex, IN.uv_MainTex).a * _Color.a * IN.color.a;
            OUT.Specular = 0.2;
            OUT.Gloss = 1.0;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

Currently the two solutions I've tried have been using ZWrite On and ColorMask 0 in a Pass block, and while both of these methods fix the face rendering issues, they totally screw up alpha blending, which is something I need.

What might be causing this issue, and how do I fix it?


texts:
I'm rendering a height map using shader-based OpenGL (3.3 to be precise). The height map data is from a grayscale bitmap (2D array of bytes). The dimension of the bitmap is 256 x 256.

With this data, being the Y value, I calculate X and Z as corners of uniformly distributed cells in a grid. I generate the vertices and upload it to a VBO. I generate indices and populate an IBO; indices are of type GLshort.

I've implemented a free roaming camera to roam around the terrain and verify its correctness. As I move around everything renders fine, except in some angles, particularly when viewing the terrain from above/afar, I see that some triangles in peaks of mountains go missing. In this position, if I vary the camera's position along its Z axis, I see the missing triangle are also varying. When I go closer to the peak, the error goes away and everything is nice and whole.

Culling

I've read other similar questions here, which mainly suggest that it could be because those triangles are deduced as back facing and thus may disappear when facet culling is enabled. To rule that case out, I tried glDisable(GL_CULL_FACE) in vain.

Z fighting

I thought of this issue too, but it doesn't make sense. Z fighting happens when two fragments have the same depth buffer value, but the triangles appearing in place of the missing ones (in a slightly different dull colour; see image below) are behind the missing ones and not at the same Z and thus shouldn't have this problem. In either case, I tried enabling and disabling depth test to be sure, but to no avail.

Floating-point

Worried about floating point issues, I make sure that the vertices of the terrain are distributed around the origin i.e. if each cell is a square of length c, then both X and Z values of vertices are distributed equally around 0 e.g. X doesn't vary between 0 to 256 but from -128 to 128, assuming a per cell dimension to be 1 unit.

Draw

Other than those I tried changing the way I give draw calls to GL: glDrawElements with GL_TRIANGLES, glDrawElementBaseVertex and glMultiDrawElementsBaseVertex with GL_TRIANGLE_STRIP didn't change the the situation too.

I tried searching on the internet for an explanation but I'm at a loss there too, particularly when one doesn't know the keyword to search for. This should be happening fairly commonly in serious games since they all have terrains of some kind. Is there a proper name for this, and a solution?


texts:
There are plenty of algorithms to scale up pixel art. (I prefer hqx, personally.) But are there any notable algorithms to scale it down? My game is designed to run at a resolution of 1280x720, but if it is played at a lower resolution I still want it to look good.

Most pixel art discussions center around 320x200 or 640x480 and upscaling for use in console emulators, but I wonder how modern 2D games like the Monkey Island Remake could look good on lower resolutions?

Of course ignoring the option of having multiple versions of assets (i.e. mipmapping).


texts: I am using a tonemapper in our project and a friend of mine asked if I could provide him with a plot of the tonemapper used (different functions are implemented). I tried in MATLAB to copy the tone-mapper function and use luma values from -5 to 5.0 to feed to the function, but the resulting plot is nothing like a classic tonemap function plot as I happen to see around. The function is totally correct, but am I missing something stupid that must be taken into account when trying to plot them?


texts: Create Render Target View [138][140] need to Bind the back buffer to the render target view DirectX 11

texts:
This is the error

D3D11 ERROR: ID3D11Device::CreateRenderTargetView: A RenderTargetView cannot be created of a Resource that did not specify the RENDER_TARGET BindFlag. [ STATE_CREATION ERROR #138: CREATERENDERTARGETVIEW_INVALIDRESOURCE]
D3D11 ERROR: ID3D11Device::CreateRenderTargetView: Returning E_INVALIDARG, meaning invalid parameters were passed. [ STATE_CREATION ERROR #140: CREATERENDERTARGETVIEW_INVALIDARG_RETURN]

So as i see here i need to set the BindFlag of the backBuffer to D3D11_BIND_RENDER_TARGET, but in all the tutorial i saw nobody is doing it, they all create the render target view by using this code

hr=m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&m_backBuffer));
if (FAILED(hr)) MessageBox(0, L"Failed get buffer", 0, 0);
hr=m_device->CreateRenderTargetView(m_backBuffer, NULL, &m_renderTargetView);
if (FAILED(hr)) MessageBox(0, L"Failed to create rendertargetview", 0, 0);

And nobody, nowhere is doing as the msdn site says, that the render target view must be created with this specific flag: D3D11_BIND_RENDER_TARGET

So I tried doing it by myself.

I created a texture2d desc like this for the back buffer:

D3D11_TEXTURE2D_DESC backBufferDescription;
    backBufferDescription.BindFlags = D3D11_BIND_RENDER_TARGET;
    backBufferDescription.ArraySize = 1;
    backBufferDescription.CPUAccessFlags = 0;
    backBufferDescription.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    backBufferDescription.Height = 600;
    backBufferDescription.Width = 800;
    backBufferDescription.MipLevels = 1;
    backBufferDescription.MiscFlags = 0;
    backBufferDescription.SampleDesc.Quality = 0;
    backBufferDescription.SampleDesc.Count = 1;
    backBufferDescription.Usage = D3D11_USAGE_DEFAULT;
    m_device->CreateTexture2D(&backBufferDescription, NULL, &m_backBuffer);
    if (FAILED(hr))
        MessageBox(0, L"Fallito back buffer desc", 0, 0);

And it doesn't work the same.

Help please


texts: Triangular grid and rendering to a texture (Direct3D 11)

texts:
Is it possible to render vertex data from a triangular grid into a texture with a same size (i.e. 3x3 vertices to 3x3 pixels - each pixel is representing one vertex)?

Consider following situation. I have a grid (3x3 to keep it simple) and in a vertex shader is a computation of Z coordinate (imagine it like some wave model of a water surface). So, each vertex has some Z value, and I need to store these values into a texture (for a comparison with a next frame). A texture is set as a render target and has a same size as the grid.

How to render a precise Z value (coordinate) of a vertex into appropriate pixel? I mean, my dilemma is a fact that rasterizer gets three vertices and interpolates their values by default, so values stored in pixels are not precise at all.


texts: Unity IAP through Google Play is forgotten after a day without internet connection

texts:
I am trying to make a NonConsumable IAP purchase persist without internet connection.

I have implemented the IAP system from Unity 5.6 through Google Play for a NonConsumable item and it is working. From a previous question I learned how to avoid using Unity's PlayerPrefs to remember purchases in favor of checking the receipt from the Unity storeController that initializes with Unity's API code below.

   public void OnInitialized (IStoreController controller, IExtensionProvider extensions)
        {
            this.controller = controller;
            this.extensions = extensions;
        }

What I have observed is that the OnInitialized will run without internet connection as long as it has recently been initialized. This seems to be cached somewhere within Android because clearing the cache on my app will not force the purchase to be forgotten. The problem is after about half a day without internet connection the controller cannot initialize. Therefore I cannot check the item receipt in the controller with the code below.

Product product = storeController.products.WithID(productId);
 if (product != null && product.hasReceipt)
 {
     // Owned Non Consumables and Subscriptions should always have receipts.
     // So here the Non Consumable product has already been bought.
     itemBought = true;
 }

What strategy or method should I use to persist a NonConsumable purchase during times without internet connection as it is recommended to not use Playerprefs on numerous guides.


texts: Unity performance: change sprite from array or sprite sheet animation?

texts:
Quite some time ago I made a "GIF player" that basically reads a sprite array and swaps the sprite using a Coroutine, one after the other, in order to imitate a "GIF" animation.

I was working but I have no clue about performance as on my PC it was fine.

Thing is, the game is meant for mobile and I experience some lag and I don't know if it is due to my not using sprite sheet animations instead of my shiny solution.

The question is: Is there some difference between the sprite sheet anim and swapping sprites from an array?
I know Unity's API (that I used) cannot be called from other than the main thread. What about sprite sheet animations? Using another thread would definitely help but I can't do that and maybe they could.


texts: Google Play Services Message Handling with Libgdx

texts:
I'm looking for some idea of how to handle Reliable Messages in Google Play Services with libGDX. So far I've been using it like this: I was waiting for message with OnRealTimeMessageReceivedListener, setting an outside byte[] array to the message received, changing a flag that suggests that new message arrived to true, getting that message in my libGDX class using methods from interface, setting newMessage flag again to false, handling message, and so again waiting for new one

private OnRealTimeMessageReceivedListener mMessageRecievedHandler = new OnRealTimeMessageReceivedListener() {
        @Override
        public void onRealTimeMessageReceived(@NonNull RealTimeMessage realTimeMessage) {

            //Handle received message here

            byte[] message = realTimeMessage.getMessageData();

            /*byte tbye[] = message;
            ByteBuffer bb = ByteBuffer.wrap(tbye);
            if(bb.getFloat() == 1884) {
                Log.d("MESSAGETEST", "Message received in anL : " + debugIntL);
                debugIntL++;
            } */

            byteArray = message;

            newMessageFlag = true;
        }
    };

@Override
    public boolean getNewMessageFlag() {
        return newMessageFlag;
    }

@Override
    public byte[] getMessage() {
        newMessageFlag = false;
        return byteArray;
    }

Libgdx class:

@Override
    public void render (float delta) {
    ...
    checkForNewMessage();
    ...
   }

private void checkForNewMessage() {

    if(game.customHandler.getNewMessageFlag()) {
        handleMessage(); // handling message here
    }

}

private void handleMessage() {

        byte[] message = game.customHandler.getMessage();

        ByteBuffer bb = ByteBuffer.wrap(message);

        float typeOfMessage = bb.getFloat();

        if(typeOfMessage == NEW_UNIT_MESSAGE) {

            Gdx.app.log("MESSAGETEST", "Message received in gdx : " + debugInt);
            debugInt++;
            ...
           }
       }

But the result is, when uncommenting the code in OnRealTimeMessageReceivedListener and adding similar log to my handleMessage(); that some messages are skipped between receiving it in listener and checking for new in my libGDX class, I don't know why, maybe because some render calls take longer to do everything inside and it skips through one check call when there's significant number of those in small amount of time

On the image you can see that first log is from OnRealTimeMessageReceivedListener, which receives every message, but the second one is from handleMessage, and at 251 there it wasn't called, so handleMessage just skipped this message and went to the next one.

So here's my question, what's good way to handle those messages so that I won't skip any?


texts: How to remotely debug a D3D9 application

texts: I've got a D3D9 application, which works fine on my machine. But when I send it to a friend, his machine won't render any of the 3D content. I already changed the build to enable all error-code checking and they all come back clean. How can I remotely debug why his machine's rendering is broken?


texts: XNA / MonoGame - render transparent background using stencil buffer problem (3d)

texts:
I'm trying to render 3d texture quads with the following properties:

With lighting (rule out "AlphaTestEffect").
Transparent background (no opacity levels, just binary opaque or transparent).
No ordering, eg, I don't want to sort objects by camera distance.

If I just try to render the quads regularly with their transparent background, the result is that even the transparent pixels are written to the depth buffer, which cause a background bug see picture:

So I try to do it with a different way, using the stencil buffer. What I do is the following:

Render just the transparent pixels on the stencil buffer, to create a mask.
Render the texture itself, again, using the stencil buffer I created before.

Now it works with the background renderings, but the problem is that different quads with transparent background hide each other in transparent pixels, as seen here:

I'm not sure if it's because the stencil buffer is not cleared between renders or maybe in one of my steps I mistakenly write to depth?

Anyway here's my code (at least the relevant parts of it):

// set effect and settings for the stencil mask phase
_alphaMaskEffect = new AlphaTestEffect(device);
_alphaMaskEffect.World = Matrix.Identity;
_alphaMaskEffect.AlphaFunction = CompareFunction.Equal;
_alphaMaskEffect.ReferenceAlpha = 0;
_alphaMaskEffect.VertexColorEnabled = true;
_alphaMaskEffect.DiffuseColor = Color.White.ToVector3();
_alphaRenderStencilMaskSettings = new DepthStencilState
{
    StencilEnable = true,
    StencilFunction = CompareFunction.Always,
    StencilPass = StencilOperation.Replace,
    ReferenceStencil = 1,
    DepthBufferEnable = true,
    DepthBufferWriteEnable = false,
};

// set settings for the regular rendering phase
_alphaRenderTextureWithStencilSettings = new DepthStencilState
{
    StencilEnable = true,
    StencilFunction = CompareFunction.Equal,
    StencilPass = StencilOperation.Keep,
    ReferenceStencil = 0,
    DepthBufferEnable = true,
    DepthBufferWriteEnable = true,
};

And here's the draw function itself:

// set settings for the stencil buffer rendering
device.DepthStencilState = _alphaRenderStencilMaskSettings;

// render stencil buffer
foreach (EffectPass pass in _alphaMaskEffect.CurrentTechnique.Passes)
{
    // draw current pass
    pass.Apply();
    device.DrawUserIndexedPrimitives
        <VertexPositionNormalTexture>(
        PrimitiveType.TriangleList,
        Vertices, 0, 4,
        Indexes, 0, 2);
}

// now render the quad with the stencil buffer
device.DepthStencilState = _alphaRenderTextureWithStencilSettings;

// render effect itself
foreach (EffectPass pass in _effect.CurrentTechnique.Passes)
{
    // draw current pass
    pass.Apply();
    device.DrawUserIndexedPrimitives
        <VertexPositionNormalTexture>(
        PrimitiveType.TriangleList,
        Vertices, 0, 4,
        Indexes, 0, 2);
}

tl;dr what's the right way to render 3d quads with transparent background, lighting and without sorting objects by distance from camera? And if it's the code I tried - how do I make the renderings stop hiding each other?


texts: How to support all iOS device screen sizes / resolutions in my game

texts:
I made this game. Right now the game supports all iOS devices except iPhone 5.

The definition of each level of the game is kept in a plist. The creation of each level is done through a graphical level editor. Each device family has its own plists. So, right now the game has 100 levels and 200 plists; 100 plists for the iPhone family and 100 plists for the iPad family.

In order to support the iPhone 5 I need to create 100 new plists and adjust the plists accordingly, which is time consuming, not to mention the creation of new levels...

The editor for creating and editing the levels is solely based on the manipulation of UIViews that describe the game elements. So, this is the code that I wrote to save and restore the state of each UIView in one level of the game.

- (void)encodeWithCoder:(NSCoder *)aCoder {
    // Save the screen size of the device that the view was saved on
    [aCoder encodeCGSize:self.gameView.bounds.size forKey:@"saveDeviceGameViewSize"];

    // ****************
    // ALL properties are saved in normalized coords
    // ****************

    // Save the center of the view
    CGPoint normCenter = CGPointMake(self.center.x / self.gameView.bounds.size.width, self.center.y / self.gameView.bounds.size.height);
    [aCoder encodeCGPoint:normCenter forKey:@"center"];

     // I rely on view bounds NOT frame
    CGRect normBounds = CGRectMake(0, 0, self.bounds.size.width / self.gameView.bounds.size.width, self.bounds.size.height / self.gameView.bounds.size.height);
    [aCoder encodeCGRect:normBounds forKey:@"bounds"];

     // Here I save the transformation of the view, it has ONLY rotation info, not translation or scalings
    [aCoder encodeCGAffineTransform:self.transform forKey:@"transform"];
}

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {

        // Restore the screen size of the device that the view was saved on
        saveDeviceGameViewSize = [aDecoder decodeCGSizeForKey:@"saveDeviceGameViewSize"];

        // Adjust the view center
        CGPoint tmpCenter = [aDecoder decodeCGPointForKey:@"center"];
        tmpCenter.x *= self.gameView.bounds.size.width;
        tmpCenter.y *= self.gameView.bounds.size.height;
        self.center = tmpCenter;

        // Restore the transform
        self.transform = [aDecoder decodeCGAffineTransformForKey:@"transform"];

        // Restore the bounds
        CGRect tmpBounds = [aDecoder decodeCGRectForKey:@"bounds"];
        CGFloat ratio = self.gameView.bounds.size.height / saveDeviceGameViewSize.height;
        tmpBounds.size.width *= (saveDeviceGameViewSize.width * ratio);
        tmpBounds.size.height *= self.gameView.bounds.size.height;
        self.bounds = tmpBounds;
    }
    return self;
}

I am really stuck here. I cannot explain what is wrong with this code. The UIViews are correctly positioned when restored on the same device. This is not true when the level is opened on another device. There are slightly misplaced elements and distortions.

Here are two pairs of screenshots demostrating the issues:

What is the correct approach to handle the scaling of the levels on different screens? Should I rely on AutoResizingMasks (I need to support iOS 4 and later)? In any case I would like to give a solid paradigm on how to achieve this.


texts: Unity get component throwing NullReferenceException only in standalone build

texts:
I'm having a very frustrating issue with GetComponent().

private void Show()
{
    var transition = GetComponent<TransitionAnimation>();

    Debug.Log($"Transition: {transition}");
    transition?.FadeIn();
}

In the editor, this works just fine. transition is not null and FadeIn() is called. In the standalone build, GetComponent() returns null, throws a NullReferenceException, and execution stops before it can even print transition to the console.

This is the output from the log file.

Uploading Crash Report
NullReferenceException
  at (wrapper managed-to-native) UnityEngine.Component.get_gameObject(UnityEngine.Component)
  at UnityEngine.Component.GetComponentInChildren (System.Type t, System.Boolean includeInactive) [0x00001] in <e314adc5a7494b5f8760be75461a94d4>:0
  at UnityEngine.Component.GetComponentInChildren[T] (System.Boolean includeInactive) [0x00001] in <e314adc5a7494b5f8760be75461a94d4>:0
  at Winglett.RR.UI.Gradient.Show () [0x00001] in /Users/redacted/Documents/repos/radical-relocation/Assets/_Core/Scripts/UI/Gradient.cs:63
  at (wrapper delegate-invoke) <Module>.invoke_void()
  at Winglett.RR.Gameplay.GameState.SetPause () [0x00001] in /Users/redacted/Documents/repos/radical-relocation/Assets/_Core/Scripts/Gameplay/GameState.cs:46
  at Winglett.RR.Gameplay.GameState.SetPause_STATIC () [0x00000] in /Users/redacted/Documents/repos/radical- relocation/Assets/_Core/Scripts/Gameplay/GameState.cs:70
  at Winglett.RR.UI.Wrapper.SetGameStatePause () [0x00000] in /Users/redacted/Documents/repos/radical-relocation/Assets/_Core/Playground/ui/Wrapper.cs:27
  at UnityEngine.Events.InvokableCall.Invoke () [0x00011] in <e314adc5a7494b5f8760be75461a94d4>:0
  at UnityEngine.Events.UnityEvent.Invoke () [0x00023] in <e314adc5a7494b5f8760be75461a94d4>:0
  at Winglett.RR.Utils.ESCButton.Update () [0x00026] in /Users/redacted/Documents/repos/radical-relocation/Assets/_Core/Scripts/Utilities/Other/ESCButton.cs:21

I wondered if the issue might be because the gameobject is disabled. So I tried GetComponentInChildren<TransitionAnimation>(true); where true is an overload for inactive gameobjects. This didn't change anything.


texts: Strategy for Levels That Blend 2 Maps Concurrently

texts:
Levels like A Crack In The Slab from Dishonored 2 allow you to jump back and forth between 2 time periods at the 'same' location.

The blending is not just a case of toggling map objects on and off, as the Timepiece in this instance gives you a view into an alternate time period, whilst the player is in a separate time period.

The drawn bounds of this Timepiece lens view are not axis aligned to x and y either, meaning you not only have to render the two time periods concurrently, but have to slice into game objects to partially occlude them (shader magic? post processing?).

I was wondering what strategies you might use to achieve such a transition/mixing of two views of the 'same' map effectively and efficiently? Maybe there is an existing library for a game engine like Unity?

Many thanks

(originally posted this question on Reddit but had no luck)


texts: Lighting shadow casting sprites with box2Dlights

texts:
I currently have something like this using box2Dlights

Ideally, I would like objects casting shadows to be lit, so the object is lit but there is still a shadow cast around it. Right now the object is covered by shadow. I am aware of the soft and softnesslength settings in box2dlights but this is not really what I'm looking for. Softness seems to light up a certain radius from the player rather than just lighting objects. It ends up kind of weird looking:

So for example in the above picture, I would want the entire grey box to be lit, and none of the area to the left/right/behind it to be lit.

Any thoughts would be appreciated. Thanks


texts: How do I fill a shape with a texture in Libgdx?

texts: I am making a 2D racing game. I want to fill the area of the ground object with a texture. I have the shapes of the ground (a Box2D shape). If I make images of the ground with textures, it uses a lot of RAM, so I instead want to fill the shapes with copies of a small texture.


texts: Does there exist a library of animations for easing, skewing, bouncing, and squishing?

texts:
I'm specifically referring to the types of animations that are typical in 2D hand held games on the Nintendo platform, where menus slide in, bounce, squish, etc.

I'm looking for something that is somewhat canned but allows for tweaks. Does something like this exist in any form (don't really care what language or for what targeted platform, I'm just looking for the pure math behind it).


texts: How to change the speed of the gameobject moving on the itween path

texts:
I have set an itween path for an object to move.And I have written the code as

iTween.MoveTo(gameObject,iTween.Hash ("path",iTweenPath.GetPath("train"),"time",300));

The above code is working for me.

Now I need to apply the change in speed that mean,when i press "S" the object should move Slow,when I press "F" the object should move Fast,When I press "M" the object should move with a medium speed on the itween path.I have written a code for.Below is the code

void Update () {

    if(Input.GetKey(KeyCode.S))
    {
        iTween.MoveTo(gameObject,iTween.Hash ("path",iTweenPath.GetPath("train"),"time",300));

    }
    if(Input.GetKey(KeyCode.M))
    {
        iTween.MoveTo(gameObject,iTween.Hash ("path",iTweenPath.GetPath("train"),"time",100));

    }
    if(Input.GetKey(KeyCode.F))
    {
        iTween.MoveTo(gameObject,iTween.Hash ("path",iTweenPath.GetPath("train"),"time",50));

    }
}

When I runned my above code,and when I press "S" key its moving slowly,next when I press "F" the object is going back to the original position where it was and then it starts moving fast ,same as for the medium "M" also.

I need to change the speed of the object moving on the itween path specified by pressing the keys.Can anybody please help me out.


texts:
I am creating a digital boardgame, which consits of muliple boards, between which the gamepieces are moved by the players.
The script of the game board needs a 2D array of positions to know where to move a gamepiece when it recives one.
Currently to mark the positions on the game boards, I added placeholder gameobjects to the prefab and named them "spawnpoint\d".In the Awake() method I use Transform.Find() to search for those gameobjects. Then, after I save their positions I call Destroy() on them, so they do not show up in the game.
I see two problems:

This is done for all Instantiated game board, altough the positions are the same on all of them.
I read that using Transform.Find() is heavily discourged by the experts in the community.

I wish to store the spawnpoint positions in a static array, so all instances refer to the same data. Furthermore I wish to easily modify these positions in the editor with visual help.
I tried serializing static members, but those do not show up in the editor to be able to modify.
    [SerializeField]
    public static int TestNumber;

TLDR:
How to make static members visually changeable from the Unity editor?


texts:
I´m starting up a new project. It´s going to be a web browser game, developed using HTML5, JavaScript and CSS3.

I have some general questions regarding the process of game developing.

Should you know everything about your game by the time you start writing the first lines of code? I mean should you know all the details, all the things the player can and can not do? Basically: should you be done writing down new ideas before you begin coding?
I understand the pre-production process is about documenting, doing research etc. What does that mean? Does it mean I should open up Word and write down everything about the game? For example what should happen when you click on different things etc.

Thanks for your help!


texts: Scaling 3D furniture while keeping the thickness constant

texts:
I am creating a program in WindowsForms and Xna that allows users to create a 3D room. By dragging and customizing different .fbx models, they can "build" a room or whatever and then look at it in 3D. Everything worked nicely so far, until I got to a point that involves scaling a model. A model is usually made up of multiple meshes, and each mesh has a class that contains information about that mesh such as, position, rotation, name, mesh, scaleFactor, etc. This class also contains a list called ScalableAxes which contains strings of the axes name, in which this mesh can be scaled.

I have also included a parent-child relationship, when a user imports a .fbx model, there is also a custom .pdn file which contains information about parenting.  Usually every mesh in the .fbx model becomes a child of an "empty mesh" (just a class, with no mesh or bone assigned to it).

Now let's say this "empty mesh" name is Body and it contains few child meshes such as left side, right side, top side, bottom side, top door, bottom door. Let's say I scale Body on the Y axis by a factor of 2. Since Body has no Mesh in his class assigned, it would skip this and loop through his children. If a child has a mesh, then it would look to ScalableAxes list and if it contains Y (in this case) it would go on to the scaling part.

The problem starts here. Let's say I come to Left side, left side can be scaled on the Y axis, but the top and bottom sides CAN'T be scaled on the Y axis. So scaling it this way would lead to gaps between left side and top and *bottom side**. Also there can be a whole variety of different models, and meshes. For example: one has only one door, other has sides between top and bottom, and so on...

EDIT:
For example: left side is 964 on Y axis, top and bottom side are each 18 on Y axis, so the combined length is 1000 on Y axis. I scale the whole Body by 2 on the Y axis (meaning the new Y size should be 1000 * 2 = 2000). If I were to use scaling by 2 on the Y axis on all meshes (that can be scaled on the Y axis), then left side would be 1928, top and bottom would stay the same so, 18 each on Y axis. This would lead to 1928+18+18, 1964 size on the Y axis instead of 2000.

EDIT2:
This program is all about arranging / making furniture in 3D.
So let's say you got this night stand in your project made with this program.

And you find the size of it to small, and you want to scale it vertically. When you would scale it the "thickness" of all of the elements (meshes that made up this model) should stay the same since you want to make it bigger not "thicker". Only the length and width should change. So the left and right side would get scaled vertically, but top and bottom side wouldn't since that vertical direction is their "thickness".
And if you would want to scale the model horizontally (make it wider), the top and bottom sides would get scaled, but left and right would stay the same since that direction is their "thickness" (they would only have to get moved to the right positions).

Thats why in my previous picture I said that top and bottom side cant be scaled on the Y axis, since that was their "thickness".

EDIT 3:
bummzack, your method works great and all, but what if I have a furniture that has, 3 or more doors. How would I be able to scale all of the doors equally?

Any help is greatly appreciated!


texts: Is it possible to look up a texel from a texture in GLES2 GLSL framgent shader without using sampler?

texts: Is there some way I can directly access texture memory from fragment shader in GLES2 GLSL? I don't need the sampler to be involved since I am just using it as a look-up table.


texts:
Using C# (VS2010) with XNA 4.0, I have a terrain layer (RenderTarget2D) in a 2D side-scroller.  My visual system tracks updates to redraw individual tiles, but I am having trouble finding a way to clear out the rectangle where the tile will be drawn, which I must do because A) there may no longer be a tile or B) the tile may itself contain transparency.

How can I draw a rectangle of transparency onto an existing RenderTarget2D?
I essentially want to clear just that rectangular portion of it.

My Google searches have not yielded anything relevant.


texts: In Unity3D, try to load a png into a Texture2D in an Editor script and then run PackTextures, but they need Readable flag to be set

texts:
I am trying to automatically create a texture atlas from a set of generated png files in an Editor script. The problem is that I can't seem to be able to load a png into a Texture3D without it being inaccessible by the PackTextures method. I have tried a few different ways to load the PNGs, such as Resources.LoadAssetAtPath(...), AssetDatabase.LoadAssetAtPath(...) and a few more.

Since all of this is done in OnPostprocessAllAssets, I don't want to have to do any manual editing of the textures. I just want to be able to drop a PNG into a certain folder and get an updated atlas. Answers such as this seem to suggest manual editing.

The actual error message is

  "Texture atlas needs textures to have Readable flag set!".

So the question is, is it possible to do this kind of post processing in Unity3D? Is there any way to import a PNG into a Texture2D with the Readable flag set, without having to manually change it?


texts:
i was following this tutorial here: https://www.youtube.com/watch?v=yNYwZMmgTJk, in which i was translating from Java to C++ to generate a terrain, and stumbled across this issue:

As it appears, it is rendering lines instead of triangles. i have checked, glDrawArrays() which was drawing triangles like normal. i checked the generator and the textures which was normal. But when i put in verticies manually it drew the terrain normally. This then leads to me suspecting that the error is in the terrain generator. another possibility, but least likely, is that i suspect is that i am not passing the data to the vertex and fragment shader correctly.

here is the terrain generator code:

const int vertex_count = 128;
const int size = 800;

GLfloat vert[(vertex_count * vertex_count) * 3]{
    0
};

GLfloat norm[(vertex_count * vertex_count) * 3]{
    0
};

GLfloat texCoord[(vertex_count * vertex_count) * 2]{
    0
};

int vertexPointer = 0;

for (int i = 0; i < vertex_count; i++) {
    for (int j= 0; j < vertex_count; j++) {
        vert[vertexPointer * 3] = -(float)j / ((float)vertex_count - 1) * size;
        vert[vertexPointer * 3 + 1] = 0;
        vert[vertexPointer * 3 + 2] = -(float)i / ((float)vertex_count - 1) * size;

        norm[vertexPointer * 3] = 0;
        norm[vertexPointer * 3 + 1] = 1;
        norm[vertexPointer * 3 + 2] = 0;

        texCoord[vertexPointer * 2] = (float)j / ((float)vertex_count - 1);
        texCoord[vertexPointer * 2 + 1] = (float)i / ((float)vertex_count - 1);

        vertexPointer++;
    }
}

and glDrawArrays():

 glDrawArrays(GL_TRIANGLES, 0, sizeof(vert));

and passing the data to the fragment and vertex shaders:

GLuint vao, vbo;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER,sizeof(vert), vert, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);

GLuint vbo2;
glGenBuffers(1, &vbo2);
glBindBuffer(GL_ARRAY_BUFFER, vbo2);
glBufferData(GL_ARRAY_BUFFER, sizeof(texCoord), texCoord, GL_STATIC_DRAW);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(1);

GLuint vbo3;
glGenBuffers(1, &vbo3);
glBindBuffer(GL_ARRAY_BUFFER, vbo3);
glBufferData(GL_ARRAY_BUFFER, sizeof(norm), norm, GL_STATIC_DRAW);
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(2);


texts: Confuse with OpenGL, SFML, and its library

texts:
I am a beginning to enter the world of game development.

Lately, I researched that "OPENGL" is one of the tools to use in graphics,
then I found out about "SFML" (I think that its a library or something that uses opengl).

I am so confuse because all books/ sites said using "GLUT",
but many people/fellow developers said that I must use a more updated one like "SFML"
but sfml has few/none tutorials.

What I am trying to say is "how to create own library or something like your own glut or sfml",
and why does opengl has no source code? And how can I use the EXACT(not glut/sfml) opengl in my c++
program?

I am so confuse....


texts: How to handle 3D collisions using raycasting (with a reflection vector?)

texts:
I'm making a game using THREE.JS, and I want my character to walk on the terrain, and collide with static 3D objects (=AABB boxes) that are on that terrain.

The problem is: THREE.JS has only a raycasting class which can be used for collisions.

I figured it would be possible if I casted 8 rays from my character to the points of an imaginary cube around the character (simulating an AABB box). I realize a sphere would be much better, but I wouldn't know how to do that using rays.

var rayDirections = [];
rayDirections.push(new THREE.Vector3(1, 1, 1));
rayDirections.push(new THREE.Vector3(-1, 1, 1));
rayDirections.push(new THREE.Vector3(1, 1, -1));
rayDirections.push(new THREE.Vector3(-1, 1, -1));
rayDirections.push(new THREE.Vector3(1, -1, 1));
rayDirections.push(new THREE.Vector3(-1, -1, 1));
rayDirections.push(new THREE.Vector3(1, -1, -1));
rayDirections.push(new THREE.Vector3(-1, -1, -1));

Then, I simply test the rays against the terrain and possible 3D meshes on the terrain, and check if the ray distance from one of the raycasts is smaller than the AABB box size. This would mean a collision occured.

Rays around the character http://www.ironbane.com/images/colbox.png.

So far so good! I cast a ray from the character's position with every rayDirection and check if one collides with the meshes array (which contains the terrain and other 3D objects on the terrain)

Once I have a collision, what to do now? Should I calculate a reflection vector? If for instance I simply walk on a flat terrain, the four rays at the bottom should trigger a collision. How do I use this reflection vector in my situation?

for(var r in rayDirections) {
    // this.position refers to the character's current position
    var ray = new THREE.Ray( this.position, rayDirections[r] );

    for (var m in meshes) {
        var intersects = ray.intersectObject( meshes[m] );

        if ( intersects.length > 0 ) {
            // Normal vector of the meshes' face we hit
            var nV = intersects[0].face.normal;

            // Velocity vector (of the character)
            var vV = this.velocity.clone();

            // And calculate the reflection vector
            var rV = n.multiplyScalar(-2 * vV.dot(nV)).addSelf(vV);;

            // ... Now what?
        }
    }
}


texts: Unity3d: Get a direction vector parallel to plane

texts:
I need to send a raycast from my camera which is parallel to the plane (Ground) and in the same direction of its forward vector (Represented by the black color vector)

I cant use world space direction because the global forward vector of the camera points at the same direction no matter how much I rotate it (Since its a VR camera)

I tried to use Vector3.ProjectOnPlane, but not sure how it works.

Can someone help me?


texts:
I'm working on some special pick ups on an arkanoid-like game. Currently, I have one that should spawn several balls all in a row, right after the original ball hits the paddle. All the additional balls should spawn just above the paddle and then they are passed the vector from the original ball, in which case they should follow that vector, essentially causing a line of balls all traveling in the same direction. The problem I am having is the ball's spawn just above the paddle, but they are spawning in place. Gravity pulls them down, and when they hit the paddle, that seems to be when the vector becomes active and the ball takes off like it should have when it spawned. I'm not sure what I am doing wrong here to keep it from just taking off like that as soon as it spawns. Can anyone see anything here that could be causing this behavior?

This is the code for spawning a ball and setting the vector.

  Instantiate(newBall, new Vector3(paddle.transform.position.x, (paddle.transform.position.y + 1), 0), Quaternion.identity);
    newBall.GetComponent<Ball>().hasStarted = true;
    GameManager.pickUpManager.allBalls.Add(newBall.GetComponent<Ball>());
    newBall.GetComponent<Rigidbody2D>().AddForce(mainBallVector, ForceMode2D.Impulse);      //use the original ball's vector3 to follow it directly

Here is where mainBallVector gets set, it is a vector3:

  mainBallVector = mainBall.GetComponent<Rigidbody2D>().velocity;


texts: A Sensor’s ContactList Keeps Old / Ignores New Contacts, When That Contact Is still

texts:
Okay this is a hard one to explain so I’ll try my best.

Basically every time my enemy class updates, it runs a SightCone Sensor Contact List test, so this is every single frame it checks for all the possible contacts in it’s sensor.

What I’m finding is that if I’m moving my player character around, the contact list updates perfectly, when the player is in the enemy’s sight, it’s true, when it is out of sight its false,

However if I keep my player still, The contact list always ignores it.

Here is a video showing the behaviour. (the true and false flag is in the top left.)

Here is the code I have. Basically in the Enemy’s update method I run the check (the sightcone is a supplemental body within the enemy class that follows the position and rotation of the enemy body every frame.)

List<Body> coneClip = GetBodiesInContactWithBody(SightCone.Body);

private List<Body> GetBodiesInContactWithBody(Body body)
        {
            var bodiesInContact = new List<Body>();
            var c = body.ContactList;
            while (c != null && c.Next != null)
            {
                if (c.Contact.IsTouching)
                {
                    bodiesInContact.Add(c.Other);
                }
                c = c.Next;
            }
            return bodiesInContact;
        }

I am not sure why this is happening. I don’t know why the contact list isn’t seeing the player, even though the body is still, it still exists, has a shape and position, and 100% exists in the physics world.

Truly hope you can help.


texts:
I have a simple 2d scene, where I'm trying to have a sprite at x = -8 which I can move up and down. The problem is, when playing the scene, the sprite "jumps" by itself to the middle, x = 0, for no apparent reason. It then only goes back to x = -8 when there is input to move it. How do I get it to stop "jumping" to the middle at the start of every play?

using UnityEngine;
public class player1 : MonoBehaviour
{
     Vector2 targetPos;
     public float speed;
     public float step;
     void Start()
     {
         transform.position = new Vector2(-8,0);
     }
     void Update()
     {
         if (Input.GetKey("w") && transform.position.y < 3.8)
         {
             targetPos = new Vector2(-8, transform.position.y + step);
         }
         if (Input.GetKey("s") && transform.position.y > -3.8)
         {
             targetPos = new Vector2(-8, transform.position.y - step);
         }
         transform.position = Vector2.MoveTowards(transform.position, targetPos, speed);
     }
}


texts: I am programming a particle engine for a 3D game written in XNA. I was wondering if somebody could point me in the right direction or perhaps give me some pointers in making the particles collide with geometry in game. In essence, I want to be able to make a spark emitter that will bounce and collide down say, a cylindrical tube.


texts:
In my voxel engine (XNA 4.0) I'm use a vertex buffer for the entire chunk and update it after the set block, changing block metadata or light level. This is not too frequent operation compared with the time of mesh rebuild. But now I want animate some blocks, for example, make door opening or lever switching smooth.

If I remember right, in Minecraft all draw on the fly using OpenGL (correct if wrong), but in my case this is not an option.

I'm know what is a bone animation and how it works, and I think that I can make something like this for animatable block X:

rebuild chunk mesh without animated part of block X;
create entity looking like removed animated part and animate it;
remove entity and rebuild chunk mesh with that part in another static position.

I'm not shure this is a correct way. Any better ideas?

Also, how to make a block with animated textures? Do I need to use for this purpose a separate shader or I can somehow a correct texture coordinates of vertices in existed meshe?

Thanks.


texts: Which gaming engine can be used for pixel manipulation?

texts:
Here is the gist of where I am going with this. I work for a printer company and basically all of our input files(or output files for virtual printers) are bitmap files. We currently have a tool built in java over 10 years ago that works, but chokes on our high end 1600x1600 files.

So I was thinking, why not utilize a game engine's built-in ability to utilize the power of a gpu?

I am thinking all I would have to do is create a 1600x1600 plane, feed it the image file and draw the scene. I figure this is the easy part.

However, the hard part is reaching into the image for example and clicking the mouse on a particular pixel. Getting RGB data, converting to CYMK, making changes, converting back into RGB and then redrawing the scene. Not only that but pulling the modified texture out of memory and saving it back into a bitmap.

Is this even possible? I haven't used a game engine since college and that was opengl 2.0.

Just figured this looked like a good place to ask. Thanks.


texts: Are there any video tutorials available for game programming with Max?

texts: Are there any videos on how to make a small game using Max? I mean is it only done in Max or are there other things used? I am a newbie in game programming.


texts: In OpenGl ES 2, should I allocate multiple transformation matrices?

texts:
In OpenGl ES 2, should I declare just one transformation matrix, and share it across all objects or should I declare a transformation matrix in each object that needs it?

for clarification... something like this:

public class someclass{
   public static float[16] transMatrix = new float[16];
   ...
   public static void translate(int x, int y){
      //do translation here
   }
}
public class someotherclass{
   ...
   void draw(GL10 unused){
      someclass.translate(10,10);
      //draw
   }
}

verses something like this:

public class obj1{
    public static float[16] transMatrix = new float[16];
   ...
   void draw(GL10 unused){
      //translate
      //draw
   }
}
public class obj2{
   public static float[16] transMatrix = new float[16];
   ...
   void draw(GL10 unused){
      //translate
      //draw
   }
}


texts: How to create activity again in Android?

texts:
I am making some game and I want to create activity again after click on  some Button.

For example:
I have activities A (game) and B (after game menu). I want to go back to activity A after clicking "Play again" in activity B. But I don't want to resume it but to create it again, so it starts from the beginning. Is there any way of doing this?

I am using android studio.


texts:
I'm working in 2D.

I have set up 2 cameras. One for UI and another one for gameplay.

I need the UI to be rendered after before game objects (over gameplay). I wanted to achieve this without using world space canvas, because It requires being scaled for every other device along with a camera.

UI can be drawn over gameplay using greater depth than gameplay camera. And because it's depth only there is no solid color, so it all works well.

But you cannot set gameplay camera to depth only because it doesn't render things right, it doesn't clear the render texture I guess.

So this is what happens if gameplay camera is set to depth only.

This is what happens when gameplay camera is set to Solid Color and UI Camera has bigger depth. You can see that the ring is covered by UI arrow.

If the UI Camera depth would be lower than gameplay camera (Solid Color). It would all be covered by gameplay camera without even displaying UI.

These are mine settings.

Is there a way to achieve this in Unity without using World Space Canvas Mode?


texts:
I'm trying to achieve that kind of scene but in real time using Unity.

It's basically composed of some primitives, a skybox, and a plane. I'm intrigued on how to do this effect in particular:

The plane acts like a mirror, but tainted and matte (and it appears to be less blurry at the bottom of the buildings... but I'm not quite sure). I have found some shaders to create mirrors in Unity but nothing about the matte effect like in this picture. Could you guide me on how to achieve this kind of effect (knowing that I'm pretty lame when it comes to write shaders but I want to learn).

Thanks.


texts: How can I draw multiple lines connected via "nodes" in libgdx Scene2D?

texts:
I have two Vectors which indicate the ending points of each line. I am trying to draw similar lines to football formation lines like these:

My main problem using ShapeRenderer is:

ShapeRenderer coordinates are relative to screen coordinates and not Scene/Table/Stack. This creates varying coordinate points in different screen sizes. Although I can fix it, I still experience get varying line width in different screen sizes.
ShapeRenderer performance issues as it is mainly intended for debugging.
ShapeRenderer draws over all Actors.

I have tried drawing the lines as a Pixmap and adding them to the scene as an image. This is part of the constructor to my custom class which extends Group.

pixmap = new Pixmap( 16, 16, Pixmap.Format.RGBA8888 );

    pixmap.setColor(Color.RED);
    pixmap.drawLine(Ax, Ay, Bx, By);
    Texture pixmaptex = new Texture(pixmap, Pixmap.Format.RGB888, false);
    Image pixmapimg = new Image(pixmaptex);
    pixmapimg.setPosition(x, y);
    this.addActor(new Image(pixmaptex));
    pixmap.dispose();

I am trying to draw using this but it just draws a square with the pixmap width and height at (0,0) of the stack. Which is the best class to extend to draw this lines? I am expecting to write a custom class if this doesn't work.


texts: How can I fix the vibration in my Player movement?

texts:
Edit: solved my issue, but look at the other answer

I am stuck with a problem that I cant quite figure out.

When I move my Player to a new point, it does get there, but it vibrates. I can't seem to get it to stop.

I've used an Entity Component System.

This is a function in my Component_Transform class

void direction(float x_pos_str, float y_pos_str, float x_pos_end, float y_pos_end)
    {
        if (x_pos_str < x_pos_end)
        {
            if (x_pos_str != x_pos_end) { velocity.x = 1; }
        }
        if (y_pos_str < y_pos_end)
        {
            if (y_pos_str != y_pos_end) { velocity.y = 1; }
        }
        if (x_pos_str > x_pos_end)
        {
            if (x_pos_str != x_pos_end) { velocity.x = -1; }
        }
        if (y_pos_str > y_pos_end)
        {
            if (y_pos_str != y_pos_end) { velocity.y = -1; }
        }
        if (x_pos_str == x_pos_end)
        {
            velocity.x = 0;
        }
        if (y_pos_str == y_pos_end)
        {
            velocity.y = 0;
        }

This is apart of my Controller_Mouse class

void update() override
    {
        if (Game::event.type == SDL_MOUSEBUTTONDOWN)
        {
            if (SDL_BUTTON_LEFT)
            {

                std::cout << "transform vals: " << transform->position.x <<", " <<transform->position.y << std::endl;
                std::cout << "click vals:     " << Game::event.motion.x << ", " << Game::event.motion.y << std::endl;

                transform->target.x = Game::event.motion.x; transform->target.y = Game::event.motion.y;

            }

        }
        if (Game::event.type == SDL_MOUSEBUTTONUP, SDL_BUTTON_LEFT)
        {
            transform->direction(transform->position.x, transform->position.y, transform->target.x, transform->target.y);

        }


texts: What is the approach of creating an image puzzle game with libgdx

texts:
I would like to create a game which consists of taking a random image, slicing it up into some number of pieces (according to a selected difficulty) and letting the player solve the puzzle.

I've googled this, but didn't find anything relevant that would at least help me understand how this kind of games are to be approached. I did come across this article Custom Sprite Batcher in LibGDX, but it is not complete and is rather confusing to me for now.

Any suggestions are much appreciated.
Thanks.


texts: How to put the “camera” inside a cube in OpenGL

texts:
I'm really new to OpenGL and can't seem to figure out how to put the "camera" inside the cube I've created so that I can move in an FPS-like style.  I tried to use gluLookAt and gluPerspective but I'm clearly missing some steps. What should I do before gluLookAt? Here's the code written so far:

    int rotate_Y; //used to rotate the cube about the Y-axis
    int rotate_X; //used to rotate the cube about the X-axis

//the display function draws the scene and redraws it
void display(){

    //clear the screen and the z-buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glLoadIdentity(); //resets the transformations

    glRotatef(rotate_X, 1.0, 0.0, 0.0);
    glRotatef(rotate_Y, 0.0, 1.0, 0.0);

    //Front Face of the cube - vertex definition
    glBegin(GL_POLYGON);
    glColor3f(0.0, 1.0, 0.0);
    glVertex3f(-0.5f, -0.5f, -0.5f);
    glVertex3f(-0.5f, 0.5f, -0.5f);
    glVertex3f(0.5f, 0.5f, -0.5f);
    glVertex3f(0.5f, -0.5f, -0.5f);
    glEnd();

    //Back Face of the cube - vertex definition
    glBegin(GL_POLYGON);
    glColor3f(1.0, 0.0, 0.0);
    glVertex3f(-0.5f, -0.5f, 0.5f);
    glVertex3f(-0.5f, 0.5f, 0.5f);
    glVertex3f(0.5f, 0.5f, 0.5f);
    glVertex3f(0.5f, -0.5f, 0.5f);
    glEnd();

    //Right Face of the cube - vertex definition
    glBegin(GL_POLYGON);
    glColor3f(1.0, 0.0, 1.0);
    glVertex3f(0.5f, -0.5f, 0.5f);
    glVertex3f(0.5f, 0.5f, 0.5f);
    glVertex3f(0.5f, 0.5f, -0.5f);
    glVertex3f(0.5f, -0.5f, -0.5f);
    glEnd();

    //Left Face of the cube - vertex definition
    glBegin(GL_POLYGON);
    glColor3f(0.7, 0.7, 0.0);
    glVertex3f(-0.5f, -0.5f, -0.5f);
    glVertex3f(-0.5f, 0.5f, -0.5f);
    glVertex3f(-0.5f, 0.5f, 0.5f);
    glVertex3f(-0.5f, -0.5f, 0.5f);
    glEnd();

    //Upper Face of the cube - vertex definition
    glBegin(GL_POLYGON);
    glColor3f(0.7, 0.7, 0.3);
    glVertex3f(-0.5f, 0.5f, 0.5f);
    glVertex3f(-0.5f, 0.5f, -0.5f);
    glVertex3f(0.5f, 0.5f, -0.5f);
    glVertex3f(0.5f, 0.5f, 0.5f);
    glEnd();

    //Bottom Face of the cube - vertex definition
    glBegin(GL_POLYGON);
    glColor3f(0.2, 0.2, 0.8);
    glVertex3f(-0.5f, -0.5f, -0.5f);
    glVertex3f(-0.5f, -0.5f, 0.5f);
    glVertex3f(0.5f, -0.5f, 0.5f);
    glVertex3f(0.5f, -0.5f, -0.5f);
    glEnd();

    glFlush();
    glutSwapBuffers(); //send image to the screen
}

int main(int argc, char*argv[]){

    //initialize GLUT
    glutInit(&argc, argv);

    //request double buffering, RGB colors window and a z-buffer
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

    //create a window
    glutInitWindowSize(600, 600);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Space");

    //enable depth
    glEnable(GL_DEPTH_TEST);

    //callback functions
    glutDisplayFunc(display); //display - redraws the scene
    glutSpecialFunc(specialKeys); //special - allows interaction with specialkeys

    //pass control to GLUT for events
    glutMainLoop();

    return 0; //this line is never reached
}

Feel free to ask more about what I'm trying to achieve if I wasn't clear enough. Thanks for your help.


texts:
I am using OGRE 1.8.1 SDK for Visual C++ 2010 (32-bit) from ogre3d.org/download/sdk and Ogre_VC10_Express_AppWizard_1.8.0.exe downloaded from https://bitbucket.org/ogreaddons/ogreappwizards/downloads. After a successful build when i am runnin application i am getting following error:

OGRE EXCEPTION(7:InternalErrorException): Could not load dynamic library .\RenderSystem_GL_d.  System Error: %1 is not a valid Win32 application.

in DynLib::load at ........\OgreMain\src\OgreDynLib.cpp (line 93)

Seems to me that there is a mismatch of some 32bit/64bit dlls but reinstalling directx didn't solved the problem.
I am new to OGRE, kindly guide me on this and i am using windows 8(64bit) and Microsoft visual C++ 2010 Express.

Edit: I tried installing SDK and directly run SampleBrowser (Without using AppWizard) but same error occurred again(build was successful).


texts:
I am trying to convert a half3 as a simple half but I am facing an issue. As for an example half3(1, 0, 0) give me white but half3(0, 1, 0) gives me black.

How can I convert properly a half3 to a simple black and white half value

Thank you.


texts:
I have a prefab A and i use it in scene A (as gameobject A). Then i to save that scene A as scene B and also renamed the gameobject A to gameobject B. Then inside unity (in project window ) , i duplicated the prefab asset A to prefab B.
Fyi, i'm using .blend (blender file) as the prefabs.
in scene B, i want the gameobject B which refers to prefab A , to switch its prefab's source to prefab B.
This way , i have 2 different scenes which has independent gameobjects  which refer to unique prefab. So i can modify prefab A and will affect scene A but not scene B.
Ussually, i can drag the gameobject to project window and choose/create 'new original prefab' option, but this method can't be used, since i want both prefab as .blend file (so i can modify them directly using blender).
What i did so far, is to drag prefab B to scene B, which then i have to manually redo all the setting which has been done in scene A . I want to avoid this tedious process.
Does anyone have any idea ?


texts: How do OpenGL ES 2 engines typically handle automatic geometry sorting and batching?

texts:
I'm trying to write a basic OpenGL ES 2 engine that can automatically sort and batch a fairly flexible set of input draw descriptions.

When I say 'draw description' I mean the actual uniforms, state, the shader, etc required to issue a single draw command for some geometry described by a vertex/index buffer.

When I say 'sort' I mean order a list of draw descriptions so that unnecessary state changes are minimized (ie. sort by surface, then shader, then texture, etc)

When I say 'batch' I'm specifically referring to merging draw calls by merging multiple vertex/index buffers that share the same draw description.

What I've tried

It seems like if you can sort a list of draw descriptions, you can batch as well because you can group draw descriptions that compare identical. So I thought I'd create something like:

std::map<DrawDesc,std::vector<Geometry>,DrawDescComparator>

std::map sorts the DrawDescs and I can stash geometry for identical draw descriptions in std::vector for batching.

However, I'm having trouble creating a draw description object that encapsulates all the required information, and specifically allows it to be compared.

Some things are easy to describe and compare, like a shader which can be assigned a unique id. Other things get complicated; to check if blend state is the same between two draw descriptions I'd have to look at (blend_enabled, equation_rgb, src_rgb, dst_rgb, equation_alpha, src_alpha, dst_alpha, and blend_color) in the worst case:

bool CompareBlendState(DrawDesc a, DrawDesc b)
{
    if (!a.blend)
        return true;

    if (!b.blend)
        return false;

    if (a.equation_rgb != b.equation_rgb)
        // just use the underlying gl_enums for a consistent comparison
        return a.equation_rgb < b.equation_rgb;

    if (a.src_rgb != b.src_rgb)
        return a.src_rgb < b.src_rgb;

    //...

    if(a.etc != b.etc)
        return a.etc < b.etc;

    return false;
}

This is probably probably pretty inefficient. One possible way of making this nicer is storing blend state information in a std::bitset and just comparing the corresponding integer(s)

In general though, I feel like I may be barking up the wrong tree. There's way more state to compare (depth, cull modes, etc) and I don't want to create a difficult-to-maintain mess of code.

I'd like to know how other engines or libraries (unity, ue4, etc) typically handle this problem and if there's a common approach I've missed.


texts: Splitting up duties for a card game server

texts:
I'm working on a game where players connect to a game server and to a lobby to play a card game against others.

I have a pretty good idea how to code it and such, I'm just not sure regarding a few details.

The game will have multiple lobbies, so although all lobbies run from the same exe and server, the player is bound to a specific lobby.

When the player connects to a lobby, I need to:

-Tell all the players in the lobby about it

-Send that player their list of online friends

-Send that player the list of all players online (in that lobby)

-Send that player the list of all current games and who's playing in each game (This info is all displayed in a ListBox).

Once that player is connected, I need to ensure that while they were receiving that information, if anyone else joined, or any games ended / started etc, that they dont miss any of those messages.

In a single-threaded world, I'd find this pretty simple, but I fear this would mean horrible lag or something every time someone joins. (I could be wrong though).

I'm wondering in general what would be an ideal way to tackle this problem such that it minimizes slow downs for other players. What I mean is, the whole server should not halt for 3 seconds while a user joins.

I guess with a message system it is not too bad since the server can get work done while it waits for the reply. But how robust is such a message system? Login / Authentication be on its own thread, and then it sends a message to the lobby thread which would handle any lobby related transactions. Should each game be in its own thread or should I loop through each active game and process them iteratively?

In addition, each game has a private chat between the 4 players. Each lobby has a chat that only players in the lobby and not in a game can see.

I was also wondering if I should incrementally update the lobby for players in a game or send them a full update when they finish a game.

If anyone could lead me in the right direction for any or all of these questions I would really appreciate it.

I'm coding this in C++ with a network library called ENet, but I'm not looking for any code, but maybe psudocode.

Thanks


texts: Panning in Direct sound wthout using SetPan function

texts:
I was wondering if it is possible to pan a WAV file in direct sound without using the SetPan function. If so how?

That is change the volume on 2 different speakers, right and left, to simulate that the sound is moving around the player.


texts: Why doesn't x fully reach y in while(x < y)

texts:
I have the following code in a coroutine

float percent = 0;

while(percent < 1) {
    Debug.Log(percent);

    percent += Time.deltaTime;
    yield return null;
}

However, percent never reaches or passes 1 (stops around ~0.98). How can I make sure that the while loop doesn't end until percent reaches 1?


texts:
i've been following tutorials online to load textures using SDL and display them on a opengl quad. but ive been getting weird results that no one else on the internet seems to be getting...

so when i render the texture in opengl i get something like this.
http://www.kiddiescissors.com/after.png

when the original .bmp file is this:
http://www.kiddiescissors.com/before.bmp

ive tried other images too, so its not that this particular image is corrupt. it seems like my rgb channels are all jumbled or something. im pulling my hair out at this point.

heres the relevant code from my init() function

if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) {
    return 1;
}
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);

SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(50, (GLfloat)WINDOW_WIDTH/WINDOW_HEIGHT, 1, 50);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glEnable(GL_MULTISAMPLE);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

heres the code that is called when my main player object (the one with which this sprite is associated) is initialized

texture = 0;
SDL_Surface* surface = IMG_Load("i.bmp");
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, surface->w, surface->h, 0, GL_RGB, GL_UNSIGNED_BYTE, surface->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
SDL_FreeSurface(surface);

and then heres the relevant code from my display function

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glColor4f(1, 1, 1, 1);
    glPushMatrix();
        glBindTexture(GL_TEXTURE_2D, texture);
        glTranslatef(getCenter().x, getCenter().y, 0);
        glRotatef(getAngle()*(180/M_PI), 0, 0, 1);
        glTranslatef(-getCenter().x, -getCenter().y, 0);
        glBegin(GL_QUADS);
            glTexCoord2f(0, 0);
            glVertex3f(getTopLeft().x, getTopLeft().y, 0);
            glTexCoord2f(0, 1);
            glVertex3f(getTopLeft().x, getTopLeft().y + size.y, 0);
            glTexCoord2f(1, 1);
            glVertex3f(getTopLeft().x + size.x, getTopLeft().y + size.y, 0);
            glTexCoord2f(1, 0);
            glVertex3f(getTopLeft().x + size.x, getTopLeft().y, 0);
        glEnd();
    glPopMatrix();

let me know if i left out anything important... or if you need more info from me.

thanks a ton,

-Dylan


texts:
In all of my tests I always regulate the fps by using this method.

const int fps = 30;
const int msPerFrame = 1000/fps; // 33 ms per frame, so it's more like 30.3030 fps
while(true)
{
  const int start = SDL_GetTicks();

  // do stuff

  const int end = SDL_GetTicks();
  const int delay = msPerFrame - ( end - start );
  if ( delay > 0 )
    SDL_Delay( delay );
  else
    std::cout <<
      "Warning, main loop took " << -delay <<
      " ms more than it was allowed." << std::endl;
}

At the beginning of the game while loop I set a start = SDL_GetTicks(); then I do various game logic followed by rendering and then finish it with end = SDL_GetTicks(). Finally, I do the regulation by this: delay = 1000/fps - (end - start); then call the SDL_Delay(delay); if it was greater than zero.

My question is, is this actually doing what I want or is there the possibility that there might be fluctuations? I got to wondering this because sometimes the smallest drawing functions make my cpu usage go up.


texts: How can I make a 32-bit render target with a 16-bit alpha channel in Direct3D?

texts:
I want to create a render target that is 32-bit, with 16 bits each for alpha and luminance. The closest surface formats I can find in the DirectX SDK are:

D3DFMT_A8L8    // 16-bit, 8 bits each for alpha and luminance.
D3DFMT_G16R16F // 32-bit float, 16 bits for red and 16 bits for green.

But I don't think either of these will work, since D3DFMT_A8L8 doesn't have the precision and D3DFMT_G16R16F doesn't have an alpha channel (I need a separate blend state for alpha).

How can I create a render target that allows a separate blend state for luminance and alpha, with 16-bit precision on each channel, that doesn't exceed 32-bits per pixel?


texts: How do I check if pressed on a text in pygame?

texts:
How do I check if pressed on a text?

This is how I draw the text:

# Full code on https://github.com/Zwengel/bunny-badgers
height = pygame.display.Info().current_h
font = pygame.font.Font("freesansbold.ttf", 24)
spText = "Single Player"
sp = font.render(spText, True, (0,0,0))
spRect = sp.get_rect()
spRect.centerx = screen.get_rect().centerx
spRect.centery = height/12*5
screen.blit(sp, spRect)


texts:
I am working on a level-based android game. The level is constructed of many blocks, all drawn with the same texture. Until now I didn't have any problems with drawing the different textures next to each other. However, when I draw a translucent rectangle over the level (in order to show a pause screen on top of it for example), I get artefacts on the places where the textures overlap. To be more clear I included a screenshot that clearly shows my issue: the regions where the textures of the different level blocks overlap do not have the same transparency as the rest of the rectangle.

As you can see, only when drawing the translucent rectangle on top of the level, the overlap is visible.


texts: Relevant file paths for reading in from a file?

texts:
Working on something in XNA, need to be able to read in data from a text file for something.

Trying to figure out how I can shorten this pathname down, so instead of it always checking there, it just checks in the directory where the actual program is.

I tried doing "\Data\Zone\"+filenamestring+".txt" as my path but it didnt work.

What I have that works:

Sub loadFromFile(ByVal fileNameString As String)
        If System.IO.File.Exists("C:\Users\user\documents\visual studio 2010\Projects\asdf\asdf\asdf\Data\Zone\" + fileNameString + ".txt") Then
            MsgBox("It found it.")
        Else
            MsgBox("Could not find it")
        End If
End Sub

While this works, unfortunately this will probably only work on my machine. How do I shorten the file path so its flexible and relevant to the directory where the program is actually located at?


texts: Do empty Update() methods get executed and slow down the game while playing?

texts:
From an optimization point of view, is it best practice to delete the predefined update() methods in all my C# scripts if there is no code inside them ?

On hundreds/thousands of GameObject(s) with Update() {} empty, does the game slow down ?
Can they be left empty or is it better to delete them ?


texts:
I'm currently working on an infinite world, mostly inspired by minecraft.
A Chunk consists of 16x16x16 blocks. A block(cube) is 1x1x1.

This runs very smoothly with a ViewRange of 12 Chunks (12x16) on my computer. Fine.
When I change the Chunk height to 256 this becomes - obviously - incredible laggy.

So what I basically want to do is stacking chunks. That means my world could be [∞,16,∞] Chunks large.

The question is now how to generate chunks on the fly?
At the moment I generate not existing chunks circular around my position (near to far). Since I don't stack chunks yet, this is not very complex.

As important side note here: I also want to have biomes, with different min/max height. So in Biome Flatlands the highest layer with blocks would be 8 (8x16) - in Biome Mountains the highest layer with blocks would be 14 (14x16). Just as example.

What I could do would be loading 1 Chunk above and below me for example.
But here the problem would be, that transitions between different bioms could be larger than one chunk on y.

My current chunk loading in action

For the completeness here my current chunk loading "algorithm"

private IEnumerator UpdateChunks(){
    for (int i = 1; i < VIEW_RANGE; i += ChunkWidth) {
        float vr = i;
        for (float x = transform.position.x - vr; x < transform.position.x + vr; x += ChunkWidth) {
            for (float z = transform.position.z - vr; z < transform.position.z + vr; z += ChunkWidth) {

                _pos.Set(x, 0, z); // no y, yet
                _pos.x = Mathf.Floor(_pos.x/ChunkWidth)*ChunkWidth;
                _pos.z = Mathf.Floor(_pos.z/ChunkWidth)*ChunkWidth;

                Chunk chunk = Chunk.FindChunk(_pos);

                // If Chunk is already created, continue
                if (chunk != null)
                    continue;

                // Create a new Chunk..
                chunk = (Chunk) Instantiate(ChunkFab, _pos, Quaternion.identity);
            }
        }
        // Skip to next frame
        yield return 0;
    }
}


texts: iOS 8 iPad Mini Orientation thinks It should be landscape despite it being disabled

texts:
I've only enabled portrait mode in the info.plist and generally the iPad Mini running my game works fine except if I quickly change its physical orientation from landscape to portrait, the app reorients itself incorrectly like what happened to this person: http://answers.unity3d.com/storage/temp/33155-screen+shot+2014-10-01+at+8.25.25+am.png (see screenshots, but the repro is different in my case).

I've tried hard setting the orientation (Screen.orientation = portrait, etc, etc) but looks like it's just ignored..


texts: Rendering efficiency for retro 2d grid chipset games. Draw by texture, or by row col?

texts:
This was the closest question on found here: Help with a Fast 2D Grid-Based world rendering technique
I'm doing a basic 2d grid where each box is filled with a texture pulled from a chipset.  I'm doing this in JavaScript.
There are two ways I can imagine going about it:

By Row / Col: iterate over every row and column, finding the texture for each block, then drawing it.  The pros are that the 2d array iterates better (should be fast access in RAM), as does writing pixels to the canvas (should also still be pretty fresh in RAM).

By Texture: organize the blocks by texture (heavy load once, up front), then draw each texture filling in every block it occupies.  The pro here is that I'm not constantly loading up a new texture to draw for each step.

I'm pretty sure #2 is better.  The loss for changing texture buffers over and over (all done on RAM) should be significantly worse than what is lost by iterating a relatively small array awkwardly (the world map blocks), or what's lost by jumping around the canvas.
Any insight on chosing between these two approaches is what I'm looking for.


texts: Detecting interesting kill in a 2D shooter

texts:
In Xonotic for some kills (and maybe even just hits?) the game plays a sound clip saying "Impressive!".
I was wondering how does the game recognize that a kill was impressive. In Xonotic it feels like giving larger damage faster (somehow) increases a probability of this announcement.

Does anyone know how are these things implemented? I can imagine it being easy(-ish) for hitscan weapons like a sniper rifle, where I can just take how fast was the target going across my screen and score the hit based on this. But what about rocket launchers where it might take time before shooting and hitting? I can't think of any reasonable rule for this.

In particular I'm trying to fit this idea onto a fast top down shooter with keyboard movement and mouse aiming and with weapons similar to Xonotic or UT99.

What exactly I'm interested in:

How do existing algorithms for detecting interesting hits / kills work?
Do these handle non-hitscan weapons?
How can they be extended to support them non-hitscan if they don't?


texts: How to implement expiring and self-refreshing buffs in an RPG?

texts:
I have a turn based RPG with buff system where buffs are always on, and the player has an option to cancel them at any time.

An exception to this system is buffs like "Effect lasts until the end of this turn" or "Absorbs first x points of damage". And I'm thinking of a good way to implement them.

Currently I have these types of effects in game:

enum {
    kBuffOnTurnStart,
    kBuffOnAttack,
    kBuffOnEffect,
    kBuffAlwaysOn
};

I think that I can implement the recharging or expiring buffs as two part buffs - one is the "always on" portion and another a worker portion that will do it's action on turn start. For example, a shield buff has 8 points of damage it can absorb. After it does so, it can no longer absorb damage. At the start of next round the "worker" buff/action would find the linked shield buff and recharge it.

Alternatively, an "always on" buff has some action or behavior associated with it, which is executed on turn start.

What is a simple and clean way to implement auto refreshing or expiring buffs?


texts: how do I add development build number each time I compile and play?

texts: I wanted each time I play my game, it will show in the console how many times you compiled or run the game. How do I do that?


texts: Missing features from WebGL and OpenGL ES

texts:
I've started using WebGL and am pleased with how easy it is to leverage my OpenGL (and by extension OpenGL ES) experience. However, my understanding is as follows:

OpenGL ES is a subset of OpenGL
WebGL is a subset of OpenGL ES

Is this correct for both cases? If so, are there resources for detailing which features are missing?

For example, one notable missing feature is glPushMatrix and glPopMatrix. I don't see those in WebGL, but in my searches I cannot find them referenced in OpenGL ES material either.


texts:
Minecraft is a game that is largely based on a heightmap and uses that heigtmap information to flood the world with light.  From my understanding the highest point in the heightmap is the end of the sunlight influenced area.  Everything above that is lit by sunlight, everything below that just is influenced by light nearby in a radius of 8 blocks.

Thus if you have a floating island on the top of your world everything below that will be seen essentially as a cave.  When two lights influence the same point the brighter light wins (unsure about that).

Either way there are a couple of problems with minecrafts lighting model: first of all, if your world does not have a heightmap it becomes trickier to figure out what exactly is supposed to emit sunlight and what not.  A simple way would be to assume that the world is (in my case) a floating rock and then traverse each axis from both directions and figure out where the rock starts and ends.  But this does not fully eliminate the problem as dents in the rock are not supposed to be in darkness.

Minecraft itself will cache the light information in its chunks together with the information about the material of a block.  Thus only if the world is modified the lighting has to update.  Unfortunately that process is still pretty slow on updates and on quick light changes one can see the lighting lag behind.  That's especially true if a lot of blocks change (TNT, sunset etc.) and you're not running the fastest computer (Or Java on Mac).

From my still limited understanding of 3D graphics lighting a world like minecraft shouldn't be the biggest issue.  How would you tackle the problem?

I think the basic requirements for lighting in a voxel world would be

update fast enough that it could happen in a single frame.  One might be able to do the lighting in the graphics device and download the changed light information to the main RAM.
light information must be quickly available for the main game logic so not entirely based on the graphics device: reasoning: light affects the growth of grass, spawning of monsters etc.
light updates would have to be local to a chunk or have some other limit so that one does not have to relight the whole world which might be very large in size.

The main idea would be to make the light updates fast, not necessarily more beautiful. For general light rendering performance improvements one could easily add SSAO on top of that which should result in much nicer worlds.


texts: How do I send multiple matrices to a vertex shader?

texts:
I'm practising animations using bones/skinning. I am trying to send the shader one matrix per vertex. I can think of these two approaches.
Method 1
I have one uniform handle for each bone matrix like this
u_Bone0 = GLES20.glGetUniformLocation(mProgram, "u_Bone[0]");
u_Bone1 = GLES20.glGetUniformLocation(mProgram, "u_Bone[1]");

and in the onDraw I send each of them to the shader:
GLES20.glUniformMatrix4fv(u_Bone0, 1, false, matrix0, 0);
This obviously isn't a good approach if I have a large number of matrices. My second idea which I haven't tried yet since there is a lot of code to refactor
Method 2
Is to use the glUniformMatrix4fv to send them all at once like (assume I have 20 matrices)
GLES20.glUniformMatrix4fv(u_Bones, 20, false, matrices, 0);

where matrices is float[16 * 20]. But then modifying the matrices for each bones becomes a bit tedious. For example, if I want to get the 3rd matrix, I need something along the lines of
float[] _3rd = Arrays.copy(matrices, 3*16, 4*16);

and saving back the values can become even more annoying.

I'm using Method 1 now, but it doesn't look very smart...
What is the best way to send multiple matrices to an OpenGL ES 2 shader?
LE: I'm using Android, so I'm looking for a Java solution.


texts: How to achieve smooth sprite movement with a scaled up canvas?

texts:
I'm developing a simple 2d platformer using haxe & openfl (currently targeting flash). To achieve the old school pixelation effect I draw 16x16 sprites over a 4x scaled up canvas. With this approach character movement is very jerky since it seems to consist of a sequence of 4px jumps.

So my question is: how to be smooth & old school at the same time? Thank you for your time.


texts: I am developing a 2d isometric game and I was wondering if I can use a 3d plane for a 2d game.


texts: Where i must put .xnb files in mono game project using VS2010?

texts:
Hello there my problem was describe below In the "The Content Pipeline" paragraph

http://blogs.msdn.com/b/bobfamiliar/archive/2012/08/07/windows-8-xna-and-monogame-part-3-code-migration-and-windows-8-feature-support.aspx#comments

Author describe how fix it using VS2012 put xnb files to \AppX\Content folder but i use VS2010 and mono game templates for it and there is no folders like this so where i must put this asstes to run game correctly


texts: OBB vs OBB and resolve/response for 2D game

texts:
Possible Duplicate:
  OBB vs OBB Collision Detection

How can I detect if a rotated OBB intersects with another rotated OBB and resolve it so both OBB objects don't go further into each other.
I want to use it for space ship collision.
I'm using C++ and OpenGL for my project.


texts:
So far I've put together a bare minimum of a DirectX 11 application. All it does is clear the window to a random shade of red.

const FLOAT clearColor[4] = { rand() / (float) RAND_MAX, 0.0F, 0.0F, 1.0F };

context->ClearRenderTargetView(renderTargetView.Get(), clearColor);
context->ClearDepthStencilView(depthStencilView.Get(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0F, 0.0F);

swapChain->Present(0, 0);

What I get however is a constant flickering (sort of like z-fighting, but apparently not).

If I enter fullscreen by pressing Alt + Enter, and then leave, this problem is solved, it no longer flickers in any way. What settings does alt + enter end up changing?

What could cause this? I don't want to continue and find out this becomes an issue later. I'll update the question with code on request.

Secondary question:
In fullscreen mode, there's a lot of flickering in horizontal bars, yet images only capture a single colour at once. Is this normal, some illusion, or also avoidable?

Update: When using "swapChain->Present(1, 0);" the original flickering still occurs (Seemingly less severely), but no longer in fullscreen mode.


texts: Coming up with manageable game ideas as a hobbyist game developer

texts:
I'm trying to come up with ideas for games to develop - as per the advice on this question I've started jotting down and brainstorming my ideas as I get them, and it has worked relatively well - I now have a growing collection of ideas that I think are relatively original.

The trouble is that I'm a solo hobbyist developer so my time is limited (and I have short attention span!)  I've decided to set myself a limit of 1 working week (i.e. 35-40 hours) to develop / prototype my game, but all of the ideas that really spark my imagination are far too complex to be achievable in that sort of time (e.g. RTS or RPG style gameplay), and none of my simpler ideas really strike me as being that good (and whenever I get a flash of inspiration I invariably end up making things more complicated!)

Am I being too picky - should I just take one of my simpler ideas and have a go?


texts: Setting Window Icon Using GLFW (LWJGL 3)

texts:
What's the best, cross platform, way of setting the window icon using LWJGL 3?

I have a PNG image and would like to set it to the icon present in my dock (OS X) or the application bar (Linux).


texts: How do I implement fog of war in a tile-based game?

texts:
I have created a 2D Tile Based game. The game has a single path that the sprite can move on. I want to create to make the entire screen black except for where the sprite is.

The sprite has commands such as left where he keeps looking left, right where he keeps looking right and move forward where he moves in the direction he is looking. I want to make it such that when he looks left then the tile on the left of the sprites, fog should be removed and so on for all the sides.

How can I do this?


texts: Vulkan best practice when submitting draw commands

texts:
As with most projects working in a graphics library, I need to dynamically send draw calls to the command buffers, but what is the best way to do this? Currently, for every frame, I rebuild my command buffers, specify the objects I wish to render, then destroy the command buffer. Am I doing it the right way? I thought there might be a clear command for the buffer but I still need to find it.

One other way I thought I could get it to work is when an object is needed to be displayed/removed, then and only then, I rebuild the command buffer. But again I'm not sure how to handle this properly.

Any help is really appreciated.


texts:
I've been trying to add this pathfinding function to my program, but when I run it, it just crashes. I've read other threads and this might be an infinite loop, but I don't see where it would be other than the recursion area (and it shouldn't break there because of the if-statement checking if it's out of bounds).

public void SetPath(Vector3 pos, Vector3 goal, Queue<Vector3> p, List<Vector3> visited, int cost) {

     Debug.Log("checking " + pos);

     //method which checks if the target tile is outside of the map
     if (core.OutOfBounds((int)goal.x, (int)goal.z))
         Debug.LogError("target tile " + goal + " is out of bounds!");

     //if the current position isn't out of bounds and hasn't been visited
     else if (!core.OutOfBounds((int)pos.x, (int)pos.z) && !visited.Contains(pos)) {

         Debug.Log("pos is within the limits of the map");

         //add tile to the visited list and path queue
         visited.Add(pos);
         p.Enqueue(pos);

         //add tile movement cost to total path cost
         cost += core.TileCost((int)pos.x, (int)pos.z);

         //if the current position is the target tile and the path is shorter than the current one
         if (pos == goal && cost < shortestPath) {
             Debug.Log("pos is the target tile");
             shortestPath = cost;
             path = p;
         }

         //else, check tiles around
         else {

             SetPath(new Vector3(pos.x + 1, 0, pos.z), goal, p, visited, cost);

             SetPath(new Vector3(pos.x, 0, pos.z + 1), goal, p, visited, cost);

             SetPath(new Vector3(pos.x - 1, 0, pos.z), goal, p, visited, cost);

             SetPath(new Vector3(pos.x, 0, pos.z - 1), goal, p, visited, cost);

         }
     }
 }


texts: Separating game logic and rendering logic in separate static libraries

texts:
I'm trying to write a game in C++ using OpenGL. I've tried to separate my game logic and my rendering logic as much as possible, and up until now, this has worked for me. I haven't written a lot of code, and right now, I'm getting to the point where I have all my separate parts, and I'm trying to put them together.

In order to keep game and rendering logic separated, I've written them both in separate static libraries (So I have a libCore and a libRendering. There's also a third static library that contains code that is shared between the two libraries (Things like utility methods for reading files, custom exceptions, ...), this library is called libShared. Both of my libraries (libCore and libRendering) are first linked against libShared and then the game executable is linked against libCore and libRendering.

I've been using an entity-component-system (Which is part of libCore) to keep track of all my entities, now I'd like to introduce a RenderingComponent which contains all the data necessary for actually rendering an object (Things like VAO's, VBO's, Textures, Normal Maps, ...).

The problem is, that doing this would bring part of the rendering code into the game logic code. And I'm wondering what the best course of action would be here.

Should I move the ECS into libShared?

Should I just create a single libEngine that I can link my game against, instead of 3 different libraries?

Do you have any other solutions?

Note: I do realize that separation of game and rendering logic has been discussed before, my question is specifically about the architecture of the various libraries I have layed out in this question, and other peoples' opionions on it.

To clarify what I mean, here's what my CMakeLists.txt looks like (They're actually separate files, but I'll keep them together for simplicity's sake).

...

add_library(Shared ${SHARED_HEADER_FILES} ${SHARED_SOURCE_FILES})

...

add_library(Rendering ${RENDERING_HEADER_FILES} ${RENDERING_SOURCE_FILES})
target_link_libraries(Rendering Shared ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${GLFW_LIBRARY})

...

add_library(Core ${CORE_HEADER_FILES} ${CORE_SOURCE_FILES})
target_link_libraries(Core Shared ${LUA_LIBRARIES})

...

add_executable(Game ${GAME_HEADER_FILES} ${GAME_SOURCE_FILES} src/main.cpp)
target_link_libraries(Game Core Rendering)

Second Note: If this is better suited for Code Review or Software Engineering StackExchange, I'll happily move my question over there.


texts: How does Unity use C# as a scripting language?

texts:
To my knowledge, thus far, I have thought that C# is and has always been a compiled language. I have recently started studying Unity3d and noticed that they give C# as an option for scripting and interacting with game objects through their API (along with JavaScript and a couple of other alternatives).

How is this done? Is C# actually being executed or is this an abstraction that is being converted to a different scripting language under the covers? It seems to me that there is some sort of interpretation going on for this functionality.


texts:
When programming Windows games, do you use multibyte character settings or Unicode character settings?  I'm under the impression that professional companies today use the Unicode setting to make future localization and translations as easy as possible.  Is using wchar's a good practice for modern games?

While I'm thinking about the subject, what is the difference between multibyte character sets and Unicode sets in Windows?  Is it UTF-8 vs. UTF-16?


texts: How create a respawn area in a tiled map

texts: I'm creating a RPG game, I need to create a monster respawn area like the Pokemon games where if I walk through the long grass areas a Pokemon can appear. I already created the battle scene, I've seen examples of tile collision with solid objects but I don't know how  create a collision action with passable objects.


texts:
I have a 3d plane in my scene and some 3d objects behind that plane.
So, i want to render only the part behind the 3d plane.

So how should I do this, should I have to use custom shaders, plz help.


texts: Using Physics.Raycast inside OnCollisionEnter2D function

texts:
void OnCollisionEnter2D(Collision2D collision)
    {
       foreach(ContactPoint2D contact in collision.contacts)
       {
           RaycastHit raycastInfo;
           Physics.Raycast(contact.point, Vector3.forward, out raycastInfo, 1000.0f);
           if(raycastInfo.collider)
           {
               Debug.Log("Hit!");
           }
       }
    }

I am using this code to raycast an abject with the contact position of collision. The collision part works fine, when collision happens this function is triggered. But when I raycast to that position, RaycastHit variable return empty.

I couldn't find what I am doing wrong.


texts: GameObject.FindWithTag throwing weird errors

texts:
I've got 2 first person controller scripts, one that handles functionality for basic movement, the other handling looking around. I also have a "CursorLockManager" script, that handles the cursor locking, as well as locking movement and looking (for when opening menus and such). At the beginning of the cursor lock script, in the start function, I have two GameObject.FindWithTag lines. One looks for the playerLook script, and the other looks for the playerMove script. I have them both set up the same way, but one of them isn't working.

First few lines of the CursorLockManager script:

public KeyCode menuKey;
public PlayerLook playerLook;
public PlayerMove playerMove;
public bool menuIsOpened;
public GameObject tempMenu;

private void Start()
{

    playerLook = GameObject.FindWithTag("Camera").GetComponent<PlayerLook>();
    playerMove = GameObject.FindWithTag("FP_Controller").GetComponent<PlayerMove>();

}

and the error Unity is throwing:

  UnityException: Tag: Camera is not defined

Line 17 of the CursorLockManager:

        playerLook = GameObject.FindWithTag("Camera").GetComponent<PlayerLook>();

Any help would be greatly appreciated. If you need any further clarification as to anything else, I'd be glad to provide it to you.


texts:
I am using LibGDX to make a game for Android and I am using 2 Viewports. One for UI and one for the actual game content. My problem is I can't find a good way to scale my UI using a Viewport.

This is a picture of my UI using a FitViewport:

As you can see it adds space on the top and bottom to fit the screen, but I want my pause button to stay on the top of the screen. I tried using a StretchViewport and that worked well for the pause button, but then the joysticks were no longer circle because they were distorted.

Is there a way to make a StretchViewport that only stretches the middle? (since nothing will be in the middle I don't care about that. Should I make a custom Viewport? And if so, how would I go about that? Thank you for any help!


texts: Continous repeatable object/image moving horizontally unity3d

texts:
I want to move objects on the screen horizontally. And the user has to pop the object by touching it. When user touch it, it gets destroyed and new object comes randomly.

For experimenting, I used Unity's Scroll Rect to move them. What can be the best solution for this.


texts:
I have multiple bodies in my game world in andengine. All the bodies affected by gravity but in that I want my specific body does not affected by the gravity.

For that solution after research I found that I have to use
body.setGravityScale(0)
method for my problem solution.

But in my andengine extension I don't found that method so please provide guidance about how get access about that method.

Also for the above problem any other guidance will be acceptable. Thank You!

I apply following code for reverse gravity
final Vector2 vec = new Vector2(0, -SensorManager.GRAVITY_EARTH
                * bulletBody.getMass());

bulletBody.applyForce(vec, bulletBody.getWorldCenter());


texts: Huge memory size with huge amount of voxels

texts:
I'm currently using a tridimensional grid for pathfinding, think of it as a huge cube with voxels (3d nodes) inside it, each voxel ita a class containing information about the voxel, if its an obstacle, its costs (for A*) and position. The problem is, there are too much nodes, which consumes a lot of memory, if I increase it too much it like a 120x90x120 volume it consumes 1gb of ram. I know that its obvious it will be this huge because there are 1.296.000 voxels, but how could I solve it with less memory?

I'm using C# and Unity for it.


texts: Pros and Cons of making one complex mesh vs more simpler ones

texts:
Looks like I have a problem with basic understanding of how OpenGL works. Lets say I have a mesh made out of three cylinders that is shown on the picture:
So are there any major difference in performance/memory if I make three different cylinder objects or one object made out of three cylinders? Well, if I make them separately with OpenGL, there would obviously be memory overhead because I repeat vertices for each of these cylinders in the middle (section area). That I can see. But, what about difference between having one big vertex shader vs having more smaller ones? Lets say we have 20 objects in the scene. Are their vertex shaders all sent separately to the GPU or are they all collected and sent together? If they are sent separately should that be slower than making one big vertex shader that will have to be sent to the GPU at once?
Second part is question about UV-s. Lets say all three cylinders have same texture, or one cylinder has half of the texture and second braching parts have second half of the texture. If I make an object containing all cylinders then obviously I would have to define UV array only for each of my vertices. Taking this into consideration are there any memory/performance issues if I use values for U and V greater than 1. For instance "lower" vertices of cylinder down would have V = 0, "upper" would have V = 1, and "upper" vertices of cylinder up would have V = 2. Does usage of UVs coordinates greater than 1 have any influence on performance or does the OpenGL only do basic rescaling? However, if I use same texture on each cylinder that are made separately then I would have to make UV array only once and just reuse it for each cylinder. Again I'm not sure what is the better option
Basically, lets say branching in this picture is repeated, like in a tree structure. What are the pros and cons of making a whole tree as one object and making it as a collection of a lot of small branches, besides simplicity of second option?