Skip to content

Commit

Permalink
fix compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
reuben1990 committed Feb 20, 2015
1 parent 6901385 commit 2b2c645
Show file tree
Hide file tree
Showing 29 changed files with 542 additions and 490 deletions.
649 changes: 326 additions & 323 deletions build/proj_mac/proj_mac.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
endingColumnNumber = "9223372036854775807"
startingLineNumber = "128"
endingLineNumber = "128"
landmarkName = "-keyUp:"
landmarkName = "-mouseUp:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
Expand Down Expand Up @@ -88,7 +88,9 @@
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "19"
endingLineNumber = "19">
endingLineNumber = "19"
landmarkName = "TinyRenderSystem::TinyRenderSystem()"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand Down Expand Up @@ -148,9 +150,7 @@
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "58"
endingLineNumber = "58"
landmarkName = "TinyRenderSystem::updateAllRenderTargets()"
landmarkType = "5">
endingLineNumber = "58">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand Down
5 changes: 0 additions & 5 deletions external/kazmath/vec2.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ struct kmMat3;
#pragma pack(push) /* push current alignment to stack */
#pragma pack(1) /* set alignment to 1 byte boundary */
typedef struct kmVec2 {
kmVec2(kmScalar x, kmScalar y)
{
x = x;
y = y;
}
kmScalar x;
kmScalar y;
} kmVec2;
Expand Down
49 changes: 41 additions & 8 deletions sample/sample_ocean/OceanDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,67 @@
#include "TinyRoot.h"
#include "TinyMemoryAlloc.h"
#include "TinySceneManager.h"
#include "TinyDelegate.h"
#include "TinyPlatform.h"
#include "TinyTextureManager.h";
#include "TinyRenderWindow.h"
#include "kazmath/kazmath.h"
#include "TinyEntityFactory.h"
#include "TinyEntity.h";
#include "TinyMath.h"

namespace Tiny
{
void TinyDelegate::initialize()
{
//Create TinyRoot.
TinyRoot* root = TINY_NEW TinyRoot();

//Create render window.
TinyRenderWindow* mainWindow = tinyCreateRenderWindow(0, 0);
root->attachRenderTarget(mainWindow);

//Init scene graph.
TinySceneManager* sceneMgr = root->createSceneManager();
TinyNode* rootNode = sceneMgr->getRootSceneNode();
TinySceneNode* secondNode = rootNode->createChildSceneNode();
secondNode->setPosition(kmVec2(0.1, 0.1));
rootNode->addChild(secondNode);
TinySceneNode* rootNode = sceneMgr->getRootSceneNode();
//Entity node.
TinySceneNode* entityNode = rootNode->createChildSceneNode();
kmVec3 entityNodePosition = kmVec3Make(0, 0, -0.5);
entityNode->setPosition(entityNodePosition);
rootNode->addChild(entityNode);
//Camera node.
TinySceneNode* cameraNode = rootNode->createChildSceneNode();
kmVec3 cameraNodePosition = kmVec3Make(0, 0, 0);
cameraNode->setPosition(cameraNodePosition);
rootNode->addChild(cameraNode);

//Create an entity and attach it to our scene graph.
TinyEntityFactory* factory = root->getMovableObjectFactory("Entity");
TinyEntity* entity = factory->createInstance();
secondNode->attachObject(entity);
entityNode->attachObject(entity);

//Create camera.
TinyCamera* camera = TINY_NEW TinyCamera();
mainWindow->addViewPort(camera);
cameraNode->attachObject(camera);


TinyTexture* texture = TinyTextureManager::getSingleton()->load("abc.png");
//Create a diffuse texture.
TinyTexture* texture = TinyTextureManager::getSingleton()->load("first_demo.png");

TinyProgram* program = TinyProgramManager::getSingleton()->load("abc.vs", "abc.fs");
//Create a gpu program, set diffuse texture to our program as parameter.
TinyProgram* program = TinyProgramManager::getSingleton()->load("first_demo.vs", "first_demo.fs");
TinyGPUProgramParameter param;
param.mName = "diffuseTexture"
param.mType = GP_SAMPLER
param.mBindData = texture->getHandlerPtr();
program->setParameter(const TinyGPUProgramParameter& value);

TinyMaterial* material = TinyMaterialManager::getSingleton()->load("abc.material");
//Create material with gpu program. TODO assemble program form script.
TinyMaterial* material = TinyMaterialManager::getSingleton()->load("first_demo.material");
material->setProgram(program);

//Set the material to entity.
entity->setMaterial(material);
}
}
105 changes: 53 additions & 52 deletions tiny3d_main/TinyCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,72 +9,73 @@
#include "TinyCamera.h"
#include "TinyMath.h"

TinyCamera::TinyCamera(std::string &name, TinySceneManager *mgr)
: mSceneMgr(mgr)
, mName(name);
, mLastViewPort(nullptr)
, mFov(kTinyPI / 4)
, mAspect(4 / 3)
, mNear(10)
, mFar(1000)
namespace Tiny
{

}

TinyCamera::~TinyCamera()
{

}
TinyCamera::TinyCamera(std::string &name, TinySceneManager *mgr)
: TinyMovableObject(name)
, mSceneMgr(mgr)
, mName(name)
, mLastViewPort(nullptr)
, mFov(kTinyPI / 4)
, mAspect(4 / 3)
, mNear(10)
, mFar(1000)
{

}

void TinyCamera::renderScene(TinyViewPort *viewPort)
{
notifyViewPort(viewPort);
mSceneMgr->renderScene(this);
}
TinyCamera::~TinyCamera()
{

}

void TinyCamera::notifyViewPort(TinyViewPort *vp)
{
mLastViewPort = vp;
auto vpSize = vp->getViewPortSize()
mAspect = vpSize.x / vpSize.y;

}
void TinyCamera::renderScene(TinyViewPort *viewPort)
{
notifyViewPort(viewPort);
mSceneMgr->renderScene(this);
}

TinyViewPort *TinyCamera::getViewPort()
{
return mLastViewPort;
}
void TinyCamera::notifyViewPort(TinyViewPort *vp)
{
mLastViewPort = vp;
auto vpSize = vp->getViewPortSize();
mAspect = vpSize.x / vpSize.y;

}

kmMat4& TinyViewPort::getViewMatrix()
{
kmMat4 ret;
if (mParentNode)
TinyViewPort *TinyCamera::getViewPort()
{
auto parentNodeDerivedOrientation = mParentNode->getDerivedOrientation();
auto parentNodeDerivedPosition = mParentNode->getDerivedPosition();
auto frontDir = kmVec3(0, 0, -1);
auto upDir = kmVec3(0, 1, 0);
kmVec3 worldFrontDir, worldUpDir, worldCenter;
kmQuaternionMultiplyVec3(&worldFrontDir, &parentNodeDerivedOrientation, &frontDir);
kmQuaternionMultiplyVec3(&worldUpDir, &parentNodeDerivedOrientation, &upDir);
kmVec3Add(&worldCenter, &parentNodeDerivedPosition, &frontDir);
kmMat4LookAt(&ret, &parentNodeDerivedPosition, &worldCenter, &worldUpDir);
return mLastViewPort;
}
else

void TinyCamera::getViewMatrix(kmMat4& ret)
{
kmMat4Identity(&ret);
if (mParentNode)
{
auto parentNodeDerivedOrientation = mParentNode->getDerivedOrientation();
auto parentNodeDerivedPosition = mParentNode->getDerivedPosition();
auto frontDir = kmVec3Make(0, 0, -1);
auto upDir = kmVec3Make(0, 1, 0);
kmVec3 worldFrontDir, worldUpDir, worldCenter;
kmQuaternionMultiplyVec3(&worldFrontDir, &parentNodeDerivedOrientation, &frontDir);
kmQuaternionMultiplyVec3(&worldUpDir, &parentNodeDerivedOrientation, &upDir);
kmVec3Add(&worldCenter, &parentNodeDerivedPosition, &frontDir);
kmMat4LookAt(&ret, &parentNodeDerivedPosition, &worldCenter, &worldUpDir);
}
else
{
kmMat4Identity(&ret);
}
}
return ret;
}

kmMat4& TinyViewPort::getProjectionMatrix()
{
kmMat4 ret;
kmMat4PerspectiveProjection(&ret, mFov, mAspect, mNear, mFar);
return ret;
void TinyCamera::getProjectionMatrix(kmMat4& ret)
{
kmMat4PerspectiveProjection(&ret, mFov, mAspect, mNear, mFar);
}
}


//- (void)updateInput:(NSTimeInterval)timeInterval
//{
// kmVec3 f, s, u;
Expand Down
33 changes: 9 additions & 24 deletions tiny3d_main/TinyCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,18 @@
// Copyright (c) 2015 reuben chao. All rights reserved.
//

#ifndef proj_mac_TinyCamera_h
#define proj_mac_TinyCamera_h

#include "kazmath/kazmath.h"
#include "GSInputController.h"
#include "TinyObject.h"

//@interface GSCameraController : NSObject<GSInputDelegate>
//
//@property (nonatomic, readonly) kmVec3 eye;
//@property (nonatomic, readonly) kmVec3 center;
//@property (nonatomic, readonly) kmVec3 up;
//@property (nonatomic, readwrite) float moveSpeed;
//@property (nonatomic, readwrite) float rotateSpeed;
//@property (nonatomic, readwrite) float fov;
//@property (nonatomic, readwrite) float aspect;
//@property (nonatomic, readwrite) float near;
//@property (nonatomic, readwrite) float far;
//
//- (id)initWithEye:(kmVec3)eye Center:(kmVec3)center Up:(kmVec3)up;
//
//- (kmMat4)viewMatrix;
//- (kmMat4)perspectiveMatrix;
//
//@end

#include "TinySceneManager.h"
#include "TinyMovableObject.h"
#include "TinyViewPort.h"
#include <string>

class TinySceneManager;

namespace Tiny
{
class TinyCamera : public TinyMovableObject
Expand All @@ -43,8 +28,8 @@ namespace Tiny
void renderScene(TinyViewPort *viewPort);
void notifyViewPort(TinyViewPort *vp);
TinyViewPort *getViewPort();
kmMat4& getViewMatrix();
kmMat4& getProjectionMatrix();
void getViewMatrix(kmMat4& ret);
void getProjectionMatrix(kmMat4& ret);
private:
TinyViewPort *mLastViewPort;
TinySceneManager *mSceneMgr;
Expand All @@ -56,6 +41,6 @@ namespace Tiny
};
}


#endif


3 changes: 2 additions & 1 deletion tiny3d_main/TinyGPUProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "TinyObject.h"
#include <string>
#include <map>
#include "TinyPlatform.h"

namespace Tiny
{
Expand Down Expand Up @@ -46,7 +47,7 @@ namespace Tiny
class TinyGPUProgramParameters : public TinyObject
{
public:
TinyGPUProgramParameters()
TinyGPUProgramParameters();
~TinyGPUProgramParameters();
void setParameter(const TinyGPUProgramParameter& value);
void bindParametersToProgram(GLuint program);
Expand Down
5 changes: 3 additions & 2 deletions tiny3d_main/TinyImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#include <stdio.h>
#include "TinyImage"
#include "TinyImage.h"

namespace Tiny
{
Expand All @@ -22,7 +22,8 @@ namespace Tiny
auto iter = mDataList.begin();
for (; iter != mDataList.end(); iter ++)
{
free(iter->second);
uint8* data = *iter;
free(data);
}
}
}
5 changes: 3 additions & 2 deletions tiny3d_main/TinyMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
//

#include "TinyMaterial.h"
#include "TinyMemoryAlloc.h"

namespace Tiny
{
TinyMaterial::TinyMaterial()
: mIsTransParent(false);
: mProgram(nullptr)
: mIsTransParent(false)
, mProgram(nullptr)
{

}
Expand Down
3 changes: 2 additions & 1 deletion tiny3d_main/TinyMovableObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "TinyObject.h"
#include <string>
#include "kazmath/kazmath.h"
#include "TinyCamera.h"

class TinyNode;

Expand All @@ -26,7 +27,7 @@ namespace Tiny {
std::string& getName();
void setName(std::string& name);
void notifyAttached(TinyNode* node);
void updateRenderQueue(TinyCamera* cam, TinyRenderQueue* queue) = 0;
virtual void updateRenderQueue(TinyCamera* cam, TinyRenderQueue* queue) = 0;
protected:
std::string mName;
TinyNode* mParentNode;
Expand Down
2 changes: 1 addition & 1 deletion tiny3d_main/TinyMovableObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 reuben chao. All rights reserved.
//

#include "MovableObjectFactory.h"
#include "TinyMovableObjectFactory.h"

namespace Tiny
{
Expand Down
Loading

0 comments on commit 2b2c645

Please sign in to comment.