on 01-12-2011 01:10 PM
So I was looking through the samples last night, and I'm kind of surprised to see how much goes into getting a texture displayed on the screen. There's a lot more lower-level code than I expected, but I also see that there's an included sprite class in the tutorial libraries.
What I'm curious about is whether this is going to remain a separate library or be folded into the Sce.PSS.Core.Graphics namespace. There's a paragraph in the documentation (Programming Guide 2) that talks about future development on it in the next release, but it's not clear how it's going to be implemented:
"Note: this SimpleSprite class is a simplified version created for explanation in this program guide, its processing is not appropriate for rendering. A formal class is scheduled for release in an SDK after the next version."
What's going to be different in the "formal" sprite class? Will it be folded into the Graphics namespace?
03-12-2011 01:21 AM - edited 03-12-2011 01:22 AM
I'm messing around with the included sprite class from TutoLib, and I made an XNA-like SpriteBatch for it by reusing some of the sample code. It's VERY basic, but you can pass it a texture and a rect and get an image drawn on the screen. Here's the class if anyone's interested:
using System;
using System.Collections.Generic;
using Sce.Pss.Core;
using Sce.Pss.Core.Environment;
using Sce.Pss.Core.Graphics;
using Sce.Pss.Core.Imaging;
using Sce.Pss.Core.Input;
using Sce.Pss.Utility;
namespace Sample
{
public class SpriteBatch
{
GraphicsContext graphics;
ImageRect imageRect;
Matrix4 unitScreenMatrix;
SimpleSprite sprite;
ShaderProgram shaderProgram;
public SpriteBatch (GraphicsContext graphics)
{
this.graphics = graphics;
imageRect = graphics.Screen.Rectangle;
this.unitScreenMatrix = new Matrix4(
2.0f/imageRect.Width, 0.0f, 0.0f, 0.0f,
0.0f, -2.0f/imageRect.Height, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 1.0f);
shaderProgram = new ShaderProgram("shaders/sprite.cgx");
shaderProgram.SetUniformBinding(0, "u_WorldMatrix");
}
public void Begin()
{
}
public void End()
{
graphics.SwapBuffers();
}
public void Draw(Texture2D texture, ImageRect DestinationRect)
{
sprite = new SimpleSprite(this.graphics, texture);
sprite.Position.X = DestinationRect.X;
sprite.Position.Y = DestinationRect.Y;
sprite.Position.Z = 0.0f;
graphics.SetShaderProgram(shaderProgram);
graphics.SetTexture(0, texture);
shaderProgram.SetUniformValue(0, ref unitScreenMatrix);
sprite.Render();
}
}
}
on 08-12-2011 11:21 AM
@NayusDante,
Thank you for providing that code, I am sure that it will help alot of people out ![]()
Regarding you question about the future of the SimpleSprite class, we will be providing a 2D Game Engine library in our next release, and the tutorial will change to use the new library instead of Tutolib.
Thanks.
on 08-12-2011 12:58 PM
on 08-12-2011 06:13 PM
on 21-12-2011 12:34 PM
on 21-12-2011 01:11 PM
on 13-05-2012 03:21 AM
on 15-05-2012 05:30 PM
Hey IngMemin,
Matrix4 is an implementation of a tranformation matrix. You can transform (scale, skew, translate, rotate, flip etc) a 2D or 3D point (Vector2D / Vector3D) with one of these tranformation matrices.
A transformation matrix is (usually) constructed of 16 values, some of which represent rotation (and are generated based on values entered) and some of which represent translation.
The following page describes the concept of transformation matrices pretty well:
http://people.bath.ac.uk/sej20/transform.html
All in all, you dont *really* need to know the internals to them to be able to use them. For example, the point [x,y,z] can be multiplied by a tranformation matrix4 [1-16 vals] to tranform the original point.
PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.
フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと
PSM DevPortalを一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870