Updated ios and osx projects. Added some RenderCamera logic to RenderScene. Also added some basic code to main to test Render* functionality before the State machine is implemented.

master
kts 2015-02-10 21:44:05 -08:00
parent 1fa87fb90f
commit 30d4b87298
7 changed files with 137 additions and 5 deletions

43
LOGIC
View File

@ -110,3 +110,46 @@ The Render call would be:
- get MVP from camera, apply, and render
* for each RenderView
- render FBO to screen, additive? multiply?
,,,,,,,,,,,,,,,,,,,,,,,,
File Transmit Logic
````````````````````````
This section defines how File and Data transfer logic works.
First, file transmission is governed by the Server, who hosts the Campaign.
All files possess identifier IDs, as established by the Server.
DataFile {
std::string name; // e.g., "token1.png"
std::string id; // e.g., "a88bok4mp1323kd90ubv"
int type; // Type of binary data, DATA_IMAGE, DATA_SOUND, DATA_MESH, etc.
byte *data; // The binary data
size_t length; // length, in bytes, of binary data
};
DataFile(s) are transferred using a non-blocking push-pull method. When a client connects, the client receives a list of required DataFile ids. For every DataFile required, the client sends a DataFile request message consisting of either a blank checksum indicating no file, or the current checksum that the client has. If the checksum is blank or does not match the server's, the server will send the client the requested FileData. Each file will be checked and requested one at a time.
The message syntax for NetData is:
FILE_REQUEST:DataFile id:checksum
To which the server can respond:
FILE_ERROR:DataFile id
Somehow the server could not find the corresponding DataFile
FILE_SEND:DataFile id:count of bytes:bytes
sends bytes of DataFile to client. if count of bytes is 0, file is complete
FILE_OK:DataFile id
indicates checksum matches
,,,,,,,,,,,,,,,,,,,,,,,,
Terrain/Map Mesh
````````````````````````
Map terrain consists of two components:
* The base Mesh, which can be grid, hexagonal, etc.
* A terrain height modifier
The terrain modifier is a std::vector of Vec3(s). Each Vec3 indicates a height "displacement" that affects the base Mesh. In this way, height modifier(heightmap?) are separate from the underlying terrain Mesh, allowing users to switch between grid-based or hexagonal tile settings.
The method for modifying the base Mesh is to (multiply?) the "Y" of nearby Mesh vectors based on the distance to/from a near-by heightmap
The final Mesh (LiveMesh?) is used to draw the grid outlines(if selected), and to map another Mesh(or Texture?) onto it.

View File

@ -10,6 +10,9 @@
0097E2D912F70C4E00724AC5 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0097E2D512F70C4D00724AC5 /* libSDL2.a */; };
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
2056AE551A8A423E00833760 /* Mat4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE4F1A8A423E00833760 /* Mat4.cpp */; };
2056AE561A8A423E00833760 /* RenderObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE511A8A423E00833760 /* RenderObject.cpp */; };
2056AE571A8A423E00833760 /* Vec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE531A8A423E00833760 /* Vec.cpp */; };
20A7A91D1A89F91300EDC1A0 /* RenderCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20A7A9151A89F91300EDC1A0 /* RenderCamera.cpp */; };
20A7A91E1A89F91300EDC1A0 /* RenderScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20A7A9171A89F91300EDC1A0 /* RenderScene.cpp */; };
20A7A91F1A89F91300EDC1A0 /* RenderSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20A7A9191A89F91300EDC1A0 /* RenderSet.cpp */; };
@ -87,6 +90,12 @@
1D6058910D05DD3D006BFB54 /* Roll them Bones.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Roll them Bones.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
20020C301A8A006300F985D8 /* common.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = common.hpp; path = ../../src/common.hpp; sourceTree = SOURCE_ROOT; };
2056AE4F1A8A423E00833760 /* Mat4.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mat4.cpp; path = ../../src/Mat4.cpp; sourceTree = SOURCE_ROOT; };
2056AE501A8A423E00833760 /* Mat4.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Mat4.hpp; path = ../../src/Mat4.hpp; sourceTree = SOURCE_ROOT; };
2056AE511A8A423E00833760 /* RenderObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderObject.cpp; path = ../../src/RenderObject.cpp; sourceTree = SOURCE_ROOT; };
2056AE521A8A423E00833760 /* RenderObject.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RenderObject.hpp; path = ../../src/RenderObject.hpp; sourceTree = SOURCE_ROOT; };
2056AE531A8A423E00833760 /* Vec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Vec.cpp; path = ../../src/Vec.cpp; sourceTree = SOURCE_ROOT; };
2056AE541A8A423E00833760 /* Vec.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Vec.hpp; path = ../../src/Vec.hpp; sourceTree = SOURCE_ROOT; };
20A7A9151A89F91300EDC1A0 /* RenderCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderCamera.cpp; path = ../../src/RenderCamera.cpp; sourceTree = SOURCE_ROOT; };
20A7A9161A89F91300EDC1A0 /* RenderCamera.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RenderCamera.hpp; path = ../../src/RenderCamera.hpp; sourceTree = SOURCE_ROOT; };
20A7A9171A89F91300EDC1A0 /* RenderScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderScene.cpp; path = ../../src/RenderScene.cpp; sourceTree = SOURCE_ROOT; };
@ -217,6 +226,12 @@
20A7A9131A89F8F600EDC1A0 /* Classes */ = {
isa = PBXGroup;
children = (
2056AE4F1A8A423E00833760 /* Mat4.cpp */,
2056AE501A8A423E00833760 /* Mat4.hpp */,
2056AE511A8A423E00833760 /* RenderObject.cpp */,
2056AE521A8A423E00833760 /* RenderObject.hpp */,
2056AE531A8A423E00833760 /* Vec.cpp */,
2056AE541A8A423E00833760 /* Vec.hpp */,
20A7A9151A89F91300EDC1A0 /* RenderCamera.cpp */,
20A7A9161A89F91300EDC1A0 /* RenderCamera.hpp */,
20A7A9171A89F91300EDC1A0 /* RenderScene.cpp */,
@ -349,6 +364,9 @@
20A7A91E1A89F91300EDC1A0 /* RenderScene.cpp in Sources */,
20A7A91F1A89F91300EDC1A0 /* RenderSet.cpp in Sources */,
20A7A9201A89F91300EDC1A0 /* RenderView.cpp in Sources */,
2056AE551A8A423E00833760 /* Mat4.cpp in Sources */,
2056AE561A8A423E00833760 /* RenderObject.cpp in Sources */,
2056AE571A8A423E00833760 /* Vec.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -9,6 +9,9 @@
/* Begin PBXBuildFile section */
20138FCC1A3DC7A700FD0095 /* SDL2_image.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 20138FCB1A3DC7A700FD0095 /* SDL2_image.framework */; };
20138FCE1A3DC7A700FD0095 /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 20138FCD1A3DC7A700FD0095 /* SDL2.framework */; };
2056AE3C1A8A421500833760 /* Mat4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE361A8A421500833760 /* Mat4.cpp */; };
2056AE3D1A8A421500833760 /* RenderObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE381A8A421500833760 /* RenderObject.cpp */; };
2056AE3E1A8A421500833760 /* Vec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE3A1A8A421500833760 /* Vec.cpp */; };
205D36CE1A6749FB00C05BD8 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 205D36CD1A6749FB00C05BD8 /* main.cpp */; };
205D370C1A674B1D00C05BD8 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 205D370B1A674B1D00C05BD8 /* OpenGL.framework */; };
20A7A8D51A89E11200EDC1A0 /* RenderScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20A7A8D11A89E11200EDC1A0 /* RenderScene.cpp */; };
@ -23,6 +26,12 @@
20020C6F1A8A01EE00F985D8 /* common.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = common.hpp; path = ../../src/common.hpp; sourceTree = SOURCE_ROOT; };
20138FCB1A3DC7A700FD0095 /* SDL2_image.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2_image.framework; path = /Library/Frameworks/SDL2_image.framework; sourceTree = "<absolute>"; };
20138FCD1A3DC7A700FD0095 /* SDL2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2.framework; path = /Library/Frameworks/SDL2.framework; sourceTree = "<absolute>"; };
2056AE361A8A421500833760 /* Mat4.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mat4.cpp; path = ../../src/Mat4.cpp; sourceTree = SOURCE_ROOT; };
2056AE371A8A421500833760 /* Mat4.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Mat4.hpp; path = ../../src/Mat4.hpp; sourceTree = SOURCE_ROOT; };
2056AE381A8A421500833760 /* RenderObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderObject.cpp; path = ../../src/RenderObject.cpp; sourceTree = SOURCE_ROOT; };
2056AE391A8A421500833760 /* RenderObject.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RenderObject.hpp; path = ../../src/RenderObject.hpp; sourceTree = SOURCE_ROOT; };
2056AE3A1A8A421500833760 /* Vec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Vec.cpp; path = ../../src/Vec.cpp; sourceTree = SOURCE_ROOT; };
2056AE3B1A8A421500833760 /* Vec.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Vec.hpp; path = ../../src/Vec.hpp; sourceTree = SOURCE_ROOT; };
205D36CD1A6749FB00C05BD8 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = ../../src/main.cpp; sourceTree = SOURCE_ROOT; };
205D370B1A674B1D00C05BD8 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; };
20A7A8D11A89E11200EDC1A0 /* RenderScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderScene.cpp; path = ../../src/RenderScene.cpp; sourceTree = SOURCE_ROOT; };
@ -54,6 +63,12 @@
080E96DDFE201D6D7F000001 /* Classes */ = {
isa = PBXGroup;
children = (
2056AE361A8A421500833760 /* Mat4.cpp */,
2056AE371A8A421500833760 /* Mat4.hpp */,
2056AE381A8A421500833760 /* RenderObject.cpp */,
2056AE391A8A421500833760 /* RenderObject.hpp */,
2056AE3A1A8A421500833760 /* Vec.cpp */,
2056AE3B1A8A421500833760 /* Vec.hpp */,
20A7A8D11A89E11200EDC1A0 /* RenderScene.cpp */,
20A7A8D21A89E11200EDC1A0 /* RenderScene.hpp */,
20A7A8D31A89E11200EDC1A0 /* RenderSet.cpp */,
@ -205,6 +220,9 @@
20A8CE551A899B72004D2504 /* RenderView.cpp in Sources */,
20A7A8D51A89E11200EDC1A0 /* RenderScene.cpp in Sources */,
20A7A8D61A89E11200EDC1A0 /* RenderSet.cpp in Sources */,
2056AE3C1A8A421500833760 /* Mat4.cpp in Sources */,
2056AE3D1A8A421500833760 /* RenderObject.cpp in Sources */,
2056AE3E1A8A421500833760 /* Vec.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -4,8 +4,48 @@ RenderScene
This header file defines the RenderScene class.
================================================================ */
#include "RenderScene.hpp"
#include <stdexcept> // for std::out_of_range
#include <iostream> // for std::cerr
#include <algorithm> // for std::find
/* ======== Constructors and Destructors ======== */
RenderScene::RenderScene() {
}
RenderScene::~RenderScene() {
}
}
// This function adds the ptr to Camera and returns its "id" which is simply its index+1
int RenderScene::addCamera(RenderCamera* camera) {
try {
cameras.push_back(camera);
} catch(...) {
std::cerr << __PRETTY_FUNCTION__ << ": Could not add RenderCamera" << '\n';
}
// return size regardless of success, likely The Wrong Thing
return cameras.size();
}
int RenderScene::remCamera(int id) {
RenderCamera *camera = getCamera(id);
if (camera) {
cameras.erase(cameras.begin()+(id-1));
return 0;
}
return 1;
}
int RenderScene::remCamera(RenderCamera *camera) {
std::vector<RenderCamera*>::iterator it;
if ((it = std::find(cameras.begin(), cameras.end(), camera)) != cameras.end()) {
cameras.erase(it);
return 0;
}
return 1;
}
RenderCamera* RenderScene::getCamera(int id) {
try {
return cameras.at(id-1);
} catch (const std::out_of_range& oor) {
std::cerr << __PRETTY_FUNCTION__ << ": Camera index out of range: "
<< oor.what() << '\n';
}
return NULL;
}

View File

@ -17,8 +17,12 @@ class RenderScene {
public:
RenderScene();
~RenderScene();
int addCamera(RenderCamera* camera);
int remCamera(RenderCamera* camera);
int remCamera(int id);
RenderCamera* getCamera(int id);
private:
std::vector<RenderCamera> cameras; // Our scene's cameras
std::vector<RenderSet> render_sets; // Our scene's render sets
std::vector<RenderCamera*> cameras; // Our scene's cameras
std::vector<RenderSet*> render_sets; // Our scene's render sets
};
#endif

View File

@ -19,7 +19,7 @@ class RenderSet {
~RenderSet();
private:
int mode; // bitflag, 0 = normal, 1 = hide
std::vector<RenderObject> objects; // Our vector of objects to render
std::vector<RenderObject*> objects; // Our vector of objects to render
GLuint program; // Our rendering program
};
#endif

View File

@ -1,4 +1,7 @@
#include "common.hpp"
#include "RenderScene.hpp"
#include "RenderView.hpp"
#include "RenderCamera.hpp"
int main(int argc, char *argv[]) {
// TEMP location of video vars
@ -28,8 +31,14 @@ int main(int argc, char *argv[]) {
return 1;
}
glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
g_running = 1;
//
RenderScene *scene = new RenderScene();
int camera_id = scene->addCamera(new RenderCamera());
RenderCamera *camera = scene->getCamera(camera_id);
camera->setRenderView(new RenderView(v_width, v_height));
// begin our main loop
g_running = 1;
while (g_running) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {