texts: Outlining external edges on a complex shape made of cubes?

texts:
A gallery of my problem can be found here. I had to do it this way as it won't let me post more than 2 links due to my reputation.

I'm trying to use 3D cubes to generate an isometric cube world.

I got that working great and I merge only the visible vertices/indices into a buffer and draw from that.

Only problem is, as with any isometric game, it becomes difficult to differentiate between heights. For example in the first image: this archways top merges with the cubes below.

I ended up finding this shader and got it working by using it against a rendered normal map (second image) of the cubes.

You may be able to guess my problem from that image. The final result looks like the third image. The back edges are not draw with an outline, which are the most important. Which based on the normal map also means that diagonals also have the same problem on their sides (fourth image).

Is there any solution I can do for this? Either in the shader itself or perhaps when calculating the normals? I almost need to add something to the normal to distinguish their depth/height so faces on similar planes don't merge on edge detection. Or maybe there's a totally different option I could use.

Ideally I was aiming more for only edges to the air to be outlined so the archways bottom edges would not be outlined like they are now =/


texts: Hit detection for partially covered object?

texts:
Say you have a character standing behind cover such that some of its body parts like a shoe or a palm is still outside the cover.

An explosion takes place close to the cover . In real life this would mean the player getting damage in his arm or whichever body part was outside the cover.

How would you simulate this kind of hit detection efficiently in a game ?

An approximation would be to line trace from center of the explosion to each bone in the character mesh. But it might still not be accurate enough for larger bones , would be performance intensive and would not work for objects which are not skeletal meshes.


texts: How to integrate the game editor with the engine?

texts:
What I am trying to figure out is what is the best way to integrate the editor(level, effects, model, etc...) in the most effective way?

Now the first thing I thought would be to create the game engine(*) extremely modular. For example I took the example of game states. You could have multiple game states that all have their own update() and draw() methods among others. Each game state class would inherit from a base GameState class. This allows for a more modular approach and a useful one at that.

Now would the most efficient approach be to implement the editor along with the modular engine, or create two different designs for both the game, and editor? I thought to take the game state example and extend it to window states, and well could be used for a lot more systems. Is there a better implementation of this design(game state) for use in other systems used in the engine?

*: Now I know the term game engine is sorta irrelevant, and misused in many situations. What I am referring to as the "game engine" is the combination of the systems that the game must interact with for short.

Also this is more of a theory / design question than an implementation. Even though both mix, I'd rather like to have a more general idea on how the editor is built in an efficient way and still using the same engine code as what the game uses.

P.S If you need more clarification or extra bits just leave a comment.


texts: Unity - Problems with scene object orientation and rotation after updating my project from 5.0.0 to 5.2.2

texts:
Last year I made a large project on Unity 5.0.0, today I re-opened it on 5.2.2 to do some work on it. I was given the message that the project needed to be updated, I allowed it to do the update. Now when I open up my scenes, many of my scene objects are misplaced, the rotation is completely wrong and positioned in the wrong place. My scenes are of a refinery and the most commonly broken object is the pipework, something that would take hours to correct manually.

My pipework is created this way...

All pipes are made in blender and each scene's pipes are saved as a single blender model (with each pipe make from a bezier curve and left as a separate object).
Once imported into Unity (as a single .blend file), I've then dragged and dropped coloured materials onto all the individual pipes, so they are all coloured correctly.

This has all been fine until updating the project to 5.2.2 - now some of the pipes are in the right place, but many are rotated in completely the wrong direction, leaving it looking a mess. If I delete the pipes from Unity and reimport the pipe model back in, this would solve the problem, but then all the materials/colours will be gone. Due to the sheer amount of pipes throughout the whole project, to re-colour them all again would be an extremely problematic task, especially as it's critical that the pipes are the right colour.

I am confused how some of the pipes within the same pipe model are fine and the others are wrong, it would be so much easier to sort if they had all changed rotation together, then I could just switch them all back in 1 go. I have a total of 13 scenes and so far all of them have suffered the same problem.

Nothing whatsoever has been changed on any of the scenes, assets or indeed anything in the project folder. In fact I haven't touched a single file within the project since October last year, so it is certainly to do with updating to 5.2.2. Is there anything I can do to fix the problem without having to re-import the models back in or manually rotate everything back?

I have attached some screenshots to show the issue - See how in the blender image, all the pipework is placed correctly and then in the Unity image, half the pipes have flipped and are facing the wrong way. I have removed the ground so this can be seen clearer. Any help would be much appreciated.

Many thanks


texts: How to disable MenuItem in play mode in Unity?

texts:
I created a function which snaps an object to pivot with a hotkey of Shift + S. When I play the game in which I run using Shift and move backwards using S I accidentally call the function. How can I have this MenuItem enabled only in Editor?

Here is the code in C#:

[MenuItem("GameObject/Snap/To pivot #s")] // snap to pivot
private static void SnapToPivot() {
    var selectedObjects = Selection.gameObjects;
    foreach (var obj in selectedObjects)
    {
        Undo.RecordObject(obj.transform, "Snap to pivot");
        obj.transform.position = SceneView.lastActiveSceneView.pivot;
    }
}


texts:
UPDATE: See photos below the description

I try desperately to implement shadows on my XNA games.
My game is a style of games like Voxel (minecraft).

The problem is that I do not find support / help or example explaining how to add shadows on cubes (vertices and indices) with (BasicEffect).
I just find examples to add shadows with a (HLSL Effect) or a "Model".

Is it possible to create shadows with the class "BasicEffect" on vertices cube ?
I already try with "Matrix.CreateShadow(...)" but no success .

I really hope so.

The logic of my function "DrawWorld":

#region DrawWorld
    // Draw all cubes in the world
    public void DrawWorld(GameTime gameTime)
    {
        effet.TextureEnabled = true;
        Plane lightPlane = new Plane(Vector3.UnitY, 0);
        Vector3 lightPos = new Vector3(-10f, 10f, 10f);

        //Try to initialize shadowMatrix
        Matrix shadowMatrix = Matrix.CreateShadow(Vector3.Normalize(lightPos), lightPlane);

        // Light settings
        effet.LightingEnabled = true;
        effet.DirectionalLight0.Enabled = true;
        effet.DirectionalLight1.Enabled = true;
        effet.DirectionalLight2.Enabled = true;
        effet.DirectionalLight0.DiffuseColor = col.ToVector3();

        effet.SpecularPower = 512f;

        // Fog settings
        effet.FogEnabled = true;
        effet.FogStart = arcadia.camera.NearPlane;
        effet.FogEnd = arcadia.camera.FarPlane;
        effet.FogColor = Microsoft.Xna.Framework.Color.White.ToVector3();

        // Set World with shadow matrice
        effet.World = Matrix.Identity * shadowMatrix  ;
        effet.View = arcadia.camera.View;
        effet.Projection = arcadia.camera.Projection;

        // Set the cube vertexBuffer and indice
        arcadia.Game.GraphicsDevice.SetVertexBuffer(graphicData[regionIndex][a].VertexBuffer);
        arcadia.Game.GraphicsDevice.Indices = graphicData[regionIndex][a].IndexBuffer;

        // Apply the basic effect
        effet.CurrentTechnique.Passes[0].Apply();

        // Draw the cubes vertices
        arcadia.Game.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, graphicData[regionIndex][a].VertexPosition.Length, 0, graphicData[regionIndex][a].Indices.Length / 3);

    }
    // #END OF DRAWWORLD
    #endregion

Without shadow is this :

When i try to add shadow with "Matrix.CreateShadow(...)" i got this bad result:


texts: How can I optimize block rendering in an OpenGL game?

texts:
I am working on a game with blocky graphics -- similar to Minecraft. My world generation algorithm is similar to the Diamond-Square algorithm. The terrain was initially too rough and uneven, so I created a smoothing algorithm and allowed for the generation of hills.

Before the smoothing algorithm does its job, there are about 900 (+/- 100) cubes. After the smoothing algorithm finishes its task, there are about 1200 cubes. The resulting terrain is satisfyingly smooth and even, but the FPS decreases.

At first I couldn't create a 10x10 world without crashing. I figured it was because I kept binding and unbinding the same VAO for every block, so I changed that because every block uses the same VAO. It continued to lag and eventually crashed, so I tried to see if it was a problem with the terrain generation.

I found out that there was an infinite loop in the generation process, so I fixed that. It worked, but not well enough. It generated a 10x10 world and doesn't crash, but it runs at only 5 FPS, sometimes less. I then enabled back-face culling. The FPS improved a little, but only by 1-2 FPS. I still haven't implemented frustum/occlusion culling.

Is there an amazingly helpful culling/optimization technique I should know about?


texts:
I want my player object rotate to face vector3 point on terrain.

public Vector3 RocketPointer;
public Transform pointer,Player;
public bool rocket_, button_move;

// Update is called once per frame
void Update()
{

    if (button_move == true)
    {
        Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit mousePoint;

        if (Physics.Raycast(mouseRay, out mousePoint, 100))
        {
            RocketPointer = mousePoint.point;
            pointer.transform.position = RocketPointer;
        }

        if (button_move == true && Input.GetMouseButtonDown(0))
        {
        // rotate player object to face rocketpointer point
            rocket_ = true;
            button_move = false;
        }

    }

    if (button_move == false && Input.GetMouseButtonUp(0))
    {
        rocket_ = false;
    }

}

public void move_button() // UI button
{
    button_move = !button_move;
}


texts: How can I sync billiard balls in network?

texts:
I'm developing a billiard game my problem is I don't know how can I sync balls in network
I use forge for networking but feel free to answer photon or unet because I know them.

What I tried
1.sending position and rotation of each ball in network
2.sending force direction and Intensity inside network

networkObject.SendRpc(RPC_SHOOT,Receivers.AllBuffered,force);

    public override void Shoot(RpcArgs args)
    {
       Vector3 Force = args.GetNext<Vector3>();
       GetComponent<Rigidbody>().AddForce(Force);
    }

I don't know why but when I send force direction and Intensity in network sometimes Physics is different!
I asked this question in forge forum and they tell me:

It's non-deterministic It's how most physics simulations work Because
of floating point inaccuracies and different CPU architectures and a
whole load of other factors That's how PhysX works Well PhysX is
technically deterministic for the same inputs But all inputs have to
be identical

source is available:
https://github.com/smkplus/BilliardNetwork


texts: What is wrong with the Linux/*nix family for games? What makes the development of games for this platform too slow compared to Windows or even OS X?


texts: algorithm for combining smaller tiles to balance the bigger ones

texts:
I have a field of tiles - basically each tile is a country that has some kind of sovereign. The tiles - countries - have different weight. For now I use some numerical value but in the future the weight will depend on tile size, produced resources and so on.

So I want for those countries to make alliances if their sole weight is much lower - or at least lower than a certain threshold - than the weight of the neighborhood tile (each sovereign is basically a primitive AI at that stage that is able to make decision to create the alliance). Here is couple of scenarios

Here are the examples for bigger maps with possible alliances

So my question is - is there some kind of algorithm that allows to achieve that or I have to create it myself or use training sets for AI to gain the ability to form alliances?


texts:
I wrote a simple SDL program using SDL 2.0. I have a little problem when I want to check the mouse wheel events. Actually, in the version 2.0 the flags SDL_BUTTON_WHEELDOWN and SDL_BUTTON_WHEELUP no longer exist. There is just the flags SDL_MOUSEWHEEL. The code below check correctly the' WHEELUP' and 'WHEELDOWN' events but with the same flag.

while(!terminer)
    {
        while (SDL_PollEvent(&evenements))
        {
            switch (evenements.type)
            {
            case SDL_QUIT:
                terminer = true;
                break;
            case SDL_KEYDOWN:
                switch (evenements.key.keysym.sym)
                {
                case SDLK_ESCAPE:
                    terminer = true;
                    break;
                }
                break;
                case SDL_MOUSEMOTION:
                    std::cout << "MOUSE : MOVE" << std::endl;
                    break;
                case SDL_MOUSEBUTTONUP:
                case SDL_MOUSEBUTTONDOWN:
                    std::cout << "MOUSE : BUTTON DOWN" << std::endl;
                    break;
                case SDL_MOUSEWHEEL:
                    std::cout << "MOUSE : WHEEL" << std::endl;
                    break;
            }
        }

But I would like to handle separately the 'WHEELUP' and 'WHEELDOWN' events. I tried several others flags in my condition but without success. Does anyone can help me, please ?

Thanks a lot in advance for your help.


texts: Is There an Easy Way to Convert Python/Pygame code into C#?

texts:
I am working on a game, sort of like this and I want to convert it to C#, as it is currently written in Python. The reason of this is because I can add features more easily and with less writing in C#, and I do NOT want to write it all again, with all of the glitches and testing having to be redone. Is there any program of internet service that can do so, for free? I don't have extra money to spend on this, which is just for fun. Thanks for all feedback, edits, and suggestions!

Edit: I use Wing IDE 4.1 for my Python coding and the Unity Version of MonoDevelop for C#.


texts: How to make a hand-drawn squared texture periodic with as little modification as possible?

texts: The obvious part is drawing as periodic as possible, but hand-drawing is impossibly so perfect, so what kind of modifications are possible that do not make the textures loose their hand-drawn character?


texts:
I have been looking for any examples for a long time, I cant get anything to work (from the examples).  I have tried using vertex/pixel shaders, effects files, but they never have any effect on the rendering.  I am using seemingly simple shaders (adding a value to the red color, or removing a color entirely). This has led me to believe that the code setting up/rendering the shader is not working correctly.  Almost every example is for non sprite based rendering, but I dont know if that matters (I cant find any info on that).

A lot of forum posts/answers point to sites that no longer exist.

I want to get a proof of concept simple shader that does anything in particular, to the entire rendered screen.

The technology I am using is C++ Directx 9 Sprite interface. Any help/links in the right direction is appreciated.

Thanks in advanced!


texts: OpenGL/GLSL/LWJGL return value from shader

texts: I'm trying to do some bone animation. I don't want the whole skeleton to be loaded to the GLSL shader every time, even tough it's not needed, because one vertex is parented to one bone, not more. My question is simple: (How) can i return some value from the vertex shader back to my code? I'm using LWJGL/Java


texts:
I started a tutorial for java's slick 2d library, called SlickBlocks which is essentally a tetris clone. The problem is I have followed and typed in the code examples to the dot, yet when I run it I get the exception: Exception in thread "main" java.lang.RuntimeException: Resource not found: testdata/alphamap.png. I just started the tutorial and am up to "Making a cool effect with Image scale".

Any ideas?

Edit:

The error has occured at:

at org.newdawn.slick.util.ResourceLoader.getResourceAsStream(ResourceLoader.java:69)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:169)
at org.newdawn.slick.Image.<init>(Image.java:196)
at org.newdawn.slick.Image.<init>(Image.java:170)
at org.newdawn.slick.Image.<init>(Image.java:158)
at org.newdawn.slick.Image.<init>(Image.java:136)
at org.newdawn.slick.tests.AlphaMapTest.init(AlphaMapTest.java:33)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
at org.newdawn.slick.tests.AlphaMapTest.main(AlphaMapTest.java:79)

Also not that I am not using "alphamap.png"  anywhere in the game, I think It is just referenced by the library itself.


texts: Saving .png from render texture results in much darker image

texts:
I wrote a script that saves a render texture to a .png.
However, the results are not very good, the .png is always much darker than the Render texture is in Unity. How can I fix this so that there is no attempt at color correction?

Script:
 [SerializeField]
     RenderTexture rt;

     [SerializeField]
     string fileName;

     [Button("Save png")]
     public void SavePNG()
     {
         var tex = new Texture2D(rt.width, rt.height);
         RenderTexture.active = rt;
         tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
         tex.Apply();

         var path = "Assets/Textures/Rendered textures/" + fileName + ".png";
         File.WriteAllBytes(path, tex.EncodeToPNG());
         Debug.Log("Saved file to: " + path);
     }


texts: Algorithm for a smooth weather transitions in game weather system

texts:
I've been slowly learning c++ and building up a codebase intending to create a simple first person role playing game.

I've coded a time management tool to track time elapsed in game, an inventory and container system, and some other bits. I have been considering a basic system to change the weather in game.

I haven't actually done code towards it yet but the simplest weather solution (not including rendering) would be a very very crude state system.

enum WEATHER_TYPES { FINE, CLOUDY, RAINY, STORM }
int min_duration = 2;   // 2 hours
int max_duration = 5;   // 5 hours

int current_duration;
if(current_duration >= min_duration && current_duration < max_duration) {
    float r = my_rand_range_float(0.f,1.f);
    if(r <= 0.25 )
        changeWeather();

That is obviously a really rough approximation and it would result in very harsh changes in the weather. It could instantly go from FINE to STORM which is very unrealistic.

I don't want a system where it models the weather based on realistic parameters. I am happy with a relatively simple randomly changing system to begin with. (Although it is worth noting that my timemanager class is tracking seasons as well as generating temperatures for the days)

I am thinking along the lines of having a WeatherManager class to keep track of the current weather state and decide when to transition between them. Each "Weather Type" would become it's own class that can be updated when it is in use. Each weather class would have a "starting" state where it would be possible to transition into the next weather state from the previous.

For example if changing from FINE to RAINY then during the "starting" state of the RAINY weather it would slowly build up the cloud layers, start the rain particle system with a small number of particles and build up to the desired number. The idea is to provide a bit of a build up.

It would also need to be able to do the reverse in the case of changing from RAINY to FINE.

I don't really know how others have implemented weather systems in game. Am I on the right track in my thinking in this regards and can anyone point me towards some resources to learn about implementing weather systems for a game?


texts:
For a solar system simulation project I'm looking for a good (semi-accurate) set of textures to texture the skybox.

I've already found these http://paulbourke.net/miscellaneous/starfield/ and we implemented a quick skysphere instead of a skybox. But after testing we found out that the 2048x1024 resolution image was too low-res for our application, and we can't use the higher resolution version because of GPU limitations (we're developing this for a specific platform).

So we came up with using 6 separate 2048x2048 textures on a skybox to have everything look pretty. However I can't seem to find any solar system star textures that are made for a skybox.

So basically what I'm asking:

Does someone know where to find skybox textures for our solar system?
Alternatively, does someone know a free program to convert a spherically-mapped texture to 6 box-mapped textures?


texts: How can I spawn monsters at random locations?

texts:
I made a little 2D shooter game for my iPhone. I want monsters to spawn at random locations.
But I don't have any clue where to start to make them spawn.

I already made the monster image and everything and everything works, but there's only one monster at the start of the game and when it dies he will not spawn again.


texts: Render (screenshot) weapon model in Counter-Strike: Global Offensive

texts: I need to take screenshot of weapon model from screen like this, without any background. Tried to remove and change resources using mat_texture_list console command, but no success.


texts: How to create a high score in Unity from a Time.deltatime float?

texts:
When I play my game, it sets my score to 0 and does not change, no matter how high my float gets.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class highscore : MonoBehaviour {

    public Text Highscore;

    void Start () {
        Highscore.text = PlayerPrefs.GetFloat ("Highscore", 0).ToString();
    }
}

This is where the next page starts

using UnityEngine;
using UnityEngine.UI;

public class Score : MonoBehaviour {

    public Text ScoreText;

    public float playerScore = 0;

    void Update () {
        playerScore += Time.deltaTime*10;

        {
            ScoreText.text = playerScore.ToString("0");
        }
    }

    private void OnCollisionEnter (Collision collisionInfo) {

        if (collisionInfo.collider.tag == "Obstacle")
        {
            PlayerPrefs.SetFloat ("Highscore", playerScore);
        }
    }
}


texts: Switching bezierpath to follow SpriteKit swift

texts:
I am trying to make it so that a SKShapeNode follows a UIBezierPath. Then when the screen is tapped it switches to another UIBezierPath to follow. I have this functionality working except that when the screen is tapped the shape node moves back to where it started. I want it so that when the screen is tapped the circle does not go back to where it starts. Here is my code.

override func didMoveToView(view: SKView) {
    //screenWidth and screenHeight
    screenWidth = view.bounds.width
    screenHeight = view.bounds.height

    // Set up the circle track
    let trackWidth = screenWidth/3

    let circleTrack = UIBezierPath(roundedRect: CGRectMake(screenWidth/2 - trackWidth/2, screenHeight/2  - trackWidth/2, trackWidth, trackWidth), cornerRadius: 100)
    let shapeTrack = SKShapeNode(path: circleTrack.CGPath, centered: true)
    shapeTrack.position = CGPointMake(screenWidth/2, screenHeight/2)
    shapeTrack.strokeColor = UIColor.whiteColor()
    self.addChild(shapeTrack)

    //Outside track
    outsideTrack = UIBezierPath(roundedRect: CGRectMake((screenWidth/2 - trackWidth/2) - trackWidth*0.08, (screenHeight/2  - trackWidth/2) - trackWidth*0.08, trackWidth + trackWidth*0.16, trackWidth + trackWidth*0.16), cornerRadius: 100)

    //Inside track
    insideTrack = UIBezierPath(roundedRect: CGRectMake((screenWidth/2 - trackWidth/2) + trackWidth*0.08, (screenHeight/2  - trackWidth/2) + trackWidth*0.08, trackWidth - trackWidth*0.16, trackWidth - trackWidth*0.16), cornerRadius: 100)

    //Set the default track
    track = outsideTrack

    // Create the ball
    circle = SKShapeNode(circleOfRadius: 15)
    //circle.position = CGPointMake(screenWidth/2, screenHeight/2)
    circle.fillColor = SKColor.whiteColor()
    self.addChild(circle)

    //Move the circle
    let followPath = SKAction.followPath(track.CGPath, asOffset: false, orientToPath: false, speed: 200.0)
    let repeatForever = SKAction.repeatActionForever(followPath)

    //Move the circle
    circle.runAction(repeatForever)
}

//Movement of circle
func movemementOfCircle(){
    if track == insideTrack{
        track = outsideTrack
    }else{
        track = insideTrack
    }

    //Actions
    circle.removeAllActions()
    //Move the circle
    let followPath = SKAction.followPath(track.CGPath, asOffset: false, orientToPath: false, speed: 200.0)
    let repeatForever = SKAction.repeatActionForever(followPath)

    //Move the circle
    circle.runAction(repeatForever)
}


texts: Are references to other games considered an infringement of copyright?

texts:
My team frequently reminisces about the games we grew up with in the 1990s, and we'd like to include references and Easter eggs that pay homage to this decade and that will invoke nostalgia or even make players smirk.

One example would be a character calling out another character: "Dude, why on Earth are you hiding in a stupid box?" (a reference to hiding in cardboard boxes from Metal Gear). Think of it as being similar to when the characters from Bad Company 2 teased the snowmobile level from Modern Warfare 2.

Would these sorts of references be considered copyright infringement? As far as I'm aware, this falls under parody and fair use, as it is neither used to capitalize on a specific game element (like basing our gameplay on people hiding inside cardboard boxes) nor does it directly reference a game character. To me, it seems more like paying homage to the companies making those games. Of course, when the time comes, we will consult with a lawyer and are willing to go as far as asking direct permission from the copyright owners.

But until then, I'd like to be informed on the topic.


texts:
I am using verlet integration to simulate some tentacles. So far it works great and I am satisfied with how it looks in general. Here is how a tentacle is built:

The very stiff sticks are colored red, in addition I added angular constraints of 180° in order to keep everything together.

But still, sometimes this happens:

When forces are too big at the peak, it flips around and gets stuck in a very ugly state.

Of course I could increase the number of iterations for satisfying the constraints, but then the tentacles get too stiff and the performance suffers.

What can I do about this? Some ideas:

add more points at the peak
more constraints overall
limit possible forces
maybe rethink my tentacle design completely?
detect flip over and undo it


texts: Making my pipes face the correct direction

texts:
I am trying to dynamically generate a pipping system. I am using a very specific way to connect the pipes after generating them. The forward has to be pointing at the next pipe and the right has to be pointing at the previous pipe.

Is it possible to do something like

transform.right = prevPipe.transform.position - transform.position;
transform.forward = nextPipe.transform.position - transform.position;

Take effect at the same time instead of being 2 individual amendments?


texts: Minecraft Bedrock behaviors: drop items for player/owner?

texts:
I'm making a simple behavior pack for Minecraft's Bedrock Edition for my own experimenting - the aim is to get tamed wolves to play fetch. The behavior pack is valid and loading, as it sort of works, but the part that isn't working is what I've been banging my head against for hours.

As per the tutorial on the official wiki, I've copied entities/wolf.json and entities/player.json from the vanilla behavior pack to my pack and added to them, borrowing cues from the villager's behavior file and referring to the reference for BE's entity components. I've also modified the priorities of the tamed wolf's behaviors so picking up items (i.e. sticks) and sharing them are a higher priority than following the owner or breeding.

wolf.json:

{
    "minecraft:entity": {
        "format_version": "1.2.0",
        "component_groups": {
            ...
            "minecraft:wolf_tame": {
                ...
                "minecraft:behavior.pickup_items": {
                    "priority": 7,
                    "max_dist": 16,
                    "speed_multiplier": 1.5,
                    "track_target": true
                },
                "minecraft:inventory": {
                    "inventory_size": 1,
                    "private": true
                },
                "minecraft:shareables": {
                    "items": [
                        {
                            "item": "minecraft:stick",
                            "want_amount": 1,
                            "surplus_amount": 1
                        }
                    ]
                },
                "minecraft:behavior.share_items": {
                    "priority": 6,
                    "max_dist": 16,
                    "speed_multiplier": 2,
                    "goal_radius": 2.0,
                    "entity_types": [
                        {
                            "filters": {
                                "test": "is_owner",
                                "subject": "other"
                            },
                            "must_see": true
                        }
                    ]
                }
                ...
            }
       }
   }
}

player.json:

{
    "minecraft:entity": {
        "format_version": "1.2.0",
        "components": {
            ...
            "minecraft:shareables": {
                "items": [
                    {
                        "item": "minecraft:stick",
                        "want_amount": 2304,
                        "surplus_amount": 2304
                    }
                ]
            }
        }
    }
}

Currently, a tamed wolf will run over to pick up a dropped stick within 16 blocks of it, but after that it simply resumes following me (its owner) and never drops/shares its sticks. I've messed with the want_amount and surplus_amount of the sticks for both the player and wolf, but with absolutely no results.


texts: Perspective Matrix doesn't work OpenGL 4

texts:
I tried to implement my own perspective matrix and it doesn't work. I don't understand why. With just with my view matrix (without Perspective Matrix) I can see my mesh.

Here my view matrix :

Vec3f position(0.0,0.0,-5.0);
Vec3f target(0.0,0.0,0.0);

Mat4f Camera::LookAt(Vec3f target, Vec3f position)
{
 //ce dont j'ai besoin pour calculer les parametre de ma camera...
 Vec3f up_world = Vec3f(0.0,1.0,0.0);
 Vec3f forward = (position - target).normalize();
 Vec3f right = up_world.cross(forward).normalize();
 Vec3f up = forward.cross(right).normalize();

 Mat3f R;
 R.setCol(2,forward);
 R.setCol(0,right);
 R.setCol(1,up);

 R.transpose();

 Mat4f R4(R);

 Vec3f mp = position * -1.0f;
 Mat4f P4;
 P4.setCol(3,mp);

 _LookAt = R4 *P4;
 return  _LookAt;
}

And my Perspective Matrix :

Mat4f Camera::perspective(float fovy, float aspect, float zNear, float zFar)
{

  float theta = fovy * 0.5f * (180.f / M_PI);
  float range = zFar - zNear;
  float invtan = 1.f/tanf(theta);

  Mat4f projMat(invtan / aspect,  0.0f,    0.0f,                       0.0f,
                           0.0f,  invtan,  0.0f,                       0.0f,
                           0.0f,  0.0f,    -(zFar + zNear) / range,  -2 * zNear * zFar / range,
                           0.0f,  0.0f,    -1.0f,                      0.0f);

    _perspectiveCam = projMat;
    std::cout << _perspectiveCam << std::endl;
    return _perspectiveCam;
}

  Mat4f perspective(float fovy = M_PI/2, float aspect = (1280.f/720.f)*1.f, float zNear = 0.1f, float zFar = 100.f);

My shader is very simple so it can't be the problem..

#version 410 core

layout(location = 0) in vec3 V_position;
layout(location = 1) in vec3 V_color;
layout(location = 2) in vec3 V_normal;

uniform mat4 view_matrix;
uniform mat4 proj_matrix;

out vec3 color;
void main()
{
    color = V_color;
    gl_Position = proj_matrix * view_matrix * vec4(V_position, 1.);
}

when I initialise _perspectiveCam with the unit matrix 4x4 it displays my triangle..
but when I implement _perspectiveCam like in the function it does not display my triangle

Here my Set col function :

template <typename TYPE>
void Mat4<TYPE>::setCol(int i, Vec4<TYPE>& vec4)
{
  for (size_t k = 0; k < 4; k++)
  {
    setElement(k,i, vec4.getElement(k));
  }

}

void setElement(int i,int j, TYPE var){element[i*4 + j] = var;}
TYPE getElement(int i, int j) const {return element[i*4 + j];}


texts: Fill closed object with water - maintaining volume

texts:
I'm showing the problem in 2D, but basically given a volume V (can be approximate), where should the center point of an upwards facing plane P be for any given rotation of the object? I'm not doing a strict fluid simulation, it doesn't need to pool in isolated areas or slop around, it's just (I think) a volume preservation exercise.

To reiterate, V is known, P is what i'm trying to solve.

Do I need to voxelize the object and essentially count boxes from the lowest bounds up?

Edit: Here's the code based on Bálint's response. Note that I haven't tested it yet (you'd call the top function and the second one is iterative).

https://pastebin.com/N4Mimnwg


texts:
I'm writing a platformer lode-runner-like game. I would like to ask experienced people to see what's wrong. Everything seems to be ok but I am absolutely confused about 3 bugs.

Why is the player jumping on top of the ladder?
I tried to put the physics of the player's sprite body to -gameSettings.gravity.v to prevent a slow slide down the stairs but after that when the player rises to the top he cannot get off the ladder.
When you collect all the boxes, a ladder appears on the uppermost platform. It is no different from other ladder, but sometimes I can climb on it and sometimes I can't.

I know that I ask too many questions, but I am sure they are all related to physics error I made somewhere in my code.

https://platformergametest.000webhostapp.com/ here I uploaded my game on free hosting


texts: What is the proper way of creating bullet in libgdx ashley ecs framework?

texts:
I'm still thinking, how do I properly pool a bullet in libgdx ashley? Because the PooledEngine is available, which the Entities, Components and Systems are already Pooled. I made this below example, which I just create a builder-pattern to spawn a bullet. Without using the ashley ECS framework, I used this memory-management reference to create a bullet pool as result this made me more confused.

class EntityFactory {

     ...

     public EntityFactory(World world, PooledEngine engine) {

          this.engine = engine;
          this.world = world;

     }

     public Entity createBullet(float x, float y) {
          ...
     }

}

class GunSystem extends IteratingSystem {

     EntityFactory factory;

     public GunSystem(EntityFactory factory) {
          super(Mappers.gunFamily);
          this.factory = factory;
     }

     @Override
     public void processEntity(Entity entity, float deltaTime) {
          GunComponent gun = Mappers.gun.get(entity);
          NodeComponent node = Mappers.node.get(entity);

          float bulletX = ...;
          float bulletY = ...;

          if(gun.reload) {
               Entity bullet = factory.createBullet(bulletX, bulletY);
               node.putChild("bullet", bullet);
          }

          if(gun.fire) {
               Entity bullet = node.getChild("bullet");
               ... move body to target destination
               BulletComponent b
               b.state.fired = true;
               node.removeChild("bullet");
          }

     }

}

Question what do you think is the proper way of creating bullet pool in ashley ecs framework?


texts: Send push notifications when realtime database change

texts:
How to send push notifications (status notifications) from one user to another? I mean a user of a unity MOBILE game to another mobile game? Both uses the SAME  game on their mobiles.
Thanks!


texts: Calculating minimum velocity of the projectile needed to hit target in parabolic arc

texts: If I have a point which I want to hit at the end or during a parabolic arc, how would I calculate the needed x and y velocity?


texts: Timing in fighting game using animations time?

texts:
I am developing a 2D fighting game in C++. I have made the basic components such as moving, guarding and even a combo system that works perfectly well.

My main concern now is that I want the game to be as balanced as possible, and thus I am entering a testing phase. I am even requesting the help of my father to play against as no AI has been implemented (yet).

In the game you can chain attacks using a punch/kick (PK) button. But you can also charge the attack by pressing the PK button longer, which basically pauses the animation, resuming it when the attack is fully charged or the player releases the button. One thing that I have noticed is that if your opponent is simply pressing the PK button when being hit, it can counter attack pretty easily if you end up charging your attack. This behaviour basically makes charging useless, because it can never go through if your opponent knows that.

So my point is that I need to add a delay so that the counter cannot occur (I do not want it to, because the game is based on an actual PS2 game where you cannot counter that way - for the record, there is a way to escape, either by pressing the guard button, or by hitting a button at the right timing to teleport behind and counter).

To add this delay, I can either modify the actual duration of the "damage" animation so that it does what I want or I can internally add a timer where the character enters a state where he cannot do anything.

I would want to go for the first one, since that way you SEE that you cannot counter using a punch since you are still in the damage animation. But the thing is that each character has its own set of animations and thus in theory, the developer or the designer (which is me in both cases) can modify the duration of one character while the others still have an old value.

My question is thus more on the design level. Is it a good idea to let the timing be decided via animation duration? Is it what is actually done ? If I have fifty characters when I discover another timing issue, it would mean to modify the animation of each and every one of them... But adding a timer internally seems more like a patch that actual fine tuning...


texts: Will Google Play Game Services allow turn-based gameplay?

texts: Will the Google Play Game Services multiplayer allow (turn-by-turn) gameplay like DrawSomething?


texts: Thread problem updating Windows Forms control in XNA C#

texts:
I'm development a network card game, and for now i've two players connected but there is a problem with one of them, this one can't do anything on the game. Looks that screen was blocked. I'm think that is because a code i used before.

That code is:

if (InvokeRequired)
            {
                this.Invoke(new MethodInvoker(delegate
                {

                   ...

            }));
                return;
            }

The code above is surrounding code to changing Button values, make connection with server and create game window. Without this code a warning is shown.

InvalidOperationException was unhandled

Cross-thread operation not valid: Control 'startGameButton' accessed from a thread other than the thread it was created on.


texts: Occlusion culling of BV tree nodes behind terrain

texts:
So I have a bounding volume tree, almost an octree but not quite.

Anyway I'm trying to optimize my drawing, right now I have a few different culling frustums that I use to cull different ranges of the BV tree, its very fast, I can pull all my world data in less than 1ms but when it comes to culling the grass and the other mesh data I'm thinking that because I have lots of mountains and hill that I'm rendering stuff that is inside the frustum but occluded but hills and mountains.

What would be the right way to cull this? Should I do a ray cast against my terrain from each corner of the bounding boxes to the player and cull anything that gets a hit? or should I find some fancy way to do it on the GPU?.

I only have to test maybe 1k boxes x 8 corners, so the ray casting shouldn't take to long.


texts:
I am developing a simple browser game, using ASP.NET, C# and SQL Server 2012.
I need to implement build time of some unit or building. One way would be storing finish date to database and just fetch remaining time on refresh, but there is one problem. If user doesn't refresh in a long time and building finished days before, the dependent records in database won't get updated (e.g. I have finished building Iron Mine 3 days ago, but the production per hour wont get updated until user refreshes).
How would you approach this problem ? Is there some sort of timed event in database, that will not ruin database server performance when there will be a lot of timers ?


texts: How to generate multiple particles at once?

texts:
I am tying to create a cartoony balloon-pop animation. I want there to be particles that come from all sides of a sphere. However they should all come at once, in a single burst.

What I've done is this. I generated a particle system as a child of the sphere. I set the shape to sphere, reduced the duration, and increased the rate. However it doesn't seem like any particles are being generated at the same time still, only one is created at once.

How can I make all of the particles come at the same time?


texts: How can I make the cursor the right size on a 4k monitor?

texts:
Since I have a 4k screen,

cursor.loadFromSystem(sf::Cursor::Hand));

gives me a cursor that is way too small.

Is there a simple way to make the cursor automatically be the right size? (I want my program to work for people with any screen size).


texts: Adding shadow and other effects on a spritefont Monogame

texts:
Is there a way that I can add shadow effect on text drawn in monogame? Because you cannot add shadow effect when creating a new spritefont file in Monogame Content Pipeline.

Thanks.


texts: Making mouse pos realtive to a moving object

texts:
I'm coding my first actual game, trying without following tutorials, just trying to use my knowledge so far to make something playable. I'm creating (attempting) a simple side-scrolling shooter. I have a reticle drawn on screen that follows the mouse position, relative to where the player is. I.e. my update method for the reticle

mouse = Mouse.GetState();

reticlePostion.X = mouse.X + (player.position.X + (player.texture.Width /2));
reticlePostion.Y = mouse.Y + (player.position.Y + (player.texture.Height /2));

The only problem is that the windows cursor, ends up being about 300-400 pixels away from where the actual reticle is. What I'm trying to accomplish is a reticle that moves with the player (when the player jumps the reticle moves up with him in relative position), but still have it follow the mouse. I hope this makes sense, just lemme know if I need to post more.


texts: Open source component-based game engines?

texts:
Possible Duplicate:
  Are there existing FOSS component-based frameworks?

What open source game engines with component-based design of game objects do you know? And which best of them? I mean best not in Graphics or Physics, but best in context of Behaviour, Messaging, etc.

This question is the result of inspiration by another question

Thank you!!!


texts: How to restrict movement of Leap Motion hand object

texts:
I have a "Hand" GameObject controlled by a Leap Motion Controller. The Hand despite having RigidBody and Box Collider just seemingly moves with no regards to physics (transform translate movement I suppose). So it clips through other Rigidbody objects.
I'm trying to pseudo-introduce physics to it. I created a second GameObject "HandClone" (with Rigidbody and Box Collider) that copies the first Hand position but moves with actual physics. HandClone script:
   private void FixedUpdate()
    {
        rb.MovePosition(targetTransform.position);
        rb.MoveRotation(targetTransform.rotation);
    }

Now HandClone goes where Hand goes, and HandClone is successfully bumping into other objects.
However, when HandClone gets stopped by something, Hand still keeps moving past HandClone and clips into the other objects, like before.
Now I am thinking that the way to solve this is to constrict Hand's movements to the bounds of HandClone so that finally Hand will stop clipping through objects. But how can this be achieved, would that even work, and is there a better way? Will movement streamed from Leap Motion Controller even respond to scripts like that?
__
Edit: I've now decided to hide Hand and place HandClone where Hand was.
But my script for HandClone to copy Hand's movements is making HandClone fly all over the place. Here's the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class clone1 : MonoBehaviour
{
    private Rigidbody rb;
    public GameObject target;
    void Start()
    {
        rb = this.GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {

    }
    private void FixedUpdate()
    {
        Vector3 newRotation = new Vector3(target.transform.eulerAngles.x + 8.5f, target.transform.eulerAngles.y - 172.78f, target.transform.eulerAngles.z - 94.02f);
        rb.MoveRotation(Quaternion.Euler(newRotation));
    }
}

The reason why I am adding those float numbers is because when the game isn't playing, those numbers are what make HandClone sit in the correct position, so I thought it would help with alignment in playmode. But HandClone is just flying everywhere regardless. Any advice with making the HandClone stay attached to the avatar's wrist would help.


texts: In my Libgdx application I would like to be able to connect to a mysql server securely and read and write data from it without other users injecting, or changing information. I've found this: http://www.helloandroid.com/tutorials/connecting-mysql-database but its only for reading what about writing data without people messing with it with other apps? I need a form of unique verification.


texts:
Anyone remember how the aim assist works in GoldenEye on n64? Where the gun model would point at an enemy if he's within a certain area in your field of view. I'm trying to do something like that but have hit a wall. I'm pretty inexperienced in Unity 3D and using this project as a way to learn the ropes.

I've currently got it so that if you're in range of an enemy (facing him or not), your gun model will rotate towards that enemy. But I need to do it so that only happens if that enemy is in front of your facing direction and near the centre of the screen.

Any tips or pointers how to do this? Do I need do a raycast in direction of camera and do some math to figure out which enemy is nearest? If so what Math functions would I need to look into?


texts: Switch Vector 3 x,y,z Components Based on Rotation

texts:
I have a cube that moves by rotating on its edge. I want my code to also work for cuboids. The following code is what I'm using to rotate my cube:

turnPoint = transform.position + new Vector3(0.5f * direction * x, -0.5f, 0.5f * direction * z); // Location of edge (resets every 90 degrees)
transform.RotateAround(turnPoint, axis, rotateSpeed * direction); // Turn around the edge

It works fine, however I want to get this to work when the cube is scaled to be a cuboid. I tried multiplying the new Vector3's x, y and z components by the objects respective x, y and z scale. This works, but only for the first rotation.

Is there a way this could work for all future rotations without using if/else for all 4 rotations?


texts: Slowdown in sliding background with Libgdx

texts:
I´m new with libgx and i have a basic question. I want an background like an image that repeats indefinetely, and moves down. I did with 2 images and it worked, but the problem is that is very slow. I stored the images with 512x512px. My code is very simple but i dont know what im doing wrong.

public void render() {
   Gdx.gl.glClearColor(0, 0, 0.2f, 1);
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   offset -= 600 * Gdx.graphics.getDeltaTime();
   offset = offset % 512;
   camera.update();
   batch.setProjectionMatrix(camera.combined);
   batch.begin();
   batch.draw(backgroundImage, 0, offset);
   batch.draw(backgroundImage, 0, offset + 512);
   batch.draw(bucketImage, 0, offset + 1024);
   batch.end();
}

Any suggestions will be appreciated Thanks a lot!


texts: How can I sample objects color based on position and apply to an object in a shader?

texts:
I think what I want to achieve is similar to how grass can get the terrain color so it looks more blended, though this is not what I will be doing.
My texture is a palette of colors:

I have created a basic example in Unity.  The cube represents an object that could be placed (and moved again later).  The plane with the colors uv mapped would act as the ground (this will become a more complex mesh).
How can I sample the color and apply it to the object placed?
Edit:
If the object is over more than one color, then ideally I would like to blend those colors instead of having a hard transition.


texts: Unwanted continuous rotation with Quaternion

texts:
I am probably missing something simple but ... this is how I'm calculating the world matrix of my object:

glm::translate(glm::mat4(1.f), mPosition) * glm::mat4_cast(mOrientation) * glm::scale(glm::mat4(1.f), mScale);

where mOrientation is a glm::quat type and it is set to identity via:

mOrientation(glm::vec3(0.0f, 0.0f, 0.0f))

What's strange is that my object keeps rotating over the Y-axis (world space) and to prove that it isn't my loop, I changed my world matrix calculation to:

glm::translate(glm::mat4(1.f), mPosition) * glm::rotate(glm::mat4(), 45.0f, glm::vec3(0.0f, 1.0f, 0.0f)) * glm::scale(glm::mat4(1.f), mScale);

And my object is static and is indeed rotated 45 degrees on the Y-axis. The key difference is that with Quaternion, it KEEPS rotating. What am I missing?


texts: How can I calculate spotlight lighting in Vertex/Fragment shader in Unity?

texts:
I've written a vertex/fragment shader for my game. It uses 3 textures and represents a floating water on the wall (so I have 1 texture for water, 1 for geometry and the last one is mask) so it looks like this:

But I also need a spot light attached to the camera to lit my geometry, and this is the single dynamic light source on the stage.

Well, I can use a surface shader to take dynamic lighting into attention, but I want to avoid using them because: it will be much larger and its execution will be much slower. Besides, I need only one dynamic light source, so I can (can I?) just calculate its lighting in the shader, and pass a position/direction to the shader using material.SetVector(). It is something like:

float4 frag(FragmentInput i) : COLOR0
{
    float4 col = i.col * tex2D(_Texture, i.uv);
    col.a = tex2D(_AlphaMask, i.uv).r / 2;

    if(col.a > 0.25f) // it's water, just return the scrolled texture color
    {
        float4 l1 = tex2D(_WaterTexture, float2(i.uv.x, i.uv.y - _Time.y / 16));
        float4 l2 = tex2D(_WaterTexture, float2(i.uv.x, i.uv.y - _Time.y / 8));
        return float4((l1 * l2).rgb, 0.5f);
    }
    else // it's geometry calculate spot light lighting
    {
        float lit = // ... calculations here ...
        return col * lit;
    }
}

Is it possible to do this? Will it work faster than the surface shader?


texts: Unity 3D recreation of Pitch/Roll from accelerometer

texts:
I have an accelerometer that is communicating serially to a PC.  As I read in the data, I filter it to clean it up and calculate the angle of the pitch and roll.  This all works great.  Then I want to apply these angles to an object in Unity3D.

I created an object an try to rotate it using

transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(new Vector3(pitchAngle, 0f, rollAngle)), Time.time);

I use this method because I read that if you try and apply Euler angles, there is potential to run into gimbal lock, so I attempted to use Quaternion to fix that.  It seems I might still be running into the problem.

If I try something like

transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(new Vector3(pitchAngle, 0f, 0f)), Time.time);

or

transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(new Vector3(0, 0f, rollAngle)), Time.time);

The rotation is perfect, there is no 180 degree flip.

I also tried one more thing that can be ruled out that did not work, I tried,

transform.localRotation =
Quaternion.AngleAxis(rollAngle, Vector3.forward) *
Quaternion.AngleAxis(0, Vector3.up) *
Quaternion.AngleAxis(pitchAngle, Vector3.right);

To describe the numbers on the next three images, the very top line is the calculated angle of pitch and roll (respectively).  The line below that is the m/sec^2 (g's) recorded from the accelerometer.  The very last line is obtained by transform.eulerAngles.ToString().

The picture above is before pitch crosses 90 degrees

The picture above is after pitch crosses 90 degrees, notice the 180 degree turn

This picture is removing roll from the equation.  The angle of the pitch works perfectly fine. transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(new Vector3(pitchAngle, 0f, 0f)), Time.time);  The 'roll' also works perfect if pitch is removed. They just don't work well together.
The one thing I noticed is when only rotating one axis, the other two both change from 0 to 180. But I can't simply subtract the 180 from one axis, as I lose my full range of motion.

Question:
How to I fix this (gimbal lock) problem? After trying Quaternion and failing to use it properly, I am very confused with finding a solution. The math doesn't seem to be clicking in my head to manipulate the angles properly.


texts: How to follow a car with correct rotation

texts: I am making a game where car will follow a user car. I am moving use car using keyboard keys it is working fine running on my game environment roads smoothly. To follow enemy car i am using nevMesh, it correctly following but the following car/enemey car rotation is not correct. I am surprise that how do i control it? or is there any other way to acheive this thing


texts: Are items such as the GameDifficulty enum, game settings, and other things in the GameDefaults class used for a lot? If so, is there a way to edit them or anything of the sorts?


texts:
I've been using OpenGL for a bit so I have a general idea of what I'm doing. Recently, I've been working on a framework to let me test stuff more easily. As part of the framework, I split up loading images into OpenGL into two parts, one where I load the data (ie from a file) and another part where I actually send the data to OpenGL. However, when I use the system I designed, only a black triangle is displayed. When I bypass the system I created and load the texture directly into OpenGL using SOIL's SOIL_load_OGL_texture function, everything works with no other changes. Here's the relevant sections of code:

Main.cpp

// Section commented out to test loading a texture using SOIL instead
/*
Texture::Texture2DSource texData;
texData.loadTextureFromFile("Background.png", Filesystem::FOLDER_TEXTURES);
auto texture = Texture::Interface::getSingleton().loadTexture(texData);
// Debugging function I added to access the texture ID directly
GLuint textureID = texture->getTextureID();
*/

// Load the texture using SOIL as opposed to my texture loading classes
GLuint textureID = SOIL_load_OGL_texture(
    "C:\\Users\\Username\\AppData\\Roaming\\Test\\Textures\\Background.png",
    SOIL_LOAD_RGBA, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);

glActiveTexture(GL_TEXTURE0);
// This line is used when the SOIL texture loading is used
glBindTexture(GL_TEXTURE_2D, textureID);
// I hardcoded in 0 as the uniform ID just for testing; normally I query the
// uniform ID and use that
glUniform1i(uniformID, 0);

Vertex Shader:

#version 440

layout(location = 0) in vec2 vertex;
layout(location = 1) in vec2 uvData;
out vec2 uv;

void main()
{
    gl_Position = vec4(vertex, 0.0f, 1.0f);
    uv = uvData;
}

Fragment Shader:

#version 440

in vec2 uv;
out vec4 color;
uniform sampler2D textureSampler;

void main()
{
    color = texture(textureSampler, uv);
}

C++ code for loading a texture into memory:

// Create variables to store the image dimensions and properties
int width = 0;
int height = 0;
int channels = 0;

// Load the image
auto data = SOIL_load_image(fileLocation.c_str(), &width, &height, &channels,
    SOIL_LOAD_RGBA);

// Resize the texture's vector to the same size as the array returned from SOIL
m_data.resize(width * height);
// Copy the data from SOIL's array to the vector
const uint32_t BYTES_PER_PIXEL = 4;
memcpy(&m_data[0], data, width * height * BYTES_PER_PIXEL);
// Set the dimensions
m_x = width;
m_y = height;

// Flip the image
// Code omitted as irrelevant

C++ code for loading the texture data into OpenGL:

// Set up the texture storage
GLuint textureID = -1;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
// Load the texture data
glTexImage2D(
    GL_TEXTURE_2D,      // Texture Target
    0,                  // Level of Detail level
    GL_RGBA,            // Internal Format
    data.m_x,           // Width
    data.m_y,           // Height
    0,                  // Border (must be 0)
    GL_RGBA,            // Pixel Data Format
    GL_UNSIGNED_BYTE,   // Data Type
    &data.m_data[0]     // Texture Data
    );

// Set texture filtering options
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);

// Create a Texture object and load the texture ID into it, then return it
Texture<GL_TEXTURE_2D> texture;
texture.m_textureID = textureID;
return texture;

Here's some more images:

This is what the window shows when using my texture loading process.

This is what Nvidia NSight shows for the Fragment shader.

This is what the window shows when bypassing my texture loading process.

This is what Nvidia NSight shows when bypassing my texture loading process.

NSight shows the texture as loaded properly for both texture loading processes, and everything else seems to be the same. Any ideas on what's causing the issue?


texts:
Supposing I have applied delaunay triangulation on a convex mesh, and I have all information (edges, vertices etc.) I would like to transform the triangles to quads

I was reading that inverse process, quad to triangle, one takes the vertices like:

quad 1 2 3 4
==>
triangle 1 2 3
triangle 3 4 1

each time we read a quad (4 vertices), we transform it to 2 triangles using these 4 vertices.

What would be the best approach to do triangles to quad?

I was thinking on pairing together adjacent triangular elements, and converting them into
quadrilateral elements by eliminating their shared edges

Do you know any sample code, would be best in c#


texts:
I'm working on learning how pass data from one script to the other in Unity and I'm getting a little confused.  I have two scripts, PlayerData and CreateCharacter.  PlayerData is used to pass persistent data from one scene to another, so it's not going to be attached to any GameObject or Transform.  CreateCharacter, however, is attached to a button which gets the information from user input.  Here are the two scripts:

PlayerData

public class PlayerData{
    private string playerName;

    public string PlayerName{
        get{return playerName;}
        set{playerName = value;}
    }
}

CreateCharacter

public class CreateCharacter:MonoBehaviour{
    public InputField playerName;
    public PlayerData playerData = new PlayerData();
    public void AddStats(){}
    public void SubtractStats(){}

    public void CreateCharacterOnClick(){
        playerData.PlayerName = playerName.text;
        Debug.Log(playerData.PlayerName);
    }
}

What's happening is, when I click the button I'm getting a null reference error on playerData.PlayerName but if I just log playerData I actually get the object to return.  What I'm trying to see is that the character name(playerName) is logged when the button is clicked.  Can anyone explain to me what I'm doing wrong and how to fix it?


texts: Hill-jumping game mechanic like Tiny Wings

texts:
I'm a huge Tiny Wings fan and I'd like to understand the game mechanic at a deeper level. What are some good resources for the basic Box2d (or similar) physics behind the hill-jumping game mechanic?

I've used some basic features of Box2d. I imagine the flying character is just a circle, tapping the screen increases the downward force on the character, and the hills are some sort of curve object from the physics engine.

Edit #1 Here's more info: I'd like to understand which objects from the Box2d physics library are used to create the bare-bones hill-jumping mechanic. This mechanic would look like a "curvy" horizontal line that just scrolls across the screen. The most basic shape for this line that comes to mind is a sine wave so that's probably a good starting point.

Then there's the character that moves around. Note the character's horizontal position is fixed while the vertical position moves up and down. I'm curious about which Box2d body shape, type etc is used for this character. What are some values for the coefficient of friction that work well? How about the density etc.

I've searched around the web for tutorials that ideally will answer the above questions and perhaps provide additional resources regarding efficiency, camera motion and so on.


texts: Advice on how to approach building background glow for 3d galaxy?

texts:
I've got a proceduraly generated 3d galaxy galaxy, very large. Milky Way scale. It is broken up into sectors, where I can relatively quickly get the star density and average star color of any given sector with a simple call:

Color GetColorAt(x,y,z); //where hue represents star color and intensity is density

I am already pulling in the sectors around the player's location, so that the player can fly through the stars. Works great, performance is fine. Now what I want to do is add in the collective glow from stars in the galaxy that are very far away. Just like when you look at the night sky (in a rural area) you can see the glow of the milky way.
So one approach is to build a skybox. For each pixel of the skybox, cast a ray through the volume of the galaxy, and check at some # of points along the ray for the star density/color there, and add it all up, then use that to set the pixel of the skybox.
However this is computationally extremely expensive. ~6x1024x1024x10 operations or thereabouts at a minimum.
Another idea was do to a much sparser sampling of the galaxy density around the player, and use that data to create a particle system. Where each particle will take up way more than just 1 pixel. The effect might even look pretty good.
Any other ideas? Is there a data structure that would let me do this quickly?


texts: Unity application freezes on ios at pause

texts:
When I play my game made with Unity on iOS device, and press the home button or let the screen close by time or by pressing the power button and then try to come back to the game, the game freezes immediately. This does not happen always, only when there's certain things happened in the game in the current session. I have found nothing in common in between these situations. If those events have not happened in the current session, I can go to home screen and play other games and come back to the game and continue where I left without issues.

I have tried debugging on xcode, with no output whatsoever in the console regarding this issue. XCode reports 200mb memory usage and Unity profiler reports roughly 300mb memory usage when going to the pause state, and nothing happens when coming back to the game. We have had memory issues previously which we have been optimizing a lot lately, but this particular crash is still persisting. Android works fine, whaterver the device memory capacity is.

I have been trying to google for this type of iOS crash, with no luck. I'm asking here if someone might have some advice or direction for me to go to.

EDIT: I updated the question to match my current situation. I previously had some code in this question and talks about memory issues, which I have found out to have nothing to do with the problem at hand.

What happens according to the debug console in XCode:

Home button is pressed
OnApplicationPause(true) gets called
One Update() gets called
GameAnalytics detects a status change (headingToBackground event) and ends session
User is at home screen, resuming game by tapping on the game icon
GameAnalytics gets a headingToForeground event and restarts the session
Nothing else happens after that

This makes me want to point my finger at GameAnalytics, but why it works sometimes, just not after these specific events?


texts:
Basically when the code says

public static Camera Instance
{
// Code and something with get statement
}

Is it declaring a method? I don't think it is a method because there is no parenthesis to indicate the area to put in parameters.
Here is the full class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace ScrollingTest
{
    public class Camera
    {
    private static Camera instance;
    public static Camera Instance
    {
        get
        {
            if (instance == null)
                instance = new Camera();
            return instance;

        }

    }
}
}


texts: Unity - Blender models/animations showing gaps

texts: As part of a college project, a member of my group has made some simple chests with an open animation. Importing these into Unity though, I instantly noticed there were gaps where the faces should be. After a bit of experimenting, I figured it was because the Normals were facing the wrong way. The outside seemed fixed, but faces were missing when the chest opens during its animation. I'm guessing the inside of the chest will need another layer of faces with the Normals facing the right way...? Though surely this would means having doubles...?


texts: OpenGL shader program per shape or model

texts:
I have a program which imports models from .obj files and then draws them with OpenGL. I have a model which contains many shapes (meshes?). Not every shape has texcoords defined inside .obj file (it looks like 1//1 instead of 1/1/1) and I try to use one shader program which depends on texcoords.

What would be the best solution for that problem? Should I use separate programs for shapes that have texcoords and another for shape without texcoords defined?

Maybe there is a way to check if some attributes were passed to shader program?

This is the gist with .obj, .mtl and shader files, maybe that will help you to understand my problem.


texts: How can I find the largest sphere that fits inside a frustum?

texts:
How do you find the largest sphere that you can draw in perspective?

Viewed from the top, it'd be this:

Added: on the frustum on the right, I've marked four points I think we know something about.  We can unproject all eight corners of the frusum, and the centres of the near and far ends.  So we know point 1, 3 and 4.  We also know that point 2 is the same distance from 3 as 4 is from 3.  So then we can compute the nearest point on the line 1 to 4 to point 2 in order to get the centre?  But the actual math and code escapes me.

I want to draw models (which are approximately spherical and which I have a miniball bounding sphere for) as large as possible.

Update: I've tried to implement the incircle-on-two-planes approach as suggested by
bobobobo and Nathan Reed :

function getFrustumsInsphere(viewport,invMvpMatrix) {
    var midX = viewport[0]+viewport[2]/2,
        midY = viewport[1]+viewport[3]/2,
        centre = unproject(midX,midY,null,null,viewport,invMvpMatrix),
        incircle = function(a,b) {
            var c = ray_ray_closest_point_3(a,b);
            a = a[1]; // far clip plane
            b = b[1]; // far clip plane
            c = c[1]; // camera
            var A = vec3_length(vec3_sub(b,c)),
                B = vec3_length(vec3_sub(a,c)),
                C = vec3_length(vec3_sub(a,b)),
                P = 1/(A+B+C),
                x = ((A*a[0])+(B*a[1])+(C*a[2]))*P,
                y = ((A*b[0])+(B*b[1])+(C*b[2]))*P,
                z = ((A*c[0])+(B*c[1])+(C*c[2]))*P;
            c = [x,y,z]; // now the centre of the incircle
            c.push(vec3_length(vec3_sub(centre[1],c))); // add its radius
            return c;
        },
        left = unproject(viewport[0],midY,null,null,viewport,invMvpMatrix),
        right = unproject(viewport[2],midY,null,null,viewport,invMvpMatrix),
        horiz = incircle(left,right),
        top = unproject(midX,viewport[1],null,null,viewport,invMvpMatrix),
        bottom = unproject(midX,viewport[3],null,null,viewport,invMvpMatrix),
        vert = incircle(top,bottom);
    return horiz[3]<vert[3]? horiz: vert;
}

I admit I'm winging it; I'm trying to adapt 2D code by extending it into 3 dimensions.  It doesn't compute the insphere correctly; the centre-point of the sphere seems to be on the line between the camera and the top-left each time, and its too big (or too close).  Is there any obvious mistakes in my code?  Does the approach, if fixed, work?


texts:
I'm trying to figure out how to do a simple search/chase AI.
I know that I'm going to have to search around the mob entity to figure out if the player is close enough, I could probably get that done on my own, but what comes after is what gets me stuck. Once I have the (x,y) of the player, how do I get my mob entity to move a single cell (up, down, left, or right) until they reach the player entity?
Here's a bit of the code for reference.

Just the first part of the Board class.
Basically the portion where the grid is created once initiated.
board = Board(10, 10)

class Board(object):
    '''Board class to create empty grid of cells'''
    def __init__(self, x_size, y_size, char='-'):
        self.x_size = x_size
        self.y_size = y_size
        self.char = char
        self.board = [[char for _ in range(x_size)] for _ in range(y_size)]

And the Entity class.
player = Entity('Player', 5, 5, 10, 'o', 'alive')

class Entity(object):
    '''Basic entity object
        Has position and character'''
    def __init__(self, name, x, y, hp, char, state):
        self.name = name
        self.x = x
        self.y = y
        self.hp = hp
        self.char = char
        self.state = state

    def move(self, direction, board):
        '''To update entity position'''
        dx = self.x
        dy = self.y
        valid_moves = board.valid_moves(self)
        if direction == 'left' and (self.x, self.y - 1) in valid_moves:
            self.y = dy - 1
        elif direction == 'right' and (self.x, self.y + 1) in valid_moves:
            self.y = dy + 1
        elif direction == 'up' and (self.x - 1, self.y) in valid_moves:
            self.x = dx - 1
        elif direction == 'down' and (self.x + 1, self.y) in valid_moves:
            self.x = dx + 1
        else:
            if self.name == 'Player':
                print 'You can\'t move there'
                time.sleep(0.3)


texts: How do you triangulate an arbitrary polygon?

texts:
I need to triangulate a polygon for rendering in OpenGL ES on Android (no GLU triangulation available).

Is there an already known algorithm for polygon triangulation?  The polygon can be convex or concave (with no holes).


texts: LWJGL3 Input for single press of keyboard

texts: I am making a game with lwjgl and GLFW and am having a hard time figuring out how to check for a single press on the keyboard.


texts: Pathfinding with MicroPather : costs calculations with sectors and portals

texts:
I'm considering using micropather to help me with pathfinding. I'm not using a discrete map : I'm working in 2d with sectors and portales. However, I'm just wondering what is the best way to compute costs with this library in this context.

Just to be more clear about geometrical shapes I'm using : sectors are basically convex polygons, and portals are segments that lies on sector's edge.

Micropather exposes a pure virtual Graph class that you must inherate and overrides 3 functions. I understand how pathfinding works, so there's no problem in overriding those functions. Right now, my implementation give me results, i.e I'm able to find a path in my map, but I'm not sure I'm using an optimal solution.

For the AdjacentCost method : I just take the distance between sector's centers as the cost. I think a better solution should be to use the portal between the two sectors, compute its center, and then the cost should be : distance( sector A center, portal center ) + distance ( sector B center, portal center ). I'm pretty sure the approximation I'm using with just sector's center is enough for most cases, but maybe with thin and long sectors that are perpendicular, this approximation could mislead the A* algorithm.

For the LeastCostEstimate method : I just take the midpoint of the two sectors.

So, as you understand, I'm always working with sectors' centers, and it's working fine.  And I'm pretty sure there's a better way to work.

Any suggestions or feedbacks? Thanks in advance!


texts: Jitter during wall collisions with Bullet Physics: contact/penetration tolerance?

texts:
I use the bullet physics engine through Panda3d.

My scene is still very simple, think 'Wolfenstein3d': tile-based, walls are solid cubes.

I expect walls to block the player, and I expect the player to slide along the walls in case of non-normal incidence.

What I get is what I expect, with one difference: there is some jitter.  If I try to force myself into the wall, then I see the frames blinking quickly between two positions.  These differ by about 0.04 units of distance, which corresponds to 4 cm in my game.

I noticed a 4 cm elsewhere: the bottom of my player capsule is 4 cm below ground, when at rest.

Does that mean that there is somewhere in the Bullet engine a default 0.04-units-long tolerance to differentiate contact from collision?  If so, what should I do ?  Should I change the scale of my game so that these 0.04 units correspond to 0.4 cm, making the jitter ten times smaller?  Or can I ask bullet to change its tolerance to a smaller value?

Edit

This is the jitter I get: 6.155 - 6.118 = 0.036

LPoint3f(0, 6.11694, 0.835)
LPoint3f(0, 6.15499, 0.835)
LPoint3f(0, 6.11802, 0.835)
LPoint3f(0, 6.15545, 0.835)
LPoint3f(0, 6.11817, 0.835)
LPoint3f(0, 6.15726, 0.835)
LPoint3f(0, 6.11876, 0.835)
LPoint3f(0, 6.15911, 0.835)
LPoint3f(0, 6.11937, 0.835)

I found a setMargin method.  I set it to 5 mm both on the BoxShape for the walls and on the Capsule shape for the player.  It still jitters by about 35 mm as illustrated by this log (11.117 - 11.082 = 0.035):

LPoint3f(0, 11.0821, 0.905)
LPoint3f(0, 11.1169, 0.905)
LPoint3f(0, 11.082, 0.905)
LPoint3f(0, 11.117, 0.905)
LPoint3f(0, 11.082, 0.905)
LPoint3f(0, 11.117, 0.905)
LPoint3f(0, 11.0821, 0.905)
LPoint3f(0, 11.1175, 0.905)
LPoint3f(0, 11.0822, 0.905)
LPoint3f(0, 11.1178, 0.905)
LPoint3f(0, 11.0823, 0.905)
LPoint3f(0, 11.1183, 0.905)

The margin on the capsule did change my penetration with the floor though, I'm a bit higher (0.905 instead of 0.835).  However, it did not change anything when colliding with the walls.

How can I make the collisions against the walls less jittery?

Edit, the day after:

After more investigation, it appears that dynamic objects behave well.  My problem comes from the btKinematicCharacterController that I use for moving my character; that stuff is totally bugged, according to the whole Internet :/.


texts:
I want the camera to follow the player and lag a little bit and then catch up with the player when the player halts. When stopped the player is in the center.

At the moment im at the point where i get the camera to move with the player but i dont know how to get the lag effect!

On the camera object

    void Update () {
    var newX =  player.transform.position.x;
    var newZ =  player.transform.position.z;
    var y = transform.position.y;
    transform.position = new Vector3(newX, y, newZ);
}


texts: How do I randomly position objects without overlap?

texts:
I'm studying a little about procedurally generating levels and decided to start with a vertical scrolling game.

I would like to position some platforms vertically in my scene. So far, I've used a basic method: Random positions, with some maximum y-distance between them. However, that means platforms at the same height can still overlap. I would like to be able to have more than one platform at each height:

I thought about using sets of platforms including unique platforms, combined platforms (2 or 3 per y, and so on), and randomly position those sets. However, this would not prevent the overlapping and I really would like to do it properly procedurally.

Even so, I cannot guarantee that each platform is accessible by the player character from the previous one.

How can I proceed?


texts: What's wrong with this Height Map in Unity?

texts:
In the first picture it seems the virtual surface of the normal map is calculated to behind the camera. I only have this bug on convex surfaces.

However in both these pictures it seems the surface of the normal map is floating above the original texture. It duplicates the surface instead of replacing it.

I really don't know what's going on here.

Rendering output

Shader Settings

Texture and Heightmap

The Height Map was created in Photoshop:

Heightmap Import Settings


texts:
Is there a game design technique I can use so that I completely remove 'No more moves left' situations. ie. the game should contain no impossible scenarios.

As far as I've guess It all depends on what jewel and where you give the user after a jewel group of 3 or 4 dissolves.

Is it possible ? An always infinitely solvable Bejewelled game?


texts: Convert vector interpolation to quaternion interpolation? (Catmull-Rom)

texts:
I have some existing code which does catmull-rom interpolation on two vectors (facing and up). I'm converting this to use quaternions instead (to replace the two vectors). Is there a general way to convert the vector based interpolation to a quaternion one?

The approach I'm using now is to exact the axis and angle from the quanternion. I then interpolate each of those independently and convert back to a quaternion. Is there a more direct method?


texts:
What is the ideal way to set up 9-slicing?

(for the people who don't know what 9-slicing is)

Let's say we have a quad, with a texture applied to it.
9-slicing is basically a way of dividing a texture in 9 parts.
The reason why we do this is to have a quad with a texture, that can be resized without the issue of having the texture all warped. we divide the edges, the corners, and the main body of the texture:

As can be seen in the pictures, we have a quad that can be scaled without warping the texture

which would look something like this(no 9-slicing):

Now, to come back to my question: How should i set up 9-slicing? should i have a multiple quads(one for the center part, one for the right edge, one for the left edge....) but then how do i specify the different texture coordinates for each quad? Another way would be to just create the quads with their texture coordinates and relative textures and then move them all toghether like a whole object. I hope someone explain me a little more about this "9 slicing" approach, since I've never used it before. Thanks everyone for the help

EDIT: (to answer HolyBlackCat)

"Another way would be to just create the quads with their texture coordinates and relative textures and then move them all toghether like a whole object."

What i wanted to say is this: I create separate quads, attach separate textures to them, render and move them at the same time:

This is, in my opinion, the most logical way to do this. Despite that, I still want to know what would be a better, faster way to do this, without having to have too many vertices for a quad


texts: Best Game Engine/Framework and Language for 2D actor/sprite intensive game

texts:
I'm new to the game dev world.

I have a rather large project in mind (I learn by setting myself challenges :P ) and I'm wondering what the best engine/framework/language is for a 2D game with thousands of sprites/actors on screen at a time. Bare metal type stuff. I need to still be able to zoom in and out with that many actors at once.

This game will have no 3D elements.

Any thoughts?

Suggestions?


texts: How do I make 2d collisions based on color?

texts: I'm a Unity noob; digital artist, first and foremost. I just want to know how I can make a simple collider for my 2d car, based on the 2 colors of this 2d map. I want it so the car doesn't touch the white, but can run smoothly on the black road. Thank you, in advance.


texts: using std::chrono::steady_clock for timing

texts:
I was wondering if it would be a good idea to use the steady_clock class (in the C++ std libraries) for game timing.
What are the pros/cons of using it as opposed to using a game library's timing mechanism?


texts: Joint based destructible physics (like Armadillo Run)

texts:
I've implemented a destructible terrain system like Worms before (where weapons create holes in the terrain), but for the game I'm designing I want something more like Armadillo Run: https://www.youtube.com/watch?v=4JoPlcyxxb4 where everything is made from individual parts connected by physics joints.

I've figured out how to make a chain of planks using Unity's joints that can fall, swing off each other, bend if unsupported, and break at the joints. But I can't think of how to make planks break instead of the joints. There's an example of what I want at 2:25 in the video, where the plank on the right breaks (not the joints, but the actual plank itself). Obviously I'd just have to destroy the plank object, but how do I decide when to do that?

I'm using the Unity engine (2D physics), but I'd be perfectly happy to implement something myself if someone can direct me to some research on the subject or anything else to help me get started.


texts: LibGDX: Smooth movement on a grid based game

texts:
I'm making a game with LibGDX where the player is on a grid (like a Chess board).
For now, I'm moving the player by teleporting him 16px in a direction.
I'd like to use the delta time to make smooth movements, I want the character to move to 16px in a direction smoothly and when he's arrived, he stops moving.

Here's the code of my Player's Class:

public Player(Sprite sprite){
    super(sprite);
    setX(16*5);
    setY(16*5);
}

@Override
public void draw(Batch batch){
    update(Gdx.graphics.getDeltaTime());
    super.draw(batch);
}

public void update(float deltaTime) {
}

public void move(int direction){

    switch(direction){
    case UP:
        setPosition(getX(), getY()+16);
        break;
    case DOWN:
        setPosition(getX(), getY()-16);
        break;
    case LEFT:
        setPosition(getX()-16, getY());
        break;
    case RIGHT:
        setPosition(getX()+16, getY());
        break;
    }
}

public boolean canMove(int direction){
    if(direction == UP){
        if(getY() == 160-getHeight())
            return false;
    }
    else if(direction == DOWN){
        if(getY() == 0)
            return false;
    }
    else if(direction == RIGHT){
        if(getX() == 160-getWidth())
            return false;
    }
    else if(direction == LEFT){
        if(getX() == 0)
            return false;
    }
    return true;
}


texts:
I've got group movement implemented pretty much like this:

http://www.red3d.com/cwr/steer/CrowdPath.html

Basically, that's combining path following and separation. It works nicely as long as units are in transit, but arrival does not work very well at all.

Right now, units just cease to use the path following component once the "exit" the path, i.e. when their closest point on the path is on or past the end.

This leads to those units bumping into each other and also overshooting the point the player clicked. Ideally, I'd have the units arrive scattered around the finish point (and reasonable close to each other), not all clumped up past the finish line.

I'd imagine that some kind of arrival steering might work here, but based on other units and a "fuzzy" classification of the end of the path.

Is there any proven way to do this?


texts:
I made a game I wish to upload to Google Play and I faced the options

Production
Beta testing
Alpha testing

I made the game all alone and I think it is complete, was tested on multiple physical as well as virtual devices, all well and good.

As I'm alone and would consider the game finished, does it make sense to upload beta instead of production? I'm not in connection with anybody, so I don't think anyone would try and play the game (apart from meself). Or would some testers employed by Google test the apps if they are submitted to open beta?


texts: How to make prefabs UI work on any canvas scaller?

texts:
I want to make my UI prefab working on all size of canvas reference resolution scaler because I already make one which is not prefab UI its work to all reference resolution but when I make it prefab and instantiate it it's fit only specific resolution.
like this, I have reference resolution 2560x1440 which normally all UI will be set on that resolution and working fine on 720p or 1080p screen but make it prefab, it's working only on the 2960x1440 screen.

here the script for instantiating that object
public static MM_PilihAyat instance;
    private void Awake()
    {
        instance = this;
    }

    public List<_PlayerInventory> playerInventories;

    public GameObject pilihAyatPrefab;
    public Transform contentHolderPilihAyat;

    public GameObject bacaPanel;
    public Transform bacaContent;

    private void Start()
    {
        for (int i = 0; i < playerInventories.Count; i++)
        {
            GameObject go = Instantiate(pilihAyatPrefab, transform.position, transform.rotation);
            go.transform.SetParent(contentHolderPilihAyat.transform);
            MM_PilihAyatItem.instance.inventory = playerInventories[i];
        }
    }

    public void BackToBaca()
    {
        MM_PilihAyatItem.instance.BackToBaca();
        MM_BacaPanel.instance.inventory = null;
    }
```


texts: Change back to initial value of rotation?

texts: I have a sprite that I can rotate and I wonder if there is a way to change the rotation back to the initial value?


texts: What does glTranslatef function is translating in this code?

texts:
I understand translation from mathematics view where we can have a triangle with a certain coordinates. We can translate this triangle by multiplying the coordinates of the triangle (expressed in the form of a matrix) by a translation vector.

In the code below, I could not see what glTranslate () is translating since we havent drawn anything yet. What are we translating? Are we applying the translation to some default objects or something?

         void display(void)
     {
     glClear (GL_COLOR_BUFFER_BIT);
     ///////////////////////////////////////////////////////
     glPushMatrix();
     glTranslatef (-1.0, 0.0, 0.0);
     glRotatef ((GLfloat) shoulder, 0.0, 0.0, 1.0);
     glTranslatef (1.0, 0.0, 0.0);
     glPushMatrix();
     glScalef (2.0, 0.5, 1.0);
     glutWireCube (1.0);
     glPopMatrix();
     ////////////////////////////////////////////////////////
     glTranslatef (1.0, 0.0, 0.0);
     glRotatef ((GLfloat) elbow, 0.0, 0.0, 1.0);
     glTranslatef (1.0, 0.0, 0.0);
     glPushMatrix();
     glScalef (2.0, 0.5, 1.0);
     glutWireCube (1.0);
     glPopMatrix();
     /////////////////////////////////////////////////////////
     glPushMatrix();
     glTranslatef(1.6, 0.22, 0.0);
     glRotatef ((GLfloat) finger, 0.0, 0.0, 1.0);
     glScalef (0.6, 0.1, 0.08);
     glutWireCube (1.0);
     glPopMatrix();
     glPopMatrix();
     ////////////////////////////////////////////////////////
     glutSwapBuffers();
     }


texts:
I downloaded the official tutorial from:CustomModelAnimationSample
It works fine but when I try to replicate it in my project, it fails to load the Tag property in my model.

Is found that the probelm is in the line:

skinnedModel = Content.Load<Model>("DudeWalk");

This line loads the model from the DudeWalk.fbx file and with the custom SkinnedModelProcessor. It loads the animations data in the model. After the line the Tag property is full. I stepped into the method and it went to the custom ModelData class.

I copied everything from the projects CustomModelAnimationWindows and CustomModelAnimationPipeline to my solution and set all the references. I tried the same line of code and couldn't step in the method. It called the default method or model constructor and after the line the model's Tag propetry was null.

I have to load the model through my custom SkinnedModelProcessor class, but how I tell the game to use this class? In the tutroail CustomModelClass the line is changed to:

model = Content.Load<CustomModel>("tank");

So I assumed that I have to set the generic type to a custom model class, but the first example works without it.

If anyone has some useful advice or some other helpful link, I'll be happy to try it.

EDIT :

I tried this tutorial Creating a Custom Importer and Processor but it didn't work either.

I understand now that the binding of the custom pipeline processor is done at build-time and not a run-time. But my custom processor never gets bound nor called.


texts: When to return a reference and when to return a copy?

texts:
I was looking at the d3dx math .h and noticed that a difference between the "+" and "+=" operators:

D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& );
D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const;

Why is it returning a reference in the case of a += operation and a copy in the case of + operation ?

I'm guessing in the first case it's modifying the vector on which you call the += operation, something like this:

this->_x += x;
...
return *this;

and in the case of a + operation it would be doing something like this:

return D3DXVECTOR3(this->_x + x, this->_y + y, this->_z + z);

That being said, if that's what happens in the D3DXVECTOR3 implementation, why not return a reference in the case of + operation ?


texts:
I've stared at this for at least half an hour now and I cannot figure out what directx is complaining about.  I know this error normally means you put float3 instead of a float4 or something like that, but I've checked over and over and as far as I can tell, everything matches.

This is the full error message:

D3D11: ERROR: ID3D11DeviceContext::DrawIndexed: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (COLOR,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND ]

This is the vertex shader's input signature as seen in PIX:

// Input signature:
//
// Name                 Index   Mask Register SysValue Format   Used
// -------------------- ----- ------ -------- -------- ------ ------
// POSITION                 0   xyz         0     NONE  float   xyz
// NORMAL                   0   xyz         1     NONE  float
// COLOR                    0   xyzw        2     NONE  float

The HLSL structure looks like this:

struct VertexShaderInput
{
    float3 Position : POSITION0;
    float3 Normal : NORMAL0;
    float4 Color: COLOR0;
};

The input layout, from PIX, is:

The C# structure holding the data looks like this:

[StructLayout(LayoutKind.Sequential)]
public struct PositionColored
{
    public static int SizeInBytes = Marshal.SizeOf(typeof(PositionColored));

    public static InputElement[] InputElements = new[]
    {
        new InputElement("POSITION", 0, Format.R32G32B32_Float, 0),
        new InputElement("NORMAL", 0, Format.R32G32B32_Float, 0),
        new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 0)
    };

    Vector3 position;
    Vector3 normal;
    Vector4 color;

    #region Properties
    ...
    #endregion

    public PositionColored(Vector3 position, Vector3 normal, Vector4 color)
    {
        this.position = position;
        this.normal = normal;
        this.color = color;
    }
    public override string ToString()
    {
        StringBuilder sb = new StringBuilder(base.ToString());
        sb.Append(" Position=");
        sb.Append(position);
        sb.Append(" Color=");
        sb.Append(Color);
        return sb.ToString();
    }
}

SizeInBytes comes out to 40, which is correct (4*3 + 4*3 + 4*4 = 40).  Can anyone find where the mistake is?


texts: Set up Android SDK path to make Android remote work on Ubuntu

texts: I used Unity 2019.4 on Ubuntu 20.04. I installed Android SDK and all other components through Unity Hub. But unfortunately, I can't use Unity remote. It's written : Set up Android SDK path to make Android remote work. I need help. Thanks


texts: Why not tiling on Shader (Sprite/Diffuse)? Unity 5.4.1 f1

texts: Why not have the "Texture Tiling" option in my editor for Sprite / Diffuse?


texts:
I'm working on my first OpenGL 2D game and I've just locked the framerate of my game. However, the way objects move is far from satisfying: they tend to lag, which is shown in this video. I've thought how more fluent animation can be achieved and started getting segmentation faults due to accessing the same object by two different threads.
I've tried the following threads' setting:

Drawing, creating new objects
Moving player, moving objects, deleting objects

Currently my application uses this setting:

Drawing, creating new objects, moving objects, deleting object
Moving player

Any ideas would be appreciated.
EDIT: I've tried increasing the FPS limit but lags are noticeable even at 200 fps.