Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - WitchD0ctor

Pages: [1]
1
Graphics / LoadFromPixels?
« on: August 11, 2011, 12:26:06 pm »
What happened to it? I can't seem to find it in the new sf::Texture and sf::Image Classes.
Am I missing something?
I am trying to upgrade my project to the newer sfml2 from the git and
My Theora Video loader heavily relies on that method

2
Feature requests / Sf::clock pause?
« on: March 13, 2011, 04:38:46 am »
Just a thought but a pause and resume function for the clock Class would be kind of useful for me, not sure how difficult it would be to add but it doesn't seem too hard.

Any body agree this would be kind of nice?

3
Graphics / [GLSL] Normal/Specular Maps
« on: February 27, 2011, 11:50:49 am »
Prerequisite: I'm Using SFML2 on Windows 7 Professional 64 bit (but compiling with 32)


Hey, Im finally trying to implement lighting in my game. What im trying to do is a simple test to see if i can load a simple brick diffuse texture, and display it with a  point light at the mouse position. I also want to use a Normal and Specular map to control how the light reacts to the Material.

The problem is when searching for examples on how to approach this, most tutorials are aimed for 3d Surfaces, so it involves a vertex shader as well as a fragment shader, but I would like to implement the lighting using only the  sf::Shader's class provided by SFML.

So far I have managed to load and feed the required maps to the shader, however im not sure where to continue from here, as im missing some data that the vertex shader is suppose to provide, here is a link to the original shader from the tutorial.

http://ciardhubh.de/node/18


another thing to note is, im not sure about is how im suppose to modify

Code: [Select]
uniform lightDataType light;
from my application, do I make a similar structure? What do I replace the vec4's with?

Any way after some reworking, I hacked up a version of the above that, Kind of, almost works, but not quite,
Code: [Select]

[source]



struct lightDataType
{
    vec4  ambient;
    vec4  diffuse;
    vec4  specular;
    vec4  position;
};


uniform float time;
uniform float mouseX;
uniform float mouseY;





uniform float shininess; // Shininess exponent for specular highlights

uniform sampler2D diffuseTexture;
uniform sampler2D normalMap;
uniform sampler2D specularMap;


void main(void)
{

vec4 light_ambient = vec4(.5, .5, .5, 1);
vec4 light_position = vec4(mouseX, mouseY, .1, 0);
vec4 light_diffuse = vec4(.5, .5, .5, 1);
vec4 light_specular = vec4(0.2, 0.2, 0.2, 1);


vec3 tbnDirToLight = normalize(light_position-texture2D(normalMap, gl_TexCoord[0].xy).xyz); // Direction to light in tangent space...I think
vec3 tbnHalfVector = normalize(vec3(0, 0, -1)); // Half vector in tangent space


    // Base colour from diffuse texture
    vec4 baseColour = texture2D(diffuseTexture, gl_TexCoord[0].xy);

    // Uncompress normal from normal map texture
    vec3 normal = normalize(texture2D(normalMap, gl_TexCoord[0].xy).xyz * 2.0 - 1.0);
    // Depending on the normal map's format, the normal's Y direction may have to be inverted to
    // achieve the correct result. This depends - for example - on how the normal map has been
    // created or how it was loaded by the engine. If the shader output seems wrong, uncomment
    // this line:
    // normal.y = -normal.y;
   
    // Ambient
    vec4 ambient = light_ambient * baseColour;
   
    // Diffuse
    // Normalize interpolated direction to light
    vec3 tbnNormDirToLight = normalize(tbnDirToLight);
    // Full strength if normal points directly at light
    float diffuseIntensity = max(dot(tbnNormDirToLight, normal), 0.0);
    vec4 diffuse = vec4(0.0, 0.0, 0.0, 0.0);

    // Specular
    vec4 specular = vec4(0.0, 0.0, 0.0, 0.0);
    // Only calculate specular light if light reaches the fragment.
    if (diffuseIntensity > 0.0) {
        // Colour of specular reflection
        vec4 specularColour = texture2D(specularMap, gl_TexCoord[0].xy);
        // Specular strength, Blinn–Phong shading model
        float specularModifier = max(dot(normal, normalize(tbnHalfVector)), 0.0);
        specular = light_specular * specularColour * pow(specularModifier, shininess);


diffuse = light_diffuse * baseColour * diffuseIntensity;


    }

    // Sum of all lights
    gl_FragColor = clamp(ambient + diffuse + specular, 0.0, 1.0);
   
    // Use the diffuse texture's alpha value.
    gl_FragColor.a = baseColour.a;
}


[/source]



The Result:

 
Not much Going on :S
The biggest problem probably is that Im not sure what to put for
Code: [Select]
vec3 tbnDirToLight
and
Code: [Select]
vec3 tbnHalfVector'



Id appreciate any help somebody with knowledge of GLSL can give me!

4
SFML projects / HyperNova
« on: December 19, 2010, 07:06:29 am »
http://www.youtube.com/watch?v=y_F61o92VN0


Working on this for my entry in Ludum Dare's Jam section



Still have a lot of work to do, I will probably also work on it after the competition as well. I'll post a download link soon enough!

also uses box2d for physics,

What do you think?
any suggestions?

5
SFML projects / SF Video Player
« on: September 08, 2010, 03:19:13 pm »
I recently Integrated kspes' Theora Playback Library
http://sourceforge.net/projects/libtheoraplayer/

to use SFML images and sprites for cut-scenes in my game, I thought I would share it here for anybody who found it useful. Its not to much more than a simple wrapper, but it works quite well for most situations




with this you can get a video up and playing in about 5 lines,
the test program,
Code: [Select]




//Project files!
#include <iostream>
#include "movie_player.h"




/* Minimal Example */
 int main()
 {

sf::RenderWindow Rendow( sf::VideoMode(800, 600, 32), "Ubar Videoz", 6 );




MoviePlayer movieManager;


//Load and play Cutscenes
std::string vid_location = "resources/demo.ogv";
movieManager.playCutscene(&Rendow, vid_location, sf::Key::Escape, true);



Rendow.Close();

     return EXIT_SUCCESS;
 }//End ov Main!



the
Code: [Select]
playCutscene() is just a utility function to play a full screened video, that can be exited by a button you specify, you can also tell it to let the user control the video or not (seek, pause, etc).

you can also create an instance of MovieClip and control how/when to update/draw your movie, since it inherits from sf::Sprite, you can treat it like any other sprite object. So,

Code: [Select]



MoviePlayer movieManager;


//Load video manually
MovieClip *clip;
clip = movieManager.loadClip( vid_location, TH_RGBA );

//TH_RGBA is an enum for how to load the video pixel data,
//SFML's LoadFromPixel function likes this one

...

//in while loop

//Do silly Sprite things to the video
                clip->SetPosition(30, 50);
clip->Rotate(10);
clip->SetColor( sf::Color(255,255,255,100) );
                clip->Resize(800, 600);



clip->Update( Rendow->GetFrameTime() );

             Rendow->Clear();
                    clip->Draw( &Rendow );
             Rendow->Display();


This would play a movie that sets its position, rotates, resizes,  and is partially transparent, not sure why you would do that, however the option is there!

here it is,

...

Includes the sources, VS2010 project,  dependencies to compile it, and a simple test program,
note I didn't include the debug version of the dependencies, so the test program  will only compile in Release mode. You should be able to fix this if you include it in your game

Let me know what you think of it.


[EDIT] Newer Version: Just updated to include vs2008 project, nothing really new :o
Win.





PS. I used the OpenAL interface straight from the Theora playback lib examples, if any body wants to make and share an interface using SFML's audio library, I would be most grateful.  

PSS. If you need to convert video into the Theora format, i would suggest Theora Converter.NET if your on windows, Dead simple to use and works quite well.

6
General / Entity issues!
« on: September 02, 2010, 07:08:50 am »
Hey, since I've had a lot of luck here, i thought I'd ask you guys,
sorry to cross-post like this, but im having some issues with my entity system in my game, I've posted the whole issue at gamedev.net which I'll link to, to save typing.

http://www.gamedev.net/community/forums/topic.asp?topic_id=580749

if any body has any advise on how to remedy the situation, I would most definitely appreciate it

thank you!

7
General / Events Misfiring?
« on: September 02, 2010, 04:35:55 am »
so here's the spiel,

In my Game i have a function that acts like a regular game loop to play a cutscene video, In it i read in events to know if the user has pressed the escape key, if so, i exit out of the cutscene and begin the real game loop. however, while watching the movie, sometimes it will randomly exit, and go to the normal game loop, i put a cout, in the Event when its suppose to be fired, and sure enough, when it exits randomly, the cout' is printed.

which is weird because my hand is nowhere near the Escape key.
Is this a known issue or am i doing something stupid?

the codez

Code: [Select]


//Play fullscreened Cutscene
bool MoviePlayer::playCutscene(sf::RenderWindow *rendow, MovieClip *cutscene, bool player_control, sf::Key::Code escKey)
{
if(!cutscene->isValid() )
{
return false;
}

bool run_cutscene = true;

cutscene->Loop(false);
cutscene->SetOrigin(0,0);
cutscene->SetPosition(0, 0);





while (run_cutscene)
     {
// Process events
         sf::Event Event;
         while (rendow->GetEvent(Event))
         {
//Exit if the close button is pressed
 if (Event.Type == sf::Event::Closed)
{
                 rendow->Close();
run_cutscene = false;
}
 
           //The Problem! this gets called randomly sometimes
if(Event.Key.Code == escKey)
{
              cout << "Escaped Cutscene!\n";
run_cutscene = false;

}

}//End of Events

cutscene->Resize(rendow->GetWidth(), rendow->GetHeight());
//Update images and sound
cutscene->Update( rendow->GetFrameTime() );


 //if finsished, exit cutscene
if(cutscene->isFinished())
{
run_cutscene = false;
}

//Draw the cutscenes
rendow->Clear();
cutscene->Draw(rendow);
rendow->Display();
}//End ov While loop

return cutscene->isFinished();
}//EoF


any ideas?

also, the problem is also in the main game loop, I've known about this problem for a while, but have finally decided to deal with it now so my cutscene system is finalized

8
General / Scrolling Enemy with map
« on: August 22, 2010, 02:30:15 pm »
I'm honestly surprised that i haven't run into this problem sooner,

I need help figuring out how to draw enemies in their correct positions, when the map starts scrolling. Previously when I worked with the allegro Library, i would do something like this
Code: [Select]

g_blitTile(Images.Enemy, enemy_x - Map.x_scroll, enemy_y-Map.y_scroll, 32, 32, frame);


which means i would simply call a draw function and subtract the Maps scroll offset, but in SFML, i can't exactly do that. because there are no parameters for draw, it just takes its current position. Seems like a simple problem to solve but I can't seem to wrap my head around it, Might be because its 5 in the morning :o...need sleep.

Any suggestions?


PS. I would use views to simply the whole matter but Mappy doesn't play nice with them, (auto culls out of screen tiles)

9
SFML projects / PlovR
« on: May 22, 2010, 02:09:58 pm »
Pronounced "plover",
It is a 2d Space shooter I'm working on, Will be an action based game with some RPG elements.

The story:
In the year 400 Billion, The Black Star is the largest corporate conglomerate in the universe. As humanity has expanded their hold on the galaxies around them, they have come upon super massive extra terrestrial creatures named 'Vulnero Astrum'. Though most are quite timid, some have proven hostile to everything around it. The black star makes it's business by disposing of the creatures that wonder to close to inhabited planets. You are a plover agent, a cog in the great black star machine. You along with your navigation operator must single handedly take these small planet sized organisms down from the inside.


screenies,





Video,
http://www.youtube.com/watch?v=SqbcUPRjXOo

Still Very much in development



EDIT:
here is a tech demo of what I have so far,

www.blackshark.nukelol.com/NSSC/PlovR_003.zip

warning, this runs fine on my gaming/development computer but i hear that it runs horrible on others thanks to the parallax backgrounds i added,

So, be warned :o

Pages: [1]
anything