Permalink
Please
sign in to comment.
Browse files
Added SkyBox - i've made test for it and added to multicraft.
- Loading branch information...
Showing
with
634 additions
and 158 deletions.
- BIN Aurora/Assets/Skybox/0Panorama.png
- BIN Aurora/Assets/Skybox/0Panorama_back.png
- BIN Aurora/Assets/Skybox/0Panorama_down.png
- BIN Aurora/Assets/Skybox/0Panorama_front.png
- BIN Aurora/Assets/Skybox/0Panorama_left.png
- BIN Aurora/Assets/Skybox/0Panorama_right.png
- BIN Aurora/Assets/Skybox/0Panorama_up.png
- BIN Aurora/Assets/Skybox/Panorama3.png
- BIN Aurora/Assets/Skybox/Panorama7.png
- +3 −4 Aurora/Aurora/Graphics/RenderManager.h
- +199 −0 Aurora/Aurora/Graphics/SkyBox.cpp
- +50 −0 Aurora/Aurora/Graphics/SkyBox.h
- +49 −3 Aurora/Aurora/Graphics/gu/GuRenderManager.cpp
- +2 −0 Aurora/Aurora/Graphics/gu/GuRenderManager.h
- +48 −148 Aurora/Aurora/Graphics/opengl/LegacyOpenGLRenderManager.cpp
- +2 −0 Aurora/Aurora/Graphics/opengl/LegacyOpenGLRenderManager.h
- +2 −0 Aurora/Build/Psp/makefile
- +4 −0 Aurora/Build/VS2012/Aurora.vcxproj
- +12 −0 Aurora/Build/VS2012/Aurora.vcxproj.filters
- +6 −0 Aurora/Games/Multicraft/Multicraft.vcxproj
- +21 −0 Aurora/Games/Multicraft/Multicraft.vcxproj.filters
- +1 −0 Aurora/Games/Multicraft/makefile
- +13 −2 Aurora/Games/Multicraft/src/PlayState.cpp
- +2 −0 Aurora/Games/Multicraft/src/PlayState.h
- +1 −0 Aurora/Starter.cpp
- +163 −0 Aurora/Tests/SkyBoxTest.cpp
- +56 −0 Aurora/Tests/SkyBoxTest.h
- +0 −1 Aurora/Tests/SpriteTest.cpp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,199 @@ | |||
| #include <Aurora/Graphics/SkyBox.h> | |||
| #include <Aurora/Graphics/RenderManager.h> | |||
| #include <Aurora/Graphics/TextureManager.h> | |||
|
|
|||
| namespace Aurora | |||
| { | |||
| namespace Graphics | |||
| { | |||
| SkyBox::SkyBox() | |||
| { | |||
| _position.set(0.0f,0.0f,0.0f); | |||
| _size.set(1.0f,1.0f,1.0f); | |||
|
|
|||
| _position = _position - _size / 2; | |||
|
|
|||
| _front = 0; | |||
| _back = 0; | |||
| _left = 0; | |||
| _right = 0; | |||
| _up = 0; | |||
| _down = 0; | |||
| } | |||
|
|
|||
| SkyBox::~SkyBox() | |||
| { | |||
| if (_front != 0) | |||
| { | |||
| delete _front; | |||
| } | |||
|
|
|||
| if (_back != 0) | |||
| { | |||
| delete _back; | |||
| } | |||
|
|
|||
| if (_left != 0) | |||
| { | |||
| delete _left; | |||
| } | |||
|
|
|||
| if (_right != 0) | |||
| { | |||
| delete _right; | |||
| } | |||
|
|
|||
| if (_up != 0) | |||
| { | |||
| delete _up; | |||
| } | |||
|
|
|||
| if (_down != 0) | |||
| { | |||
| delete _down; | |||
| } | |||
| } | |||
|
|
|||
| void SkyBox::LoadImage(const char* fileName,SkyFace skyFace) | |||
| { | |||
| switch (skyFace) | |||
| { | |||
| case Aurora::Graphics::Front: | |||
| { | |||
| _front = new Image(); | |||
| _front = TextureManager::Instance()->loadImageFromFile(fileName); | |||
| } | |||
| break; | |||
| case Aurora::Graphics::Back: | |||
| { | |||
| _back = new Image(); | |||
| _back = TextureManager::Instance()->loadImageFromFile(fileName); | |||
| } | |||
| break; | |||
| case Aurora::Graphics::Left: | |||
| { | |||
| _left = new Image(); | |||
| _left = TextureManager::Instance()->loadImageFromFile(fileName); | |||
| } | |||
| break; | |||
| case Aurora::Graphics::Right: | |||
| { | |||
| _right = new Image(); | |||
| _right = TextureManager::Instance()->loadImageFromFile(fileName); | |||
| } | |||
| break; | |||
| case Aurora::Graphics::Up: | |||
| { | |||
| _up = new Image(); | |||
| _up = TextureManager::Instance()->loadImageFromFile(fileName); | |||
| } | |||
| break; | |||
| case Aurora::Graphics::Down: | |||
| { | |||
| _down = new Image(); | |||
| _down = TextureManager::Instance()->loadImageFromFile(fileName); | |||
| } | |||
| break; | |||
| default: | |||
| break; | |||
| } | |||
| } | |||
|
|
|||
| void SkyBox::SetPositionSize(Vector3 position,Vector3 size) | |||
| { | |||
| _position = position; | |||
| _size = size; | |||
|
|
|||
| _position = _position - _size / 2; | |||
| } | |||
|
|
|||
| void SkyBox::Draw() | |||
| { | |||
| RenderManager::Instance()->SetColor(0xffffffff); | |||
|
|
|||
| RenderManager::Instance()->SetDepthTest(false); | |||
| RenderManager::Instance()->SetDepthMask(false); | |||
|
|
|||
| //back | |||
| { | |||
| TexturedVertex* vertices = (TexturedVertex*)RenderManager::Instance()->CreateVertexObject(Textured,4); | |||
|
|
|||
| vertices[0].u = 0.0f; vertices[0].v = 1.0f;vertices[0].x =_position.x ;vertices[0].y =_position.y ;vertices[0].z =_position.z; | |||
| vertices[1].u = 1.0f; vertices[1].v = 1.0f;vertices[1].x =_position.x + _size.x ;vertices[1].y =_position.y ;vertices[1].z =_position.z; | |||
| vertices[2].u = 0.0f; vertices[2].v = 0.0f;vertices[2].x =_position.x ;vertices[2].y =_position.y + _size.y ;vertices[2].z =_position.z; | |||
| vertices[3].u = 1.0f; vertices[3].v = 0.0f;vertices[3].x =_position.x + _size.x ;vertices[3].y =_position.y + _size.y ;vertices[3].z =_position.z; | |||
|
|
|||
| RenderManager::Instance()->bindTexture(_back); | |||
| RenderManager::Instance()->DrawVertexObject(vertices,4,true,Textured,TriangleStrip); | |||
| } | |||
|
|
|||
| //front | |||
| { | |||
| TexturedVertex* vertices = (TexturedVertex*)RenderManager::Instance()->CreateVertexObject(Textured,4); | |||
|
|
|||
| vertices[0].u = 1.0f; vertices[0].v = 1.0f;vertices[0].x =_position.x ;vertices[0].y =_position.y ;vertices[0].z =_position.z + _size.z; | |||
| vertices[1].u = 1.0f; vertices[1].v = 0.0f;vertices[1].x =_position.x ;vertices[1].y =_position.y + _size.y ;vertices[1].z =_position.z + _size.z; | |||
| vertices[2].u = 0.0f; vertices[2].v = 1.0f;vertices[2].x =_position.x + _size.x ;vertices[2].y =_position.y ;vertices[2].z =_position.z + _size.z; | |||
| vertices[3].u = 0.0f; vertices[3].v = 0.0f;vertices[3].x =_position.x + _size.x ;vertices[3].y =_position.y + _size.y ;vertices[3].z =_position.z + _size.z; | |||
|
|
|||
| RenderManager::Instance()->bindTexture(_front); | |||
| RenderManager::Instance()->DrawVertexObject(vertices,4,true,Textured,TriangleStrip); | |||
| } | |||
|
|
|||
| //down | |||
| { | |||
| TexturedVertex* vertices = (TexturedVertex*)RenderManager::Instance()->CreateVertexObject(Textured,4); | |||
|
|
|||
| vertices[0].u = 1.0f; vertices[0].v = 1.0f;vertices[0].x =_position.x ;vertices[0].y =_position.y ;vertices[0].z =_position.z; | |||
| vertices[1].u = 1.0f; vertices[1].v = 0.0f;vertices[1].x =_position.x ;vertices[1].y =_position.y ;vertices[1].z =_position.z + _size.z; | |||
| vertices[2].u = 0.0f; vertices[2].v = 1.0f;vertices[2].x =_position.x + _size.x ;vertices[2].y =_position.y ;vertices[2].z =_position.z; | |||
| vertices[3].u = 0.0f; vertices[3].v = 0.0f;vertices[3].x =_position.x + _size.x ;vertices[3].y =_position.y ;vertices[3].z =_position.z + _size.z; | |||
|
|
|||
| RenderManager::Instance()->bindTexture(_down); | |||
| RenderManager::Instance()->DrawVertexObject(vertices,4,true,Textured,TriangleStrip); | |||
| } | |||
|
|
|||
| //up | |||
| { | |||
| TexturedVertex* vertices = (TexturedVertex*)RenderManager::Instance()->CreateVertexObject(Textured,4); | |||
|
|
|||
| vertices[0].u = 1.0f; vertices[0].v = 0.0f;vertices[0].x =_position.x ;vertices[0].y =_position.y + _size.y ;vertices[0].z =_position.z; | |||
| vertices[1].u = 0.0f; vertices[1].v = 0.0f;vertices[1].x =_position.x + _size.x ;vertices[1].y =_position.y + _size.y ;vertices[1].z =_position.z; | |||
| vertices[2].u = 1.0f; vertices[2].v = 1.0f;vertices[2].x =_position.x ;vertices[2].y =_position.y + _size.y ;vertices[2].z =_position.z + _size.z; | |||
| vertices[3].u = 0.0f; vertices[3].v = 1.0f;vertices[3].x =_position.x + _size.x ;vertices[3].y =_position.y + _size.y ;vertices[3].z =_position.z + _size.z; | |||
|
|
|||
| RenderManager::Instance()->bindTexture(_up); | |||
| RenderManager::Instance()->DrawVertexObject(vertices,4,true,Textured,TriangleStrip); | |||
| } | |||
|
|
|||
| //right | |||
| { | |||
| TexturedVertex* vertices = (TexturedVertex*)RenderManager::Instance()->CreateVertexObject(Textured,4); | |||
|
|
|||
| vertices[0].u = 1.0f; vertices[0].v = 1.0f;vertices[0].x =_position.x ;vertices[0].y =_position.y ;vertices[0].z =_position.z; | |||
| vertices[1].u = 1.0f; vertices[1].v = 0.0f;vertices[1].x =_position.x ;vertices[1].y =_position.y + _size.y ;vertices[1].z =_position.z; | |||
| vertices[2].u = 0.0f; vertices[2].v = 1.0f;vertices[2].x =_position.x ;vertices[2].y =_position.y ;vertices[2].z =_position.z + _size.z; | |||
| vertices[3].u = 0.0f; vertices[3].v = 0.0f;vertices[3].x =_position.x ;vertices[3].y =_position.y + _size.y ;vertices[3].z =_position.z + _size.z; | |||
|
|
|||
| RenderManager::Instance()->bindTexture(_right); | |||
| RenderManager::Instance()->DrawVertexObject(vertices,4,true,Textured,TriangleStrip); | |||
| } | |||
|
|
|||
| //left | |||
| { | |||
| TexturedVertex* vertices = (TexturedVertex*)RenderManager::Instance()->CreateVertexObject(Textured,4); | |||
|
|
|||
| vertices[0].u = 0.0f; vertices[0].v = 1.0f;vertices[0].x =_position.x + _size.x ;vertices[0].y =_position.y ;vertices[0].z =_position.z; | |||
| vertices[1].u = 1.0f; vertices[1].v = 1.0f;vertices[1].x =_position.x + _size.x ;vertices[1].y =_position.y ;vertices[1].z =_position.z + _size.z; | |||
| vertices[2].u = 0.0f; vertices[2].v = 0.0f;vertices[2].x =_position.x + _size.x ;vertices[2].y =_position.y + _size.y ;vertices[2].z =_position.z; | |||
| vertices[3].u = 1.0f; vertices[3].v = 0.0f;vertices[3].x =_position.x + _size.x ;vertices[3].y =_position.y + _size.y ;vertices[3].z =_position.z + _size.z; | |||
|
|
|||
| RenderManager::Instance()->bindTexture(_left); | |||
| RenderManager::Instance()->DrawVertexObject(vertices,4,true,Textured,TriangleStrip); | |||
| } | |||
|
|
|||
| RenderManager::Instance()->SetDepthTest(true); | |||
| RenderManager::Instance()->SetDepthMask(true); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| #ifndef SKYBOX_H | |||
| #define SKYBOX_H | |||
|
|
|||
| #include <Aurora/Graphics/Image.h> | |||
| #include <Aurora/Math/Vector3.h> | |||
|
|
|||
| using namespace Aurora::Math; | |||
|
|
|||
| namespace Aurora | |||
| { | |||
| namespace Graphics | |||
| { | |||
| enum SkyFace | |||
| { | |||
| Front, | |||
| Back, | |||
| Left, | |||
| Right, | |||
| Up, | |||
| Down | |||
| }; | |||
|
|
|||
| class SkyBox | |||
| { | |||
| private: | |||
|
|
|||
| Image* _front; | |||
| Image* _back; | |||
| Image* _left; | |||
| Image* _right; | |||
| Image* _up; | |||
| Image* _down; | |||
|
|
|||
| Vector3 _position; | |||
| Vector3 _size; | |||
|
|
|||
| public: | |||
|
|
|||
| SkyBox(); | |||
| ~SkyBox(); | |||
|
|
|||
| void LoadImage(const char* fileName,SkyFace skyFace); | |||
| void SetPositionSize(Vector3 position,Vector3 size); | |||
|
|
|||
| void Draw(); | |||
| }; | |||
| } | |||
| } | |||
|
|
|||
| #endif | |||
Oops, something went wrong.
0 comments on commit
18ce0fb