Jump to content

  • Log In with Google      Sign In   
  • Create Account

Mr_PoP

Member Since 20 May 2011
Offline Last Active Jan 06 2015 01:53 PM

Topics I've Started

Trying to implement Camera

27 December 2014 - 03:43 PM

what am trying to do is implementing Camera calss so I can walk and look on the world as follow:

#ifndef _CAMERA_H_
#define _CAMERA_H_

#include <glm\glm.hpp>

class Camera
{
public:
    Camera();
    ~Camera();

    void Update(const glm::vec2& newXY);
    //if by = 0.0 it means, it will use the const Class speed to scale it
    void MoveForward(const float by = 0.0f);
    void MoveBackword(const float by = 0.0f);
    void MoveLef(const float by = 0.0f);
    void MoveRight(const float by = 0.0f);
    void MoveUp(const float by = 0.0f);
    void MoveDown(const float by = 0.0f);
    void Speed(const float speed = 0.0f);

    glm::vec3& GetCurrentPosition();
    glm::vec3& GetCurrentDirection();
    glm::mat4 GetWorldToView() const;
private:
    glm::vec3 position, viewDirection, strafeDir;
    glm::vec2 oldYX;

    float speed;
    const glm::vec3 up;
};

#endif

#include "Camera.h"
#include <glm\gtx\transform.hpp>

Camera::Camera()
    :up(0.0f, 1.0f, 0.0), viewDirection(0.0f, 0.0f, -1.0f),
    speed(0.1f)
{
}


Camera::~Camera()
{
}


void Camera::Update(const glm::vec2& newXY)
{
    glm::vec2 delta = newXY - oldYX;
    auto length = glm::length(delta);
    if (glm::length(delta) < 50.f)
    {
        strafeDir = glm::cross(viewDirection, up);
        glm::mat4 rotation = glm::rotate(-delta.x * speed, up) *
            glm::rotate(-delta.y * speed, strafeDir);

        viewDirection = glm::mat3(rotation) * viewDirection;
    }

    oldYX = newXY;
}

void Camera::Speed(const float speed)
{
    this->speed = speed;
}

void Camera::MoveForward(const float by)
{
    float s = by == 0.0f ? speed : by;

    position += s * viewDirection;
}
void Camera::MoveBackword(const float by)
{
    float s = by == 0.0f ? speed : by;

    position += -s * viewDirection;
}
void Camera::MoveLef(const float by )
{
    float s = by == 0.0f ? speed : by;
    position += -s * strafeDir;
}
void Camera::MoveRight(const float by )
{
    float s = by == 0.0f ? speed : by;
    position += -s * strafeDir;
}
void Camera::MoveUp(const float by )
{
    float s = by == 0.0f ? speed : by;
    position += s * up;
}
void Camera::MoveDown(const float by )
{
    float s = by == 0.0f ? speed : by;
    position += -s * up;
}

glm::vec3& Camera::GetCurrentPosition()
{
    return position;
}
glm::vec3& Camera::GetCurrentDirection()
{
    return viewDirection;
}

glm::mat4 Camera::GetWorldToView() const
{
    return glm::lookAt(position, position + viewDirection, up);
}

and I update and render as follow :

void Game::OnUpdate()
{
    glLoadIdentity();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    glUniformMatrix4fv(program->GetUniformLocation("modelToViewWorld"), 1, GL_FALSE, &cam.GetWorldToView()[0][0]);
    
}

void Game::OnRender()
{

    model->Draw();

}

where the Vertix shader:

#version 410

layout (location = 0) in vec3 inVertex;
layout (location = 1) in vec2 inTexture;
layout (location = 2) in vec3 inNormal;

uniform mat4 modelToViewWorld;


void main()
{
        gl_Position    = vec4(mat3(modelToViewWorld) * inVertex, 1);
    
}

but what is happening is am moving/rotating the Model it's self not the camrea around it . what am doing wrong here?

 


Drawing a triangle using GLSL on custom window not working correctly

05 December 2014 - 06:45 AM

what i am trying to do is;- creating custom window and enable `OpenGL` to draw on it using `glew`, I draw the triangle fine , rotate , scale , etc fine , but when it comes to use `Shaders`, the screen start to flicker and I got wrong colors on the triangle

ScreenManager Class:

    void GraphicManager::CreateScreen(std::string screenName, int width, int hight, int posX, int posY)
    {
        WNDCLASSEX winex;
        ZeroMemory(&winex, sizeof(WNDCLASSEX));
    
        m_hInstance = m_hInstance;
        m_screenName = screenName;
    
        winex.cbSize = sizeof(WNDCLASSEX);
        winex.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
        winex.lpfnWndProc = MsgProc;
        winex.cbClsExtra = 0;
        winex.cbWndExtra = 0;
        winex.hInstance = m_hInstance;
        winex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        winex.hCursor = LoadCursor(NULL, IDC_ARROW);
        winex.hbrBackground = NULL;
        winex.lpszMenuName = NULL;
        winex.lpszClassName = m_screenName.c_str();
        winex.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
    
        if (!RegisterClassEx(&winex))
        {
            MessageBox(NULL, std::string("Faild to register " + m_screenName + " class!").c_str(), NULL, NULL);
            return ;
        }
    
        m_hwnd = CreateWindowEx(NULL, m_screenName.c_str(), m_screenName.c_str(), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, posX, posY, width, hight, NULL, NULL, m_hInstance, NULL);
    
        if (!m_hwnd)
        {
            MessageBox(NULL, std::string("Faild to create " + m_screenName + " window!").c_str(), NULL, NULL);
        }
    
        EnableOGL();
    }
    
    void GraphicManager::EnableOGL()
    {
        m_hdc = GetDC(m_hwnd);
    
        if (m_hdc == NULL)
            MessageBox(NULL, "Faild to get Device Context!", "Error", NULL);
    
        PIXELFORMATDESCRIPTOR pfd =
        {
            sizeof(PIXELFORMATDESCRIPTOR),
            1,
            PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,    //Flags
            PFD_TYPE_RGBA,            //The kind of framebuffer. RGBA or palette.
            32,                        //Colordepth of the framebuffer.
            0, 0, 0, 0, 0, 0,
            0,
            0,
            0,
            0, 0, 0, 0,
            24,                        //Number of bits for the depthbuffer
            8,                        //Number of bits for the stencilbuffer
            0,                        //Number of Aux buffers in the framebuffer.
            PFD_MAIN_PLANE,
            0,
            0, 0, 0
        };
    
        int PixelFormat;
        PixelFormat = ChoosePixelFormat(m_hdc, &pfd);
        SetPixelFormat(m_hdc, PixelFormat, &pfd);
        m_hglrc = wglCreateContext(m_hdc);
    
        if (m_hglrc == NULL)
            MessageBox(NULL, "Faild to get OpenGL Context!", "Error", NULL);
    
        if (!wglMakeCurrent(m_hdc, m_hglrc))
        {
            MessageBox(NULL, "Faild to Create OpenGL Context!", "Error", NULL);
        }
    
        if (glewInit() != GLEW_OK)
            MessageBox(NULL, "Faild to Init GLEW!", "Error", NULL);
    
        ShowWindow(m_hwnd, SW_SHOW);
        UpdateWindow(m_hwnd);
    }
    
    void GraphicManager::RunScreenMainLoop()
    {
        m_game->Init();
        while (WM_QUIT != msg.message)
        {
            if (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE))
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
            else
            {
                m_game->Update();
                m_game->Render();
                SwapBuffers(m_hdc);
            }
        }
    
    }


ShaderManager Class:

    void ShaderManager::Load(const std::string& file, GLenum shaderType)
    {
        if (!isProgramCreated)
        {
            program = glCreateProgram();
            isProgramCreated = true;
        }
    
        std::ifstream fil(std::string(path + file).c_str());
    
        if (fil.is_open())
        {
            std::string output;
            char buf[256];
            while (!fil.eof())
            {
                fil.getline((buf), 256, '\n');
                output.append(std::string(buf) + '\n');
            }
    
            GLuint shader = glCreateShader(shaderType);
    
            if (shader == 0)
            {
                //std::exception("craete shader faild");
                return;
            }
    
            const GLchar* shaderSourceStrings[1];
            GLint shaderSourceStringLengths[1];
    
            shaderSourceStrings[0] = output.c_str();
            shaderSourceStringLengths[0] = output.length();
    
            glShaderSource(shader, 1, shaderSourceStrings, shaderSourceStringLengths);
            glCompileShader(shader);
            GLint shader_ok;
            glGetShaderiv(shader, GL_COMPILE_STATUS, &shader_ok);
            if (!shader_ok)
            {
                fprintf(stderr, "Failed to compile %s:\n", file.data());
                show_info_log(shader, glGetShaderiv, glGetShaderInfoLog);
                glDeleteShader(shader);
                return;
            }
    
            glAttachShader(program, shader);
    
            //glBindAttribLocation(program, 0, "position");
    
            glLinkProgram(program);
    
            GLint program_ok;
            glGetProgramiv(program, GL_LINK_STATUS, &program_ok);
            if (!program_ok)
            {
                fprintf(stderr, "Failed to link shader program:\n");
                show_info_log(program, glGetProgramiv, glGetProgramInfoLog);
                glDeleteProgram(program);
                return;
            }
    
            glValidateProgram(program);//check valdiet
    
            shaders[Utilities::SplitString(file, '.')[0]] = shader;
            fil.close();
        }
        else
        {
            //std::exception(std::string("Faild to load" + file).c_str());
        }
    }
    
    void ShaderManager::BindShaders()
    {
        glUseProgram(program);
    }

and the Game Class:

    void Game::Init()
    {
        
    
        glClearColor(0, 0, 0, 1);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(50, 640.0 / 480.0, 1, 1000);
        glMatrixMode(GL_MODELVIEW);
        glEnable(GL_DEPTH_TEST);
    
        engine->getShaderManager()->setPath("..\\Debug\\Engine\\Shaders\\");
        engine->getShaderManager()->Load("VertexShader.vs", GL_VERTEX_SHADER);
        engine->getShaderManager()->Load("FragmentShader.vs", GL_FRAGMENT_SHADER);
        engine->getShaderManager()->BindShaders();
    }
    
    
    void Game::Update()
    {
    
    
    }
    
    void Game::Render()
    {
        glLoadIdentity();
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        
    
        glBegin(GL_TRIANGLES);
        glVertex3f(0, 1, -4);
        glVertex3f(-1, -1, -4);
        glVertex3f(1, -1, -4);
        glEnd();
    }



VertixShader :

    void main()
    {
        gl_Position=gl_ModelViewProjectionMatrix*gl_Vertex;
    }

FragmentShader :

    void main()
    {
        gl_FragColor=vec4(1.0,0.0,0.0,1.0);
    }


the final result should be a red triangle , but what am getting is mixed color triangle with flickering on the screen!

ibb87m.jpg

am not sure what am missing here!


trying to draw with modern opengl but am geeting wrong result

30 September 2014 - 01:53 AM

I'm trying to draw a triangle using `OpenGL` , but it's keep flickering with wrong color , here is my code :

    // my generic vector class
    template <class T>
    struct Vector3D
    {
    	T X;
    	T Y;
    	T Z;
    
    	Vector3D(){
    		X = 0;
    		Y = 0;
    		Z = 0;
    	}
    
    	Vector3D(T x, T y, T z){
    		X = x;
    		Y = y;
    		Z = z;
    	}
    
    	Vector3D(T x, T y){
    		X = x;
    		Y = y;
    		Z = 0;
    	}
    .......
    }
    
    //here where I init the model data and send it to the opengl
    void Model::Init(std::vector<Vector3D<float>> vertices, std::vector<Vector3D<float>> uvs, std::vector<Vector3D<float>> normals, std::vector<Face> faces)
    {
    	std::vector<Vector3D<float>> drawVertices;
    	if (!faces.empty()){
    		for (size_t i = 0; i < faces.size(); i++)
    		{
    			drawVertices.push_back(vertices[faces[i].VerticesIndex[0]]);
    			drawVertices.push_back(vertices[faces[i].VerticesIndex[1]]);
    			drawVertices.push_back(vertices[faces[i].VerticesIndex[2]]);
    			if (faces[i].IsQuad)
    				drawVertices.push_back(vertices[faces[i].VerticesIndex[3]]);
    
    		}
    	}
    	else
    	{
    		drawVertices = vertices;
    	}
    
    
    	verticesSize = drawVertices.size();
    	glGenVertexArrays(1, &vertexArray);
    	glBindVertexArray(vertexArray);
    
    	glGenBuffers(1, &generatedBuffer);
    	glBindBuffer(GL_ARRAY_BUFFER, generatedBuffer);
    	glBufferData(GL_ARRAY_BUFFER, drawVertices.size() * sizeof(drawVertices[0]), &drawVertices[0], GL_STATIC_DRAW);
    
    	glEnableVertexAttribArray(0);
    	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
    
    	glBindVertexArray(0);
    }
    
    //here is how am drawing it 
    void Model::Draw()
    {
    	if (!isInited)
    	{
    		Init(tempVertices, tempUVs, tempNormals, tempFaces);
    		isInited = true;
    		tempVertices.clear();
    		tempUVs.clear();
    		tempNormals.clear();
    		tempFaces.clear();
    	}
    
    	glBindVertexArray(vertexArray);
    
    	glDrawArrays(GL_TRIANGLES, 0, verticesSize);
    
    	glBindVertexArray(0);
    }
    
    //the fragmentshader 
    #version 120
    
    void main()
    {
      gl_FragColor = vec4(1.0f, 0.0f, 0.0f, 1.0f);
    }
    
    //the obj file data
    v -0.5 -0.5 0.0
    v 0.0 0.5 0.0
    v 0.5 -0.5 0.0
    
result is a wrong colored flickering triangle
where it should be red triangle without flickering!


http://i.stack.imgur.com/KXKwW.jpgjpg

am trying to load a model but it's not displaying

05 November 2012 - 01:15 PM

am trying to load an obj model :

[source lang="plain"]# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware# File Created: 05.11.2012 20:07:48mtllib test.mtl## object Box001#v -12.6264 0.0000 -58.6877v -12.6264 0.0000 6.8357v 43.9557 0.0000 6.8357v 43.9557 0.0000 -58.6877v 43.9557 -51.9219 6.8357v -12.6264 -51.9219 6.8357v -12.6264 -51.9219 -58.6877v 43.9557 -51.9219 -58.6877# 8 verticesvn 0.0000 1.0000 -0.0000vn 0.0000 -1.0000 -0.0000vn 0.0000 0.0000 1.0000vn 1.0000 0.0000 -0.0000vn 0.0000 0.0000 -1.0000vn -1.0000 0.0000 -0.0000# 6 vertex normalsvt 0.0000 65.5234 0.0000vt 0.0000 0.0000 0.0000vt 56.5821 0.0000 0.0000vt 56.5821 65.5234 0.0000vt 0.0000 -51.9219 0.0000vt 56.5821 -51.9219 0.0000vt 65.5234 0.0000 0.0000vt 65.5234 -51.9219 0.0000# 8 texture coordsg Box001usemtl wire_229154215s 2f 1/1/1 2/2/1 3/3/1 4/4/1 s 4f 5/2/2 6/3/2 7/4/2 8/1/2 s 8f 3/3/3 2/2/3 6/5/3 5/6/3 s 16f 4/7/4 3/2/4 5/5/4 8/8/4 s 32f 1/3/5 4/2/5 8/5/5 7/6/5 s 64f 2/7/6 1/2/6 7/5/6 6/8/6 # 6 polygons[/source]


I have a class called Model :

[source lang="cpp"]#ifndef _Model_H_#define _Model_H_#include <vector>struct Coordinate{ float X,Y,Z; Coordinate(float x,float y,float z);};struct TextureCoordinate{ float U,V; TextureCoordinate(float u,float v);};struct Face{ int VertexIndex,TextureIndex,NormalIndex; Face(int vi, int ti, int ni);};class Model{public: Model(void); ~Model(void); bool IsTriangle; std::string Name; std::vector<Coordinate> Vertices; std::vector<Coordinate> VerticesNormals; std::vector<Coordinate> VerticesTexture; std::vector<Face > Faces; int ModelNumber;};#endif[/source]


and am trying to load it like this :-

[source lang="cpp"]Model ModelsLoader::LoadModel(const char * ModelName){ std::ifstream fs(ModelName); char temp[256]; std::string * line; Model m; float tempX,tempY,tempZ; int tempA1,tempA2,tempA3,tempA4; if(fs.is_open()){ while (!fs.eof()) { fs.getline(temp,256); Lines.push_back(new std::string(temp)); } int c,slashes; for (int i = 0; i < Lines.size(); i++) { line = Lines[i]; if(line->size() == 0 ||(*line)[0] == '#' ) continue; else if((*line)[0] == 'v' && (*line)[1] == ' ') { sscanf(line->c_str(),"v %f %f %f",&tempX,&tempY,&tempZ); m.Vertices.push_back( Coordinate(tempX,tempY,tempZ)); } else if((*line)[0] == 'v' && (*line)[1] == 't'){ sscanf(line->c_str(),"vn %f %f %f",&tempX,&tempY,&tempZ); m.VerticesTexture.push_back( Coordinate(tempX,tempY,tempZ)); } else if((*line)[0] == 'v' && (*line)[1] == 'n'){ sscanf(line->c_str(),"vn %f %f %f",&tempX,&tempY,&tempZ); m.VerticesNormals.push_back( Coordinate(tempX,tempY,tempZ)); } else if((*line)[0] == 'f' && (*line)[1] == ' ') { c = std::count(line->begin(),line->end(),' ') - 1; slashes = std::count(line->begin(),line->end(),'/'); if( slashes / c == 2){ int i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12; sscanf(line->c_str(),"f %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d",&i1,&i2,&i3,&i4,&i5,&i6,&i7,&i8,&i9,&i10,&i11,&i12); m.Faces.push_back(Face(i1-1,i2-1,i3-1)); m.Faces.push_back(Face(i4-1,i5-1,i6-1)); m.Faces.push_back(Face(i7-1,i8-1,i9-1)); m.Faces.push_back(Face(i10-1,i11-1,i12-1)); m.IsTriangle = false; } else if (slashes / c == 3) { int i1,i2,i3,i4,i5,i6,i7,i8,i9; sscanf(line->c_str(),"f %d/%d/%d %d/%d/%d %d/%d/%d",&i1,&i2,&i3,&i4,&i5,&i6,&i7,&i8,&i9); m.Faces.push_back(Face(i1-1,i2-1,i3-1)); m.Faces.push_back(Face(i4-1,i5-1,i6-1)); m.Faces.push_back(Face(i7-1,i8-1,i9-1)); m.IsTriangle = true; } } } fs.close(); m.ModelNumber = glGenLists(1); glNewList(m.ModelNumber, GL_COMPILE); for (int i = 0; i < m.Faces.size(); i++) { if(m.IsTriangle){ } else { glBegin(GL_QUADS); for (int i = 0; i < m.Faces.size(); i++) { glVertex3f(m.VerticesNormals[m.Faces[i].NormalIndex].X,m.VerticesNormals[m.Faces[i].NormalIndex].Y,m.VerticesNormals[m.Faces[i].NormalIndex].Z); glVertex3f(m.Vertices[m.Faces[i].VertexIndex].X,m.Vertices[m.Faces[i].VertexIndex].Y,m.Vertices[m.Faces[i].VertexIndex].Z); } glEnd(); } } glEndList(); } Clear(); return m;}[/source]


now when I call the list it's not showing anything:-

[source lang="cpp"]void drawScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective glLoadIdentity(); //Reset the drawing perspective camera(); glCallList(model.ModelNumber); glutSwapBuffers(); //Send the 3D scene to the screen}[/source]

what am doing worng here!?

[.net] BouncyCastle BlowFish Crypto issue

25 June 2011 - 09:22 PM

here is my BlowFishCrypto Class
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;
	using Org.BouncyCastle.Crypto;
	using Org.BouncyCastle.Crypto.Modes;
	using Org.BouncyCastle.Crypto.Engines;
	using Org.BouncyCastle.Crypto.Parameters;
	using Org.BouncyCastle.Math;
	namespace Common.Encryption
	{
    	public class BlowfishCryptographer
    	{
        	private bool forEncryption;
        	private IBufferedCipher cipher;
	
        	public BlowfishCryptographer(bool forEncryption)
        	{
            	this.forEncryption = forEncryption;
            	cipher = new BufferedBlockCipher(new CfbBlockCipher(new BlowfishEngine(), 64));
            	cipher.Init(forEncryption, new ParametersWithIV(new KeyParameter(Encoding.ASCII.GetBytes("DR654dt34trg4UI6")), new byte[8]));
        	}
        	public void ReInit(byte[] IV,BigInteger pubkey)
        	{
            	cipher.Init(forEncryption, new ParametersWithIV(new KeyParameter(pubkey.ToByteArrayUnsigned()),IV));
        	}
        	public byte[] DoFinal()
        	{
            	return cipher.DoFinal();
        	}
        	public byte[] DoFinal(byte[] buffer)
        	{
           	return cipher.DoFinal(buffer);
        	}
        	public byte[] DoFinal(byte[] buffer, int startIndex, int len)
        	{
            	return cipher.DoFinal(buffer, startIndex, len);
        	}
        	public byte[] ProcessBytes(byte[] buffer)
        	{
            	return cipher.ProcessBytes(buffer);
        	}
        	public byte[] ProcessBytes(byte[] buffer, int startIndex, int len)
        	{
            	return cipher.ProcessBytes(buffer, startIndex, len);
        	}
        	public void   Reset()
        	{
            	cipher.Reset();
        	}
    	}
	}

in my other class i tried to test it so i made it like this
 	BlowfishCryptographer incomingCipher=new BlowfishCryptographer(true);
 	BlowfishCryptographer outgoingCipher=new BlowfishCryptographer(false);
	
	byte[] buffer = new byte[] { 0x83, 0x00, 0xEE, 0x03, 0x26, 0x6D, 0x14, 0x00, 0xF1, 0x65, 0x27, 0x00, 0x19, 0x02, 0xD8, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDB, 0xD7, 0x0F, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x41, 0x00, 0x64, 0x00, 0xE4, 0x00, 0x00, 0x00, 0xDD, 0x0A, 0x18, 0x19, 0x00, 0x00, 0x79, 0x91, 0x87, 0x00, 0x00, 0x01, 0x00, 0xA8, 0x02, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x34, 0x00, 0x6A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0A, 0x7E, 0x42, 0x6C, 0x75, 0x65, 0x57, 0x61, 0x76, 0x65, 0x7E, 0x00, 0x09, 0x42, 0x6C, 0x61, 0x63, 0x6B, 0x44, 0x75, 0x73, 0x74 };
	
	Console.WriteLine("\n\nBuffer\n" + outPutHex.ToHex(buffer));
            	Console.WriteLine("\n\nBuffer enc\n" + outPutHex.ToHex(outgoingCipher.DoFinal(buffer)));
            	Console.WriteLine("\n\nBuffer dec\n" + outPutHex.ToHex(incomingCipher.DoFinal(buffer)));

outputhex func will out put the result as hex

public static String ToHex(byte[] buf)
        	{
            	var builder = new StringBuilder();
            	foreach (var b in buf) builder.Append(b.ToString("X2")+ " ");
            	return builder.ToString();
        	} 
so the result is:

Buffer
	83 00 EE 03 26 6D 14 00 F1 65 27 00 19 02 D8 0F 00 00 00 00 00 00 DB D7 0F 08 00
 	00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2B 04 00 00 00 00 00 00 07 00 41 0
	0 64 00 E4 00 00 00 DD 0A 18 19 00 00 79 91 87 00 00 01 00 A8 02 00 00 64 00 00
	00 34 00 6A 18 00 00 00 00 00 00 C2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 	00 03 0A 7E 42 6C 75 65 57 61 76 65 7E 00 09 42 6C 61 63 6B 44 75 73 74
	
	
	Buffer enc
	EB 28 65 06 EF B5 B9 3E 01 2F D0 B4 C2 25 4C 9C E2 05 D8 B5 93 AC F9 0F 92 87 8B
 	5D 1E 45 F6 59 F8 FE 57 A8 0D CF 6C 6B E8 8D F9 88 A6 1D 6D 05 CC B8 6A 9F B0 8
	D 13 70 AB F6 3F F8 DD EA ED 16 C3 DB A6 77 B2 46 29 0B DA F4 E2 FF A4 BA 6F C0
	06 28 71 57 08 C8 EC 0F 65 54 13 46 C1 23 08 A5 28 C9 9F 9F 1D AD F9 66 09 A7 3B
 	E3 22 64 A3 A0 8C 90 BC 1A 99 F1 4F F6 73 49 32 10 78 7D CF FF 68 01 75
	
	
	Buffer dec
	EB 28 65 06 EF B5 B9 3E B7 BE A2 2A 3D 92 5F D5 CF E3 D5 09 C0 5B 9D AD 01 D6 E4
 	6D 73 3A 66 59 A9 83 10 11 80 FE 31 48 68 28 A0 01 C9 D8 AD 3E 38 B7 42 4B E5 E
	5 56 44 99 91 E8 72 F0 C9 2B AF 83 8C 35 33 6E 08 CA 1E F0 3F 59 E8 64 8D A6 1C
	CE 6E FF DC D6 3A FC D0 80 5B 36 81 06 FA 4E 0F 0B FA 54 CA C0 AD 32 52 68 28 8B
 	05 CA D2 D3 7C 90 48 93 71 99 CE 28 0B 38 F2 8E 93 74 2F B1 67 9E 68 3F

it's not working but why?

PARTNERS