Jump to content
  • Advertisement
Sign in to follow this  
pascalh

Rendering issue oval Sprite

This topic is 2953 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

Hello together,

i am stucking at a Renderproblem. I render two Sprite that are rendered as circle, but they are presented as oval sprites. So far i dont know if i do any mistake when i transform the vertices.

I hope that somebody is able to aid me.

Thanks in Advance
Pascal


tmpvec.X = Math.Abs(tmpvec.X);
tmpvec.Y = Math.Abs(tmpvec.Y);
m_vertices[0] = CreateVertexC(-tmpvec.X,tmpvec.Y,1f,0f,0f);
m_vertices[1] = CreateVertexC(tmpvec.X,tmpvec.Y,1f,1f,0f);
m_vertices[2] = CreateVertexC(-tmpvec.X,-tmpvec.Y,1f,0f,1f);
m_vertices[3] = CreateVertexC(tmpvec.X,-tmpvec.Y,1f,1f,1f);


private Direct3D.CustomVertex.PositionColoredTextured CreateVertexC(float x, float y, float z, float tu, float tv){
Direct3D.CustomVertex.PositionColoredTextured PNT;
PNT.X = x;
PNT.Y = y;
PNT.Z = z;
PNT.Tu = tu;
PNT.Tv = tv;
PNT.Color = Color.White.ToArgb();
return (PNT);
}




if (b_ValidDraw){

m_Origin = GraFX_001_GRAPHIC.Get3DCoords(new Vector2((float)GraFX_001_GRAPHIC.X_RES/2+
(float)cm_Width/2, (float)GraFX_001_GRAPHIC.Y_RES/2+
(float)cm_Height/2));

//m_VerticeCount++;

m_Position = Position;

m_Transformation = true;

if (m_Transformation)
m_ShadowVector3 = new Vector3(0f,0f,0f);


Matrix ViewBackup = m_Target.Transform.View;
Matrix ManipWorld = Matrix.Identity;
m_TransformationMatrix = Matrix.Identity;

if (m_Transformation){
ManipWorld *= Matrix.RotationZ(Direct3D.Geometry.DegreeToRadian(Angle));
m_TransformationMatrix *= Matrix.RotationZ(Direct3D.Geometry.DegreeToRadian(Angle));

ManipWorld *= Matrix.Translation(new Vector3(m_Position.X,m_Position.Y,0f));

if (m_ChaseTransform && !m_ChaseWRotation){
ManipWorld *= Matrix.RotationZ(Direct3D.Geometry.DegreeToRadian(m_ChaseAngle));
//m_TransformationMatrix *= Matrix.RotationZ(Direct3D.Geometry.DegreeToRadian(m_ChaseAngle));
}

//m_TransformationMatrix Try to capture Rotations...

if (m_ChaseTransform && m_ChaseWRotation){
Vector3 vChaseOrigin = GraFX_001_GRAPHIC.Get3DCoords(new Vector2(m_ChaseOriginX,m_ChaseOriginY));

ManipWorld *= Matrix.Translation(new Vector3(-vChaseOrigin.X,-vChaseOrigin.Y,0f));
ManipWorld *= Matrix.RotationZ(Direct3D.Geometry.DegreeToRadian(m_ChaseAngle));
m_TransformationMatrix *= Matrix.RotationZ(Direct3D.Geometry.DegreeToRadian(m_ChaseAngle));
ManipWorld *= Matrix.Translation(new Vector3(vChaseOrigin.X, vChaseOrigin.Y,0f));
}


if (m_useTransfAngleY){

Vector3 vOrigin = GraFX_001_GRAPHIC.Get3DCoords(new Vector2(m_ChaseOriginX,m_ChaseOriginY));
//TEST Rotation um Y-Achse
ManipWorld *= Matrix.Translation(new Vector3(-vOrigin.X, 0f, 29f));
//ManipWorld *= Matrix.RotationAxis(new Vector3(0f,1f,0f), Direct3D.Geometry.DegreeToRadian(m_TransfAngleY));
ManipWorld *= Matrix.RotationY(Direct3D.Geometry.DegreeToRadian(m_TransfAngleY));
ManipWorld *= Matrix.Translation(new Vector3(vOrigin.X, 0f, -29f));
}



//m_TransformationMatrix = ManipWorld;




m_ShadowVector3.TransformCoordinate(ManipWorld);
Vector2 vectmp2 = GraFX_001_GRAPHIC.Get2DCoords(m_ShadowVector3);
m_ShadowVector3.X = vectmp2.X;
m_ShadowVector3.Y = vectmp2.Y;
/*
Vector2 vectmp2 = GraFX_001_GRAPHIC.Get2DCoords(m_ShadowVector3);
m_ShadowVector3.X = vectmp2.X;
m_ShadowVector3.Y = vectmp2.Y;
*/



/*
m_ShadowVector3.X = 0 * ShadowWorld.M11 + 0 * ShadowWorld.M21 +
ShadowWorld.M41;
m_ShadowVector3.Y = 0 * ShadowWorld.M12 + 0 * ShadowWorld.M22 +
ShadowWorld.M42;
*/

}else{
ManipWorld *= Matrix.Translation(new Vector3(m_Position.X,m_Position.Y,0f));
}

//m_Target.Transform.World *= ManipWorld;

Direct3D.CustomVertex.PositionColoredTextured[] tempVertices = new Microsoft.DirectX.Direct3D.CustomVertex.PositionColoredTextured[4];
for(int i=0;i<4;i++){


tempVertices.X = m_vertices.X * (m_scaleX*1f);
tempVertices.Y = m_vertices.Y * (m_scaleY*1f);
tempVertices.Z = -29f;
//tempVertices.X = tempVertices.X + (m_Position.X*1f);
//tempVertices.Y = tempVertices.Y + (m_Position.Y*1f);



Vector3 tmpVector = new Vector3(tempVertices.X, tempVertices.Y, -29f);
tmpVector.TransformCoordinate(ManipWorld);
tempVertices.X = tmpVector.X;
tempVertices.Y = tmpVector.Y;

m_VBC[m_VBC_indexer].VerticesChain[m_VBC[m_VBC_indexer].vertex_count+i].X = tempVertices.X; //* (m_scaleX*1f);
m_VBC[m_VBC_indexer].VerticesChain[m_VBC[m_VBC_indexer].vertex_count+i].Y = tempVertices.Y; //* (m_scaleY*1f);
m_VBC[m_VBC_indexer].VerticesChain[m_VBC[m_VBC_indexer].vertex_count+i].Z = -29f;
m_VBC[m_VBC_indexer].VerticesChain[m_VBC[m_VBC_indexer].vertex_count+i].Tu = m_vertices.Tu;
m_VBC[m_VBC_indexer].VerticesChain[m_VBC[m_VBC_indexer].vertex_count+i].Tv = m_vertices.Tv;
m_VBC[m_VBC_indexer].VerticesChain[m_VBC[m_VBC_indexer].vertex_count+i].Color = Color.FromArgb((int)(Material.DiffuseColor.Alpha*255f),
(int)(Material.EmissiveColor.Red*255f),
(int)(Material.EmissiveColor.Green*255f),
(int)(Material.EmissiveColor.Blue*255f)).ToArgb();

}



m_VBC[m_VBC_indexer].vertex_count += 4;

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!