Jump to content
  • Advertisement
Sign in to follow this  

[PlaystationMobile, XNA] Need Help with the Syntax for a Simple 3D Effect

This topic is 2095 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I have been porting a game made in XNA, a 2D RPG, to PSM using Monogame.  Unfortunately, I use a simple 3D effect that cannot be translated because Monogame did not write translation code for the BasicEffect class.


The effect is a simple 3D manipulation used in battle.  I know almost nothing about 3D coding so it was a struggle to get this work in XNA to begin with.


Here's how it works.  Enemies in battle don't move and are just standard sprites from a spritesheet, like this:



The enemy sprite is like a wooden cut out from a shooting gallery.  Now certain actions can move it around.  For example if you hit the enemy it will tilt back and forth.






Now the logic behind how this works is very simple, although it was difficult for me to find the right syntax.  I'm simply manipulating the verticies that draw the sprite.  For example, if I want it to look like it's tilting back, I simply move the top left vertex down and left and the top right vertex down and right.


Here's what the code for tilting looks like in my XNA code.

public void TiltBackward(GameTime gameTime)
            if (transitionTimer >= tiltForwardInterval)
                transitionTimer = TimeSpan.Zero;
                TiltFinished = true;
                transitionTimer += gameTime.ElapsedGameTime;

                gpuVertices[0].Position.X =
                    startVertices[0].X +
                    (((float)entity.Width * (float)bits / 4f) * (float)Math.Min(1,(transitionTimer.TotalSeconds / tiltForwardInterval.TotalSeconds)));

                gpuVertices[1].Position.X =
                    startVertices[1].X +
                    (((float)-entity.Width * (float)bits / 4f) * (float)Math.Min(1,(transitionTimer.TotalSeconds / tiltForwardInterval.TotalSeconds)));

                gpuVertices[0].Position.Y =
                    startVertices[0].Y +
                    (((float)entity.Height * (float)bits / 4f) * (float)Math.Min(1,(transitionTimer.TotalSeconds / tiltForwardInterval.TotalSeconds)));

                gpuVertices[1].Position.Y = gpuVertices[0].Position.Y;

The XNA code that draws it uses syntax that I don't fully  underestand, like rasterized states, index buffers, basiceffect passes.  Here's what that looks like in XNA.

 basicEffect.Texture = image;
                basicEffect.VertexColorEnabled = true;
                basicEffect.TextureEnabled = true; //Will make colors black instead of red


                graphics.Indices = indexBuffer;

                graphics.RasterizerState = rasterizerState;
                foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)



  private void DrawTriangleStrip()


So now I need to simply translate this code to the PSM native language.  This is a difficult task for someone who barely understands the original syntax, has been using Monogame to port, and doesn't really understand 3D coding to begin with.


I've looked at all the examples and looked up some things in the SDK.  It seems like to pull this off all I would need to do is manipulate the quad points.  Unfortunately, those are read only and cannot be changed manually.  


I understand the logic, I just can't figure out the syntax.  This is a problem where anyone with even a passing familiarity in 3D coding for PSM could tell me exactly how to do this in seconds.  But I've spent days trying to figure it out without any success.  I'm hoping such a person can throw me a bone. 

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!