Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all 6821 articles
Browse latest View live

can’t create c# project in debian

$
0
0

@Jack-Ji wrote:

I’ve been trying to hack monogame on my debian recently. I first installed monodevelop 7.4 using apt, and then installed monogame 3.6. I opened monodevelop without any warning message, however, it reports “create project failed. no access to the given key” when I try to create solutions. Does anyone know what’s going on?

Posts: 1

Participants: 1

Read full topic


2MGFX.EXE for Monogame 3.6 ?

$
0
0

@DexterZ wrote:

Hello,

Kindly point me out where can I find/download the latest 2MGFX.EXE for MG 3.6 , I tried to use some of my effect and got an exception System.Exception: 'This MGFX effect is for an older release of MonoGame and needs to be rebuilt.' most likely my 2MGFX is previous version.

Thanks ^_^y

EDIT : I need it because this is how I compiled my effects using a batch file.

2MGFX.EXE Effects\NormalMapsDX.fx OUTPUT\NormalMaps.FxDX /Profile:DirectX_11 
2MGFX.EXE Effects\NormalMapsGL.fx OUTPUT\NormalMaps.FxGL /Profile:OpenGL 

TIMEOUT /t 250 /NOBREAK

Posts: 1

Participants: 1

Read full topic

Issues showing animated model on screen

$
0
0

@Aurioch wrote:

Hello.

Lately I've been experimenting with 3D and trying to load animated models into the game. After some research I've found out how it's supposed to be done, so I've attempted to do it myself following SkinnedModel tutorial , buuut... I've come across few obstacles I don't know how to deal with.

There are actually 2 problems with might be caused by the same issue:
1) On one model, I'm getting Value does not fall within the expected range exception when calling SkinnedEffect.SetBoneTransforms(Matrix[]) method. Matrix array containing animation transformations is properly populated, so I really have no idea what the problem is.
2) On few other models, I'm not getting anything rendered on screen at all. However, if I comment the line containing SetBoneTransforms() call, I do get something on screen... but (most probably) way oversized.

Example (I think lack of texture is unrelated though):

The sample code using Aether.Extras (same thing happens with BetterSkinnedModel as well):

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using tainicom.Aether.Animation;

namespace _3DFightTest
{
    /// <summary>
    /// This is the main type for your game.
    /// </summary>
    public class Game1 : Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        Matrix _world;
        Matrix _view;
        Matrix _projection;

        Model _knight;
        Animations _animations;
        
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            _world = Matrix.CreateTranslation(Vector3.Zero);
            _view = Matrix.CreateLookAt(new Vector3(0, 500, 500), Vector3.Zero, Vector3.Up);
            _projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), GraphicsDevice.Viewport.AspectRatio, 0.1f, 1000f);

            base.Initialize();
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            _knight = Content.Load<Model>("Animated Human");
            _animations = _knight.GetAnimations();
            _animations?.SetClip(_animations.Clips["Human Armature|Idle"]);
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// game-specific content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();

            // TODO: Add your update logic here
            _animations?.Update(gameTime.ElapsedGameTime, true, Matrix.Identity);

            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            foreach (var mesh in _knight.Meshes)
            {
                foreach (var part in mesh.MeshParts)
                {
                    var effect = part.Effect as SkinnedEffect;

                    effect.SetBoneTransforms(_animations.AnimationTransforms);
                    effect.World = _world;
                    effect.View = _view;
                    effect.Projection = _projection;

                    effect.EnableDefaultLighting();
                }

                mesh.Draw();
            }

            base.Draw(gameTime);
        }
    }
}

Now, I've tried multiple things to resolve issues, and only managed to resolve when model has more bones that the max limit allows for. Other issues have already started to frustrate me greatly.

What I've already tried:
1) Using both SkinnedModel and BetterSkinnedModel to extend Content Pipeline (with appropriate loading and drawing code from my side)
2) Using @nkast's Aether.Extras extension for Monogame (preferred due to how code is used and the fact that it's possible to define max amount of bones in Content Pipeline tool)
3) Testing with different models

What I did not yet try:
1) Using Bos FBX Importer/Exporter as suggested by @KonajuGames
2) Making my own animated model in Blender

Now, from what I've understood, at this moment it's not strictly problem with the code (either Monogame's default or extensions), but with the model itself. I've also read that models should be in T-position when loading, and I've changed one model accordingly, but it didn't help. Since I've pretty much exhausted possible solutions (as mentioned Bos FBX exporter) and I'd really like things to be as much out-of-the-box as possible (easier to restore things), I'm turning here for some help and suggestions. I just hope problem isn't related to Blender... and that I won't need to switch to Unity X)

Thanks in advance!

Posts: 1

Participants: 1

Read full topic

I need help asap

$
0
0

@Staeri wrote:

Hello. I am new to programming and not very skilled. The problem I have faced is that when I was programming a game using visual studios and monogame i was supposed to add two .png to my monogame pipeline but somehow I accidentally added all items on my desktop. After i closed visual studios I noticed that all my files on my desktop where missing and that the game i was making was unable to start. I have tried looking for the files but I can’t seem to find them. Please help me find the missing files as they include most of my school work.

Thanks

Posts: 2

Participants: 2

Read full topic

"Adapter 'NVIDIA GeForce GTX 1070' does not support the Reach profile" in current development build

$
0
0

@hui_buh wrote:

I normally use the Monogame 3.6 version but now I upgraded to a nightly build version (current).

But now after upgrading my game does not work anymore because I get the following exception:

Microsoft.Xna.Framework.Graphics.NoSuitableGraphicsDeviceException: 'Adapter 'NVIDIA GeForce GTX 1070' does not support the Reach profile.'

When I change the code to this, then I get the same message but now stating that HiDef would be not supported:

   GraphicsDeviceManager = new GraphicsDeviceManager(Game);
   GraphicsDeviceManager.GraphicsProfile = GraphicsProfile.HiDef; 
   GraphicsDeviceManager.ApplyChanges();

I cannot imagine my graphics card is not supported anymore. Is this a known bug? Does there exist a workaround?

Posts: 1

Participants: 1

Read full topic

FBX load model render.

Problem in the shader compiler

$
0
0

@StainlessTobii wrote:

Hi Guys,

Came across something you should be aware of.

I am working on a terrain system and the first time I ran it, the terrain was white.

After a bit of digging about I found the problem in the pixel shader.

It's not finished, but should have worked.

My vertex shader outputs a structure

`struct VS_OUTPUT
{
float4 position : POSITION;
float4 uv : TEXCOORD0;
float4 worldPos : TEXCOORD1;
float4 textureWeights : TEXCOORD2;
};
'
My pixel shader initially was .....

float4 PixelShader(in float4 uv : TEXCOORD0, in float4 weights : TEXCOORD2) : COLOR

And I had white terrain indicating the weights was wrong.

I changed it to ....

float4 Pixel(VS_OUTPUT input) : COLOR

And all of a sudden my terrain was textured.

Do you use a bespoke shader compiler?

Posts: 2

Participants: 2

Read full topic

I encountered a problem with the input method

$
0
0

@esengine wrote:

My English is not good. Please read my questions patiently. Thank you.
I have a problem with using the empty key input box when using MonoGame. It can't call system ime. I can't type Chinese/Japanese. When I asked the author of the emptys key, he told me that monogame does not seem to support ime. I would like to ask if this is the case. Is there any way to let monogame call Ime to support the input method.

Posts: 5

Participants: 2

Read full topic


My tutorials "Getting started" look sometimes bad....

$
0
0

@Jens_Eckervogt wrote:

Hello everyone,

I really have written own simple Tutorial:

RB blog looks outdated.

I really want improve but I can't understand why does MonoGame force to require EffectPass ?

  1. Initalizing Game // Like simple create MonoGame's project with DesktopGL
  2. Drawing triangles
  3. Rendering indicesbuffer
  4. Loading Shaders "PROBLEM WITH COLORS PASSING TO VERTICES"
    5 .....

How do I load shader and shader should pass color to verticesData? I really don't understand about FNA-Template because it used only texture. but for me no texture. Only vertices should pass with shader of custom color.

Posts: 12

Participants: 2

Read full topic

(Remove)Get GamePad controller type

Loading progress.

$
0
0

@MuntyScruntFundle wrote:

I'm thinking of giving users an update bar on loading, but before I go and write hundreds of lines I thought I'd check a couple of things.

If I ignore the Loading routine and set a flag in the Update code to load a graphic item each time the update is called until everything is loaded, and make something spin in the draw routine, will this be synchronous?

At the moment the game is taking about 6 seconds for everything to setup and I'm using a huge PC, I'm about to add a load more graphics and setup code so this is going to get worse.

What crevasses am I going to fall into, or should this be pretty simple?

Many thanks.

Posts: 1

Participants: 1

Read full topic

Caution Gitter.im is still down again! We can't chat in public???

$
0
0

@Jens_Eckervogt wrote:

Hello everyone,

Please read Twitter ( funny bird on social media )

Look out

And how do we have to chat with public chat? Skype? Other alternative?

But I don't like Discord because many bad people of Unity3D

I want we have serious team chat like team viewer or other alternative?

Thank you!

Posts: 1

Participants: 1

Read full topic

Simple 3D camera rotation not working

$
0
0

@SquareBread wrote:

Hello everyone,

I know this is a very basic question, but I've been struggling for too long and right now I'm just try-and-error-ing. I would be really thankful for an explanation what is going on.

So, what I'm trying to do is implement a simple 3D camera. I managed to get the movement right, but I really struggle with the rotation. Imagine the camera is looking at (0, 0, 0). I want my camera to orbit the point around the Y-Axis ("left and right") as well as around the axis pointing left from the camera ("Up and down").
Now, I've managed to do just that. The Camera rotates as I want, but only if I disable the other rotation. Also, when I do the vertical rotation before the horizontal rotation, the camera only rotates horizontally. When I do the horizontal rotation before the vertical rotation, the rotation becomes really messy.

I know that matrix multiplication is not commutative, so I'm assuming this is where the error comes from. But I don't exactly understand what the problem is, since it doesn't work properly no matter the order.

This is what I do in my camera class:
Up is a property that stores the cameras Up direction, which is initially (-1, 1, 0).Normalized();
Position is initialized to (1000, 1000, 0)
Target is (0, 0, 0)
Left is the normalized cross of Up x (Target - Position)

At the end of the camera update code, I calculate a new ViewMatrix using
Matrix.CreateLookAt(Position, Target, Up);

var deltaX = Mouse.GetState().X - 100; //Get mouse movement since last frame with right mouse button pressed
var deltaY = Mouse.GetState().Y - 100;
deltaX = -deltaX; // invert for right feeling

var direction = Position - Target; //Vector pointing from target to position

 //Vertical rotation:
var rotLeft = Matrix.CreateFromAxisAngle(Left, deltaY * rotationSpeed);
Position = Vector3.Transform(direction, rotLeft) + Target;
Up = Vector3.Transform(Up, rotLeft);

//Horizontal rotation:
var rotY = Matrix.CreateRotationY(deltaX * rotationSpeed);
Position = Vector3.Transform(direction, rotY) + Target;
Up = Vector3.Transform(Up, rotY);


Mouse.SetPosition(100, 100);

Posts: 1

Participants: 1

Read full topic

Setting up for Windows"is missing

Font runtime rendering?

$
0
0

@Alias wrote:

Hi There,

I'm new to monogame and was wondering if there a way to render TTF fonts on runtime? I'm asking this because I want to set the size variable dynamically depending on the screen-size and some local scale variables. Also being able to play around with the font weight and italic options on runtime would be nice.

It seems that if I want to do this with the Content Pipeline then I have to render the font N times. (say from 8-72). This seems highly inefficient.

For my graphics I'm not using the Content Pipeline at all. This is because i'm building a 2d game engine for my game(s) and i am building my atlases on runtime. (based on the max_texture_size, stuff as many groups on a single texture). And a small minor proportion of my graphics are vector based and rendered at runtime.

Textures have: Texture2D.FromStream() and Texture2D.SetData()
Audio has: SoundEffect.FromStream()

But fonts do not seem to have something like this :frowning: Which is inconsistent with the other assets.

What would you recommend me do? Still use the Content Pipeline just for my fonts and render N copies of it, or introduce a third party font library? Or perhaps somethings else?

Thanks!

Posts: 2

Participants: 2

Read full topic


Problem with Matrix

$
0
0

@Jens_Eckervogt wrote:

Hello everyone,

I am sorry for disturbation!

I really don't understand why does youtube teller but why does he need spriteBatch?

But for me only vertices..

// EDIT:
My result:


And I tried to make custom transformation with position, rotation and scale?

But it doesn't move or rotate? Why does it happen?

using Microsoft.Xna.Framework;

namespace MyTransformation
{
    public class Transformation
    {
        private static float _rotX, _rotY, _rotZ;

        private static Vector3 _position;

        private static Matrix translation;
        private static Matrix rotation;
        private static Matrix scalation;

        public static void Renderer(float _posX, float _posY, float _posZ, float rotX, float rotY, float rotZ, float scale)
        {
            translation = Matrix.CreateTranslation(_posX, _posY, _posZ);
            rotation = Matrix.CreateRotationX(rotX) * Matrix.CreateRotationY(rotY) * Matrix.CreateRotationZ(rotZ);
            scalation = Matrix.CreateScale(scale);

            Matrix CompletedMatrix = Matrix.Identity;
            CompletedMatrix *= translation;
            CompletedMatrix *= rotation;
            CompletedMatrix *= scalation;

            _position = Vector3.Transform(new Vector3(_posX, _posY, _posZ), CompletedMatrix);
        }

        public static void IncreasePosition(float posX, float posY, float posZ)
        {
            _position.X += posX;
            _position.Y += posY;
            _position.Z += posZ;
        }

        public static void IncreaseRotate(float rotateX, float rotateY, float rotateZ)
        {
            _rotX += rotateX;
            _rotY += rotateY;
            _rotZ += rotateZ;
        }

        public static void IncreaseScale(float scale)
        {
            scale += scale;
        }
    }
}

I am trying to resolve but I have tried youtube video. But it is not for me spriteBatch just I am using only vertices and indices.

Thank you for help and I appreciate that.

Posts: 1

Participants: 1

Read full topic

Game1 Constructor Called Twice, Crashes Game

$
0
0

@michaelarts wrote:

Hey everyone,

I'm using UWP on Xbox One to ship an ID@Xbox game. I was in the middle of testing if my game can handle exiting to the Xbox home screen and signing out when I found a really weird error where my Game1() constructor gets called twice. I'm not sure what to make of this! Here are my steps:

  1. I launch my game from my laptop, sign in an XboxLiveUser and play a bit of my game.
  2. Press Xbox Home, go to My Game & Apps.
  3. Sign out of the current gamertag, sign in on another one
  4. Resume my game
  5. Game1() constructor gets called again and crashes the game when it tries to create a new GraphicsDevice because there's already an instance of GraphicsDevice created from the first time Game1() was called.

Any ideas what's causing this? This doesn't seem like correct behavior to me.

Michael

Posts: 1

Participants: 1

Read full topic

Weird texture bug.

$
0
0

@willmotil wrote:

Well this one is beyond me.

Win 10, desktop gl project.

I draw this it works.

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            GraphicsDevice.SamplerStates[0] = new SamplerState() { Filter = TextureFilter.Point, AddressU = TextureAddressMode.Clamp, AddressV = TextureAddressMode.Clamp };
            GraphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true, DepthBufferFunction = CompareFunction.LessEqual };

            GraphicsDevice.RasterizerState = new RasterizerState() { FillMode = FillMode.Solid, CullMode = CullMode.None };
            effect.Texture = BasicTextures.green;
            effect.World = worldGrid;
            gridUp.Draw(GraphicsDevice, effect);

            base.Draw(gameTime);
        }

..

I add a couple more draws and the first draw goes black ?

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            GraphicsDevice.SamplerStates[0] = new SamplerState() { Filter = TextureFilter.Point, AddressU = TextureAddressMode.Clamp, AddressV = TextureAddressMode.Clamp };
            GraphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true, DepthBufferFunction = CompareFunction.LessEqual };

            GraphicsDevice.RasterizerState = new RasterizerState() { FillMode = FillMode.Solid, CullMode = CullMode.None };
            effect.Texture = BasicTextures.green;
            effect.World = worldGrid;
            gridUp.Draw(GraphicsDevice, effect);

            GraphicsDevice.RasterizerState = new RasterizerState() { FillMode = FillMode.Solid, CullMode = CullMode.None };
            effect.Texture = BasicTextures.checkerBoard;
            effect.World = worldSurface;
            surfaceTerrain.meshSurface.Draw(GraphicsDevice, effect);

            GraphicsDevice.RasterizerState = new RasterizerState() { FillMode = FillMode.WireFrame, CullMode = CullMode.None };
            effect.Texture = BasicTextures.red;
            effect.World = worldSurface;
            surfaceTerrain.meshControlGrid.Draw(GraphicsDevice, effect);

            base.Draw(gameTime);
        }

..

The first draw is basically the same as the second.
Well its using a different ivertex structure, could that cause this ?

        public void Draw(GraphicsDevice gd, Effect effect)
        {
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, (indices.Length / 3), VertexPositionTexture.VertexDeclaration);
            }
        }

        public void Draw(GraphicsDevice gd, Effect effect)
        {
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, (indices.Length / 3), VertexPositionNormalTexture.VertexDeclaration);
            }
        }

Posts: 2

Participants: 1

Read full topic

Extended.Gui or Extended.NuclexGui

$
0
0

@Zei wrote:

Hi there, I started working with monogame and monogame.extended in the last week and I'm in love.

Working on a little top down RPG and I've finally come to the point where I need to start s̶l̶a̶p̶p̶i̶n̶g̶ ̶t̶o̶g̶e̶t̶h̶e̶r carefully implementing the interface.

Reading through the discussions here and here, it seems like it's been a real adventure in terms of putting together a system. Nearly two years on at this point and here I am, late to the party as usual.

So monogame community, which do you recommend? The extended GUI or NuclexGUI? Appreciate any input, thanks!

Posts: 2

Participants: 1

Read full topic

Right way to use matrices to scale a GUI across different display configs

$
0
0

@Watercolor_Games wrote:

Hey there. I'm designing an operating system/desktop UI in MonoGame. The user interface is in 2D though I plan to do 3D rendering for certain UI effects like wobbly windows.

The issue right now is that I design the game on a 1080p 16:9 display and on that display configuration, everything fits perfectly. However, on lower resolutions and aspect ratios, windows, buttons and other UI elements are physically bigger and take up more space leading to less items fitting on screen.

Higher resolutions and aspect ratios lead to more screen real estate but also smaller UI elements and text. In 4K, the user interface is completely unusable because you cannot read anything.

So there are several things I need to tackle.

  1. I need to make sure that UI elements scale and translate based on the screen resolution and aspect ratio, so that everything fits in the right place, nothing gets cut off, and there's room to draw larger text on higher resolutions.
  2. If I have three font sizes - small, medium and large, I want to know which one will fit best with the current GUI scale.
  3. I want to make sure my textures don't get blurry and my text doesn't get pixelated, garbled, blurry, etc.
  4. I want to keep SpriteBatch support if possible.
  5. I'd like to keep units of measurement in pixels before the transformation is done - even if they map to a virtual screen. If I draw a rectangle at (64, 64) with the size (85x20), I want it to be rendered at 64 virtual pixels from the top left of the screen, and with a size of 85x20 virtual pixels. My virtual screen height would be 1080 pixels, and virtual screen width would be the real screen's aspect ratio (expressed as a float) multiplied by the virtual screen height. This accounts for stuff like NVidia Surround where I actually do want more horizontal screen real estate but I want everything to be the same size as a regular non-Surround setup.

My question is, how can I do this with matrices in MonoGame at a renderer level so that the entire engine is affected and the most porting I have to do is to make sure the coordinates and sizes of all my UI elements and other objects are changed to make better use of the new renderer?

I've been stumped on this for months. Any help would be greatly appreciated. My game's not going into alpha until I figure this stuff out.

Posts: 3

Participants: 3

Read full topic

Viewing all 6821 articles
Browse latest View live