Permalink
Browse files

IMPLEMENTED: Transformation.GetMatrix,

Transformation.GetInverseMatrix, Node.Update
  • Loading branch information...
1 parent e910b5f commit 8084e5291341b5e30dcb9a596e70dd177ef40053 @gnuvince committed Jan 24, 2012
Showing with 2,895 additions and 6 deletions.
  1. +4 −0 .gitignore
  2. +7 −4 Application/Sources/Scene/Boat.cpp
  3. +3 −2 Application/Sources/Scene/MainScene.cpp
  4. +62 −0 CoreLib/Includes/CoreLib/BlinnPhongMaterial.h
  5. +108 −0 CoreLib/Includes/CoreLib/Camera.h
  6. +31 −0 CoreLib/Includes/CoreLib/CameraNode.h
  7. +80 −0 CoreLib/Includes/CoreLib/Color.h
  8. +16 −0 CoreLib/Includes/CoreLib/Color.inl
  9. +36 −0 CoreLib/Includes/CoreLib/Cone.h
  10. +35 −0 CoreLib/Includes/CoreLib/Cube.h
  11. +39 −0 CoreLib/Includes/CoreLib/CubeMap.h
  12. +36 −0 CoreLib/Includes/CoreLib/Cylinder.h
  13. +33 −0 CoreLib/Includes/CoreLib/DirectionalLight.h
  14. +32 −0 CoreLib/Includes/CoreLib/EnvironmentMaterial.h
  15. +21 −0 CoreLib/Includes/CoreLib/FileUtilities.h
  16. +46 −0 CoreLib/Includes/CoreLib/GLSLBlinnPhongProgram.h
  17. +34 −0 CoreLib/Includes/CoreLib/GLSLEnvironmentProgram.h
  18. +78 −0 CoreLib/Includes/CoreLib/GLSLProgram.h
  19. +33 −0 CoreLib/Includes/CoreLib/GLSLProgramFactory.h
  20. +40 −0 CoreLib/Includes/CoreLib/GLSLProgramManager.h
  21. +37 −0 CoreLib/Includes/CoreLib/GLSLShader.h
  22. +32 −0 CoreLib/Includes/CoreLib/Geometry.h
  23. +61 −0 CoreLib/Includes/CoreLib/GeometryBuffer.h
  24. +33 −0 CoreLib/Includes/CoreLib/GeometryRenderer.h
  25. +56 −0 CoreLib/Includes/CoreLib/HeightField.h
  26. +50 −0 CoreLib/Includes/CoreLib/Image2D.h
  27. +83 −0 CoreLib/Includes/CoreLib/Image2D.inl
  28. +21 −0 CoreLib/Includes/CoreLib/Image2DImporter.h
  29. +21 −0 CoreLib/Includes/CoreLib/Image2DPngImporter.h
  30. +45 −0 CoreLib/Includes/CoreLib/Light.h
  31. +30 −0 CoreLib/Includes/CoreLib/LightNode.h
  32. +64 −0 CoreLib/Includes/CoreLib/Log.h
  33. +68 −0 CoreLib/Includes/CoreLib/Log.inl
  34. +36 −0 CoreLib/Includes/CoreLib/Material.h
  35. +98 −0 CoreLib/Includes/CoreLib/Matrix3.h
  36. +21 −0 CoreLib/Includes/CoreLib/Matrix3.inl
  37. +104 −0 CoreLib/Includes/CoreLib/Matrix4.h
  38. +28 −0 CoreLib/Includes/CoreLib/Matrix4.inl
  39. +78 −0 CoreLib/Includes/CoreLib/Node.h
  40. +37 −0 CoreLib/Includes/CoreLib/Object.h
  41. +38 −0 CoreLib/Includes/CoreLib/Plane.h
  42. +26 −0 CoreLib/Includes/CoreLib/PointLight.h
  43. +65 −0 CoreLib/Includes/CoreLib/Quaternion.h
  44. +62 −0 CoreLib/Includes/CoreLib/RenderState.h
  45. +126 −0 CoreLib/Includes/CoreLib/Scene.h
  46. +36 −0 CoreLib/Includes/CoreLib/Sphere.h
  47. +36 −0 CoreLib/Includes/CoreLib/SpotLight.h
  48. +39 −0 CoreLib/Includes/CoreLib/StdDefinition.h
  49. +27 −0 CoreLib/Includes/CoreLib/TexturableMaterial.h
  50. +39 −0 CoreLib/Includes/CoreLib/Texture.h
  51. +39 −0 CoreLib/Includes/CoreLib/Texture2D.h
  52. +22 −0 CoreLib/Includes/CoreLib/Timer.h
  53. +86 −0 CoreLib/Includes/CoreLib/Transformation.h
  54. +51 −0 CoreLib/Includes/CoreLib/TurntableCamera.h
  55. +59 −0 CoreLib/Includes/CoreLib/Vector.h
  56. +76 −0 CoreLib/Includes/CoreLib/Vector2.h
  57. +14 −0 CoreLib/Includes/CoreLib/Vector2.inl
  58. +81 −0 CoreLib/Includes/CoreLib/Vector3.h
  59. +15 −0 CoreLib/Includes/CoreLib/Vector3.inl
  60. +82 −0 CoreLib/Includes/CoreLib/Vector4.h
  61. +16 −0 CoreLib/Includes/CoreLib/Vector4.inl
  62. +27 −0 CoreLib/Includes/CoreLib/Vertex.h
  63. +42 −0 CoreLib/Includes/CoreLib/VisualNode.h
  64. +10 −0 CoreLib/Sources/BaseTypes/Transformation.cpp
  65. +4 −0 CoreLib/Sources/Scene/Objects/Node.cpp
View
@@ -1 +1,5 @@
*.o
+*.d
+core.*
+*.a
+Application
@@ -1,5 +1,6 @@
#include "Boat.h"
#include "MainWindow.h"
+#include "CoreLib/Cube.h"
using namespace CoreLib;
@@ -16,6 +17,8 @@ Boat::Boat()
// un Node<real> vous pouvez attacher ses
// sous-objet à l'aide de la méthode this->AddChild(...)
///////////////////////////////////////
+ Cube<real> *platform = new Cube<real>(10, 2, 10);
+ this->AddChild(platform);
// Size definition
///////////////////////////////////////
@@ -63,9 +66,9 @@ void Boat::Animate( const WaterSurface& waterSurface, real time, real dt )
{
///////////////////////////////////////
// IFT3355
- // Ici vous devrez gérer la rotation et
+ // Ici vous devrez gérer la rotation et
// la translation dû au mouvement de l'eau.
- // La méthode GetGlobalWithHeight() de la
+ // La méthode GetGlobalWithHeight() de la
// classe parent HeightFieldprend une
// position dans le repère global en entrée et
// retourne la même position, mais en ajustant la
@@ -83,14 +86,14 @@ void Boat::Animate( const WaterSurface& waterSurface, real time, real dt )
real Boat::GetSizeZ() const
{
- // Vous pouvez remplacer cette valeur au besoin.
+ // Vous pouvez remplacer cette valeur au besoin.
//Elle doit correspondre à la taille de la coque du bateau
return 2;
}
real Boat::GetSizeX() const
{
- // Vous pouvez remplacer cette valeur au besoin.
+ // Vous pouvez remplacer cette valeur au besoin.
//Elle doit correspondre à la taille de la coque du bateau
return 1;
}
@@ -88,8 +88,9 @@ void MainScene::CreateCamera()
// Lorsque le bateau sera fonctionnel,
// vous devrez lui attacher la caméra, remplaçant
// donc la ligne ci-dessous
- ///////////////////////////////////////
- mSceneGraph.AddChild( &mCamera );
+ ///////////////////////////////////////
+ mBoat.AddChild( &mCamera );
+ //mSceneGraph.AddChild( &mCamera );
}
void MainScene::CreateLights()
@@ -0,0 +1,62 @@
+#ifndef _CORELIB_BLINNPHONGMATERIAL_H_
+#define _CORELIB_BLINNPHONGMATERIAL_H_
+
+#include "StdDefinition.h"
+#include "Material.h"
+#include "Color.h"
+#include "Texture2D.h"
+#include "TexturableMaterial.h"
+#include "CubeMap.h"
+#include <vector>
+
+namespace CoreLib
+{
+
+template<typename real>
+class GLSLProgram;
+
+template<typename real>
+class BlinnPhongMaterial : public Material, public TexturableMaterial
+{
+public:
+ BlinnPhongMaterial();
+
+ virtual Material::Type GetMaterialType() const;
+ virtual void Setup();
+
+ // 'Setters'
+ void SetSurface( const Color<real>& surface );
+ void SetSpecular( const Color<real>& specular );
+ void SetReflection( const Color<real>& reflection );
+ void SetRefraction( const Color<real>& refraction );
+ void SetRefractionIndex( real refractionIndex );
+ void SetShininess( real shininess );
+ void SetWireframe( bool isWireframe );
+ void SetEnvironment( CubeMap* environment );
+
+ // 'Getters'
+ const Color<real>& GetSurface() const;
+ const Color<real>& GetSpecular() const;
+ const Color<real>& GetReflection() const;
+ const Color<real>& GetRefraction() const;
+ real GetRefractionIndex() const;
+ real GetShininess() const;
+ bool IsWireframe() const;
+ const CubeMap* GetEnvironment() const;
+
+private:
+ Color<real> mSurface;
+ Color<real> mSpecular;
+ Color<real> mReflection;
+ Color<real> mRefraction;
+ real mRefractionIndex;
+ real mShininess;
+ bool mIsWireframe;
+ CubeMap* mEnvironment;
+};
+
+}
+
+#endif //_CORELIB_PHONGMATERIAL_H_
+
+
@@ -0,0 +1,108 @@
+#ifndef _CORELIB_CAMERA_H_
+#define _CORELIB_CAMERA_H_
+
+#include "StdDefinition.h"
+#include "CameraNode.h"
+#include "Matrix4.h"
+#include "Transformation.h"
+#include "Vector2.h"
+
+namespace CoreLib
+{
+
+template<typename real>
+class Camera : public CameraNode<real>
+{
+public:
+ enum CameraType
+ {
+ TypeStandard,
+ TypeTurntable
+ };
+
+ typedef Object::ObjectType ObjectType;
+
+public:
+ Camera();
+ virtual ~Camera();
+
+ virtual ObjectType GetObjectType() const;
+ virtual CameraType GetCameraType() const;
+ virtual void Update();
+
+ void SetFieldOfView( real fieldOview );
+ void SetAspectRatio( real aspectRatio );
+ void SetNearClipping( real nearClipping );
+ void SetFarClipping( real farClipping );
+ void SetPerspective();
+ void SetPerspective( real fieldOview, real aspectRatio, real nearClipping, real farClipping );
+ void SetViewHeight( real viewHeight );
+ void SetOrthogonal();
+ void SetOrthogonal( real viewHeight, real aspectRatio, real nearClipping, real farClipping );
+ void SetFocalDistance( real focalDistance );
+ void SetLensRadius( real lensRadius );
+ void SetViewport( const Vector2<int>& position, const Vector2<int>& size );
+
+ virtual const Matrix4<real>& GetProjectionMatrix();
+ virtual const Matrix4<real>& GetViewportMatrix();
+ const Matrix4<real>& GetCameraMatrix();
+
+ Vector3<real> GetPosition() const;
+ const Vector2<int>& GetViewportPosition() const;
+ const Vector2<int>& GetViewportSize() const;
+ real GetFocalDistance() const;
+ real GetLensRadius() const;
+ real GetNearClipping() const;
+ real GetFarClipping() const;
+ bool IsPerspective() const;
+ bool IsOrthogonal() const;
+
+protected:
+ enum DirtyMatrix
+ {
+ eProjectionMatrix = 1,
+ eViewportMatrix = 2,
+ eCameraMatrix = 4
+ };
+
+ enum ProjectionType
+ {
+ ePerspective = 1,
+ eOrthogonal = 2
+ };
+
+protected:
+ void SetDirtyOn( DirtyMatrix dirtyMatrix );
+ void SetDirtyOff( DirtyMatrix dirtyMatrix );
+ bool IsDirty( DirtyMatrix dirtyMatrix ) const;
+
+private:
+ DirtyMatrix mDirtyBits;
+ Matrix4<real> mProjectionMatrix;
+ Matrix4<real> mViewportMatrix;
+ Matrix4<real> mCameraMatrix;
+
+ // Projection information
+ ProjectionType mProjectionType;
+ Vector2<int> mViewportPosition;
+ Vector2<int> mViewportSize;
+ real mAspectRatio;
+ real mNearClipping;
+ real mFarClipping;
+
+ // Perspective camera
+ real mFieldOfView;
+
+ // Orthogonal camera
+ real mViewHeight;
+
+ // Depth of field
+ real mFocalDistance;
+ real mLensRadius;
+};
+
+}
+
+#endif //_CORELIB_CAMERA_H_
+
+
@@ -0,0 +1,31 @@
+#ifndef _CORELIB_CAMERANODE_H_
+#define _CORELIB_CAMERANODE_H_
+
+#include "StdDefinition.h"
+#include "Node.h"
+
+namespace CoreLib
+{
+
+template<typename real>
+class CameraNode : public Node<real>
+{
+public:
+ typedef typename Node<real>::NodeType NodeType;
+
+public:
+ CameraNode();
+ virtual ~CameraNode();
+
+ virtual NodeType GetNodeType() const;
+ virtual void Update();
+ virtual void Render();
+
+private:
+};
+
+}
+
+#endif //_CORELIB_CAMERANODE_H_
+
+
@@ -0,0 +1,80 @@
+#ifndef _CORELIB_COLOR_H_
+#define _CORELIB_COLOR_H_
+
+#include "StdDefinition.h"
+#include <iostream>
+#include <cmath>
+#include <cassert>
+
+namespace CoreLib
+{
+
+template<typename real>
+class Color
+{
+public:
+ // Constructors
+ Color( void );
+ Color( const Color& color );
+ Color( const real elements[4] );
+ Color( real in_R, real in_G, real in_B, real in_A );
+ template<typename real_> Color( const Color<real_>& color );
+
+ // Access functions
+ real& R();
+ real& G();
+ real& B();
+ real& A();
+ const real& R() const;
+ const real& G() const;
+ const real& B() const;
+ const real& A() const;
+ void R( real in_R );
+ void G( real in_G );
+ void B( real in_B );
+ void A( real in_A );
+
+ const real& operator[]( int index ) const;
+ real& operator[]( int index );
+ const real& operator()( int index ) const;
+ real& operator()( int index );
+
+ void Black();
+ void White();
+
+ // Operators
+ Color operator + ( const Color& color ) const;
+ Color operator - ( const Color& color ) const;
+ Color operator * ( const Color& color ) const;
+ Color operator * ( real constant ) const;
+ Color operator / ( real constant ) const;
+ Color operator - ( ) const;
+
+ Color& operator += ( const Color& color );
+ Color& operator -= ( const Color& color );
+ Color& operator *= ( const Color& color );
+ Color& operator *= ( real constant );
+ Color& operator /= ( real constant );
+
+ friend std::ostream& operator << ( std::ostream& ioStream, const Color<real>& color )
+ {
+ ioStream << "( " << color[0] << ", " << color[1] << ", " << color[2] << ", " << color[3] << " )";
+ return ioStream;
+ }
+
+ friend Color operator * ( real constant, const Color<real>& color )
+ {
+ return Color<real>( color.mElements[0] * constant, color.mElements[1] * constant, color.mElements[2] * constant, color.mElements[3] * constant );
+ }
+
+private:
+ real mElements[4];
+};
+
+}
+
+#include "Color.inl"
+
+#endif //_CORELIB_COLOR_H_
+
+
@@ -0,0 +1,16 @@
+namespace CoreLib
+{
+
+template<typename real>
+template<typename real_>
+Color<real>::Color( const Color<real_>& color )
+{
+ mElements[0] = color[0];
+ mElements[1] = color[1];
+ mElements[2] = color[2];
+ mElements[3] = color[3];
+}
+
+}
+
+
Oops, something went wrong.

0 comments on commit 8084e52

Please sign in to comment.