View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

No replies to this topic

### #1DapperDave  Members

Posted 20 January 2014 - 06:02 PM

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;
}
else
{
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.SetVertexBuffer(vertexBuffer);

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

DrawTriangleStrip();

}


  private void DrawTriangleStrip()
{
graphics.DrawUserIndexedPrimitives<VertexPositionColorTexture>(
PrimitiveType.TriangleList,
gpuVertices,
0,
gpuVertices.Length,
shortUshortConversion(edgeFaceList),//*edgeFaceList,
0,
2);

}


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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.