Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9941b03fdc | ||
|
|
9031873721 | ||
|
|
fd2aadfdf7 | ||
|
|
4dd6aef904 | ||
|
|
a1a0028f5a | ||
|
|
c06298f78f | ||
|
|
858ffc8fde | ||
|
|
1da4dedcea | ||
|
|
297f8a456c | ||
|
|
3b131e949d | ||
|
|
2c6132ca17 | ||
|
|
83240e2c57 | ||
|
|
2bab7e05f8 | ||
|
|
92460b8ca4 | ||
|
|
2ebff1b3dc | ||
|
|
b6b42b3afc | ||
|
|
e7c7dbaf39 | ||
|
|
9a31e09bff | ||
|
|
2230682a85 | ||
|
|
c5e7117bac | ||
|
|
ec76b4e754 | ||
|
|
cfb8a7ada8 | ||
|
|
42cffd796d | ||
|
|
82acf0d9fc | ||
|
|
f6d7695405 | ||
|
|
5de58e6f74 | ||
|
|
316d6c9e14 | ||
|
|
80f0c33b91 | ||
|
|
9f455be8d6 | ||
|
|
5ad61e525f | ||
|
|
df611e8e51 | ||
|
|
5fc92d3f2a | ||
|
|
d1abc20f64 | ||
|
|
97d43a1249 | ||
|
|
cdd3b962eb | ||
|
|
c9e5be2573 | ||
|
|
5b6e7b54c7 | ||
|
|
9143204610 | ||
|
|
5f31b2e602 | ||
|
|
342a56fa5a | ||
|
|
27dfaf74c4 | ||
|
|
fea7728139 | ||
|
|
50e2b1c7ea | ||
|
|
5bff991b77 | ||
|
|
9192eb7371 | ||
|
|
eaa6f9cd57 | ||
|
|
6306e8abd4 | ||
|
|
7edbcd4d4d | ||
|
|
d3bde622f0 | ||
|
|
a407be072d | ||
|
|
97448bfabf | ||
|
|
7e6514581e | ||
|
|
ba0482ee0a | ||
|
|
0e99b9f719 | ||
|
|
e7163fc07c | ||
|
|
52ef1b4494 | ||
|
|
3cf6bf5857 | ||
|
|
579a04a9b4 | ||
|
|
b09311d810 | ||
|
|
d42ae6ccd3 | ||
|
|
f80b513d90 | ||
|
|
3025fecf94 | ||
|
|
41a81d104e | ||
|
|
9543dd8324 | ||
|
|
d56625e19a | ||
|
|
0431e9c230 | ||
|
|
d14f045708 | ||
|
|
4437acb9f2 | ||
|
|
02a537dc60 | ||
|
|
4249e35653 | ||
|
|
ec900f7410 | ||
|
|
0a0fdfc8b1 | ||
|
|
4effce6fea | ||
|
|
81cf7f43c0 | ||
|
|
58ac7d13cf | ||
|
|
c91bb5c656 | ||
|
|
ed3e537a3c | ||
|
|
942b068851 | ||
|
|
eadfea9d63 | ||
|
|
e848780535 | ||
|
|
ea22712a45 | ||
|
|
36dc74a39e | ||
|
|
35c21260e4 | ||
|
|
06a768a3a1 | ||
|
|
3f8623d0bf | ||
|
|
83557c7ba7 | ||
|
|
da0b1f5588 |
@@ -1,9 +1,10 @@
|
|||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
project(CrystalPoint)
|
project(CrystalPoint)
|
||||||
|
|
||||||
file(GLOB SOURCE_FILES
|
file(GLOB_RECURSE SOURCE_FILES
|
||||||
"*.h"
|
"*.h"
|
||||||
"*.cpp"
|
"*.cpp"
|
||||||
|
"*.cc"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(CrystalPoint ${SOURCE_FILES})
|
add_executable(CrystalPoint ${SOURCE_FILES})
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// Created by janco on 5/24/16.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Controller.h"
|
||||||
|
|
||||||
|
Controller::Controller(int controllerId) {
|
||||||
|
this->controllerId = controllerId;
|
||||||
|
this->ypr = Vec3f();
|
||||||
|
this->joystick = Vec2f();
|
||||||
|
this->setConnected(false);
|
||||||
|
this->setConnected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller::~Controller() { }
|
||||||
|
|
||||||
|
void Controller::rumble(int duration, int power){
|
||||||
|
// controllerhandler->rumble(controllerId, duration, power);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::setConnected(bool connected) {
|
||||||
|
if(connected){
|
||||||
|
this->connected = true;
|
||||||
|
}else{
|
||||||
|
this->connected = false;
|
||||||
|
this->ypr = Vec3f(0,0,0);
|
||||||
|
this->joystick = Vec2f(0,0);
|
||||||
|
this->button = false;
|
||||||
|
this->magnetSwitch = false;
|
||||||
|
this ->joystickButton = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Controller::isConnected(void) {
|
||||||
|
return connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Vector.h"
|
||||||
|
|
||||||
|
class Controller{
|
||||||
|
public:
|
||||||
|
Controller(int controllerId);
|
||||||
|
~Controller();
|
||||||
|
Vec3f ypr;
|
||||||
|
Vec2f joystick;
|
||||||
|
bool button, joystickButton, magnetSwitch;
|
||||||
|
bool lastButton, lastJoystickButton, lastMagetSwitch;
|
||||||
|
int controllerId;
|
||||||
|
|
||||||
|
void setConnected(bool connected);
|
||||||
|
bool isConnected(void);
|
||||||
|
|
||||||
|
void rumble(int duration, int power);
|
||||||
|
private:
|
||||||
|
bool connected = false;
|
||||||
|
};
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
//
|
||||||
|
// Created by janco on 5/23/16.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "ControllerHandler.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* String split helper functions
|
||||||
|
*/
|
||||||
|
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
|
||||||
|
std::stringstream ss(s);
|
||||||
|
std::string item;
|
||||||
|
while (std::getline(ss, item, delim)) {
|
||||||
|
elems.push_back(item);
|
||||||
|
}
|
||||||
|
return elems;
|
||||||
|
}
|
||||||
|
std::vector<std::string> split(const std::string &s, char delim) {
|
||||||
|
std::vector<std::string> elems;
|
||||||
|
split(s, delim, elems);
|
||||||
|
return elems;
|
||||||
|
}
|
||||||
|
|
||||||
|
ControllerHandler::ControllerHandler(){
|
||||||
|
readthread = std::thread(&ControllerHandler::BasestationReader, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
Controller* ControllerHandler::getLeftController(void){
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if(controllers[i] != nullptr && controllers[i]->isConnected()){
|
||||||
|
return controllers[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller* ControllerHandler::getRightController(void){
|
||||||
|
bool c1found = false;
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if(controllers[i] != nullptr && controllers[i]->isConnected()){
|
||||||
|
if(c1found){
|
||||||
|
return controllers[i];
|
||||||
|
}
|
||||||
|
c1found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerHandler::SearchBasestation(void){
|
||||||
|
basestationFound = false;
|
||||||
|
std::vector<serial::PortInfo> devices_found = serial::list_ports();
|
||||||
|
std::vector<serial::PortInfo>::iterator iter = devices_found.begin();
|
||||||
|
while( iter != devices_found.end() )
|
||||||
|
{
|
||||||
|
serial::PortInfo device = *iter++;
|
||||||
|
std::cout << device.hardware_id << " "<< device.port << std::endl;
|
||||||
|
|
||||||
|
if(device.hardware_id == "USB\\VID_10C4&PID_EA60&REV_0100"){
|
||||||
|
basestationFound = true;
|
||||||
|
baseStation = new serial::Serial(device.port, BasestationBaudrate, serial::Timeout::simpleTimeout(1000));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerHandler::rumble(int idController, int duration, int power){
|
||||||
|
if (basestationFound)
|
||||||
|
{
|
||||||
|
char sendbuffer[16];
|
||||||
|
sprintf(sendbuffer, "1|%01d|%06d|%03d\n", idController, duration, power);
|
||||||
|
baseStation->write(sendbuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reading from basestation
|
||||||
|
*/
|
||||||
|
|
||||||
|
void ControllerHandler::BasestationReader() {
|
||||||
|
while(1){
|
||||||
|
while(!basestationFound){
|
||||||
|
SearchBasestation();
|
||||||
|
if(basestationFound){
|
||||||
|
baseStation ->write("stop\n");
|
||||||
|
baseStation ->write("clientlist\n");
|
||||||
|
}
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
||||||
|
}
|
||||||
|
while(baseStation->isOpen()){
|
||||||
|
std::string basestationMessage = baseStation->readline();
|
||||||
|
std::vector<std::string> basestationMessageSplit = split(basestationMessage, '|');
|
||||||
|
if(basestationMessageSplit.size() > 1){ //Valid message
|
||||||
|
//std::cout << "DEBUG: Message received. Length: " << basestationMessageSplit.size() << " Type: " << basestationMessageSplit[0] << " Message: " << basestationMessage;
|
||||||
|
int messageId = std::stoi(basestationMessageSplit[0]);
|
||||||
|
switch(messageId){
|
||||||
|
//commandList[messageId](basestationMessageSplit);
|
||||||
|
case 0: commandDebug(basestationMessageSplit); break; //Debug message
|
||||||
|
case 1: commandControllerData(basestationMessageSplit); break; //Data from controller
|
||||||
|
case 2: commandControllerEvent(basestationMessageSplit); break; //Controller events
|
||||||
|
case 3: commandControllerList(basestationMessageSplit); break; //Connected controller list
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerHandler::commandDebug(std::vector<std::string> data) {
|
||||||
|
std::cout << "DEBUG: " << data[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerHandler::commandControllerData(std::vector<std::string> data) {
|
||||||
|
if(data.size() == 10){
|
||||||
|
Controller* c = controllers[std::stoi(data[1])];
|
||||||
|
if(c != nullptr && c->isConnected()){
|
||||||
|
c->ypr.x = std::stoi(data[5])/100.0f;
|
||||||
|
c->ypr.y = std::stoi(data[6])/100.0f;
|
||||||
|
c->ypr.z = std::stoi(data[7])/100.0f;
|
||||||
|
|
||||||
|
c->joystick.x = std::stoi(data[2])/2000.0f;
|
||||||
|
c->joystick.y = std::stoi(data[3])/2000.0f;
|
||||||
|
|
||||||
|
c->lastButton = c->button;
|
||||||
|
c->lastJoystickButton = c->joystickButton;
|
||||||
|
c->lastMagetSwitch = c->magnetSwitch;
|
||||||
|
|
||||||
|
c->joystickButton = !(data[4] == "0");
|
||||||
|
c->button = !(data[8] == "0");
|
||||||
|
c->magnetSwitch = !(data[9] == "0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerHandler::commandControllerEvent(std::vector<std::string> data) {
|
||||||
|
if(data.size() == 3){
|
||||||
|
if(data[1] == "connected"){
|
||||||
|
int controllerId = std::stoi(data[2]);
|
||||||
|
controllers[controllerId] = new Controller(controllerId);
|
||||||
|
controllers[controllerId]->setConnected(true);
|
||||||
|
}else if(data[1] == "disconnected"){
|
||||||
|
// controllers.erase(*controllers[std::stoi(data[2])]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerHandler::commandControllerList(std::vector<std::string> data) {
|
||||||
|
for(unsigned int i = 1; i < data.size() - 1; i++){
|
||||||
|
int controllerId = std::stoi(data[i]);
|
||||||
|
controllers[controllerId] = new Controller(controllerId);
|
||||||
|
rumble(controllerId, 100, 100);
|
||||||
|
}
|
||||||
|
if(basestationFound)
|
||||||
|
baseStation->write("start\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#pragma once
|
||||||
|
//
|
||||||
|
// Created by janco on 5/23/16.
|
||||||
|
//
|
||||||
|
|
||||||
|
#define BasestationBaudrate 115200
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include "include/serial.h"
|
||||||
|
#else
|
||||||
|
#include "lib/serial/include/serial.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "Controller.h"
|
||||||
|
|
||||||
|
class ControllerHandler{
|
||||||
|
public:
|
||||||
|
ControllerHandler();
|
||||||
|
Controller* getLeftController(void);
|
||||||
|
Controller* getRightController(void);
|
||||||
|
void rumble(int idController, int duration, int power);
|
||||||
|
private:
|
||||||
|
void SearchBasestation(void);
|
||||||
|
void BasestationReader(void);
|
||||||
|
|
||||||
|
bool basestationFound;
|
||||||
|
serial::Serial *baseStation;
|
||||||
|
std::thread readthread;
|
||||||
|
Controller* controllers[4];
|
||||||
|
|
||||||
|
//Command functions
|
||||||
|
void commandDebug(std::vector<std::string> data);
|
||||||
|
void commandControllerData(std::vector<std::string> data);
|
||||||
|
void commandControllerEvent(std::vector<std::string> data);
|
||||||
|
void commandControllerList(std::vector<std::string> data);
|
||||||
|
|
||||||
|
//void(*commandList [1])(std::vector<std::string> data);
|
||||||
|
};
|
||||||
|
|
||||||
@@ -9,16 +9,22 @@ Crystal::Crystal(const std::string & filled, const std::string & empty, const Ve
|
|||||||
this->empty = Model::load(empty);
|
this->empty = Model::load(empty);
|
||||||
model = this->filled;
|
model = this->filled;
|
||||||
|
|
||||||
|
|
||||||
this->position = position;
|
this->position = position;
|
||||||
this->rotation = rotation;
|
this->rotation = rotation;
|
||||||
this->scale = scale;
|
this->scale = scale;
|
||||||
this->canCollide = true;
|
this->canCollide = true;
|
||||||
isFilled = true;
|
isFilled = true;
|
||||||
|
|
||||||
|
sound_id = CrystalPoint::GetSoundSystem().LoadSound("WAVE/Crystal.wav", false);
|
||||||
|
music = CrystalPoint::GetSoundSystem().GetSound(sound_id);
|
||||||
|
music->SetPos(position, Vec3f());
|
||||||
|
|
||||||
|
crystalRot = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Crystal::~Crystal()
|
Crystal::~Crystal()
|
||||||
{
|
{
|
||||||
|
CrystalPoint::GetSoundSystem().UnloadSound(sound_id);
|
||||||
if (model)
|
if (model)
|
||||||
Model::unload(model);
|
Model::unload(model);
|
||||||
|
|
||||||
@@ -34,6 +40,8 @@ Crystal::~Crystal()
|
|||||||
|
|
||||||
void Crystal::draw()
|
void Crystal::draw()
|
||||||
{
|
{
|
||||||
|
crystalRot -= 0.5f;
|
||||||
|
rotation = Vec3f(0, crystalRot, 0);
|
||||||
Entity::draw();
|
Entity::draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +49,7 @@ void Crystal::collide()
|
|||||||
{
|
{
|
||||||
if (isFilled)
|
if (isFilled)
|
||||||
{
|
{
|
||||||
|
music->Play();
|
||||||
Player::getInstance()->crystals++;
|
Player::getInstance()->crystals++;
|
||||||
isFilled = false;
|
isFilled = false;
|
||||||
model = empty;
|
model = empty;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "CrystalPoint.h"
|
||||||
|
|
||||||
class Crystal :
|
class Crystal :
|
||||||
public Entity
|
public Entity
|
||||||
@@ -9,11 +10,13 @@ public:
|
|||||||
Crystal(const std::string &filled, const std::string &empty,
|
Crystal(const std::string &filled, const std::string &empty,
|
||||||
const Vec3f &position, Vec3f &rotation, const float &scale);
|
const Vec3f &position, Vec3f &rotation, const float &scale);
|
||||||
~Crystal();
|
~Crystal();
|
||||||
|
float crystalRot;
|
||||||
bool isFilled;
|
bool isFilled;
|
||||||
void draw();
|
void draw();
|
||||||
void collide();
|
void collide();
|
||||||
private:
|
private:
|
||||||
|
int sound_id;
|
||||||
|
Sound* music;
|
||||||
Model* filled;
|
Model* filled;
|
||||||
Model* empty;
|
Model* empty;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ void CrystalPoint::draw()
|
|||||||
|
|
||||||
if(!state)
|
if(!state)
|
||||||
menu->draw();
|
menu->draw();
|
||||||
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,21 +66,35 @@ void CrystalPoint::update()
|
|||||||
if (keyboardState.keys[27] && !prevKeyboardState.keys[27])
|
if (keyboardState.keys[27] && !prevKeyboardState.keys[27])
|
||||||
state = !state;
|
state = !state;
|
||||||
|
|
||||||
|
Controller *rightcontroller = controller.getRightController();
|
||||||
|
Controller *leftcontroller = controller.getLeftController();
|
||||||
|
|
||||||
if (state)
|
if (state)
|
||||||
{
|
{
|
||||||
|
Player* player = Player::getInstance();
|
||||||
|
|
||||||
if (keyboardState.special[GLUT_KEY_LEFT] && !prevKeyboardState.special[GLUT_KEY_LEFT])
|
if (keyboardState.special[GLUT_KEY_LEFT] && !prevKeyboardState.special[GLUT_KEY_LEFT])
|
||||||
worldhandler->PreviousWorld();
|
worldhandler->PreviousWorld();
|
||||||
if (keyboardState.special[GLUT_KEY_RIGHT] && !prevKeyboardState.special[GLUT_KEY_RIGHT])
|
if (keyboardState.special[GLUT_KEY_RIGHT] && !prevKeyboardState.special[GLUT_KEY_RIGHT])
|
||||||
worldhandler->NextWorld();
|
worldhandler->NextWorld();
|
||||||
|
if (keyboardState.special[GLUT_KEY_UP] && !prevKeyboardState.special[GLUT_KEY_UP])
|
||||||
|
player->NextRightWeapon();
|
||||||
|
if (keyboardState.special[GLUT_KEY_DOWN] && !prevKeyboardState.special[GLUT_KEY_DOWN])
|
||||||
|
player->PreviousLeftWeapon();
|
||||||
|
if (keyboardState.keys[27])
|
||||||
|
state = false;
|
||||||
|
|
||||||
Player* player = Player::getInstance();
|
//testing code
|
||||||
|
if (keyboardState.keys['u'])
|
||||||
|
player->HpUp(1);
|
||||||
|
if (keyboardState.keys['i'])
|
||||||
|
player->HpDown(1);
|
||||||
|
if (keyboardState.keys['o'])
|
||||||
|
player->XpUp(1);
|
||||||
|
|
||||||
player->rotation.y += mouseOffset.x / 10.0f;
|
player->rotation.y += mouseOffset.x / 10.0f;
|
||||||
player->rotation.x += mouseOffset.y / 10.0f;
|
player->rotation.x += mouseOffset.y / 10.0f;
|
||||||
if (player->rotation.x > 90)
|
|
||||||
player->rotation.x = 90;
|
|
||||||
if (player->rotation.x < -90)
|
|
||||||
player->rotation.x = -90;
|
|
||||||
|
|
||||||
float speed = 10;
|
float speed = 10;
|
||||||
|
|
||||||
@@ -91,14 +106,101 @@ void CrystalPoint::update()
|
|||||||
if (keyboardState.keys['q']) player->setPosition(1, deltaTime*speed, true);
|
if (keyboardState.keys['q']) player->setPosition(1, deltaTime*speed, true);
|
||||||
if (keyboardState.keys['e']) player->setPosition(-1, deltaTime*speed, true);
|
if (keyboardState.keys['e']) player->setPosition(-1, deltaTime*speed, true);
|
||||||
|
|
||||||
|
if (leftcontroller != nullptr) {
|
||||||
|
Vec2f *leftControllerJoystick = &leftcontroller->joystick;
|
||||||
|
|
||||||
|
if (leftControllerJoystick->y > 0.3 || leftControllerJoystick->y < -0.3) {
|
||||||
|
player->rotation.x += leftControllerJoystick->y/4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leftControllerJoystick->x > 0.3 || leftControllerJoystick->x < -0.3) {
|
||||||
|
player->rotation.y += leftControllerJoystick->x/4;
|
||||||
|
}
|
||||||
|
|
||||||
|
player->leftWeapon->rotateWeapon(Vec3f(leftcontroller->ypr.y + 140, 0, -leftcontroller->ypr.z));
|
||||||
|
|
||||||
|
if(leftcontroller->button && leftcontroller->joystickButton){
|
||||||
|
state = !state;
|
||||||
|
}else if(!leftcontroller->lastButton && leftcontroller->button){
|
||||||
|
leftcontroller->lastButton = leftcontroller->button;
|
||||||
|
controller.rumble(leftcontroller->controllerId, 100, 200);
|
||||||
|
player->NextLeftWeapon();
|
||||||
|
}else if(!leftcontroller->lastJoystickButton && leftcontroller->joystickButton){
|
||||||
|
leftcontroller->lastJoystickButton = leftcontroller->joystickButton;
|
||||||
|
player->hit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player->isHit){
|
||||||
|
controller.rumble(leftcontroller->controllerId, 50, 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!leftcontroller->lastMagetSwitch && leftcontroller->magnetSwitch){
|
||||||
|
worldhandler -> teleportRandom();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if(rightcontroller != nullptr){
|
||||||
|
Vec2f *rightControllerJoystick = &rightcontroller->joystick;
|
||||||
|
|
||||||
|
if (rightControllerJoystick->y > 0.3) {
|
||||||
|
player->setPosition(270, rightControllerJoystick->y * deltaTime * 2.0f, false);
|
||||||
|
}
|
||||||
|
else if (rightControllerJoystick->y < -0.3) {
|
||||||
|
player->setPosition(90, rightControllerJoystick->y * -1 * deltaTime * 2.0f, false);
|
||||||
|
}
|
||||||
|
if (rightControllerJoystick->x > 0.3) {
|
||||||
|
player->setPosition(180, rightControllerJoystick->x * deltaTime * 2.0f, false);
|
||||||
|
}
|
||||||
|
else if (rightControllerJoystick->x < -0.3) {
|
||||||
|
player->setPosition(0, rightControllerJoystick->x * -1 * deltaTime * 2.0f, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!rightcontroller->lastButton && rightcontroller->button){
|
||||||
|
rightcontroller->lastButton = rightcontroller->button;
|
||||||
|
controller.rumble(rightcontroller->controllerId, 100, 200);
|
||||||
|
player->NextRightWeapon();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player->isHit){
|
||||||
|
controller.rumble(rightcontroller->controllerId, 50, 250);
|
||||||
|
player->isHit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!rightcontroller->lastMagetSwitch && rightcontroller->magnetSwitch){
|
||||||
|
worldhandler -> teleportRandom();
|
||||||
|
}
|
||||||
|
|
||||||
|
player->rightWeapon->rotateWeapon(Vec3f(rightcontroller->ypr.y + 140, 0, -rightcontroller->ypr.z));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player->rotation.x > 90)
|
||||||
|
player->rotation.x = 90;
|
||||||
|
if (player->rotation.x < -90)
|
||||||
|
player->rotation.x = -90;
|
||||||
|
|
||||||
|
player->position.y = worldhandler->getHeight(player->position.x, player->position.z) + 1.7f;
|
||||||
|
|
||||||
if (!worldhandler->isPlayerPositionValid())
|
if (!worldhandler->isPlayerPositionValid())
|
||||||
player->position = oldPosition;
|
player->position = oldPosition;
|
||||||
player->position.y = worldhandler->getHeight(player->position.x, player->position.z) + 2.5f;
|
|
||||||
worldhandler->update(deltaTime);
|
worldhandler->update(deltaTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menu->update();
|
menu->update();
|
||||||
|
if (leftcontroller != nullptr) {
|
||||||
|
Vec2f *leftControllerJoystick = &leftcontroller->joystick;
|
||||||
|
if (leftControllerJoystick->y > 0.3 || leftControllerJoystick->y < -0.3) {
|
||||||
|
cursor->update(Vec2f(cursor->mousePosition.x,cursor->mousePosition.y+leftControllerJoystick->y ));
|
||||||
|
}
|
||||||
|
if (leftControllerJoystick->x > 0.3 || leftControllerJoystick->x < -0.3) {
|
||||||
|
cursor->update(Vec2f(cursor->mousePosition.x+leftControllerJoystick->x ,cursor->mousePosition.y));
|
||||||
|
}
|
||||||
|
if(leftcontroller->button){
|
||||||
|
cursor->state = 137;
|
||||||
|
}else if(cursor->state == 137){
|
||||||
|
cursor->state = GLUT_UP;
|
||||||
|
}
|
||||||
|
}
|
||||||
cursor->update(cursor->mousePosition + mouseOffset);
|
cursor->update(cursor->mousePosition + mouseOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class Cursor;
|
|||||||
class Menu;
|
class Menu;
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
#include "SoundSystem.h"
|
#include "SoundSystem.h"
|
||||||
|
#include "ControllerHandler.h"
|
||||||
|
|
||||||
class KeyboardState
|
class KeyboardState
|
||||||
{
|
{
|
||||||
@@ -27,8 +28,8 @@ public:
|
|||||||
|
|
||||||
WorldHandler* worldhandler;
|
WorldHandler* worldhandler;
|
||||||
Player* player;
|
Player* player;
|
||||||
|
ControllerHandler controller;
|
||||||
Cursor* cursor;
|
Cursor* cursor;
|
||||||
|
|
||||||
Menu* menu;
|
Menu* menu;
|
||||||
|
|
||||||
static int width, height;
|
static int width, height;
|
||||||
|
|||||||
@@ -89,13 +89,13 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PrecompiledHeaderFile />
|
<PrecompiledHeaderFile />
|
||||||
<AdditionalIncludeDirectories>freeglut/include; openAL/include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>lib/serial;freeglut/include; openAL/include</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>freeglut/lib; openAL/libs/Win32</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>freeglut/lib; openAL/libs/Win32</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;OpenAL32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>setupapi.lib;openal32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
@@ -105,13 +105,13 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PrecompiledHeaderFile />
|
<PrecompiledHeaderFile />
|
||||||
<AdditionalIncludeDirectories>freeglut/include;C:\Program Files (x86)\OpenAL 1.1 SDK\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>lib/serial;freeglut/include;C:\Program Files (x86)\OpenAL 1.1 SDK\include</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>freeglut/lib;C:\Program Files (x86)\OpenAL 1.1 SDK\libs\Win32</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>freeglut/lib;C:\Program Files (x86)\OpenAL 1.1 SDK\libs\Win32</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;OpenAL32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>setupapi.lib;openal32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PrecompiledHeaderFile />
|
<PrecompiledHeaderFile />
|
||||||
<AdditionalIncludeDirectories>freeglut/include; openAL/include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>lib/serial;freeglut/include; openAL/include</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>freeglut/lib; openAL/libs/Win32</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>freeglut/lib; openAL/libs/Win32</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;OpenAL32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>setupapi.lib;openal32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
@@ -143,7 +143,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PrecompiledHeaderFile />
|
<PrecompiledHeaderFile />
|
||||||
<AdditionalIncludeDirectories>freeglut/include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>lib/serial;freeglut/include;</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@@ -151,10 +151,13 @@
|
|||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>freeglut/lib</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>freeglut/lib</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>setupapi.lib;openal32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Button.cpp" />
|
<ClCompile Include="Button.cpp" />
|
||||||
|
<ClCompile Include="Controller.cpp" />
|
||||||
|
<ClCompile Include="ControllerHandler.cpp" />
|
||||||
<ClCompile Include="Crystal.cpp" />
|
<ClCompile Include="Crystal.cpp" />
|
||||||
<ClCompile Include="CrystalPoint.cpp" />
|
<ClCompile Include="CrystalPoint.cpp" />
|
||||||
<ClCompile Include="Cursor.cpp" />
|
<ClCompile Include="Cursor.cpp" />
|
||||||
@@ -164,6 +167,9 @@
|
|||||||
<ClCompile Include="Interface.cpp" />
|
<ClCompile Include="Interface.cpp" />
|
||||||
<ClCompile Include="json.cpp" />
|
<ClCompile Include="json.cpp" />
|
||||||
<ClCompile Include="LevelObject.cpp" />
|
<ClCompile Include="LevelObject.cpp" />
|
||||||
|
<ClCompile Include="lib\serial\src\impl\list_ports\list_ports_win.cc" />
|
||||||
|
<ClCompile Include="lib\serial\src\impl\win.cc" />
|
||||||
|
<ClCompile Include="lib\serial\src\serial.cc" />
|
||||||
<ClCompile Include="Main.cpp" />
|
<ClCompile Include="Main.cpp" />
|
||||||
<ClCompile Include="Menu.cpp" />
|
<ClCompile Include="Menu.cpp" />
|
||||||
<ClCompile Include="MenuElement.cpp" />
|
<ClCompile Include="MenuElement.cpp" />
|
||||||
@@ -177,11 +183,14 @@
|
|||||||
<ClCompile Include="Util.cpp" />
|
<ClCompile Include="Util.cpp" />
|
||||||
<ClCompile Include="Vector.cpp" />
|
<ClCompile Include="Vector.cpp" />
|
||||||
<ClCompile Include="Vertex.cpp" />
|
<ClCompile Include="Vertex.cpp" />
|
||||||
|
<ClCompile Include="Weapon.cpp" />
|
||||||
<ClCompile Include="World.cpp" />
|
<ClCompile Include="World.cpp" />
|
||||||
<ClCompile Include="WorldHandler.cpp" />
|
<ClCompile Include="WorldHandler.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Button.h" />
|
<ClInclude Include="Button.h" />
|
||||||
|
<ClInclude Include="Controller.h" />
|
||||||
|
<ClInclude Include="ControllerHandler.h" />
|
||||||
<ClInclude Include="Crystal.h" />
|
<ClInclude Include="Crystal.h" />
|
||||||
<ClInclude Include="CrystalPoint.h" />
|
<ClInclude Include="CrystalPoint.h" />
|
||||||
<ClInclude Include="Cursor.h" />
|
<ClInclude Include="Cursor.h" />
|
||||||
@@ -191,6 +200,9 @@
|
|||||||
<ClInclude Include="Interface.h" />
|
<ClInclude Include="Interface.h" />
|
||||||
<ClInclude Include="json.h" />
|
<ClInclude Include="json.h" />
|
||||||
<ClInclude Include="LevelObject.h" />
|
<ClInclude Include="LevelObject.h" />
|
||||||
|
<ClInclude Include="lib\serial\include\impl\win.h" />
|
||||||
|
<ClInclude Include="lib\serial\include\serial.h" />
|
||||||
|
<ClInclude Include="lib\serial\include\v8stdint.h" />
|
||||||
<ClInclude Include="Main.h" />
|
<ClInclude Include="Main.h" />
|
||||||
<ClInclude Include="Menu.h" />
|
<ClInclude Include="Menu.h" />
|
||||||
<ClInclude Include="MenuElement.h" />
|
<ClInclude Include="MenuElement.h" />
|
||||||
@@ -205,10 +217,12 @@
|
|||||||
<ClInclude Include="Util.h" />
|
<ClInclude Include="Util.h" />
|
||||||
<ClInclude Include="vector.h" />
|
<ClInclude Include="vector.h" />
|
||||||
<ClInclude Include="Vertex.h" />
|
<ClInclude Include="Vertex.h" />
|
||||||
|
<ClInclude Include="Weapon.h" />
|
||||||
<ClInclude Include="World.h" />
|
<ClInclude Include="World.h" />
|
||||||
<ClInclude Include="WorldHandler.h" />
|
<ClInclude Include="WorldHandler.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="weapons.json" />
|
||||||
<None Include="worlds\fire.json" />
|
<None Include="worlds\fire.json" />
|
||||||
<None Include="worlds\ice.json" />
|
<None Include="worlds\ice.json" />
|
||||||
<None Include="worlds\rock.json" />
|
<None Include="worlds\rock.json" />
|
||||||
@@ -216,8 +230,10 @@
|
|||||||
<None Include="worlds\worlds.json" />
|
<None Include="worlds\worlds.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Media Include="WAVE\bond.wav" />
|
<Media Include="WAVE\Crystal.wav" />
|
||||||
<Media Include="WAVE\Sound.wav" />
|
<Media Include="WAVE\ghostEnemy.wav" />
|
||||||
|
<Media Include="WAVE\portal.wav" />
|
||||||
|
<Media Include="WAVE\world1.wav" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
<Filter Include="Source Files\json">
|
<Filter Include="Source Files\json">
|
||||||
<UniqueIdentifier>{9c655946-3f99-44ea-bc97-2817656954e0}</UniqueIdentifier>
|
<UniqueIdentifier>{9c655946-3f99-44ea-bc97-2817656954e0}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Source Files\Menu">
|
<Filter Include="Source Files\Serial">
|
||||||
<UniqueIdentifier>{e7a88896-78e1-4544-bfc8-cfd55323728e}</UniqueIdentifier>
|
<UniqueIdentifier>{98128574-9e08-4c28-9372-8d50b6e1a101}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -90,20 +90,38 @@
|
|||||||
<ClCompile Include="Portal.cpp">
|
<ClCompile Include="Portal.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Controller.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ControllerHandler.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="lib\serial\src\impl\list_ports\list_ports_win.cc">
|
||||||
|
<Filter>Source Files\Serial</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="lib\serial\src\impl\win.cc">
|
||||||
|
<Filter>Source Files\Serial</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="lib\serial\src\serial.cc">
|
||||||
|
<Filter>Source Files\Serial</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Weapon.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="Button.cpp">
|
<ClCompile Include="Button.cpp">
|
||||||
<Filter>Source Files\Menu</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Menu.cpp">
|
<ClCompile Include="Menu.cpp">
|
||||||
<Filter>Source Files\Menu</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="MenuElement.cpp">
|
<ClCompile Include="MenuElement.cpp">
|
||||||
<Filter>Source Files\Menu</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Text.cpp">
|
<ClCompile Include="Text.cpp">
|
||||||
<Filter>Source Files\Menu</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Util.cpp">
|
<ClCompile Include="Util.cpp">
|
||||||
<Filter>Source Files\Menu</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -170,19 +188,37 @@
|
|||||||
<ClInclude Include="Portal.h">
|
<ClInclude Include="Portal.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Text.h">
|
<ClInclude Include="ControllerHandler.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Util.h">
|
<ClInclude Include="Controller.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="MenuElement.h">
|
<ClInclude Include="lib\serial\include\serial.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="lib\serial\include\v8stdint.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="lib\serial\include\impl\win.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Weapon.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Button.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Menu.h">
|
<ClInclude Include="Menu.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Button.h">
|
<ClInclude Include="MenuElement.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Text.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Util.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -202,12 +238,21 @@
|
|||||||
<None Include="worlds\rock.json">
|
<None Include="worlds\rock.json">
|
||||||
<Filter>Source Files\json</Filter>
|
<Filter>Source Files\json</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="weapons.json">
|
||||||
|
<Filter>Source Files\json</Filter>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Media Include="WAVE\Sound.wav">
|
<Media Include="WAVE\Crystal.wav">
|
||||||
<Filter>Resource Files</Filter>
|
<Filter>Resource Files</Filter>
|
||||||
</Media>
|
</Media>
|
||||||
<Media Include="WAVE\bond.wav">
|
<Media Include="WAVE\portal.wav">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Media>
|
||||||
|
<Media Include="WAVE\ghostEnemy.wav">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Media>
|
||||||
|
<Media Include="WAVE\world1.wav">
|
||||||
<Filter>Resource Files</Filter>
|
<Filter>Resource Files</Filter>
|
||||||
</Media>
|
</Media>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "Enemy.h"
|
#include "Enemy.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
|
#include "Player.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
Enemy::Enemy(const std::string &fileName,
|
Enemy::Enemy(const std::string &fileName,
|
||||||
const std::string &fileMusic,
|
const std::string &fileMusic,
|
||||||
|
float damage,
|
||||||
|
float health,
|
||||||
const Vec3f &position,
|
const Vec3f &position,
|
||||||
const Vec3f &rotation,
|
const Vec3f &rotation,
|
||||||
const float &scale)
|
const float &scale)
|
||||||
@@ -18,6 +21,11 @@ Enemy::Enemy(const std::string &fileName,
|
|||||||
target = position;
|
target = position;
|
||||||
speed = 1;
|
speed = 1;
|
||||||
radius = 10;
|
radius = 10;
|
||||||
|
|
||||||
|
xp = health;
|
||||||
|
this->health = health;
|
||||||
|
this->damage = damage;
|
||||||
|
|
||||||
hasTarget = false;
|
hasTarget = false;
|
||||||
hit_sound_id = CrystalPoint::GetSoundSystem().LoadSound(fileMusic.c_str(), false);
|
hit_sound_id = CrystalPoint::GetSoundSystem().LoadSound(fileMusic.c_str(), false);
|
||||||
music = CrystalPoint::GetSoundSystem().GetSound(hit_sound_id);
|
music = CrystalPoint::GetSoundSystem().GetSound(hit_sound_id);
|
||||||
@@ -27,29 +35,15 @@ Enemy::Enemy(const std::string &fileName,
|
|||||||
|
|
||||||
Enemy::~Enemy()
|
Enemy::~Enemy()
|
||||||
{
|
{
|
||||||
|
music->Stop();
|
||||||
|
CrystalPoint::GetSoundSystem().UnloadSound(hit_sound_id);
|
||||||
if (model)
|
if (model)
|
||||||
Model::unload(model);
|
Model::unload(model);
|
||||||
|
|
||||||
delete music;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Enemy::draw()
|
void Enemy::draw()
|
||||||
{
|
{
|
||||||
Entity::draw();
|
Entity::draw();
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
glTranslatef(position.x, position.y, position.z);
|
|
||||||
|
|
||||||
glBegin(GL_LINE_LOOP);
|
|
||||||
for (int i = 0; i < 360; i++)
|
|
||||||
{
|
|
||||||
//convert degrees into radians
|
|
||||||
float degInRad = i*(M_PI / 180.0);
|
|
||||||
glVertex3f(cos(degInRad)*radius, 1*scale,sin(degInRad)*radius);
|
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Enemy::inEyeSight(Vec3f & TargetPosition)
|
void Enemy::inEyeSight(Vec3f & TargetPosition)
|
||||||
@@ -73,6 +67,14 @@ void Enemy::collide(const Entity * entity)
|
|||||||
position.z = difference.z + entity->position.z;
|
position.z = difference.z + entity->position.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Enemy::hit(int damage){
|
||||||
|
health -= damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Enemy::isDead(){
|
||||||
|
return health < 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Enemy::update(float delta)
|
void Enemy::update(float delta)
|
||||||
{
|
{
|
||||||
music->SetPos(position, Vec3f());
|
music->SetPos(position, Vec3f());
|
||||||
@@ -106,14 +108,24 @@ void Enemy::update(float delta)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
attack = true;
|
attack = true;
|
||||||
if (music->IsPlaying() == true)
|
|
||||||
{
|
|
||||||
// music->Pause();
|
|
||||||
music->Stop();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
rotation.y = atan2f(dx, dz) * 180 / M_PI;
|
rotation.y = atan2f(dx, dz) * 180 / M_PI;
|
||||||
}
|
}
|
||||||
|
Player *player = Player::getInstance();
|
||||||
|
|
||||||
|
/* if(inObject(player->position + player->leftWeapon->collisionPoint)){
|
||||||
|
if(!isHit){
|
||||||
|
isHit = true;
|
||||||
|
hit(player->leftWeapon->damage);
|
||||||
|
}
|
||||||
|
std::cout << "HIT1";
|
||||||
|
}else if(inObject(player->rightWeapon->collisionPoint)){
|
||||||
|
if(!isHit){
|
||||||
|
isHit = true;
|
||||||
|
hit(player->rightWeapon->damage);
|
||||||
|
}
|
||||||
|
std::cout << "HIT2";
|
||||||
|
}else{
|
||||||
|
isHit = false;
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
class Enemy : public Entity
|
class Enemy : public Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Enemy(const std::string &fileName, const std::string &fileMusic, const Vec3f &position, const Vec3f &rotation, const float &scale);
|
Enemy(const std::string &fileName, const std::string &fileMusic, float damage, float health, const Vec3f &position, const Vec3f &rotation, const float &scale);
|
||||||
~Enemy();
|
~Enemy();
|
||||||
|
|
||||||
Sound* music;
|
Sound* music;
|
||||||
@@ -16,13 +16,20 @@ public:
|
|||||||
bool hasTarget;
|
bool hasTarget;
|
||||||
Vec3f target;
|
Vec3f target;
|
||||||
float speed,radius;
|
float speed,radius;
|
||||||
|
float health;
|
||||||
|
float damage;
|
||||||
|
int xp;
|
||||||
bool attack;
|
bool attack;
|
||||||
|
|
||||||
|
bool isHit;
|
||||||
|
|
||||||
void update(float);
|
void update(float);
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
void inEyeSight(Vec3f &);
|
void inEyeSight(Vec3f &);
|
||||||
void collide(const Entity *entity);
|
void collide(const Entity *entity);
|
||||||
|
void hit(int damage);
|
||||||
|
bool isDead(void);
|
||||||
private:
|
private:
|
||||||
int hit_sound_id;
|
int hit_sound_id;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ HeightMap::HeightMap(const std::string &file, World* world)
|
|||||||
{
|
{
|
||||||
int offsets[4][2] = { { 0, 0 },{ 1, 0 },{ 1, 1 },{ 0, 1 } };
|
int offsets[4][2] = { { 0, 0 },{ 1, 0 },{ 1, 1 },{ 0, 1 } };
|
||||||
|
|
||||||
if (valueAt(x, y, GREEN) > 0)
|
if (valueAt(x, y, GREEN) > 5)
|
||||||
{
|
{
|
||||||
world->addLevelObject(new LevelObject(world->getObjectFromValue(valueAt(x, y, GREEN)).first, Vec3f(x, heightAt(x, y), y), Vec3f(0, 0, 0), 1, world->getObjectFromValue(valueAt(x, y, GREEN)).second));
|
world->addLevelObject(new LevelObject(world->getObjectFromValue(valueAt(x, y, GREEN)).first, Vec3f(x, heightAt(x, y), y), Vec3f(0, 0, 0), 1, world->getObjectFromValue(valueAt(x, y, GREEN)).second));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ void Interface::draw()
|
|||||||
glVertex2f(250, 965);
|
glVertex2f(250, 965);
|
||||||
|
|
||||||
glColor4f(1.0f, 0.5f, 0.5f, 1.0);
|
glColor4f(1.0f, 0.5f, 0.5f, 1.0);
|
||||||
glVertex2f(250 + (player->health / 100 * 500), 965);
|
glVertex2f(250 + (player->health / player->maxHp * 500), 965);
|
||||||
glVertex2f(250 + (player->health / 100 * 500), 980);
|
glVertex2f(250 + (player->health / player->maxHp * 500), 980);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
//XP bar
|
//XP bar
|
||||||
@@ -79,14 +79,18 @@ void Interface::draw()
|
|||||||
glVertex2f(250, 935);
|
glVertex2f(250, 935);
|
||||||
|
|
||||||
glColor4f(1.0f, 1.0f, 0.5f, 1.0);
|
glColor4f(1.0f, 1.0f, 0.5f, 1.0);
|
||||||
glVertex2f(250 + (player->xp / 100 * 500), 935);
|
glVertex2f(250 + (player->xp / player->maxXp * 500), 935);
|
||||||
glVertex2f(250 + (player->xp / 100 * 500), 950);
|
glVertex2f(250 + (player->xp / player->maxXp * 500), 950);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
//Text: level
|
//Text: level
|
||||||
glColor4f(1.0f, 1.0f, 0.1f, 1.0);
|
glColor4f(1.0f, 1.0f, 0.1f, 1.0);
|
||||||
Util::glutBitmapString("Level: " + std::to_string(player->level), 490, 900);
|
Util::glutBitmapString("Level: " + std::to_string(player->level), 490, 900);
|
||||||
|
|
||||||
|
//Text: weapons
|
||||||
|
Util::glutBitmapString(player->leftWeapon->name, 850, 900);
|
||||||
|
Util::glutBitmapString(player->rightWeapon->name, 10, 900);
|
||||||
|
|
||||||
for (int i = 0; i < maxCrystals; i++)
|
for (int i = 0; i < maxCrystals; i++)
|
||||||
{
|
{
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
#include "Cursor.h"
|
#include "Cursor.h"
|
||||||
|
|
||||||
void configureOpenGL(void);
|
void configureOpenGL(void);
|
||||||
@@ -15,11 +16,15 @@ CrystalPoint* app;
|
|||||||
|
|
||||||
bool justMoved = false;
|
bool justMoved = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
app = new CrystalPoint();
|
app = new CrystalPoint();
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
srand (time(NULL));
|
||||||
|
|
||||||
configureOpenGL();
|
configureOpenGL();
|
||||||
|
|
||||||
app->init();
|
app->init();
|
||||||
@@ -61,6 +66,7 @@ int main(int argc, char* argv[])
|
|||||||
if (button == GLUT_LEFT_BUTTON)
|
if (button == GLUT_LEFT_BUTTON)
|
||||||
Cursor::getInstance()->state = state;
|
Cursor::getInstance()->state = state;
|
||||||
|
|
||||||
|
|
||||||
//std::cout << "Left button is down" << std::endl;
|
//std::cout << "Left button is down" << std::endl;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -79,7 +85,7 @@ void configureOpenGL()
|
|||||||
{
|
{
|
||||||
//Init window and glut display mode
|
//Init window and glut display mode
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
glutInitWindowSize(800, 600);
|
glutInitWindowSize(1440, 900);
|
||||||
//glutInitWindowPosition(glutGet(GLUT_WINDOW_WIDTH) / 2 - 800/2, glutGet(GLUT_WINDOW_HEIGHT) / 2 - 600/2);
|
//glutInitWindowPosition(glutGet(GLUT_WINDOW_WIDTH) / 2 - 800/2, glutGet(GLUT_WINDOW_HEIGHT) / 2 - 600/2);
|
||||||
glutCreateWindow("Crystal Point");
|
glutCreateWindow("Crystal Point");
|
||||||
//glutFullScreen();
|
//glutFullScreen();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <GL\freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "CrystalPoint.h"
|
#include "CrystalPoint.h"
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
//Prototypes
|
//Prototypes
|
||||||
std::vector<std::string> split(std::string str, std::string sep);
|
std::vector<std::string> split(std::string str, std::string sep);
|
||||||
|
|||||||
@@ -3,15 +3,32 @@
|
|||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
Player* Player::instance = NULL;
|
Player* Player::instance = NULL;
|
||||||
|
|
||||||
Player::Player()
|
Player::Player()
|
||||||
{
|
{
|
||||||
speed = 10;
|
speed = 10;
|
||||||
health = 50;
|
maxHp = 100;
|
||||||
xp = 75;
|
health = maxHp;
|
||||||
level = 10;
|
xp = 0;
|
||||||
|
maxXp = 100;
|
||||||
|
level = 1;
|
||||||
crystals = 0;
|
crystals = 0;
|
||||||
|
hit = false;
|
||||||
|
|
||||||
|
loadWeapons();
|
||||||
|
|
||||||
|
currentleftweapon = 0;
|
||||||
|
leftWeapon = leftweapons[0];
|
||||||
|
leftWeapon->rotateWeapon(Vec3f(150, 0, 60));
|
||||||
|
|
||||||
|
currentrightweapon = 0;
|
||||||
|
rightWeapon = rightweapons[0];
|
||||||
|
rightWeapon->rotateWeapon(Vec3f(150, 0, 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* Player::getInstance()
|
Player* Player::getInstance()
|
||||||
@@ -42,6 +59,9 @@ void Player::setCamera()
|
|||||||
glRotatef(rotation.y, 0, 1, 0);
|
glRotatef(rotation.y, 0, 1, 0);
|
||||||
glTranslatef(-position.x, -position.y, -position.z);
|
glTranslatef(-position.x, -position.y, -position.z);
|
||||||
|
|
||||||
|
leftWeapon->rotate(rotation);
|
||||||
|
rightWeapon->rotate(rotation);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setPosition(float angle, float fac, bool height)
|
void Player::setPosition(float angle, float fac, bool height)
|
||||||
@@ -53,4 +73,160 @@ void Player::setPosition(float angle, float fac, bool height)
|
|||||||
position.x -= (float)cos((rotation.y + angle) / 180 * M_PI) * fac;
|
position.x -= (float)cos((rotation.y + angle) / 180 * M_PI) * fac;
|
||||||
position.z -= (float)sin((rotation.y + angle) / 180 * M_PI) * fac;
|
position.z -= (float)sin((rotation.y + angle) / 180 * M_PI) * fac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leftWeapon->move(position);
|
||||||
|
rightWeapon->move(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::draw() {
|
||||||
|
leftWeapon->draw();
|
||||||
|
rightWeapon->draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::HpDown(int damage)
|
||||||
|
{
|
||||||
|
int newHealth = health - damage;
|
||||||
|
isHit = true;
|
||||||
|
if (newHealth <= 0)
|
||||||
|
{
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
health = newHealth;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::HpUp(int hp)
|
||||||
|
{
|
||||||
|
if (health != maxHp)
|
||||||
|
{
|
||||||
|
int newHealth = health + hp;
|
||||||
|
if (newHealth >= maxHp)
|
||||||
|
{
|
||||||
|
newHealth = maxHp;
|
||||||
|
}
|
||||||
|
health = newHealth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::XpUp(int xpUp)
|
||||||
|
{
|
||||||
|
float newXp = xp + xpUp;
|
||||||
|
if (newXp >= maxXp)
|
||||||
|
{
|
||||||
|
newXp -= maxXp;
|
||||||
|
levelUp();
|
||||||
|
}
|
||||||
|
xp = newXp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Player::levelUp()
|
||||||
|
{
|
||||||
|
level++;
|
||||||
|
maxXp += 50;
|
||||||
|
maxHp += 10;
|
||||||
|
health = maxHp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::loadWeapons()
|
||||||
|
{
|
||||||
|
std::string fileName = "weapons.json";
|
||||||
|
|
||||||
|
//Open world json file
|
||||||
|
std::ifstream file(fileName);
|
||||||
|
if (!file.is_open())
|
||||||
|
std::cout << "Error, can't open world file - " << fileName << "\n";
|
||||||
|
|
||||||
|
json::Value v = json::readJson(file);
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
//Check file
|
||||||
|
if (v["weapons"].isNull())
|
||||||
|
std::cout << "Invalid weapons file: " << fileName << "\n";
|
||||||
|
|
||||||
|
//Load object templates
|
||||||
|
for (auto w : v["weapons"])
|
||||||
|
{
|
||||||
|
Weapon* lweapon;
|
||||||
|
Weapon* rweapon;
|
||||||
|
|
||||||
|
std::string name = w["name"].asString();
|
||||||
|
std::string fileN = w["file"].asString();
|
||||||
|
float damage = w["damage"].asFloat();
|
||||||
|
float scale = w["scale"].asFloat();
|
||||||
|
|
||||||
|
Weapon::Element e = Weapon::FIRE;
|
||||||
|
|
||||||
|
if(w["element"].asString() == "fire")
|
||||||
|
e = Weapon::FIRE;
|
||||||
|
else if (w["element"].asString() == "water")
|
||||||
|
e = Weapon::WATER;
|
||||||
|
else if (w["element"].asString() == "earth")
|
||||||
|
e = Weapon::EARTH;
|
||||||
|
else if (w["element"].asString() == "air")
|
||||||
|
e = Weapon::AIR;
|
||||||
|
else
|
||||||
|
e = Weapon::FIRE;
|
||||||
|
|
||||||
|
|
||||||
|
Vec3f leftoffset = Vec3f(w["left"]["offset"][0].asFloat(), w["left"]["offset"][1].asFloat(), w["left"]["offset"][2].asFloat());
|
||||||
|
Vec3f rightoffset = Vec3f(w["right"]["offset"][0].asFloat(), w["right"]["offset"][1].asFloat(), w["right"]["offset"][2].asFloat());
|
||||||
|
|
||||||
|
Vec3f anchor = Vec3f(w["anchor"][0].asFloat(), w["anchor"][1].asFloat(), w["anchor"][2].asFloat());
|
||||||
|
Vec3f collision = Vec3f(w["collision"][0].asFloat(), w["collision"][1].asFloat(), w["collision"][2].asFloat());
|
||||||
|
|
||||||
|
Vec2f maxRot = Vec2f(w["maxRotation"][0].asFloat(), w["maxRotation"][1].asFloat());
|
||||||
|
Vec2f minRot = Vec2f(w["minRotation"][0].asFloat(), w["minRotation"][1].asFloat());
|
||||||
|
|
||||||
|
lweapon = new Weapon(name, damage, e, fileN, scale, position, rotation, leftoffset, anchor, maxRot, minRot, collision);
|
||||||
|
rweapon = new Weapon(name, damage, e, fileN, scale, position, rotation, rightoffset, anchor, maxRot, minRot, collision);
|
||||||
|
|
||||||
|
leftweapons.push_back(lweapon);
|
||||||
|
rightweapons.push_back(rweapon);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::PreviousRightWeapon()
|
||||||
|
{
|
||||||
|
currentrightweapon--;
|
||||||
|
|
||||||
|
if (currentrightweapon < 0)
|
||||||
|
currentrightweapon = (rightweapons.size() > level ? level - 1 : rightweapons.size() - 1);
|
||||||
|
|
||||||
|
rightWeapon = rightweapons[currentrightweapon];
|
||||||
|
rightWeapon->move(position);
|
||||||
|
rightWeapon->rotate(rotation);
|
||||||
|
}
|
||||||
|
void Player::NextRightWeapon(void)
|
||||||
|
{
|
||||||
|
currentrightweapon++;
|
||||||
|
|
||||||
|
if (currentrightweapon > level - 1 || currentrightweapon > rightweapons.size() - 1)
|
||||||
|
currentrightweapon = 0;
|
||||||
|
|
||||||
|
rightWeapon = rightweapons[currentrightweapon];
|
||||||
|
rightWeapon->move(position);
|
||||||
|
rightWeapon->rotate(rotation);
|
||||||
|
}
|
||||||
|
void Player::PreviousLeftWeapon(void)
|
||||||
|
{
|
||||||
|
currentleftweapon--;
|
||||||
|
|
||||||
|
if (currentleftweapon < 0)
|
||||||
|
currentleftweapon = (leftweapons.size() > level ? level - 1 : leftweapons.size() - 1);
|
||||||
|
|
||||||
|
leftWeapon = leftweapons[currentleftweapon];
|
||||||
|
leftWeapon->move(position);
|
||||||
|
leftWeapon->rotate(rotation);
|
||||||
|
}
|
||||||
|
void Player::NextLeftWeapon(void)
|
||||||
|
{
|
||||||
|
currentleftweapon++;
|
||||||
|
|
||||||
|
if (currentleftweapon > level - 1 || currentleftweapon > leftweapons.size() - 1)
|
||||||
|
currentleftweapon = 0;
|
||||||
|
|
||||||
|
leftWeapon = leftweapons[currentleftweapon];
|
||||||
|
leftWeapon->move(position);
|
||||||
|
leftWeapon->rotate(rotation);
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,30 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
|
#include "Weapon.h"
|
||||||
|
#include "json.h"
|
||||||
|
|
||||||
class Model;
|
#include <vector>
|
||||||
|
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static Player* instance;
|
static Player* instance;
|
||||||
|
void levelUp();
|
||||||
|
|
||||||
|
std::vector<Weapon*> leftweapons;
|
||||||
|
std::vector<Weapon*> rightweapons;
|
||||||
|
void loadWeapons(void);
|
||||||
|
|
||||||
|
int currentrightweapon;
|
||||||
|
int currentleftweapon;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Player();
|
Player();
|
||||||
~Player();
|
~Player();
|
||||||
|
|
||||||
void setCamera();
|
void setCamera();
|
||||||
void setPosition(float angle, float fac, bool height);
|
void setPosition(float angle, float fac, bool height);
|
||||||
|
void draw(void);
|
||||||
|
|
||||||
static Player* getInstance(void);
|
static Player* getInstance(void);
|
||||||
static void init(void);
|
static void init(void);
|
||||||
@@ -20,13 +32,25 @@ public:
|
|||||||
Vec3f position;
|
Vec3f position;
|
||||||
Vec2f rotation;
|
Vec2f rotation;
|
||||||
|
|
||||||
Model* leftWeapon;
|
Weapon* leftWeapon;
|
||||||
Model* rightWeapon;
|
Weapon* rightWeapon;
|
||||||
|
|
||||||
float health;
|
float health, maxHp;
|
||||||
float xp;
|
float xp, maxXp;
|
||||||
int level;
|
int level;
|
||||||
int crystals;
|
int crystals;
|
||||||
|
|
||||||
|
bool hit;
|
||||||
|
bool isHit;
|
||||||
|
|
||||||
float speed;
|
float speed;
|
||||||
|
|
||||||
|
void HpUp(int);
|
||||||
|
void HpDown(int);
|
||||||
|
void XpUp(int);
|
||||||
|
|
||||||
|
void PreviousRightWeapon(void);
|
||||||
|
void NextRightWeapon(void);
|
||||||
|
void PreviousLeftWeapon(void);
|
||||||
|
void NextLeftWeapon(void);
|
||||||
};
|
};
|
||||||
@@ -30,7 +30,7 @@ Portal::Portal(const std::string &fileName,
|
|||||||
Portal::~Portal()
|
Portal::~Portal()
|
||||||
{
|
{
|
||||||
// Model::unload(model);
|
// Model::unload(model);
|
||||||
// delete music;
|
CrystalPoint::GetSoundSystem().UnloadSound(sound_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Portal::collide()
|
void Portal::collide()
|
||||||
@@ -46,7 +46,6 @@ bool Portal::enter(float deltaTime)
|
|||||||
{
|
{
|
||||||
if (delay > 3 && started)
|
if (delay > 3 && started)
|
||||||
{
|
{
|
||||||
delete music;
|
|
||||||
delay = 0;
|
delay = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,3 +48,11 @@ Sound* SoundSystem::GetSound(unsigned int inID)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
return sounds[inID];
|
return sounds[inID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoundSystem::UnloadSound(unsigned int inID)
|
||||||
|
{
|
||||||
|
if (inID > sounds.size())
|
||||||
|
return;
|
||||||
|
delete sounds[inID];
|
||||||
|
//sounds.erase(sounds.begin() + inID);
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public:
|
|||||||
|
|
||||||
unsigned int LoadSound(const char* inWavPath, bool inLooping);
|
unsigned int LoadSound(const char* inWavPath, bool inLooping);
|
||||||
Sound* GetSound(unsigned int inID);
|
Sound* GetSound(unsigned int inID);
|
||||||
|
void UnloadSound(unsigned int inID);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ALCdevice* device;
|
ALCdevice* device;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <GL\freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
|
|
||||||
class Util
|
class Util
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
|
|
||||||
|
|
||||||
Vec3f::Vec3f(float x, float y, float z)
|
Vec3f::Vec3f(float x, float y, float z)
|
||||||
{
|
{
|
||||||
this->x = x;
|
this->x = x;
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
//
|
||||||
|
// Created by janco on 25-5-16.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Weapon.h"
|
||||||
|
#include "Model.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
|
||||||
|
Weapon::Weapon(std::string name, int damage, Element e, std::string modelFilename, float scale, Vec3f location, Vec2f rotation,
|
||||||
|
Vec3f offsetPlayer, Vec3f ankerPoint,
|
||||||
|
Vec2f maxRotation, Vec2f minRotation,
|
||||||
|
Vec3f collision){
|
||||||
|
|
||||||
|
weaponmodel = Model::load(modelFilename);
|
||||||
|
rotate(rotation);
|
||||||
|
move(location);
|
||||||
|
this->scale = scale;
|
||||||
|
|
||||||
|
this->name = name;
|
||||||
|
this->damage = damage;
|
||||||
|
this->element = e;
|
||||||
|
|
||||||
|
this->offsetPlayer = offsetPlayer;
|
||||||
|
this->ankerPoint = ankerPoint;
|
||||||
|
this->maxRotation = maxRotation;
|
||||||
|
this->minRotation = minRotation;
|
||||||
|
this->collisionPoint = collisionPoint;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Weapon::~Weapon(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Weapon::rotateWeapon(Vec3f rotation){
|
||||||
|
if(rotation.x < maxRotation.x && rotation.x > minRotation.x){
|
||||||
|
rotationWeapon.x = rotation.x;
|
||||||
|
}
|
||||||
|
if(rotation.z < maxRotation.y && rotation.z > minRotation.y){
|
||||||
|
rotationWeapon.z = rotation.z;
|
||||||
|
}
|
||||||
|
rotationWeapon.y = rotation.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Weapon::rotate(Vec2f rotation){
|
||||||
|
this->rotation.y = -rotation.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Weapon::move(Vec3f location){
|
||||||
|
position = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3f multiply(float matrix[16], Vec3f vec)
|
||||||
|
{
|
||||||
|
Vec3f result;
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
for(int p = 0; p < 4; p++)
|
||||||
|
{
|
||||||
|
result[i] += matrix[i * p] * vec[p];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Weapon::draw(){
|
||||||
|
if (weaponmodel != nullptr)
|
||||||
|
{
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
|
||||||
|
//Player position and rotation
|
||||||
|
glTranslatef(position.x, position.y, position.z);
|
||||||
|
glRotatef(rotation.x, 1, 0, 0);
|
||||||
|
glRotatef(rotation.y, 0, 1, 0);
|
||||||
|
glRotatef(rotation.z, 0, 0, 1);
|
||||||
|
|
||||||
|
//offset from player
|
||||||
|
glTranslatef(offsetPlayer.x, offsetPlayer.y, offsetPlayer.z);
|
||||||
|
|
||||||
|
glScalef(scale, scale, scale);
|
||||||
|
|
||||||
|
//Rotate weapon itself, from specific anker point
|
||||||
|
glTranslatef(ankerPoint.x, ankerPoint.y, ankerPoint.z);
|
||||||
|
glRotatef(rotationWeapon.z, 0, 0, 1);
|
||||||
|
glRotatef(rotationWeapon.y, 0, 1, 0);
|
||||||
|
glRotatef(rotationWeapon.x, 1, 0, 0);
|
||||||
|
glTranslatef(-ankerPoint.x, -ankerPoint.y, -ankerPoint.z);
|
||||||
|
|
||||||
|
weaponmodel->draw();
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// Created by janco on 25-5-16.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef CRYSTALPOINT_WEAPON_H
|
||||||
|
#define CRYSTALPOINT_WEAPON_H
|
||||||
|
|
||||||
|
#include "Vector.h"
|
||||||
|
#include "Model.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Weapon {
|
||||||
|
public:
|
||||||
|
enum Element {FIRE, WATER, EARTH, AIR};
|
||||||
|
|
||||||
|
Weapon(std::string name, int damage, Element element, std::string modelFilename, float scale, Vec3f location, Vec2f rotation,
|
||||||
|
Vec3f offsetPlayer, Vec3f ankerPoint,
|
||||||
|
Vec2f maxRotation, Vec2f minXRotation,
|
||||||
|
Vec3f collisionPoint);
|
||||||
|
~Weapon();
|
||||||
|
|
||||||
|
void draw();
|
||||||
|
void rotateWeapon(Vec3f rotation);
|
||||||
|
void rotate(Vec2f rotation);
|
||||||
|
void move(Vec3f location);
|
||||||
|
|
||||||
|
std::string name;
|
||||||
|
unsigned int damage;
|
||||||
|
Element element;
|
||||||
|
|
||||||
|
Model* weaponmodel;
|
||||||
|
|
||||||
|
float scale;
|
||||||
|
Vec3f position, rotation, rotationWeapon;
|
||||||
|
Vec3f offsetPlayer, ankerPoint, collisionPoint;
|
||||||
|
Vec2f maxRotation, minRotation;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //CRYSTALPOINT_WEAPON_H
|
||||||
@@ -6,10 +6,11 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <cstdlib>
|
||||||
#include "WorldHandler.h"
|
#include "WorldHandler.h"
|
||||||
|
|
||||||
World::World(const std::string &fileName):
|
World::World(const std::string &fileName)
|
||||||
music_id(-1)
|
|
||||||
{
|
{
|
||||||
nextworld = false;
|
nextworld = false;
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ World::World(const std::string &fileName):
|
|||||||
std::cout << "Invalid world file: objects - " << fileName << "\n";
|
std::cout << "Invalid world file: objects - " << fileName << "\n";
|
||||||
if (v["enemies"].isNull())
|
if (v["enemies"].isNull())
|
||||||
std::cout << "Invalid world file: enemies - " << fileName << "\n";
|
std::cout << "Invalid world file: enemies - " << fileName << "\n";
|
||||||
if (v["crystals"].isNull())
|
if (v["crystal"].isNull())
|
||||||
std::cout << "Invalid world file: crystals - " << fileName << "\n";
|
std::cout << "Invalid world file: crystals - " << fileName << "\n";
|
||||||
|
|
||||||
//Load object templates
|
//Load object templates
|
||||||
@@ -65,8 +66,8 @@ World::World(const std::string &fileName):
|
|||||||
|
|
||||||
//Set player starting position
|
//Set player starting position
|
||||||
player->position.x = v["player"]["startposition"][0].asFloat();
|
player->position.x = v["player"]["startposition"][0].asFloat();
|
||||||
player->position.y = v["player"]["startposition"][1].asFloat();
|
|
||||||
player->position.z = v["player"]["startposition"][2].asFloat();
|
player->position.z = v["player"]["startposition"][2].asFloat();
|
||||||
|
player->position.y = heightmap->GetHeight(player->position.x, player->position.z);
|
||||||
|
|
||||||
//Load and place objects into world
|
//Load and place objects into world
|
||||||
for (auto object : v["objects"])
|
for (auto object : v["objects"])
|
||||||
@@ -127,12 +128,20 @@ World::World(const std::string &fileName):
|
|||||||
if (e["music"].isNull())
|
if (e["music"].isNull())
|
||||||
std::cout << "Invalid world file: enemies music - " << fileName << "\n";
|
std::cout << "Invalid world file: enemies music - " << fileName << "\n";
|
||||||
|
|
||||||
|
//Damage
|
||||||
|
if (e["damage"].isNull())
|
||||||
|
std::cout << "Invalid world file: enemies damage - " << fileName << "\n";
|
||||||
|
|
||||||
|
//Health
|
||||||
|
if (e["health"].isNull())
|
||||||
|
std::cout << "Invalid world file: enemies health - " << fileName << "\n";
|
||||||
|
|
||||||
//Create
|
//Create
|
||||||
Vec3f position(e["pos"][0].asFloat(), e["pos"][1].asFloat(), e["pos"][2].asFloat());
|
Vec3f position(e["pos"][0].asFloat(), e["pos"][1].asFloat(), e["pos"][2].asFloat());
|
||||||
position.y = getHeight(position.x, position.z) + 2.0f;
|
position.y = getHeight(position.x, position.z) + 2.0f;
|
||||||
|
|
||||||
maxEnemies++;
|
maxEnemies++;
|
||||||
enemies.push_back(new Enemy(e["file"].asString(), e["music"].asString(), position, rotation, scale));
|
enemies.push_back(new Enemy(e["file"].asString(), e["music"].asString(), e["damage"].asFloat(), e["health"].asFloat(), position, rotation, scale));
|
||||||
}
|
}
|
||||||
maxCrystals = 0;
|
maxCrystals = 0;
|
||||||
if (!v["crystal"].isNull())
|
if (!v["crystal"].isNull())
|
||||||
@@ -183,8 +192,8 @@ World::World(const std::string &fileName):
|
|||||||
|
|
||||||
if (!v["world"]["music"].isNull())
|
if (!v["world"]["music"].isNull())
|
||||||
{
|
{
|
||||||
music_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true);
|
sound_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true);
|
||||||
music = CrystalPoint::GetSoundSystem().GetSound(music_id);
|
music = CrystalPoint::GetSoundSystem().GetSound(sound_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!v["portal"].isNull())
|
if (!v["portal"].isNull())
|
||||||
@@ -193,7 +202,7 @@ World::World(const std::string &fileName):
|
|||||||
if (!v["portal"]["pos"].isNull())
|
if (!v["portal"]["pos"].isNull())
|
||||||
pos = Vec3f(v["portal"]["pos"][0].asFloat(),
|
pos = Vec3f(v["portal"]["pos"][0].asFloat(),
|
||||||
v["portal"]["pos"][1].asFloat(),
|
v["portal"]["pos"][1].asFloat(),
|
||||||
v["portal"]["pos"][0].asFloat());
|
v["portal"]["pos"][2].asFloat());
|
||||||
|
|
||||||
pos.y = getHeight(pos.x, pos.z);
|
pos.y = getHeight(pos.x, pos.z);
|
||||||
|
|
||||||
@@ -201,7 +210,7 @@ World::World(const std::string &fileName):
|
|||||||
if (!v["portal"]["rot"].isNull())
|
if (!v["portal"]["rot"].isNull())
|
||||||
pos = Vec3f(v["portal"]["rot"][0].asFloat(),
|
pos = Vec3f(v["portal"]["rot"][0].asFloat(),
|
||||||
v["portal"]["rot"][1].asFloat(),
|
v["portal"]["rot"][1].asFloat(),
|
||||||
v["portal"]["rot"][0].asFloat());
|
v["portal"]["rot"][2].asFloat());
|
||||||
|
|
||||||
float scale = 1.0f;
|
float scale = 1.0f;
|
||||||
if (!v["portal"]["scale"].isNull())
|
if (!v["portal"]["scale"].isNull())
|
||||||
@@ -213,12 +222,17 @@ World::World(const std::string &fileName):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vec2f World::randomPosition(void){
|
||||||
|
int randNum = rand()%(entities.size() + 1);
|
||||||
|
Vec3f position = entities[randNum]->position;
|
||||||
|
Vec2f position2 = Vec2f(position.x+100, position.y+100);
|
||||||
|
return position2;
|
||||||
|
}
|
||||||
World::~World()
|
World::~World()
|
||||||
{
|
{
|
||||||
delete heightmap;
|
delete heightmap;
|
||||||
music->Stop();
|
music->Stop();
|
||||||
delete music;
|
CrystalPoint::GetSoundSystem().UnloadSound(sound_id);
|
||||||
delete skybox;
|
delete skybox;
|
||||||
delete portal;
|
delete portal;
|
||||||
}
|
}
|
||||||
@@ -243,17 +257,19 @@ void World::draw()
|
|||||||
{
|
{
|
||||||
player->setCamera();
|
player->setCamera();
|
||||||
|
|
||||||
float lightPosition[4] = { 0, 12, 1, 0 };
|
float lightPosition[4] = { 0, 2, 1, 0 };
|
||||||
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
|
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
|
||||||
|
|
||||||
GLfloat lightAmbient[] = { 0.05, 0.05, 0.05, 0 };
|
GLfloat lightAmbient[] = { 0.05, 0.05, 0.05, 0 };
|
||||||
GLfloat light_diffuse[] = { 0.9, 0.9, 0.9, 0 };
|
GLfloat light_diffuse[] = { 0.9, 0.9, 0.9, 0 };
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
|
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
|
||||||
GLfloat mat_specular[] = { 0.15, 0.15, 0.15, 0 };
|
|
||||||
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
|
|
||||||
glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);
|
glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);
|
||||||
|
|
||||||
|
GLfloat mat_specular[] = { 0.15, 0.15, 0.15, 0 };
|
||||||
|
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
|
||||||
|
|
||||||
skybox->draw();
|
skybox->draw();
|
||||||
|
player->draw();
|
||||||
|
|
||||||
heightmap->Draw();
|
heightmap->Draw();
|
||||||
|
|
||||||
@@ -296,6 +312,9 @@ void World::update(float elapsedTime)
|
|||||||
enemy->update(elapsedTime);
|
enemy->update(elapsedTime);
|
||||||
if (enemy->hasTarget)
|
if (enemy->hasTarget)
|
||||||
{
|
{
|
||||||
|
if(player->hit)
|
||||||
|
enemy->hit(player->leftWeapon->damage);
|
||||||
|
|
||||||
for (auto e : entities)
|
for (auto e : entities)
|
||||||
{
|
{
|
||||||
if (e->canCollide && e->inObject(enemy->position))
|
if (e->canCollide && e->inObject(enemy->position))
|
||||||
@@ -307,18 +326,24 @@ void World::update(float elapsedTime)
|
|||||||
|
|
||||||
if (enemy->attack)
|
if (enemy->attack)
|
||||||
{
|
{
|
||||||
remove = true;
|
player->HpDown(enemy->damage);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enemy->position.y = getHeight(enemy->position.x, enemy->position.z) + 2.0f;
|
enemy->position.y = getHeight(enemy->position.x, enemy->position.z) + 0.5f;
|
||||||
|
|
||||||
|
if (enemy->isDead())
|
||||||
|
remove = true;
|
||||||
if(!remove)
|
if(!remove)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remove)
|
if (remove)
|
||||||
|
{
|
||||||
|
delete enemies[count];
|
||||||
|
player->XpUp(enemies[count]->xp*2);
|
||||||
enemies.erase(enemies.begin() + count);
|
enemies.erase(enemies.begin() + count);
|
||||||
|
player->HpUp(10);
|
||||||
|
}
|
||||||
|
|
||||||
skybox->update(elapsedTime, maxEnemies - enemies.size(), maxEnemies);
|
skybox->update(elapsedTime, maxEnemies - enemies.size(), maxEnemies);
|
||||||
|
|
||||||
@@ -328,6 +353,8 @@ void World::update(float elapsedTime)
|
|||||||
nextworld = true;
|
nextworld = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player->hit = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::addLevelObject(LevelObject* obj)
|
void World::addLevelObject(LevelObject* obj)
|
||||||
@@ -347,3 +374,4 @@ bool World::isPlayerPositionValid()
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ private:
|
|||||||
|
|
||||||
bool nextworld;
|
bool nextworld;
|
||||||
|
|
||||||
int music_id,maxCrystals,maxEnemies;
|
int sound_id,maxCrystals,maxEnemies;
|
||||||
|
|
||||||
std::vector<Entity*> entities;
|
std::vector<Entity*> entities;
|
||||||
std::vector<Enemy*> enemies;
|
std::vector<Enemy*> enemies;
|
||||||
@@ -41,6 +41,7 @@ public:
|
|||||||
bool isPlayerPositionValid();
|
bool isPlayerPositionValid();
|
||||||
float getHeight(float x, float y);
|
float getHeight(float x, float y);
|
||||||
void addLevelObject(LevelObject* obj);
|
void addLevelObject(LevelObject* obj);
|
||||||
|
Vec2f randomPosition(void);
|
||||||
std::pair<std::string, bool> getObjectFromValue(int i);
|
std::pair<std::string, bool> getObjectFromValue(int i);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -93,6 +93,13 @@ void WorldHandler::update(float deltaTime)
|
|||||||
world->update(deltaTime);
|
world->update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldHandler::teleportRandom(){
|
||||||
|
Vec2f randomposition = world->randomPosition();
|
||||||
|
printf("test %d %d", randomposition.x, randomposition.y);
|
||||||
|
Player::getInstance()->position = Vec3f(randomposition.x, randomposition.y, world->getHeight(randomposition.x, randomposition.y));
|
||||||
|
Player::getInstance()->setPosition(50,50,true);
|
||||||
|
}
|
||||||
|
|
||||||
bool WorldHandler::isPlayerPositionValid(void)
|
bool WorldHandler::isPlayerPositionValid(void)
|
||||||
{
|
{
|
||||||
if(!loadingWorld)
|
if(!loadingWorld)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public:
|
|||||||
|
|
||||||
void draw(void);
|
void draw(void);
|
||||||
void update(float deltaTime);
|
void update(float deltaTime);
|
||||||
|
void teleportRandom();
|
||||||
|
|
||||||
bool isPlayerPositionValid(void);
|
bool isPlayerPositionValid(void);
|
||||||
float getHeight(float x, float y);
|
float getHeight(float x, float y);
|
||||||
|
|||||||
@@ -0,0 +1,221 @@
|
|||||||
|
/*!
|
||||||
|
* \file serial/impl/unix.h
|
||||||
|
* \author William Woodall <wjwwood@gmail.com>
|
||||||
|
* \author John Harrison <ash@greaterthaninfinity.com>
|
||||||
|
* \version 0.1
|
||||||
|
*
|
||||||
|
* \section LICENSE
|
||||||
|
*
|
||||||
|
* The MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 William Woodall, John Harrison
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* \section DESCRIPTION
|
||||||
|
*
|
||||||
|
* This provides a unix based pimpl for the Serial class. This implementation is
|
||||||
|
* based off termios.h and uses select for multiplexing the IO ports.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
|
||||||
|
#ifndef SERIAL_IMPL_UNIX_H
|
||||||
|
#define SERIAL_IMPL_UNIX_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include "../serial.h"
|
||||||
|
|
||||||
|
namespace serial {
|
||||||
|
|
||||||
|
using std::size_t;
|
||||||
|
using std::string;
|
||||||
|
using std::invalid_argument;
|
||||||
|
|
||||||
|
using serial::SerialException;
|
||||||
|
using serial::IOException;
|
||||||
|
|
||||||
|
class MillisecondTimer {
|
||||||
|
public:
|
||||||
|
MillisecondTimer(const uint32_t millis);
|
||||||
|
int64_t remaining();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static timespec timespec_now();
|
||||||
|
timespec expiry;
|
||||||
|
};
|
||||||
|
|
||||||
|
class serial::Serial::SerialImpl {
|
||||||
|
public:
|
||||||
|
SerialImpl (const string &port,
|
||||||
|
unsigned long baudrate,
|
||||||
|
bytesize_t bytesize,
|
||||||
|
parity_t parity,
|
||||||
|
stopbits_t stopbits,
|
||||||
|
flowcontrol_t flowcontrol);
|
||||||
|
|
||||||
|
virtual ~SerialImpl ();
|
||||||
|
|
||||||
|
void
|
||||||
|
open ();
|
||||||
|
|
||||||
|
void
|
||||||
|
close ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
isOpen () const;
|
||||||
|
|
||||||
|
size_t
|
||||||
|
available ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
waitReadable (uint32_t timeout);
|
||||||
|
|
||||||
|
void
|
||||||
|
waitByteTimes (size_t count);
|
||||||
|
|
||||||
|
size_t
|
||||||
|
read (uint8_t *buf, size_t size = 1);
|
||||||
|
|
||||||
|
size_t
|
||||||
|
write (const uint8_t *data, size_t length);
|
||||||
|
|
||||||
|
void
|
||||||
|
flush ();
|
||||||
|
|
||||||
|
void
|
||||||
|
flushInput ();
|
||||||
|
|
||||||
|
void
|
||||||
|
flushOutput ();
|
||||||
|
|
||||||
|
void
|
||||||
|
sendBreak (int duration);
|
||||||
|
|
||||||
|
void
|
||||||
|
setBreak (bool level);
|
||||||
|
|
||||||
|
void
|
||||||
|
setRTS (bool level);
|
||||||
|
|
||||||
|
void
|
||||||
|
setDTR (bool level);
|
||||||
|
|
||||||
|
bool
|
||||||
|
waitForChange ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
getCTS ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
getDSR ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
getRI ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
getCD ();
|
||||||
|
|
||||||
|
void
|
||||||
|
setPort (const string &port);
|
||||||
|
|
||||||
|
string
|
||||||
|
getPort () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setTimeout (Timeout &timeout);
|
||||||
|
|
||||||
|
Timeout
|
||||||
|
getTimeout () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setBaudrate (unsigned long baudrate);
|
||||||
|
|
||||||
|
unsigned long
|
||||||
|
getBaudrate () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setBytesize (bytesize_t bytesize);
|
||||||
|
|
||||||
|
bytesize_t
|
||||||
|
getBytesize () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setParity (parity_t parity);
|
||||||
|
|
||||||
|
parity_t
|
||||||
|
getParity () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setStopbits (stopbits_t stopbits);
|
||||||
|
|
||||||
|
stopbits_t
|
||||||
|
getStopbits () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setFlowcontrol (flowcontrol_t flowcontrol);
|
||||||
|
|
||||||
|
flowcontrol_t
|
||||||
|
getFlowcontrol () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
readLock ();
|
||||||
|
|
||||||
|
void
|
||||||
|
readUnlock ();
|
||||||
|
|
||||||
|
void
|
||||||
|
writeLock ();
|
||||||
|
|
||||||
|
void
|
||||||
|
writeUnlock ();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void reconfigurePort ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
string port_; // Path to the file descriptor
|
||||||
|
int fd_; // The current file descriptor
|
||||||
|
|
||||||
|
bool is_open_;
|
||||||
|
bool xonxoff_;
|
||||||
|
bool rtscts_;
|
||||||
|
|
||||||
|
Timeout timeout_; // Timeout for read operations
|
||||||
|
unsigned long baudrate_; // Baudrate
|
||||||
|
uint32_t byte_time_ns_; // Nanoseconds to transmit/receive a single byte
|
||||||
|
|
||||||
|
parity_t parity_; // Parity
|
||||||
|
bytesize_t bytesize_; // Size of the bytes
|
||||||
|
stopbits_t stopbits_; // Stop Bits
|
||||||
|
flowcontrol_t flowcontrol_; // Flow Control
|
||||||
|
|
||||||
|
// Mutex used to lock the read functions
|
||||||
|
pthread_mutex_t read_mutex;
|
||||||
|
// Mutex used to lock the write functions
|
||||||
|
pthread_mutex_t write_mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SERIAL_IMPL_UNIX_H
|
||||||
|
|
||||||
|
#endif // !defined(_WIN32)
|
||||||
@@ -0,0 +1,207 @@
|
|||||||
|
/*!
|
||||||
|
* \file serial/impl/windows.h
|
||||||
|
* \author William Woodall <wjwwood@gmail.com>
|
||||||
|
* \author John Harrison <ash@greaterthaninfinity.com>
|
||||||
|
* \version 0.1
|
||||||
|
*
|
||||||
|
* \section LICENSE
|
||||||
|
*
|
||||||
|
* The MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 William Woodall, John Harrison
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* \section DESCRIPTION
|
||||||
|
*
|
||||||
|
* This provides a windows implementation of the Serial class interface.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
|
||||||
|
#ifndef SERIAL_IMPL_WINDOWS_H
|
||||||
|
#define SERIAL_IMPL_WINDOWS_H
|
||||||
|
|
||||||
|
#include "include/serial.h"
|
||||||
|
|
||||||
|
#include "windows.h"
|
||||||
|
|
||||||
|
namespace serial {
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::wstring;
|
||||||
|
using std::invalid_argument;
|
||||||
|
|
||||||
|
using serial::SerialException;
|
||||||
|
using serial::IOException;
|
||||||
|
|
||||||
|
class serial::Serial::SerialImpl {
|
||||||
|
public:
|
||||||
|
SerialImpl (const string &port,
|
||||||
|
unsigned long baudrate,
|
||||||
|
bytesize_t bytesize,
|
||||||
|
parity_t parity,
|
||||||
|
stopbits_t stopbits,
|
||||||
|
flowcontrol_t flowcontrol);
|
||||||
|
|
||||||
|
virtual ~SerialImpl ();
|
||||||
|
|
||||||
|
void
|
||||||
|
open ();
|
||||||
|
|
||||||
|
void
|
||||||
|
close ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
isOpen () const;
|
||||||
|
|
||||||
|
size_t
|
||||||
|
available ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
waitReadable (uint32_t timeout);
|
||||||
|
|
||||||
|
void
|
||||||
|
waitByteTimes (size_t count);
|
||||||
|
|
||||||
|
size_t
|
||||||
|
read (uint8_t *buf, size_t size = 1);
|
||||||
|
|
||||||
|
size_t
|
||||||
|
write (const uint8_t *data, size_t length);
|
||||||
|
|
||||||
|
void
|
||||||
|
flush ();
|
||||||
|
|
||||||
|
void
|
||||||
|
flushInput ();
|
||||||
|
|
||||||
|
void
|
||||||
|
flushOutput ();
|
||||||
|
|
||||||
|
void
|
||||||
|
sendBreak (int duration);
|
||||||
|
|
||||||
|
void
|
||||||
|
setBreak (bool level);
|
||||||
|
|
||||||
|
void
|
||||||
|
setRTS (bool level);
|
||||||
|
|
||||||
|
void
|
||||||
|
setDTR (bool level);
|
||||||
|
|
||||||
|
bool
|
||||||
|
waitForChange ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
getCTS ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
getDSR ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
getRI ();
|
||||||
|
|
||||||
|
bool
|
||||||
|
getCD ();
|
||||||
|
|
||||||
|
void
|
||||||
|
setPort (const string &port);
|
||||||
|
|
||||||
|
string
|
||||||
|
getPort () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setTimeout (Timeout &timeout);
|
||||||
|
|
||||||
|
Timeout
|
||||||
|
getTimeout () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setBaudrate (unsigned long baudrate);
|
||||||
|
|
||||||
|
unsigned long
|
||||||
|
getBaudrate () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setBytesize (bytesize_t bytesize);
|
||||||
|
|
||||||
|
bytesize_t
|
||||||
|
getBytesize () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setParity (parity_t parity);
|
||||||
|
|
||||||
|
parity_t
|
||||||
|
getParity () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setStopbits (stopbits_t stopbits);
|
||||||
|
|
||||||
|
stopbits_t
|
||||||
|
getStopbits () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
setFlowcontrol (flowcontrol_t flowcontrol);
|
||||||
|
|
||||||
|
flowcontrol_t
|
||||||
|
getFlowcontrol () const;
|
||||||
|
|
||||||
|
void
|
||||||
|
readLock ();
|
||||||
|
|
||||||
|
void
|
||||||
|
readUnlock ();
|
||||||
|
|
||||||
|
void
|
||||||
|
writeLock ();
|
||||||
|
|
||||||
|
void
|
||||||
|
writeUnlock ();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void reconfigurePort ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
wstring port_; // Path to the file descriptor
|
||||||
|
HANDLE fd_;
|
||||||
|
|
||||||
|
bool is_open_;
|
||||||
|
|
||||||
|
Timeout timeout_; // Timeout for read operations
|
||||||
|
unsigned long baudrate_; // Baudrate
|
||||||
|
|
||||||
|
parity_t parity_; // Parity
|
||||||
|
bytesize_t bytesize_; // Size of the bytes
|
||||||
|
stopbits_t stopbits_; // Stop Bits
|
||||||
|
flowcontrol_t flowcontrol_; // Flow Control
|
||||||
|
|
||||||
|
// Mutex used to lock the read functions
|
||||||
|
HANDLE read_mutex;
|
||||||
|
// Mutex used to lock the write functions
|
||||||
|
HANDLE write_mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SERIAL_IMPL_WINDOWS_H
|
||||||
|
|
||||||
|
#endif // if defined(_WIN32)
|
||||||
@@ -0,0 +1,772 @@
|
|||||||
|
/*!
|
||||||
|
* \file serial/serial.h
|
||||||
|
* \author William Woodall <wjwwood@gmail.com>
|
||||||
|
* \author John Harrison <ash.gti@gmail.com>
|
||||||
|
* \version 0.1
|
||||||
|
*
|
||||||
|
* \section LICENSE
|
||||||
|
*
|
||||||
|
* The MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 William Woodall
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* \section DESCRIPTION
|
||||||
|
*
|
||||||
|
* This provides a cross platform interface for interacting with Serial Ports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SERIAL_H
|
||||||
|
#define SERIAL_H
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <cstring>
|
||||||
|
#include <sstream>
|
||||||
|
#include <exception>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#define THROW(exceptionClass, message) throw exceptionClass(__FILE__, \
|
||||||
|
__LINE__, (message) )
|
||||||
|
|
||||||
|
namespace serial {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Enumeration defines the possible bytesizes for the serial port.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
fivebits = 5,
|
||||||
|
sixbits = 6,
|
||||||
|
sevenbits = 7,
|
||||||
|
eightbits = 8
|
||||||
|
} bytesize_t;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Enumeration defines the possible parity types for the serial port.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
parity_none = 0,
|
||||||
|
parity_odd = 1,
|
||||||
|
parity_even = 2,
|
||||||
|
parity_mark = 3,
|
||||||
|
parity_space = 4
|
||||||
|
} parity_t;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Enumeration defines the possible stopbit types for the serial port.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
stopbits_one = 1,
|
||||||
|
stopbits_two = 2,
|
||||||
|
stopbits_one_point_five
|
||||||
|
} stopbits_t;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Enumeration defines the possible flowcontrol types for the serial port.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
flowcontrol_none = 0,
|
||||||
|
flowcontrol_software,
|
||||||
|
flowcontrol_hardware
|
||||||
|
} flowcontrol_t;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Structure for setting the timeout of the serial port, times are
|
||||||
|
* in milliseconds.
|
||||||
|
*
|
||||||
|
* In order to disable the interbyte timeout, set it to Timeout::max().
|
||||||
|
*/
|
||||||
|
struct Timeout {
|
||||||
|
#ifdef max
|
||||||
|
# undef max
|
||||||
|
#endif
|
||||||
|
static uint32_t max() {return std::numeric_limits<uint32_t>::max();}
|
||||||
|
/*!
|
||||||
|
* Convenience function to generate Timeout structs using a
|
||||||
|
* single absolute timeout.
|
||||||
|
*
|
||||||
|
* \param timeout A long that defines the time in milliseconds until a
|
||||||
|
* timeout occurs after a call to read or write is made.
|
||||||
|
*
|
||||||
|
* \return Timeout struct that represents this simple timeout provided.
|
||||||
|
*/
|
||||||
|
static Timeout simpleTimeout(uint32_t timeout) {
|
||||||
|
return Timeout(max(), timeout, 0, timeout, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Number of milliseconds between bytes received to timeout on. */
|
||||||
|
uint32_t inter_byte_timeout;
|
||||||
|
/*! A constant number of milliseconds to wait after calling read. */
|
||||||
|
uint32_t read_timeout_constant;
|
||||||
|
/*! A multiplier against the number of requested bytes to wait after
|
||||||
|
* calling read.
|
||||||
|
*/
|
||||||
|
uint32_t read_timeout_multiplier;
|
||||||
|
/*! A constant number of milliseconds to wait after calling write. */
|
||||||
|
uint32_t write_timeout_constant;
|
||||||
|
/*! A multiplier against the number of requested bytes to wait after
|
||||||
|
* calling write.
|
||||||
|
*/
|
||||||
|
uint32_t write_timeout_multiplier;
|
||||||
|
|
||||||
|
explicit Timeout (uint32_t inter_byte_timeout_=0,
|
||||||
|
uint32_t read_timeout_constant_=0,
|
||||||
|
uint32_t read_timeout_multiplier_=0,
|
||||||
|
uint32_t write_timeout_constant_=0,
|
||||||
|
uint32_t write_timeout_multiplier_=0)
|
||||||
|
: inter_byte_timeout(inter_byte_timeout_),
|
||||||
|
read_timeout_constant(read_timeout_constant_),
|
||||||
|
read_timeout_multiplier(read_timeout_multiplier_),
|
||||||
|
write_timeout_constant(write_timeout_constant_),
|
||||||
|
write_timeout_multiplier(write_timeout_multiplier_)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Class that provides a portable serial port interface.
|
||||||
|
*/
|
||||||
|
class Serial {
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Creates a Serial object and opens the port if a port is specified,
|
||||||
|
* otherwise it remains closed until serial::Serial::open is called.
|
||||||
|
*
|
||||||
|
* \param port A std::string containing the address of the serial port,
|
||||||
|
* which would be something like 'COM1' on Windows and '/dev/ttyS0'
|
||||||
|
* on Linux.
|
||||||
|
*
|
||||||
|
* \param baudrate An unsigned 32-bit integer that represents the baudrate
|
||||||
|
*
|
||||||
|
* \param timeout A serial::Timeout struct that defines the timeout
|
||||||
|
* conditions for the serial port. \see serial::Timeout
|
||||||
|
*
|
||||||
|
* \param bytesize Size of each byte in the serial transmission of data,
|
||||||
|
* default is eightbits, possible values are: fivebits, sixbits, sevenbits,
|
||||||
|
* eightbits
|
||||||
|
*
|
||||||
|
* \param parity Method of parity, default is parity_none, possible values
|
||||||
|
* are: parity_none, parity_odd, parity_even
|
||||||
|
*
|
||||||
|
* \param stopbits Number of stop bits used, default is stopbits_one,
|
||||||
|
* possible values are: stopbits_one, stopbits_one_point_five, stopbits_two
|
||||||
|
*
|
||||||
|
* \param flowcontrol Type of flowcontrol used, default is
|
||||||
|
* flowcontrol_none, possible values are: flowcontrol_none,
|
||||||
|
* flowcontrol_software, flowcontrol_hardware
|
||||||
|
*
|
||||||
|
* \throw serial::PortNotOpenedException
|
||||||
|
* \throw serial::IOException
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
Serial (const std::string &port = "",
|
||||||
|
uint32_t baudrate = 9600,
|
||||||
|
Timeout timeout = Timeout(),
|
||||||
|
bytesize_t bytesize = eightbits,
|
||||||
|
parity_t parity = parity_none,
|
||||||
|
stopbits_t stopbits = stopbits_one,
|
||||||
|
flowcontrol_t flowcontrol = flowcontrol_none);
|
||||||
|
|
||||||
|
/*! Destructor */
|
||||||
|
virtual ~Serial ();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Opens the serial port as long as the port is set and the port isn't
|
||||||
|
* already open.
|
||||||
|
*
|
||||||
|
* If the port is provided to the constructor then an explicit call to open
|
||||||
|
* is not needed.
|
||||||
|
*
|
||||||
|
* \see Serial::Serial
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
* \throw serial::SerialException
|
||||||
|
* \throw serial::IOException
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
open ();
|
||||||
|
|
||||||
|
/*! Gets the open status of the serial port.
|
||||||
|
*
|
||||||
|
* \return Returns true if the port is open, false otherwise.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
isOpen () const;
|
||||||
|
|
||||||
|
/*! Closes the serial port. */
|
||||||
|
void
|
||||||
|
close ();
|
||||||
|
|
||||||
|
/*! Return the number of characters in the buffer. */
|
||||||
|
size_t
|
||||||
|
available ();
|
||||||
|
|
||||||
|
/*! Block until there is serial data to read or read_timeout_constant
|
||||||
|
* number of milliseconds have elapsed. The return value is true when
|
||||||
|
* the function exits with the port in a readable state, false otherwise
|
||||||
|
* (due to timeout or select interruption). */
|
||||||
|
bool
|
||||||
|
waitReadable ();
|
||||||
|
|
||||||
|
/*! Block for a period of time corresponding to the transmission time of
|
||||||
|
* count characters at present serial settings. This may be used in con-
|
||||||
|
* junction with waitReadable to read larger blocks of data from the
|
||||||
|
* port. */
|
||||||
|
void
|
||||||
|
waitByteTimes (size_t count);
|
||||||
|
|
||||||
|
/*! Read a given amount of bytes from the serial port into a given buffer.
|
||||||
|
*
|
||||||
|
* The read function will return in one of three cases:
|
||||||
|
* * The number of requested bytes was read.
|
||||||
|
* * In this case the number of bytes requested will match the size_t
|
||||||
|
* returned by read.
|
||||||
|
* * A timeout occurred, in this case the number of bytes read will not
|
||||||
|
* match the amount requested, but no exception will be thrown. One of
|
||||||
|
* two possible timeouts occurred:
|
||||||
|
* * The inter byte timeout expired, this means that number of
|
||||||
|
* milliseconds elapsed between receiving bytes from the serial port
|
||||||
|
* exceeded the inter byte timeout.
|
||||||
|
* * The total timeout expired, which is calculated by multiplying the
|
||||||
|
* read timeout multiplier by the number of requested bytes and then
|
||||||
|
* added to the read timeout constant. If that total number of
|
||||||
|
* milliseconds elapses after the initial call to read a timeout will
|
||||||
|
* occur.
|
||||||
|
* * An exception occurred, in this case an actual exception will be thrown.
|
||||||
|
*
|
||||||
|
* \param buffer An uint8_t array of at least the requested size.
|
||||||
|
* \param size A size_t defining how many bytes to be read.
|
||||||
|
*
|
||||||
|
* \return A size_t representing the number of bytes read as a result of the
|
||||||
|
* call to read.
|
||||||
|
*
|
||||||
|
* \throw serial::PortNotOpenedException
|
||||||
|
* \throw serial::SerialException
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
read (uint8_t *buffer, size_t size);
|
||||||
|
|
||||||
|
/*! Read a given amount of bytes from the serial port into a give buffer.
|
||||||
|
*
|
||||||
|
* \param buffer A reference to a std::vector of uint8_t.
|
||||||
|
* \param size A size_t defining how many bytes to be read.
|
||||||
|
*
|
||||||
|
* \return A size_t representing the number of bytes read as a result of the
|
||||||
|
* call to read.
|
||||||
|
*
|
||||||
|
* \throw serial::PortNotOpenedException
|
||||||
|
* \throw serial::SerialException
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
read (std::vector<uint8_t> &buffer, size_t size = 1);
|
||||||
|
|
||||||
|
/*! Read a given amount of bytes from the serial port into a give buffer.
|
||||||
|
*
|
||||||
|
* \param buffer A reference to a std::string.
|
||||||
|
* \param size A size_t defining how many bytes to be read.
|
||||||
|
*
|
||||||
|
* \return A size_t representing the number of bytes read as a result of the
|
||||||
|
* call to read.
|
||||||
|
*
|
||||||
|
* \throw serial::PortNotOpenedException
|
||||||
|
* \throw serial::SerialException
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
read (std::string &buffer, size_t size = 1);
|
||||||
|
|
||||||
|
/*! Read a given amount of bytes from the serial port and return a string
|
||||||
|
* containing the data.
|
||||||
|
*
|
||||||
|
* \param size A size_t defining how many bytes to be read.
|
||||||
|
*
|
||||||
|
* \return A std::string containing the data read from the port.
|
||||||
|
*
|
||||||
|
* \throw serial::PortNotOpenedException
|
||||||
|
* \throw serial::SerialException
|
||||||
|
*/
|
||||||
|
std::string
|
||||||
|
read (size_t size = 1);
|
||||||
|
|
||||||
|
/*! Reads in a line or until a given delimiter has been processed.
|
||||||
|
*
|
||||||
|
* Reads from the serial port until a single line has been read.
|
||||||
|
*
|
||||||
|
* \param buffer A std::string reference used to store the data.
|
||||||
|
* \param size A maximum length of a line, defaults to 65536 (2^16)
|
||||||
|
* \param eol A string to match against for the EOL.
|
||||||
|
*
|
||||||
|
* \return A size_t representing the number of bytes read.
|
||||||
|
*
|
||||||
|
* \throw serial::PortNotOpenedException
|
||||||
|
* \throw serial::SerialException
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
readline (std::string &buffer, size_t size = 65536, std::string eol = "\n");
|
||||||
|
|
||||||
|
/*! Reads in a line or until a given delimiter has been processed.
|
||||||
|
*
|
||||||
|
* Reads from the serial port until a single line has been read.
|
||||||
|
*
|
||||||
|
* \param size A maximum length of a line, defaults to 65536 (2^16)
|
||||||
|
* \param eol A string to match against for the EOL.
|
||||||
|
*
|
||||||
|
* \return A std::string containing the line.
|
||||||
|
*
|
||||||
|
* \throw serial::PortNotOpenedException
|
||||||
|
* \throw serial::SerialException
|
||||||
|
*/
|
||||||
|
std::string
|
||||||
|
readline (size_t size = 65536, std::string eol = "\n");
|
||||||
|
|
||||||
|
/*! Reads in multiple lines until the serial port times out.
|
||||||
|
*
|
||||||
|
* This requires a timeout > 0 before it can be run. It will read until a
|
||||||
|
* timeout occurs and return a list of strings.
|
||||||
|
*
|
||||||
|
* \param size A maximum length of combined lines, defaults to 65536 (2^16)
|
||||||
|
*
|
||||||
|
* \param eol A string to match against for the EOL.
|
||||||
|
*
|
||||||
|
* \return A vector<string> containing the lines.
|
||||||
|
*
|
||||||
|
* \throw serial::PortNotOpenedException
|
||||||
|
* \throw serial::SerialException
|
||||||
|
*/
|
||||||
|
std::vector<std::string>
|
||||||
|
readlines (size_t size = 65536, std::string eol = "\n");
|
||||||
|
|
||||||
|
/*! Write a string to the serial port.
|
||||||
|
*
|
||||||
|
* \param data A const reference containing the data to be written
|
||||||
|
* to the serial port.
|
||||||
|
*
|
||||||
|
* \param size A size_t that indicates how many bytes should be written from
|
||||||
|
* the given data buffer.
|
||||||
|
*
|
||||||
|
* \return A size_t representing the number of bytes actually written to
|
||||||
|
* the serial port.
|
||||||
|
*
|
||||||
|
* \throw serial::PortNotOpenedException
|
||||||
|
* \throw serial::SerialException
|
||||||
|
* \throw serial::IOException
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
write (const uint8_t *data, size_t size);
|
||||||
|
|
||||||
|
/*! Write a string to the serial port.
|
||||||
|
*
|
||||||
|
* \param data A const reference containing the data to be written
|
||||||
|
* to the serial port.
|
||||||
|
*
|
||||||
|
* \return A size_t representing the number of bytes actually written to
|
||||||
|
* the serial port.
|
||||||
|
*
|
||||||
|
* \throw serial::PortNotOpenedException
|
||||||
|
* \throw serial::SerialException
|
||||||
|
* \throw serial::IOException
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
write (const std::vector<uint8_t> &data);
|
||||||
|
|
||||||
|
/*! Write a string to the serial port.
|
||||||
|
*
|
||||||
|
* \param data A const reference containing the data to be written
|
||||||
|
* to the serial port.
|
||||||
|
*
|
||||||
|
* \return A size_t representing the number of bytes actually written to
|
||||||
|
* the serial port.
|
||||||
|
*
|
||||||
|
* \throw serial::PortNotOpenedException
|
||||||
|
* \throw serial::SerialException
|
||||||
|
* \throw serial::IOException
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
write (const std::string &data);
|
||||||
|
|
||||||
|
/*! Sets the serial port identifier.
|
||||||
|
*
|
||||||
|
* \param port A const std::string reference containing the address of the
|
||||||
|
* serial port, which would be something like 'COM1' on Windows and
|
||||||
|
* '/dev/ttyS0' on Linux.
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
setPort (const std::string &port);
|
||||||
|
|
||||||
|
/*! Gets the serial port identifier.
|
||||||
|
*
|
||||||
|
* \see Serial::setPort
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
std::string
|
||||||
|
getPort () const;
|
||||||
|
|
||||||
|
/*! Sets the timeout for reads and writes using the Timeout struct.
|
||||||
|
*
|
||||||
|
* There are two timeout conditions described here:
|
||||||
|
* * The inter byte timeout:
|
||||||
|
* * The inter_byte_timeout component of serial::Timeout defines the
|
||||||
|
* maximum amount of time, in milliseconds, between receiving bytes on
|
||||||
|
* the serial port that can pass before a timeout occurs. Setting this
|
||||||
|
* to zero will prevent inter byte timeouts from occurring.
|
||||||
|
* * Total time timeout:
|
||||||
|
* * The constant and multiplier component of this timeout condition,
|
||||||
|
* for both read and write, are defined in serial::Timeout. This
|
||||||
|
* timeout occurs if the total time since the read or write call was
|
||||||
|
* made exceeds the specified time in milliseconds.
|
||||||
|
* * The limit is defined by multiplying the multiplier component by the
|
||||||
|
* number of requested bytes and adding that product to the constant
|
||||||
|
* component. In this way if you want a read call, for example, to
|
||||||
|
* timeout after exactly one second regardless of the number of bytes
|
||||||
|
* you asked for then set the read_timeout_constant component of
|
||||||
|
* serial::Timeout to 1000 and the read_timeout_multiplier to zero.
|
||||||
|
* This timeout condition can be used in conjunction with the inter
|
||||||
|
* byte timeout condition with out any problems, timeout will simply
|
||||||
|
* occur when one of the two timeout conditions is met. This allows
|
||||||
|
* users to have maximum control over the trade-off between
|
||||||
|
* responsiveness and efficiency.
|
||||||
|
*
|
||||||
|
* Read and write functions will return in one of three cases. When the
|
||||||
|
* reading or writing is complete, when a timeout occurs, or when an
|
||||||
|
* exception occurs.
|
||||||
|
*
|
||||||
|
* \param timeout A serial::Timeout struct containing the inter byte
|
||||||
|
* timeout, and the read and write timeout constants and multipliers.
|
||||||
|
*
|
||||||
|
* \see serial::Timeout
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
setTimeout (Timeout &timeout);
|
||||||
|
|
||||||
|
/*! Sets the timeout for reads and writes. */
|
||||||
|
void
|
||||||
|
setTimeout (uint32_t inter_byte_timeout, uint32_t read_timeout_constant,
|
||||||
|
uint32_t read_timeout_multiplier, uint32_t write_timeout_constant,
|
||||||
|
uint32_t write_timeout_multiplier)
|
||||||
|
{
|
||||||
|
Timeout timeout(inter_byte_timeout, read_timeout_constant,
|
||||||
|
read_timeout_multiplier, write_timeout_constant,
|
||||||
|
write_timeout_multiplier);
|
||||||
|
return setTimeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Gets the timeout for reads in seconds.
|
||||||
|
*
|
||||||
|
* \return A Timeout struct containing the inter_byte_timeout, and read
|
||||||
|
* and write timeout constants and multipliers.
|
||||||
|
*
|
||||||
|
* \see Serial::setTimeout
|
||||||
|
*/
|
||||||
|
Timeout
|
||||||
|
getTimeout () const;
|
||||||
|
|
||||||
|
/*! Sets the baudrate for the serial port.
|
||||||
|
*
|
||||||
|
* Possible baudrates depends on the system but some safe baudrates include:
|
||||||
|
* 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 56000,
|
||||||
|
* 57600, 115200
|
||||||
|
* Some other baudrates that are supported by some comports:
|
||||||
|
* 128000, 153600, 230400, 256000, 460800, 921600
|
||||||
|
*
|
||||||
|
* \param baudrate An integer that sets the baud rate for the serial port.
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
setBaudrate (uint32_t baudrate);
|
||||||
|
|
||||||
|
/*! Gets the baudrate for the serial port.
|
||||||
|
*
|
||||||
|
* \return An integer that sets the baud rate for the serial port.
|
||||||
|
*
|
||||||
|
* \see Serial::setBaudrate
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
uint32_t
|
||||||
|
getBaudrate () const;
|
||||||
|
|
||||||
|
/*! Sets the bytesize for the serial port.
|
||||||
|
*
|
||||||
|
* \param bytesize Size of each byte in the serial transmission of data,
|
||||||
|
* default is eightbits, possible values are: fivebits, sixbits, sevenbits,
|
||||||
|
* eightbits
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
setBytesize (bytesize_t bytesize);
|
||||||
|
|
||||||
|
/*! Gets the bytesize for the serial port.
|
||||||
|
*
|
||||||
|
* \see Serial::setBytesize
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
bytesize_t
|
||||||
|
getBytesize () const;
|
||||||
|
|
||||||
|
/*! Sets the parity for the serial port.
|
||||||
|
*
|
||||||
|
* \param parity Method of parity, default is parity_none, possible values
|
||||||
|
* are: parity_none, parity_odd, parity_even
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
setParity (parity_t parity);
|
||||||
|
|
||||||
|
/*! Gets the parity for the serial port.
|
||||||
|
*
|
||||||
|
* \see Serial::setParity
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
parity_t
|
||||||
|
getParity () const;
|
||||||
|
|
||||||
|
/*! Sets the stopbits for the serial port.
|
||||||
|
*
|
||||||
|
* \param stopbits Number of stop bits used, default is stopbits_one,
|
||||||
|
* possible values are: stopbits_one, stopbits_one_point_five, stopbits_two
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
setStopbits (stopbits_t stopbits);
|
||||||
|
|
||||||
|
/*! Gets the stopbits for the serial port.
|
||||||
|
*
|
||||||
|
* \see Serial::setStopbits
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
stopbits_t
|
||||||
|
getStopbits () const;
|
||||||
|
|
||||||
|
/*! Sets the flow control for the serial port.
|
||||||
|
*
|
||||||
|
* \param flowcontrol Type of flowcontrol used, default is flowcontrol_none,
|
||||||
|
* possible values are: flowcontrol_none, flowcontrol_software,
|
||||||
|
* flowcontrol_hardware
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
setFlowcontrol (flowcontrol_t flowcontrol);
|
||||||
|
|
||||||
|
/*! Gets the flow control for the serial port.
|
||||||
|
*
|
||||||
|
* \see Serial::setFlowcontrol
|
||||||
|
*
|
||||||
|
* \throw std::invalid_argument
|
||||||
|
*/
|
||||||
|
flowcontrol_t
|
||||||
|
getFlowcontrol () const;
|
||||||
|
|
||||||
|
/*! Flush the input and output buffers */
|
||||||
|
void
|
||||||
|
flush ();
|
||||||
|
|
||||||
|
/*! Flush only the input buffer */
|
||||||
|
void
|
||||||
|
flushInput ();
|
||||||
|
|
||||||
|
/*! Flush only the output buffer */
|
||||||
|
void
|
||||||
|
flushOutput ();
|
||||||
|
|
||||||
|
/*! Sends the RS-232 break signal. See tcsendbreak(3). */
|
||||||
|
void
|
||||||
|
sendBreak (int duration);
|
||||||
|
|
||||||
|
/*! Set the break condition to a given level. Defaults to true. */
|
||||||
|
void
|
||||||
|
setBreak (bool level = true);
|
||||||
|
|
||||||
|
/*! Set the RTS handshaking line to the given level. Defaults to true. */
|
||||||
|
void
|
||||||
|
setRTS (bool level = true);
|
||||||
|
|
||||||
|
/*! Set the DTR handshaking line to the given level. Defaults to true. */
|
||||||
|
void
|
||||||
|
setDTR (bool level = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Blocks until CTS, DSR, RI, CD changes or something interrupts it.
|
||||||
|
*
|
||||||
|
* Can throw an exception if an error occurs while waiting.
|
||||||
|
* You can check the status of CTS, DSR, RI, and CD once this returns.
|
||||||
|
* Uses TIOCMIWAIT via ioctl if available (mostly only on Linux) with a
|
||||||
|
* resolution of less than +-1ms and as good as +-0.2ms. Otherwise a
|
||||||
|
* polling method is used which can give +-2ms.
|
||||||
|
*
|
||||||
|
* \return Returns true if one of the lines changed, false if something else
|
||||||
|
* occurred.
|
||||||
|
*
|
||||||
|
* \throw SerialException
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
waitForChange ();
|
||||||
|
|
||||||
|
/*! Returns the current status of the CTS line. */
|
||||||
|
bool
|
||||||
|
getCTS ();
|
||||||
|
|
||||||
|
/*! Returns the current status of the DSR line. */
|
||||||
|
bool
|
||||||
|
getDSR ();
|
||||||
|
|
||||||
|
/*! Returns the current status of the RI line. */
|
||||||
|
bool
|
||||||
|
getRI ();
|
||||||
|
|
||||||
|
/*! Returns the current status of the CD line. */
|
||||||
|
bool
|
||||||
|
getCD ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Disable copy constructors
|
||||||
|
Serial(const Serial&);
|
||||||
|
Serial& operator=(const Serial&);
|
||||||
|
|
||||||
|
// Pimpl idiom, d_pointer
|
||||||
|
class SerialImpl;
|
||||||
|
SerialImpl *pimpl_;
|
||||||
|
|
||||||
|
// Scoped Lock Classes
|
||||||
|
class ScopedReadLock;
|
||||||
|
class ScopedWriteLock;
|
||||||
|
|
||||||
|
// Read common function
|
||||||
|
size_t
|
||||||
|
read_ (uint8_t *buffer, size_t size);
|
||||||
|
// Write common function
|
||||||
|
size_t
|
||||||
|
write_ (const uint8_t *data, size_t length);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class SerialException : public std::exception
|
||||||
|
{
|
||||||
|
// Disable copy constructors
|
||||||
|
SerialException& operator=(const SerialException&);
|
||||||
|
std::string e_what_;
|
||||||
|
public:
|
||||||
|
SerialException (const char *description) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "SerialException " << description << " failed.";
|
||||||
|
e_what_ = ss.str();
|
||||||
|
}
|
||||||
|
SerialException (const SerialException& other) : e_what_(other.e_what_) {}
|
||||||
|
virtual ~SerialException() throw() {}
|
||||||
|
virtual const char* what () const throw () {
|
||||||
|
return e_what_.c_str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class IOException : public std::exception
|
||||||
|
{
|
||||||
|
// Disable copy constructors
|
||||||
|
IOException& operator=(const IOException&);
|
||||||
|
std::string file_;
|
||||||
|
int line_;
|
||||||
|
std::string e_what_;
|
||||||
|
int errno_;
|
||||||
|
public:
|
||||||
|
explicit IOException (std::string file, int line, int errnum)
|
||||||
|
: file_(file), line_(line), errno_(errnum) {
|
||||||
|
std::stringstream ss;
|
||||||
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
|
char error_str [1024];
|
||||||
|
strerror_s(error_str, 1024, errnum);
|
||||||
|
#else
|
||||||
|
char * error_str = strerror(errnum);
|
||||||
|
#endif
|
||||||
|
ss << "IO Exception (" << errno_ << "): " << error_str;
|
||||||
|
ss << ", file " << file_ << ", line " << line_ << ".";
|
||||||
|
e_what_ = ss.str();
|
||||||
|
}
|
||||||
|
explicit IOException (std::string file, int line, const char * description)
|
||||||
|
: file_(file), line_(line), errno_(0) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "IO Exception: " << description;
|
||||||
|
ss << ", file " << file_ << ", line " << line_ << ".";
|
||||||
|
e_what_ = ss.str();
|
||||||
|
}
|
||||||
|
virtual ~IOException() throw() {}
|
||||||
|
IOException (const IOException& other) : line_(other.line_), e_what_(other.e_what_), errno_(other.errno_) {}
|
||||||
|
|
||||||
|
int getErrorNumber () { return errno_; }
|
||||||
|
|
||||||
|
virtual const char* what () const throw () {
|
||||||
|
return e_what_.c_str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class PortNotOpenedException : public std::exception
|
||||||
|
{
|
||||||
|
// Disable copy constructors
|
||||||
|
const PortNotOpenedException& operator=(PortNotOpenedException);
|
||||||
|
std::string e_what_;
|
||||||
|
public:
|
||||||
|
PortNotOpenedException (const char * description) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "PortNotOpenedException " << description << " failed.";
|
||||||
|
e_what_ = ss.str();
|
||||||
|
}
|
||||||
|
PortNotOpenedException (const PortNotOpenedException& other) : e_what_(other.e_what_) {}
|
||||||
|
virtual ~PortNotOpenedException() throw() {}
|
||||||
|
virtual const char* what () const throw () {
|
||||||
|
return e_what_.c_str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Structure that describes a serial device.
|
||||||
|
*/
|
||||||
|
struct PortInfo {
|
||||||
|
|
||||||
|
/*! Address of the serial port (this can be passed to the constructor of Serial). */
|
||||||
|
std::string port;
|
||||||
|
|
||||||
|
/*! Human readable description of serial device if available. */
|
||||||
|
std::string description;
|
||||||
|
|
||||||
|
/*! Hardware ID (e.g. VID:PID of USB serial devices) or "n/a" if not available. */
|
||||||
|
std::string hardware_id;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Lists the serial ports available on the system
|
||||||
|
*
|
||||||
|
* Returns a vector of available serial ports, each represented
|
||||||
|
* by a serial::PortInfo data structure:
|
||||||
|
*
|
||||||
|
* \return vector of serial::PortInfo.
|
||||||
|
*/
|
||||||
|
std::vector<PortInfo>
|
||||||
|
list_ports();
|
||||||
|
|
||||||
|
} // namespace serial
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
// This header is from the v8 google project:
|
||||||
|
// http://code.google.com/p/v8/source/browse/trunk/include/v8stdint.h
|
||||||
|
|
||||||
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following
|
||||||
|
// disclaimer in the documentation and/or other materials provided
|
||||||
|
// with the distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
// Load definitions of standard types.
|
||||||
|
|
||||||
|
#ifndef V8STDINT_H_
|
||||||
|
#define V8STDINT_H_
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
|
|
||||||
|
typedef signed char int8_t;
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef short int16_t; // NOLINT
|
||||||
|
typedef unsigned short uint16_t; // NOLINT
|
||||||
|
typedef int int32_t;
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
typedef __int64 int64_t;
|
||||||
|
typedef unsigned __int64 uint64_t;
|
||||||
|
// intptr_t and friends are defined in crtdefs.h through stdio.h.
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // V8STDINT_H_
|
||||||
@@ -0,0 +1,335 @@
|
|||||||
|
#if defined(__linux__)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2014 Craig Lilley <cralilley@gmail.com>
|
||||||
|
* This software is made available under the terms of the MIT licence.
|
||||||
|
* A copy of the licence can be obtained from:
|
||||||
|
* http://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#include <glob.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "../../../include/serial.h"
|
||||||
|
|
||||||
|
|
||||||
|
using serial::PortInfo;
|
||||||
|
using std::istringstream;
|
||||||
|
using std::ifstream;
|
||||||
|
using std::getline;
|
||||||
|
using std::vector;
|
||||||
|
using std::string;
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
static vector<string> glob(const vector<string>& patterns);
|
||||||
|
static string basename(const string& path);
|
||||||
|
static string dirname(const string& path);
|
||||||
|
static bool path_exists(const string& path);
|
||||||
|
static string realpath(const string& path);
|
||||||
|
static string usb_sysfs_friendly_name(const string& sys_usb_path);
|
||||||
|
static vector<string> get_sysfs_info(const string& device_path);
|
||||||
|
static string read_line(const string& file);
|
||||||
|
static string usb_sysfs_hw_string(const string& sysfs_path);
|
||||||
|
static string format(const char* format, ...);
|
||||||
|
|
||||||
|
vector<string>
|
||||||
|
glob(const vector<string>& patterns)
|
||||||
|
{
|
||||||
|
vector<string> paths_found;
|
||||||
|
|
||||||
|
if(patterns.size() == 0)
|
||||||
|
return paths_found;
|
||||||
|
|
||||||
|
glob_t glob_results;
|
||||||
|
|
||||||
|
int glob_retval = glob(patterns[0].c_str(), 0, NULL, &glob_results);
|
||||||
|
|
||||||
|
vector<string>::const_iterator iter = patterns.begin();
|
||||||
|
|
||||||
|
while(++iter != patterns.end())
|
||||||
|
{
|
||||||
|
glob_retval = glob(iter->c_str(), GLOB_APPEND, NULL, &glob_results);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int path_index = 0; path_index < glob_results.gl_pathc; path_index++)
|
||||||
|
{
|
||||||
|
paths_found.push_back(glob_results.gl_pathv[path_index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
globfree(&glob_results);
|
||||||
|
|
||||||
|
return paths_found;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
basename(const string& path)
|
||||||
|
{
|
||||||
|
size_t pos = path.rfind("/");
|
||||||
|
|
||||||
|
if(pos == std::string::npos)
|
||||||
|
return path;
|
||||||
|
|
||||||
|
return string(path, pos+1, string::npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
dirname(const string& path)
|
||||||
|
{
|
||||||
|
size_t pos = path.rfind("/");
|
||||||
|
|
||||||
|
if(pos == std::string::npos)
|
||||||
|
return path;
|
||||||
|
else if(pos == 0)
|
||||||
|
return "/";
|
||||||
|
|
||||||
|
return string(path, 0, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
path_exists(const string& path)
|
||||||
|
{
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
if( stat(path.c_str(), &sb ) == 0 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
realpath(const string& path)
|
||||||
|
{
|
||||||
|
char* real_path = realpath(path.c_str(), NULL);
|
||||||
|
|
||||||
|
string result;
|
||||||
|
|
||||||
|
if(real_path != NULL)
|
||||||
|
{
|
||||||
|
result = real_path;
|
||||||
|
|
||||||
|
free(real_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
usb_sysfs_friendly_name(const string& sys_usb_path)
|
||||||
|
{
|
||||||
|
unsigned int device_number = 0;
|
||||||
|
|
||||||
|
istringstream( read_line(sys_usb_path + "/devnum") ) >> device_number;
|
||||||
|
|
||||||
|
string manufacturer = read_line( sys_usb_path + "/manufacturer" );
|
||||||
|
|
||||||
|
string product = read_line( sys_usb_path + "/product" );
|
||||||
|
|
||||||
|
string serial = read_line( sys_usb_path + "/serial" );
|
||||||
|
|
||||||
|
if( manufacturer.empty() && product.empty() && serial.empty() )
|
||||||
|
return "";
|
||||||
|
|
||||||
|
return format("%s %s %s", manufacturer.c_str(), product.c_str(), serial.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<string>
|
||||||
|
get_sysfs_info(const string& device_path)
|
||||||
|
{
|
||||||
|
string device_name = basename( device_path );
|
||||||
|
|
||||||
|
string friendly_name;
|
||||||
|
|
||||||
|
string hardware_id;
|
||||||
|
|
||||||
|
string sys_device_path = format( "/sys/class/tty/%s/device", device_name.c_str() );
|
||||||
|
|
||||||
|
if( device_name.compare(0,6,"ttyUSB") == 0 )
|
||||||
|
{
|
||||||
|
sys_device_path = dirname( dirname( realpath( sys_device_path ) ) );
|
||||||
|
|
||||||
|
if( path_exists( sys_device_path ) )
|
||||||
|
{
|
||||||
|
friendly_name = usb_sysfs_friendly_name( sys_device_path );
|
||||||
|
|
||||||
|
hardware_id = usb_sysfs_hw_string( sys_device_path );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( device_name.compare(0,6,"ttyACM") == 0 )
|
||||||
|
{
|
||||||
|
sys_device_path = dirname( realpath( sys_device_path ) );
|
||||||
|
|
||||||
|
if( path_exists( sys_device_path ) )
|
||||||
|
{
|
||||||
|
friendly_name = usb_sysfs_friendly_name( sys_device_path );
|
||||||
|
|
||||||
|
hardware_id = usb_sysfs_hw_string( sys_device_path );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Try to read ID string of PCI device
|
||||||
|
|
||||||
|
string sys_id_path = sys_device_path + "/id";
|
||||||
|
|
||||||
|
if( path_exists( sys_id_path ) )
|
||||||
|
hardware_id = read_line( sys_id_path );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( friendly_name.empty() )
|
||||||
|
friendly_name = device_name;
|
||||||
|
|
||||||
|
if( hardware_id.empty() )
|
||||||
|
hardware_id = "n/a";
|
||||||
|
|
||||||
|
vector<string> result;
|
||||||
|
result.push_back(friendly_name);
|
||||||
|
result.push_back(hardware_id);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
read_line(const string& file)
|
||||||
|
{
|
||||||
|
ifstream ifs(file.c_str(), ifstream::in);
|
||||||
|
|
||||||
|
string line;
|
||||||
|
|
||||||
|
if(ifs)
|
||||||
|
{
|
||||||
|
getline(ifs, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
format(const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
size_t buffer_size_bytes = 256;
|
||||||
|
|
||||||
|
string result;
|
||||||
|
|
||||||
|
char* buffer = (char*)malloc(buffer_size_bytes);
|
||||||
|
|
||||||
|
if( buffer == NULL )
|
||||||
|
return result;
|
||||||
|
|
||||||
|
bool done = false;
|
||||||
|
|
||||||
|
unsigned int loop_count = 0;
|
||||||
|
|
||||||
|
while(!done)
|
||||||
|
{
|
||||||
|
va_start(ap, format);
|
||||||
|
|
||||||
|
int return_value = vsnprintf(buffer, buffer_size_bytes, format, ap);
|
||||||
|
|
||||||
|
if( return_value < 0 )
|
||||||
|
{
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
else if( return_value >= buffer_size_bytes )
|
||||||
|
{
|
||||||
|
// Realloc and try again.
|
||||||
|
|
||||||
|
buffer_size_bytes = return_value + 1;
|
||||||
|
|
||||||
|
char* new_buffer_ptr = (char*)realloc(buffer, buffer_size_bytes);
|
||||||
|
|
||||||
|
if( new_buffer_ptr == NULL )
|
||||||
|
{
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer = new_buffer_ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = buffer;
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if( ++loop_count > 5 )
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
usb_sysfs_hw_string(const string& sysfs_path)
|
||||||
|
{
|
||||||
|
string serial_number = read_line( sysfs_path + "/serial" );
|
||||||
|
|
||||||
|
if( serial_number.length() > 0 )
|
||||||
|
{
|
||||||
|
serial_number = format( "SNR=%s", serial_number.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
string vid = read_line( sysfs_path + "/idVendor" );
|
||||||
|
|
||||||
|
string pid = read_line( sysfs_path + "/idProduct" );
|
||||||
|
|
||||||
|
return format("USB VID:PID=%s:%s %s", vid.c_str(), pid.c_str(), serial_number.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<PortInfo>
|
||||||
|
serial::list_ports()
|
||||||
|
{
|
||||||
|
vector<PortInfo> results;
|
||||||
|
|
||||||
|
vector<string> search_globs;
|
||||||
|
search_globs.push_back("/dev/ttyACM*");
|
||||||
|
search_globs.push_back("/dev/ttyS*");
|
||||||
|
search_globs.push_back("/dev/ttyUSB*");
|
||||||
|
search_globs.push_back("/dev/tty.*");
|
||||||
|
search_globs.push_back("/dev/cu.*");
|
||||||
|
|
||||||
|
vector<string> devices_found = glob( search_globs );
|
||||||
|
|
||||||
|
vector<string>::iterator iter = devices_found.begin();
|
||||||
|
|
||||||
|
while( iter != devices_found.end() )
|
||||||
|
{
|
||||||
|
string device = *iter++;
|
||||||
|
|
||||||
|
vector<string> sysfs_info = get_sysfs_info( device );
|
||||||
|
|
||||||
|
string friendly_name = sysfs_info[0];
|
||||||
|
|
||||||
|
string hardware_id = sysfs_info[1];
|
||||||
|
|
||||||
|
PortInfo device_entry;
|
||||||
|
device_entry.port = device;
|
||||||
|
device_entry.description = friendly_name;
|
||||||
|
device_entry.hardware_id = hardware_id;
|
||||||
|
|
||||||
|
results.push_back( device_entry );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // defined(__linux__)
|
||||||
@@ -0,0 +1,286 @@
|
|||||||
|
#if defined(__APPLE__)
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#include <IOKit/IOKitLib.h>
|
||||||
|
#include <IOKit/serial/IOSerialKeys.h>
|
||||||
|
#include <IOKit/IOBSD.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "serial/serial.h"
|
||||||
|
|
||||||
|
using serial::PortInfo;
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
#define HARDWARE_ID_STRING_LENGTH 128
|
||||||
|
|
||||||
|
string cfstring_to_string( CFStringRef cfstring );
|
||||||
|
string get_device_path( io_object_t& serial_port );
|
||||||
|
string get_class_name( io_object_t& obj );
|
||||||
|
io_registry_entry_t get_parent_iousb_device( io_object_t& serial_port );
|
||||||
|
string get_string_property( io_object_t& device, const char* property );
|
||||||
|
uint16_t get_int_property( io_object_t& device, const char* property );
|
||||||
|
string rtrim(const string& str);
|
||||||
|
|
||||||
|
string
|
||||||
|
cfstring_to_string( CFStringRef cfstring )
|
||||||
|
{
|
||||||
|
char cstring[MAXPATHLEN];
|
||||||
|
string result;
|
||||||
|
|
||||||
|
if( cfstring )
|
||||||
|
{
|
||||||
|
Boolean success = CFStringGetCString( cfstring,
|
||||||
|
cstring,
|
||||||
|
sizeof(cstring),
|
||||||
|
kCFStringEncodingASCII );
|
||||||
|
|
||||||
|
if( success )
|
||||||
|
result = cstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
get_device_path( io_object_t& serial_port )
|
||||||
|
{
|
||||||
|
CFTypeRef callout_path;
|
||||||
|
string device_path;
|
||||||
|
|
||||||
|
callout_path = IORegistryEntryCreateCFProperty( serial_port,
|
||||||
|
CFSTR(kIOCalloutDeviceKey),
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
0 );
|
||||||
|
|
||||||
|
if (callout_path)
|
||||||
|
{
|
||||||
|
if( CFGetTypeID(callout_path) == CFStringGetTypeID() )
|
||||||
|
device_path = cfstring_to_string( static_cast<CFStringRef>(callout_path) );
|
||||||
|
|
||||||
|
CFRelease(callout_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return device_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
get_class_name( io_object_t& obj )
|
||||||
|
{
|
||||||
|
string result;
|
||||||
|
io_name_t class_name;
|
||||||
|
kern_return_t kern_result;
|
||||||
|
|
||||||
|
kern_result = IOObjectGetClass( obj, class_name );
|
||||||
|
|
||||||
|
if( kern_result == KERN_SUCCESS )
|
||||||
|
result = class_name;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
io_registry_entry_t
|
||||||
|
get_parent_iousb_device( io_object_t& serial_port )
|
||||||
|
{
|
||||||
|
io_object_t device = serial_port;
|
||||||
|
io_registry_entry_t parent = 0;
|
||||||
|
io_registry_entry_t result = 0;
|
||||||
|
kern_return_t kern_result = KERN_FAILURE;
|
||||||
|
string name = get_class_name(device);
|
||||||
|
|
||||||
|
// Walk the IO Registry tree looking for this devices parent IOUSBDevice.
|
||||||
|
while( name != "IOUSBDevice" )
|
||||||
|
{
|
||||||
|
kern_result = IORegistryEntryGetParentEntry( device,
|
||||||
|
kIOServicePlane,
|
||||||
|
&parent );
|
||||||
|
|
||||||
|
if(kern_result != KERN_SUCCESS)
|
||||||
|
{
|
||||||
|
result = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
device = parent;
|
||||||
|
|
||||||
|
name = get_class_name(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(kern_result == KERN_SUCCESS)
|
||||||
|
result = device;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
get_string_property( io_object_t& device, const char* property )
|
||||||
|
{
|
||||||
|
string property_name;
|
||||||
|
|
||||||
|
if( device )
|
||||||
|
{
|
||||||
|
CFStringRef property_as_cfstring = CFStringCreateWithCString (
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
property,
|
||||||
|
kCFStringEncodingASCII );
|
||||||
|
|
||||||
|
CFTypeRef name_as_cfstring = IORegistryEntryCreateCFProperty(
|
||||||
|
device,
|
||||||
|
property_as_cfstring,
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
0 );
|
||||||
|
|
||||||
|
if( name_as_cfstring )
|
||||||
|
{
|
||||||
|
if( CFGetTypeID(name_as_cfstring) == CFStringGetTypeID() )
|
||||||
|
property_name = cfstring_to_string( static_cast<CFStringRef>(name_as_cfstring) );
|
||||||
|
|
||||||
|
CFRelease(name_as_cfstring);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(property_as_cfstring)
|
||||||
|
CFRelease(property_as_cfstring);
|
||||||
|
}
|
||||||
|
|
||||||
|
return property_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t
|
||||||
|
get_int_property( io_object_t& device, const char* property )
|
||||||
|
{
|
||||||
|
uint16_t result = 0;
|
||||||
|
|
||||||
|
if( device )
|
||||||
|
{
|
||||||
|
CFStringRef property_as_cfstring = CFStringCreateWithCString (
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
property,
|
||||||
|
kCFStringEncodingASCII );
|
||||||
|
|
||||||
|
CFTypeRef number = IORegistryEntryCreateCFProperty( device,
|
||||||
|
property_as_cfstring,
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
0 );
|
||||||
|
|
||||||
|
if(property_as_cfstring)
|
||||||
|
CFRelease(property_as_cfstring);
|
||||||
|
|
||||||
|
if( number )
|
||||||
|
{
|
||||||
|
if( CFGetTypeID(number) == CFNumberGetTypeID() )
|
||||||
|
{
|
||||||
|
bool success = CFNumberGetValue( static_cast<CFNumberRef>(number),
|
||||||
|
kCFNumberSInt16Type,
|
||||||
|
&result );
|
||||||
|
|
||||||
|
if( !success )
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFRelease(number);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
string rtrim(const string& str)
|
||||||
|
{
|
||||||
|
string result = str;
|
||||||
|
|
||||||
|
string whitespace = " \t\f\v\n\r";
|
||||||
|
|
||||||
|
std::size_t found = result.find_last_not_of(whitespace);
|
||||||
|
|
||||||
|
if (found != std::string::npos)
|
||||||
|
result.erase(found+1);
|
||||||
|
else
|
||||||
|
result.clear();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<PortInfo>
|
||||||
|
serial::list_ports(void)
|
||||||
|
{
|
||||||
|
vector<PortInfo> devices_found;
|
||||||
|
CFMutableDictionaryRef classes_to_match;
|
||||||
|
io_iterator_t serial_port_iterator;
|
||||||
|
io_object_t serial_port;
|
||||||
|
mach_port_t master_port;
|
||||||
|
kern_return_t kern_result;
|
||||||
|
|
||||||
|
kern_result = IOMasterPort(MACH_PORT_NULL, &master_port);
|
||||||
|
|
||||||
|
if(kern_result != KERN_SUCCESS)
|
||||||
|
return devices_found;
|
||||||
|
|
||||||
|
classes_to_match = IOServiceMatching(kIOSerialBSDServiceValue);
|
||||||
|
|
||||||
|
if (classes_to_match == NULL)
|
||||||
|
return devices_found;
|
||||||
|
|
||||||
|
CFDictionarySetValue( classes_to_match,
|
||||||
|
CFSTR(kIOSerialBSDTypeKey),
|
||||||
|
CFSTR(kIOSerialBSDAllTypes) );
|
||||||
|
|
||||||
|
kern_result = IOServiceGetMatchingServices(master_port, classes_to_match, &serial_port_iterator);
|
||||||
|
|
||||||
|
if (KERN_SUCCESS != kern_result)
|
||||||
|
return devices_found;
|
||||||
|
|
||||||
|
while ( (serial_port = IOIteratorNext(serial_port_iterator)) )
|
||||||
|
{
|
||||||
|
string device_path = get_device_path( serial_port );
|
||||||
|
io_registry_entry_t parent = get_parent_iousb_device( serial_port );
|
||||||
|
IOObjectRelease(serial_port);
|
||||||
|
|
||||||
|
if( device_path.empty() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
PortInfo port_info;
|
||||||
|
port_info.port = device_path;
|
||||||
|
port_info.description = "n/a";
|
||||||
|
port_info.hardware_id = "n/a";
|
||||||
|
|
||||||
|
string device_name = rtrim( get_string_property( parent, "USB Product Name" ) );
|
||||||
|
string vendor_name = rtrim( get_string_property( parent, "USB Vendor Name") );
|
||||||
|
string description = rtrim( vendor_name + " " + device_name );
|
||||||
|
if( !description.empty() )
|
||||||
|
port_info.description = description;
|
||||||
|
|
||||||
|
string serial_number = rtrim(get_string_property( parent, "USB Serial Number" ) );
|
||||||
|
uint16_t vendor_id = get_int_property( parent, "idVendor" );
|
||||||
|
uint16_t product_id = get_int_property( parent, "idProduct" );
|
||||||
|
|
||||||
|
if( vendor_id && product_id )
|
||||||
|
{
|
||||||
|
char cstring[HARDWARE_ID_STRING_LENGTH];
|
||||||
|
|
||||||
|
if(serial_number.empty())
|
||||||
|
serial_number = "None";
|
||||||
|
|
||||||
|
int ret = snprintf( cstring, HARDWARE_ID_STRING_LENGTH, "USB VID:PID=%04x:%04x SNR=%s",
|
||||||
|
vendor_id,
|
||||||
|
product_id,
|
||||||
|
serial_number.c_str() );
|
||||||
|
|
||||||
|
if( (ret >= 0) && (ret < HARDWARE_ID_STRING_LENGTH) )
|
||||||
|
port_info.hardware_id = cstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
devices_found.push_back(port_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
IOObjectRelease(serial_port_iterator);
|
||||||
|
return devices_found;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // defined(__APPLE__)
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
#if defined(_WIN32)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2014 Craig Lilley <cralilley@gmail.com>
|
||||||
|
* This software is made available under the terms of the MIT licence.
|
||||||
|
* A copy of the licence can be obtained from:
|
||||||
|
* http://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "include/serial.h"
|
||||||
|
#include <tchar.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <setupapi.h>
|
||||||
|
#include <initguid.h>
|
||||||
|
#include <devguid.h>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
using serial::PortInfo;
|
||||||
|
using std::vector;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
static const DWORD port_name_max_length = 256;
|
||||||
|
static const DWORD friendly_name_max_length = 256;
|
||||||
|
static const DWORD hardware_id_max_length = 256;
|
||||||
|
|
||||||
|
// Convert a wide Unicode string to an UTF8 string
|
||||||
|
std::string utf8_encode(const std::wstring &wstr)
|
||||||
|
{
|
||||||
|
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
|
||||||
|
std::string strTo( size_needed, 0 );
|
||||||
|
WideCharToMultiByte (CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
|
||||||
|
return strTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<PortInfo>
|
||||||
|
serial::list_ports()
|
||||||
|
{
|
||||||
|
vector<PortInfo> devices_found;
|
||||||
|
|
||||||
|
HDEVINFO device_info_set = SetupDiGetClassDevs(
|
||||||
|
(const GUID *) &GUID_DEVCLASS_PORTS,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
DIGCF_PRESENT);
|
||||||
|
|
||||||
|
unsigned int device_info_set_index = 0;
|
||||||
|
SP_DEVINFO_DATA device_info_data;
|
||||||
|
|
||||||
|
device_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
|
||||||
|
|
||||||
|
while(SetupDiEnumDeviceInfo(device_info_set, device_info_set_index, &device_info_data))
|
||||||
|
{
|
||||||
|
device_info_set_index++;
|
||||||
|
|
||||||
|
// Get port name
|
||||||
|
|
||||||
|
HKEY hkey = SetupDiOpenDevRegKey(
|
||||||
|
device_info_set,
|
||||||
|
&device_info_data,
|
||||||
|
DICS_FLAG_GLOBAL,
|
||||||
|
0,
|
||||||
|
DIREG_DEV,
|
||||||
|
KEY_READ);
|
||||||
|
|
||||||
|
TCHAR port_name[port_name_max_length];
|
||||||
|
DWORD port_name_length = port_name_max_length;
|
||||||
|
|
||||||
|
LONG return_code = RegQueryValueEx(
|
||||||
|
hkey,
|
||||||
|
_T("PortName"),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(LPBYTE)port_name,
|
||||||
|
&port_name_length);
|
||||||
|
|
||||||
|
RegCloseKey(hkey);
|
||||||
|
|
||||||
|
if(return_code != EXIT_SUCCESS)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(port_name_length > 0 && port_name_length <= port_name_max_length)
|
||||||
|
port_name[port_name_length-1] = '\0';
|
||||||
|
else
|
||||||
|
port_name[0] = '\0';
|
||||||
|
|
||||||
|
// Ignore parallel ports
|
||||||
|
|
||||||
|
if(_tcsstr(port_name, _T("LPT")) != NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Get port friendly name
|
||||||
|
|
||||||
|
TCHAR friendly_name[friendly_name_max_length];
|
||||||
|
DWORD friendly_name_actual_length = 0;
|
||||||
|
|
||||||
|
BOOL got_friendly_name = SetupDiGetDeviceRegistryProperty(
|
||||||
|
device_info_set,
|
||||||
|
&device_info_data,
|
||||||
|
SPDRP_FRIENDLYNAME,
|
||||||
|
NULL,
|
||||||
|
(PBYTE)friendly_name,
|
||||||
|
friendly_name_max_length,
|
||||||
|
&friendly_name_actual_length);
|
||||||
|
|
||||||
|
if(got_friendly_name == TRUE && friendly_name_actual_length > 0)
|
||||||
|
friendly_name[friendly_name_actual_length-1] = '\0';
|
||||||
|
else
|
||||||
|
friendly_name[0] = '\0';
|
||||||
|
|
||||||
|
// Get hardware ID
|
||||||
|
|
||||||
|
TCHAR hardware_id[hardware_id_max_length];
|
||||||
|
DWORD hardware_id_actual_length = 0;
|
||||||
|
|
||||||
|
BOOL got_hardware_id = SetupDiGetDeviceRegistryProperty(
|
||||||
|
device_info_set,
|
||||||
|
&device_info_data,
|
||||||
|
SPDRP_HARDWAREID,
|
||||||
|
NULL,
|
||||||
|
(PBYTE)hardware_id,
|
||||||
|
hardware_id_max_length,
|
||||||
|
&hardware_id_actual_length);
|
||||||
|
|
||||||
|
if(got_hardware_id == TRUE && hardware_id_actual_length > 0)
|
||||||
|
hardware_id[hardware_id_actual_length-1] = '\0';
|
||||||
|
else
|
||||||
|
hardware_id[0] = '\0';
|
||||||
|
|
||||||
|
#ifdef UNICODE
|
||||||
|
std::string portName = utf8_encode(port_name);
|
||||||
|
std::string friendlyName = utf8_encode(friendly_name);
|
||||||
|
std::string hardwareId = utf8_encode(hardware_id);
|
||||||
|
#else
|
||||||
|
std::string portName = port_name;
|
||||||
|
std::string friendlyName = friendly_name;
|
||||||
|
std::string hardwareId = hardware_id;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PortInfo port_entry;
|
||||||
|
port_entry.port = portName;
|
||||||
|
port_entry.description = friendlyName;
|
||||||
|
port_entry.hardware_id = hardwareId;
|
||||||
|
|
||||||
|
devices_found.push_back(port_entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetupDiDestroyDeviceInfoList(device_info_set);
|
||||||
|
|
||||||
|
return devices_found;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(_WIN32)
|
||||||
@@ -0,0 +1,640 @@
|
|||||||
|
#if defined(_WIN32)
|
||||||
|
|
||||||
|
/* Copyright 2012 William Woodall and John Harrison */
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "include/impl/win.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::wstring;
|
||||||
|
using std::stringstream;
|
||||||
|
using std::invalid_argument;
|
||||||
|
using serial::Serial;
|
||||||
|
using serial::Timeout;
|
||||||
|
using serial::bytesize_t;
|
||||||
|
using serial::parity_t;
|
||||||
|
using serial::stopbits_t;
|
||||||
|
using serial::flowcontrol_t;
|
||||||
|
using serial::SerialException;
|
||||||
|
using serial::PortNotOpenedException;
|
||||||
|
using serial::IOException;
|
||||||
|
|
||||||
|
inline wstring
|
||||||
|
_prefix_port_if_needed(const wstring &input)
|
||||||
|
{
|
||||||
|
static wstring windows_com_port_prefix = L"\\\\.\\";
|
||||||
|
if (input.compare(windows_com_port_prefix) != 0)
|
||||||
|
{
|
||||||
|
return windows_com_port_prefix + input;
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial::SerialImpl::SerialImpl (const string &port, unsigned long baudrate,
|
||||||
|
bytesize_t bytesize,
|
||||||
|
parity_t parity, stopbits_t stopbits,
|
||||||
|
flowcontrol_t flowcontrol)
|
||||||
|
: port_ (port.begin(), port.end()), fd_ (INVALID_HANDLE_VALUE), is_open_ (false),
|
||||||
|
baudrate_ (baudrate), parity_ (parity),
|
||||||
|
bytesize_ (bytesize), stopbits_ (stopbits), flowcontrol_ (flowcontrol)
|
||||||
|
{
|
||||||
|
read_mutex = CreateMutex(NULL, false, NULL);
|
||||||
|
write_mutex = CreateMutex(NULL, false, NULL);
|
||||||
|
if (port_.empty () == false)
|
||||||
|
open ();
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial::SerialImpl::~SerialImpl ()
|
||||||
|
{
|
||||||
|
this->close();
|
||||||
|
CloseHandle(read_mutex);
|
||||||
|
CloseHandle(write_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::open ()
|
||||||
|
{
|
||||||
|
if (port_.empty ()) {
|
||||||
|
throw invalid_argument ("Empty port is invalid.");
|
||||||
|
}
|
||||||
|
if (is_open_ == true) {
|
||||||
|
throw SerialException ("Serial port already open.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// See: https://github.com/wjwwood/serial/issues/84
|
||||||
|
wstring port_with_prefix = _prefix_port_if_needed(port_);
|
||||||
|
LPCWSTR lp_port = port_with_prefix.c_str();
|
||||||
|
fd_ = CreateFileW(lp_port,
|
||||||
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
0);
|
||||||
|
|
||||||
|
if (fd_ == INVALID_HANDLE_VALUE) {
|
||||||
|
DWORD errno_ = GetLastError();
|
||||||
|
stringstream ss;
|
||||||
|
switch (errno_) {
|
||||||
|
case ERROR_FILE_NOT_FOUND:
|
||||||
|
// Use this->getPort to convert to a std::string
|
||||||
|
ss << "Specified port, " << this->getPort() << ", does not exist.";
|
||||||
|
THROW (IOException, ss.str().c_str());
|
||||||
|
default:
|
||||||
|
ss << "Unknown error opening the serial port: " << errno;
|
||||||
|
THROW (IOException, ss.str().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reconfigurePort();
|
||||||
|
is_open_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::reconfigurePort ()
|
||||||
|
{
|
||||||
|
if (fd_ == INVALID_HANDLE_VALUE) {
|
||||||
|
// Can only operate on a valid file descriptor
|
||||||
|
THROW (IOException, "Invalid file descriptor, is the serial port open?");
|
||||||
|
}
|
||||||
|
|
||||||
|
DCB dcbSerialParams = {0};
|
||||||
|
|
||||||
|
dcbSerialParams.DCBlength=sizeof(dcbSerialParams);
|
||||||
|
|
||||||
|
if (!GetCommState(fd_, &dcbSerialParams)) {
|
||||||
|
//error getting state
|
||||||
|
THROW (IOException, "Error getting the serial port state.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup baud rate
|
||||||
|
switch (baudrate_) {
|
||||||
|
#ifdef CBR_0
|
||||||
|
case 0: dcbSerialParams.BaudRate = CBR_0; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_50
|
||||||
|
case 50: dcbSerialParams.BaudRate = CBR_50; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_75
|
||||||
|
case 75: dcbSerialParams.BaudRate = CBR_75; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_110
|
||||||
|
case 110: dcbSerialParams.BaudRate = CBR_110; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_134
|
||||||
|
case 134: dcbSerialParams.BaudRate = CBR_134; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_150
|
||||||
|
case 150: dcbSerialParams.BaudRate = CBR_150; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_200
|
||||||
|
case 200: dcbSerialParams.BaudRate = CBR_200; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_300
|
||||||
|
case 300: dcbSerialParams.BaudRate = CBR_300; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_600
|
||||||
|
case 600: dcbSerialParams.BaudRate = CBR_600; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_1200
|
||||||
|
case 1200: dcbSerialParams.BaudRate = CBR_1200; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_1800
|
||||||
|
case 1800: dcbSerialParams.BaudRate = CBR_1800; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_2400
|
||||||
|
case 2400: dcbSerialParams.BaudRate = CBR_2400; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_4800
|
||||||
|
case 4800: dcbSerialParams.BaudRate = CBR_4800; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_7200
|
||||||
|
case 7200: dcbSerialParams.BaudRate = CBR_7200; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_9600
|
||||||
|
case 9600: dcbSerialParams.BaudRate = CBR_9600; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_14400
|
||||||
|
case 14400: dcbSerialParams.BaudRate = CBR_14400; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_19200
|
||||||
|
case 19200: dcbSerialParams.BaudRate = CBR_19200; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_28800
|
||||||
|
case 28800: dcbSerialParams.BaudRate = CBR_28800; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_57600
|
||||||
|
case 57600: dcbSerialParams.BaudRate = CBR_57600; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_76800
|
||||||
|
case 76800: dcbSerialParams.BaudRate = CBR_76800; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_38400
|
||||||
|
case 38400: dcbSerialParams.BaudRate = CBR_38400; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_115200
|
||||||
|
case 115200: dcbSerialParams.BaudRate = CBR_115200; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_128000
|
||||||
|
case 128000: dcbSerialParams.BaudRate = CBR_128000; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_153600
|
||||||
|
case 153600: dcbSerialParams.BaudRate = CBR_153600; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_230400
|
||||||
|
case 230400: dcbSerialParams.BaudRate = CBR_230400; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_256000
|
||||||
|
case 256000: dcbSerialParams.BaudRate = CBR_256000; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_460800
|
||||||
|
case 460800: dcbSerialParams.BaudRate = CBR_460800; break;
|
||||||
|
#endif
|
||||||
|
#ifdef CBR_921600
|
||||||
|
case 921600: dcbSerialParams.BaudRate = CBR_921600; break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
// Try to blindly assign it
|
||||||
|
dcbSerialParams.BaudRate = baudrate_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup char len
|
||||||
|
if (bytesize_ == eightbits)
|
||||||
|
dcbSerialParams.ByteSize = 8;
|
||||||
|
else if (bytesize_ == sevenbits)
|
||||||
|
dcbSerialParams.ByteSize = 7;
|
||||||
|
else if (bytesize_ == sixbits)
|
||||||
|
dcbSerialParams.ByteSize = 6;
|
||||||
|
else if (bytesize_ == fivebits)
|
||||||
|
dcbSerialParams.ByteSize = 5;
|
||||||
|
else
|
||||||
|
throw invalid_argument ("invalid char len");
|
||||||
|
|
||||||
|
// setup stopbits
|
||||||
|
if (stopbits_ == stopbits_one)
|
||||||
|
dcbSerialParams.StopBits = ONESTOPBIT;
|
||||||
|
else if (stopbits_ == stopbits_one_point_five)
|
||||||
|
dcbSerialParams.StopBits = ONE5STOPBITS;
|
||||||
|
else if (stopbits_ == stopbits_two)
|
||||||
|
dcbSerialParams.StopBits = TWOSTOPBITS;
|
||||||
|
else
|
||||||
|
throw invalid_argument ("invalid stop bit");
|
||||||
|
|
||||||
|
// setup parity
|
||||||
|
if (parity_ == parity_none) {
|
||||||
|
dcbSerialParams.Parity = NOPARITY;
|
||||||
|
} else if (parity_ == parity_even) {
|
||||||
|
dcbSerialParams.Parity = EVENPARITY;
|
||||||
|
} else if (parity_ == parity_odd) {
|
||||||
|
dcbSerialParams.Parity = ODDPARITY;
|
||||||
|
} else if (parity_ == parity_mark) {
|
||||||
|
dcbSerialParams.Parity = MARKPARITY;
|
||||||
|
} else if (parity_ == parity_space) {
|
||||||
|
dcbSerialParams.Parity = SPACEPARITY;
|
||||||
|
} else {
|
||||||
|
throw invalid_argument ("invalid parity");
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup flowcontrol
|
||||||
|
if (flowcontrol_ == flowcontrol_none) {
|
||||||
|
dcbSerialParams.fOutxCtsFlow = false;
|
||||||
|
dcbSerialParams.fRtsControl = 0x00;
|
||||||
|
dcbSerialParams.fOutX = false;
|
||||||
|
dcbSerialParams.fInX = false;
|
||||||
|
}
|
||||||
|
if (flowcontrol_ == flowcontrol_software) {
|
||||||
|
dcbSerialParams.fOutxCtsFlow = false;
|
||||||
|
dcbSerialParams.fRtsControl = 0x00;
|
||||||
|
dcbSerialParams.fOutX = true;
|
||||||
|
dcbSerialParams.fInX = true;
|
||||||
|
}
|
||||||
|
if (flowcontrol_ == flowcontrol_hardware) {
|
||||||
|
dcbSerialParams.fOutxCtsFlow = true;
|
||||||
|
dcbSerialParams.fRtsControl = 0x03;
|
||||||
|
dcbSerialParams.fOutX = false;
|
||||||
|
dcbSerialParams.fInX = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// activate settings
|
||||||
|
if (!SetCommState(fd_, &dcbSerialParams)){
|
||||||
|
CloseHandle(fd_);
|
||||||
|
THROW (IOException, "Error setting serial port settings.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup timeouts
|
||||||
|
COMMTIMEOUTS timeouts = {0};
|
||||||
|
timeouts.ReadIntervalTimeout = timeout_.inter_byte_timeout;
|
||||||
|
timeouts.ReadTotalTimeoutConstant = timeout_.read_timeout_constant;
|
||||||
|
timeouts.ReadTotalTimeoutMultiplier = timeout_.read_timeout_multiplier;
|
||||||
|
timeouts.WriteTotalTimeoutConstant = timeout_.write_timeout_constant;
|
||||||
|
timeouts.WriteTotalTimeoutMultiplier = timeout_.write_timeout_multiplier;
|
||||||
|
if (!SetCommTimeouts(fd_, &timeouts)) {
|
||||||
|
THROW (IOException, "Error setting timeouts.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::close ()
|
||||||
|
{
|
||||||
|
if (is_open_ == true) {
|
||||||
|
if (fd_ != INVALID_HANDLE_VALUE) {
|
||||||
|
int ret;
|
||||||
|
ret = CloseHandle(fd_);
|
||||||
|
if (ret == 0) {
|
||||||
|
stringstream ss;
|
||||||
|
ss << "Error while closing serial port: " << GetLastError();
|
||||||
|
THROW (IOException, ss.str().c_str());
|
||||||
|
} else {
|
||||||
|
fd_ = INVALID_HANDLE_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is_open_ = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Serial::SerialImpl::isOpen () const
|
||||||
|
{
|
||||||
|
return is_open_;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::SerialImpl::available ()
|
||||||
|
{
|
||||||
|
if (!is_open_) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
COMSTAT cs;
|
||||||
|
if (!ClearCommError(fd_, NULL, &cs)) {
|
||||||
|
stringstream ss;
|
||||||
|
ss << "Error while checking status of the serial port: " << GetLastError();
|
||||||
|
THROW (IOException, ss.str().c_str());
|
||||||
|
}
|
||||||
|
return static_cast<size_t>(cs.cbInQue);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Serial::SerialImpl::waitReadable (uint32_t /*timeout*/)
|
||||||
|
{
|
||||||
|
THROW (IOException, "waitReadable is not implemented on Windows.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::waitByteTimes (size_t /*count*/)
|
||||||
|
{
|
||||||
|
THROW (IOException, "waitByteTimes is not implemented on Windows.");
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::SerialImpl::read (uint8_t *buf, size_t size)
|
||||||
|
{
|
||||||
|
if (!is_open_) {
|
||||||
|
throw PortNotOpenedException ("Serial::read");
|
||||||
|
}
|
||||||
|
DWORD bytes_read;
|
||||||
|
if (!ReadFile(fd_, buf, static_cast<DWORD>(size), &bytes_read, NULL)) {
|
||||||
|
stringstream ss;
|
||||||
|
ss << "Error while reading from the serial port: " << GetLastError();
|
||||||
|
THROW (IOException, ss.str().c_str());
|
||||||
|
}
|
||||||
|
return (size_t) (bytes_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::SerialImpl::write (const uint8_t *data, size_t length)
|
||||||
|
{
|
||||||
|
if (is_open_ == false) {
|
||||||
|
throw PortNotOpenedException ("Serial::write");
|
||||||
|
}
|
||||||
|
DWORD bytes_written;
|
||||||
|
if (!WriteFile(fd_, data, static_cast<DWORD>(length), &bytes_written, NULL)) {
|
||||||
|
stringstream ss;
|
||||||
|
ss << "Error while writing to the serial port: " << GetLastError();
|
||||||
|
THROW (IOException, ss.str().c_str());
|
||||||
|
}
|
||||||
|
return (size_t) (bytes_written);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::setPort (const string &port)
|
||||||
|
{
|
||||||
|
port_ = wstring(port.begin(), port.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
Serial::SerialImpl::getPort () const
|
||||||
|
{
|
||||||
|
return string(port_.begin(), port_.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::setTimeout (serial::Timeout &timeout)
|
||||||
|
{
|
||||||
|
timeout_ = timeout;
|
||||||
|
if (is_open_) {
|
||||||
|
reconfigurePort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
serial::Timeout
|
||||||
|
Serial::SerialImpl::getTimeout () const
|
||||||
|
{
|
||||||
|
return timeout_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::setBaudrate (unsigned long baudrate)
|
||||||
|
{
|
||||||
|
baudrate_ = baudrate;
|
||||||
|
if (is_open_) {
|
||||||
|
reconfigurePort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long
|
||||||
|
Serial::SerialImpl::getBaudrate () const
|
||||||
|
{
|
||||||
|
return baudrate_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::setBytesize (serial::bytesize_t bytesize)
|
||||||
|
{
|
||||||
|
bytesize_ = bytesize;
|
||||||
|
if (is_open_) {
|
||||||
|
reconfigurePort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
serial::bytesize_t
|
||||||
|
Serial::SerialImpl::getBytesize () const
|
||||||
|
{
|
||||||
|
return bytesize_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::setParity (serial::parity_t parity)
|
||||||
|
{
|
||||||
|
parity_ = parity;
|
||||||
|
if (is_open_) {
|
||||||
|
reconfigurePort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
serial::parity_t
|
||||||
|
Serial::SerialImpl::getParity () const
|
||||||
|
{
|
||||||
|
return parity_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::setStopbits (serial::stopbits_t stopbits)
|
||||||
|
{
|
||||||
|
stopbits_ = stopbits;
|
||||||
|
if (is_open_) {
|
||||||
|
reconfigurePort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
serial::stopbits_t
|
||||||
|
Serial::SerialImpl::getStopbits () const
|
||||||
|
{
|
||||||
|
return stopbits_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::setFlowcontrol (serial::flowcontrol_t flowcontrol)
|
||||||
|
{
|
||||||
|
flowcontrol_ = flowcontrol;
|
||||||
|
if (is_open_) {
|
||||||
|
reconfigurePort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
serial::flowcontrol_t
|
||||||
|
Serial::SerialImpl::getFlowcontrol () const
|
||||||
|
{
|
||||||
|
return flowcontrol_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::flush ()
|
||||||
|
{
|
||||||
|
if (is_open_ == false) {
|
||||||
|
throw PortNotOpenedException ("Serial::flush");
|
||||||
|
}
|
||||||
|
FlushFileBuffers (fd_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::flushInput ()
|
||||||
|
{
|
||||||
|
THROW (IOException, "flushInput is not supported on Windows.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::flushOutput ()
|
||||||
|
{
|
||||||
|
THROW (IOException, "flushOutput is not supported on Windows.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::sendBreak (int /*duration*/)
|
||||||
|
{
|
||||||
|
THROW (IOException, "sendBreak is not supported on Windows.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::setBreak (bool level)
|
||||||
|
{
|
||||||
|
if (is_open_ == false) {
|
||||||
|
throw PortNotOpenedException ("Serial::setBreak");
|
||||||
|
}
|
||||||
|
if (level) {
|
||||||
|
EscapeCommFunction (fd_, SETBREAK);
|
||||||
|
} else {
|
||||||
|
EscapeCommFunction (fd_, CLRBREAK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::setRTS (bool level)
|
||||||
|
{
|
||||||
|
if (is_open_ == false) {
|
||||||
|
throw PortNotOpenedException ("Serial::setRTS");
|
||||||
|
}
|
||||||
|
if (level) {
|
||||||
|
EscapeCommFunction (fd_, SETRTS);
|
||||||
|
} else {
|
||||||
|
EscapeCommFunction (fd_, CLRRTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::setDTR (bool level)
|
||||||
|
{
|
||||||
|
if (is_open_ == false) {
|
||||||
|
throw PortNotOpenedException ("Serial::setDTR");
|
||||||
|
}
|
||||||
|
if (level) {
|
||||||
|
EscapeCommFunction (fd_, SETDTR);
|
||||||
|
} else {
|
||||||
|
EscapeCommFunction (fd_, CLRDTR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Serial::SerialImpl::waitForChange ()
|
||||||
|
{
|
||||||
|
if (is_open_ == false) {
|
||||||
|
throw PortNotOpenedException ("Serial::waitForChange");
|
||||||
|
}
|
||||||
|
DWORD dwCommEvent;
|
||||||
|
|
||||||
|
if (!SetCommMask(fd_, EV_CTS | EV_DSR | EV_RING | EV_RLSD)) {
|
||||||
|
// Error setting communications mask
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!WaitCommEvent(fd_, &dwCommEvent, NULL)) {
|
||||||
|
// An error occurred waiting for the event.
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// Event has occurred.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Serial::SerialImpl::getCTS ()
|
||||||
|
{
|
||||||
|
if (is_open_ == false) {
|
||||||
|
throw PortNotOpenedException ("Serial::getCTS");
|
||||||
|
}
|
||||||
|
DWORD dwModemStatus;
|
||||||
|
if (!GetCommModemStatus(fd_, &dwModemStatus)) {
|
||||||
|
THROW (IOException, "Error getting the status of the CTS line.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (MS_CTS_ON & dwModemStatus) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Serial::SerialImpl::getDSR ()
|
||||||
|
{
|
||||||
|
if (is_open_ == false) {
|
||||||
|
throw PortNotOpenedException ("Serial::getDSR");
|
||||||
|
}
|
||||||
|
DWORD dwModemStatus;
|
||||||
|
if (!GetCommModemStatus(fd_, &dwModemStatus)) {
|
||||||
|
THROW (IOException, "Error getting the status of the DSR line.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (MS_DSR_ON & dwModemStatus) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Serial::SerialImpl::getRI()
|
||||||
|
{
|
||||||
|
if (is_open_ == false) {
|
||||||
|
throw PortNotOpenedException ("Serial::getRI");
|
||||||
|
}
|
||||||
|
DWORD dwModemStatus;
|
||||||
|
if (!GetCommModemStatus(fd_, &dwModemStatus)) {
|
||||||
|
THROW (IOException, "Error getting the status of the RI line.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (MS_RING_ON & dwModemStatus) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Serial::SerialImpl::getCD()
|
||||||
|
{
|
||||||
|
if (is_open_ == false) {
|
||||||
|
throw PortNotOpenedException ("Serial::getCD");
|
||||||
|
}
|
||||||
|
DWORD dwModemStatus;
|
||||||
|
if (!GetCommModemStatus(fd_, &dwModemStatus)) {
|
||||||
|
// Error in GetCommModemStatus;
|
||||||
|
THROW (IOException, "Error getting the status of the CD line.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (MS_RLSD_ON & dwModemStatus) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::readLock()
|
||||||
|
{
|
||||||
|
if (WaitForSingleObject(read_mutex, INFINITE) != WAIT_OBJECT_0) {
|
||||||
|
THROW (IOException, "Error claiming read mutex.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::readUnlock()
|
||||||
|
{
|
||||||
|
if (!ReleaseMutex(read_mutex)) {
|
||||||
|
THROW (IOException, "Error releasing read mutex.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::writeLock()
|
||||||
|
{
|
||||||
|
if (WaitForSingleObject(write_mutex, INFINITE) != WAIT_OBJECT_0) {
|
||||||
|
THROW (IOException, "Error claiming write mutex.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::SerialImpl::writeUnlock()
|
||||||
|
{
|
||||||
|
if (!ReleaseMutex(write_mutex)) {
|
||||||
|
THROW (IOException, "Error releasing write mutex.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(_WIN32)
|
||||||
|
|
||||||
@@ -0,0 +1,415 @@
|
|||||||
|
/* Copyright 2012 William Woodall and John Harrison */
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#if !defined(_WIN32) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
|
||||||
|
# include <alloca.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (__MINGW32__)
|
||||||
|
# define alloca __builtin_alloca
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "include/serial.h"
|
||||||
|
#include "include/impl/win.h"
|
||||||
|
#else
|
||||||
|
#include "../include/serial.h"
|
||||||
|
#include "../include/impl/unix.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using std::invalid_argument;
|
||||||
|
using std::min;
|
||||||
|
using std::numeric_limits;
|
||||||
|
using std::vector;
|
||||||
|
using std::size_t;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
using serial::Serial;
|
||||||
|
using serial::SerialException;
|
||||||
|
using serial::IOException;
|
||||||
|
using serial::bytesize_t;
|
||||||
|
using serial::parity_t;
|
||||||
|
using serial::stopbits_t;
|
||||||
|
using serial::flowcontrol_t;
|
||||||
|
|
||||||
|
class Serial::ScopedReadLock {
|
||||||
|
public:
|
||||||
|
ScopedReadLock(SerialImpl *pimpl) : pimpl_(pimpl) {
|
||||||
|
this->pimpl_->readLock();
|
||||||
|
}
|
||||||
|
~ScopedReadLock() {
|
||||||
|
this->pimpl_->readUnlock();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
// Disable copy constructors
|
||||||
|
ScopedReadLock(const ScopedReadLock&);
|
||||||
|
const ScopedReadLock& operator=(ScopedReadLock);
|
||||||
|
|
||||||
|
SerialImpl *pimpl_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Serial::ScopedWriteLock {
|
||||||
|
public:
|
||||||
|
ScopedWriteLock(SerialImpl *pimpl) : pimpl_(pimpl) {
|
||||||
|
this->pimpl_->writeLock();
|
||||||
|
}
|
||||||
|
~ScopedWriteLock() {
|
||||||
|
this->pimpl_->writeUnlock();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
// Disable copy constructors
|
||||||
|
ScopedWriteLock(const ScopedWriteLock&);
|
||||||
|
const ScopedWriteLock& operator=(ScopedWriteLock);
|
||||||
|
SerialImpl *pimpl_;
|
||||||
|
};
|
||||||
|
|
||||||
|
Serial::Serial (const string &port, uint32_t baudrate, serial::Timeout timeout,
|
||||||
|
bytesize_t bytesize, parity_t parity, stopbits_t stopbits,
|
||||||
|
flowcontrol_t flowcontrol)
|
||||||
|
: pimpl_(new SerialImpl (port, baudrate, bytesize, parity,
|
||||||
|
stopbits, flowcontrol))
|
||||||
|
{
|
||||||
|
pimpl_->setTimeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial::~Serial ()
|
||||||
|
{
|
||||||
|
delete pimpl_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::open ()
|
||||||
|
{
|
||||||
|
pimpl_->open ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::close ()
|
||||||
|
{
|
||||||
|
pimpl_->close ();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Serial::isOpen () const
|
||||||
|
{
|
||||||
|
return pimpl_->isOpen ();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::available ()
|
||||||
|
{
|
||||||
|
return pimpl_->available ();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Serial::waitReadable ()
|
||||||
|
{
|
||||||
|
serial::Timeout timeout(pimpl_->getTimeout ());
|
||||||
|
return pimpl_->waitReadable(timeout.read_timeout_constant);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::waitByteTimes (size_t count)
|
||||||
|
{
|
||||||
|
pimpl_->waitByteTimes(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::read_ (uint8_t *buffer, size_t size)
|
||||||
|
{
|
||||||
|
return this->pimpl_->read (buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::read (uint8_t *buffer, size_t size)
|
||||||
|
{
|
||||||
|
ScopedReadLock lock(this->pimpl_);
|
||||||
|
return this->pimpl_->read (buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::read (std::vector<uint8_t> &buffer, size_t size)
|
||||||
|
{
|
||||||
|
ScopedReadLock lock(this->pimpl_);
|
||||||
|
uint8_t *buffer_ = new uint8_t[size];
|
||||||
|
size_t bytes_read = this->pimpl_->read (buffer_, size);
|
||||||
|
buffer.insert (buffer.end (), buffer_, buffer_+bytes_read);
|
||||||
|
delete[] buffer_;
|
||||||
|
return bytes_read;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::read (std::string &buffer, size_t size)
|
||||||
|
{
|
||||||
|
ScopedReadLock lock(this->pimpl_);
|
||||||
|
uint8_t *buffer_ = new uint8_t[size];
|
||||||
|
size_t bytes_read = this->pimpl_->read (buffer_, size);
|
||||||
|
buffer.append (reinterpret_cast<const char*>(buffer_), bytes_read);
|
||||||
|
delete[] buffer_;
|
||||||
|
return bytes_read;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
Serial::read (size_t size)
|
||||||
|
{
|
||||||
|
std::string buffer;
|
||||||
|
this->read (buffer, size);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::readline (string &buffer, size_t size, string eol)
|
||||||
|
{
|
||||||
|
ScopedReadLock lock(this->pimpl_);
|
||||||
|
size_t eol_len = eol.length ();
|
||||||
|
uint8_t *buffer_ = static_cast<uint8_t*>
|
||||||
|
(alloca (size * sizeof (uint8_t)));
|
||||||
|
size_t read_so_far = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
size_t bytes_read = this->read_ (buffer_ + read_so_far, 1);
|
||||||
|
read_so_far += bytes_read;
|
||||||
|
if (bytes_read == 0) {
|
||||||
|
break; // Timeout occured on reading 1 byte
|
||||||
|
}
|
||||||
|
if (string (reinterpret_cast<const char*>
|
||||||
|
(buffer_ + read_so_far - eol_len), eol_len) == eol) {
|
||||||
|
break; // EOL found
|
||||||
|
}
|
||||||
|
if (read_so_far == size) {
|
||||||
|
break; // Reached the maximum read length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buffer.append(reinterpret_cast<const char*> (buffer_), read_so_far);
|
||||||
|
return read_so_far;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
Serial::readline (size_t size, string eol)
|
||||||
|
{
|
||||||
|
std::string buffer;
|
||||||
|
this->readline (buffer, size, eol);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<string>
|
||||||
|
Serial::readlines (size_t size, string eol)
|
||||||
|
{
|
||||||
|
ScopedReadLock lock(this->pimpl_);
|
||||||
|
std::vector<std::string> lines;
|
||||||
|
size_t eol_len = eol.length ();
|
||||||
|
uint8_t *buffer_ = static_cast<uint8_t*>
|
||||||
|
(alloca (size * sizeof (uint8_t)));
|
||||||
|
size_t read_so_far = 0;
|
||||||
|
size_t start_of_line = 0;
|
||||||
|
while (read_so_far < size) {
|
||||||
|
size_t bytes_read = this->read_ (buffer_+read_so_far, 1);
|
||||||
|
read_so_far += bytes_read;
|
||||||
|
if (bytes_read == 0) {
|
||||||
|
if (start_of_line != read_so_far) {
|
||||||
|
lines.push_back (
|
||||||
|
string (reinterpret_cast<const char*> (buffer_ + start_of_line),
|
||||||
|
read_so_far - start_of_line));
|
||||||
|
}
|
||||||
|
break; // Timeout occured on reading 1 byte
|
||||||
|
}
|
||||||
|
if (string (reinterpret_cast<const char*>
|
||||||
|
(buffer_ + read_so_far - eol_len), eol_len) == eol) {
|
||||||
|
// EOL found
|
||||||
|
lines.push_back(
|
||||||
|
string(reinterpret_cast<const char*> (buffer_ + start_of_line),
|
||||||
|
read_so_far - start_of_line));
|
||||||
|
start_of_line = read_so_far;
|
||||||
|
}
|
||||||
|
if (read_so_far == size) {
|
||||||
|
if (start_of_line != read_so_far) {
|
||||||
|
lines.push_back(
|
||||||
|
string(reinterpret_cast<const char*> (buffer_ + start_of_line),
|
||||||
|
read_so_far - start_of_line));
|
||||||
|
}
|
||||||
|
break; // Reached the maximum read length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::write (const string &data)
|
||||||
|
{
|
||||||
|
ScopedWriteLock lock(this->pimpl_);
|
||||||
|
return this->write_ (reinterpret_cast<const uint8_t*>(data.c_str()),
|
||||||
|
data.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::write (const std::vector<uint8_t> &data)
|
||||||
|
{
|
||||||
|
ScopedWriteLock lock(this->pimpl_);
|
||||||
|
return this->write_ (&data[0], data.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::write (const uint8_t *data, size_t size)
|
||||||
|
{
|
||||||
|
ScopedWriteLock lock(this->pimpl_);
|
||||||
|
return this->write_(data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Serial::write_ (const uint8_t *data, size_t length)
|
||||||
|
{
|
||||||
|
return pimpl_->write (data, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::setPort (const string &port)
|
||||||
|
{
|
||||||
|
ScopedReadLock rlock(this->pimpl_);
|
||||||
|
ScopedWriteLock wlock(this->pimpl_);
|
||||||
|
bool was_open = pimpl_->isOpen ();
|
||||||
|
if (was_open) close();
|
||||||
|
pimpl_->setPort (port);
|
||||||
|
if (was_open) open ();
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
Serial::getPort () const
|
||||||
|
{
|
||||||
|
return pimpl_->getPort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::setTimeout (serial::Timeout &timeout)
|
||||||
|
{
|
||||||
|
pimpl_->setTimeout (timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
serial::Timeout
|
||||||
|
Serial::getTimeout () const {
|
||||||
|
return pimpl_->getTimeout ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::setBaudrate (uint32_t baudrate)
|
||||||
|
{
|
||||||
|
pimpl_->setBaudrate (baudrate);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
Serial::getBaudrate () const
|
||||||
|
{
|
||||||
|
return uint32_t(pimpl_->getBaudrate ());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::setBytesize (bytesize_t bytesize)
|
||||||
|
{
|
||||||
|
pimpl_->setBytesize (bytesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
bytesize_t
|
||||||
|
Serial::getBytesize () const
|
||||||
|
{
|
||||||
|
return pimpl_->getBytesize ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::setParity (parity_t parity)
|
||||||
|
{
|
||||||
|
pimpl_->setParity (parity);
|
||||||
|
}
|
||||||
|
|
||||||
|
parity_t
|
||||||
|
Serial::getParity () const
|
||||||
|
{
|
||||||
|
return pimpl_->getParity ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::setStopbits (stopbits_t stopbits)
|
||||||
|
{
|
||||||
|
pimpl_->setStopbits (stopbits);
|
||||||
|
}
|
||||||
|
|
||||||
|
stopbits_t
|
||||||
|
Serial::getStopbits () const
|
||||||
|
{
|
||||||
|
return pimpl_->getStopbits ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::setFlowcontrol (flowcontrol_t flowcontrol)
|
||||||
|
{
|
||||||
|
pimpl_->setFlowcontrol (flowcontrol);
|
||||||
|
}
|
||||||
|
|
||||||
|
flowcontrol_t
|
||||||
|
Serial::getFlowcontrol () const
|
||||||
|
{
|
||||||
|
return pimpl_->getFlowcontrol ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Serial::flush ()
|
||||||
|
{
|
||||||
|
ScopedReadLock rlock(this->pimpl_);
|
||||||
|
ScopedWriteLock wlock(this->pimpl_);
|
||||||
|
pimpl_->flush ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Serial::flushInput ()
|
||||||
|
{
|
||||||
|
ScopedReadLock lock(this->pimpl_);
|
||||||
|
pimpl_->flushInput ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Serial::flushOutput ()
|
||||||
|
{
|
||||||
|
ScopedWriteLock lock(this->pimpl_);
|
||||||
|
pimpl_->flushOutput ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Serial::sendBreak (int duration)
|
||||||
|
{
|
||||||
|
pimpl_->sendBreak (duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Serial::setBreak (bool level)
|
||||||
|
{
|
||||||
|
pimpl_->setBreak (level);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Serial::setRTS (bool level)
|
||||||
|
{
|
||||||
|
pimpl_->setRTS (level);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Serial::setDTR (bool level)
|
||||||
|
{
|
||||||
|
pimpl_->setDTR (level);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Serial::waitForChange()
|
||||||
|
{
|
||||||
|
return pimpl_->waitForChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Serial::getCTS ()
|
||||||
|
{
|
||||||
|
return pimpl_->getCTS ();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Serial::getDSR ()
|
||||||
|
{
|
||||||
|
return pimpl_->getDSR ();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Serial::getRI ()
|
||||||
|
{
|
||||||
|
return pimpl_->getRI ();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Serial::getCD ()
|
||||||
|
{
|
||||||
|
return pimpl_->getCD ();
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
newmtl bob1:initialShadingGroup
|
||||||
|
illum 4
|
||||||
|
Kd 0.50 0.50 0.50
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl initialShadingGroup
|
||||||
|
illum 4
|
||||||
|
Kd 0.67 0.67 0.67
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert2SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.20 0.32 0.50
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert5SG
|
||||||
|
illum 4
|
||||||
|
Kd 1.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert6SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert7SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert8SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert10SG
|
||||||
|
illum 4
|
||||||
|
Kd 1.00 1.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert12SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.58 0.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert13SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 1.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert14SG
|
||||||
|
illum 4
|
||||||
|
Kd 1.00 1.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert15SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd TheThing2.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert16SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd SkateboardwielThing.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert17SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.25 0.25 0.25
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
newmtl lambert18SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd BobStoneTexture.png
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
newmtl pasted__lambert2SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__lambert4SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.50 1.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__lambert5SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 1.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
newmtl BobRock:lambert18SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd Bobhelemaal2.png
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
Ns 0.06
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
newmtl bob1:initialShadingGroup
|
||||||
|
illum 4
|
||||||
|
Kd 0.50 0.50 0.50
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl initialShadingGroup
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert2SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.20 0.32 0.50
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert5SG
|
||||||
|
illum 4
|
||||||
|
Kd 1.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert6SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert7SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert8SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert10SG
|
||||||
|
illum 4
|
||||||
|
Kd 1.00 1.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert12SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.58 0.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert13SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 1.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert14SG
|
||||||
|
illum 4
|
||||||
|
Kd 1.00 1.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert15SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd TheThing2.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert16SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd SkateboardwielThing.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert17SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.25 0.25 0.25
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
newmtl lambert18SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd BobStoneTexture.png
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
newmtl pasted__lambert2SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__lambert4SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.50 1.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__lambert5SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 1.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
After Width: | Height: | Size: 241 KiB |
|
After Width: | Height: | Size: 232 KiB |
|
After Width: | Height: | Size: 580 KiB |
|
After Width: | Height: | Size: 599 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
newmtl initialShadingGroup
|
||||||
|
illum 4
|
||||||
|
Kd 1.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
# This file uses centimeters as units for non-parametric coordinates.
|
||||||
|
|
||||||
|
mtllib Cube.mtl
|
||||||
|
g default
|
||||||
|
v -0.500000 -0.500000 0.500000
|
||||||
|
v 0.500000 -0.500000 0.500000
|
||||||
|
v -0.500000 0.500000 0.500000
|
||||||
|
v 0.500000 0.500000 0.500000
|
||||||
|
v -0.500000 0.500000 -0.500000
|
||||||
|
v 0.500000 0.500000 -0.500000
|
||||||
|
v -0.500000 -0.500000 -0.500000
|
||||||
|
v 0.500000 -0.500000 -0.500000
|
||||||
|
vt 0.375000 0.000000
|
||||||
|
vt 0.625000 0.000000
|
||||||
|
vt 0.375000 0.250000
|
||||||
|
vt 0.625000 0.250000
|
||||||
|
vt 0.375000 0.500000
|
||||||
|
vt 0.625000 0.500000
|
||||||
|
vt 0.375000 0.750000
|
||||||
|
vt 0.625000 0.750000
|
||||||
|
vt 0.375000 1.000000
|
||||||
|
vt 0.625000 1.000000
|
||||||
|
vt 0.875000 0.000000
|
||||||
|
vt 0.875000 0.250000
|
||||||
|
vt 0.125000 0.000000
|
||||||
|
vt 0.125000 0.250000
|
||||||
|
vn 0.000000 0.000000 1.000000
|
||||||
|
vn 0.000000 0.000000 1.000000
|
||||||
|
vn 0.000000 0.000000 1.000000
|
||||||
|
vn 0.000000 0.000000 1.000000
|
||||||
|
vn 0.000000 1.000000 0.000000
|
||||||
|
vn 0.000000 1.000000 0.000000
|
||||||
|
vn 0.000000 1.000000 0.000000
|
||||||
|
vn 0.000000 1.000000 0.000000
|
||||||
|
vn 0.000000 0.000000 -1.000000
|
||||||
|
vn 0.000000 0.000000 -1.000000
|
||||||
|
vn 0.000000 0.000000 -1.000000
|
||||||
|
vn 0.000000 0.000000 -1.000000
|
||||||
|
vn 0.000000 -1.000000 0.000000
|
||||||
|
vn 0.000000 -1.000000 0.000000
|
||||||
|
vn 0.000000 -1.000000 0.000000
|
||||||
|
vn 0.000000 -1.000000 0.000000
|
||||||
|
vn 1.000000 0.000000 0.000000
|
||||||
|
vn 1.000000 0.000000 0.000000
|
||||||
|
vn 1.000000 0.000000 0.000000
|
||||||
|
vn 1.000000 0.000000 0.000000
|
||||||
|
vn -1.000000 0.000000 0.000000
|
||||||
|
vn -1.000000 0.000000 0.000000
|
||||||
|
vn -1.000000 0.000000 0.000000
|
||||||
|
vn -1.000000 0.000000 0.000000
|
||||||
|
s off
|
||||||
|
g pCube1
|
||||||
|
usemtl initialShadingGroup
|
||||||
|
f 1/1/1 2/2/2 4/4/3 3/3/4
|
||||||
|
f 3/3/5 4/4/6 6/6/7 5/5/8
|
||||||
|
f 5/5/9 6/6/10 8/8/11 7/7/12
|
||||||
|
f 7/7/13 8/8/14 2/10/15 1/9/16
|
||||||
|
f 2/2/17 8/11/18 6/12/19 4/4/20
|
||||||
|
f 7/13/21 1/1/22 3/3/23 5/14/24
|
||||||
|
After Width: | Height: | Size: 468 KiB |
|
After Width: | Height: | Size: 254 KiB |
@@ -0,0 +1,7 @@
|
|||||||
|
newmtl Monkey1:initialShadingGroup
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd tex_wendy.jpg
|
||||||
|
Ni 1.00
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
newmtl SpringIsComing:Material_007
|
||||||
|
illum 4
|
||||||
|
Kd 0.75 0.80 0.80
|
||||||
|
Ka 1.00 1.00 1.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
Ns 96.08
|
||||||
|
newmtl Tree01:Material_001
|
||||||
|
illum 4
|
||||||
|
Kd 0.01 0.00 0.00
|
||||||
|
Ka 1.00 1.00 1.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
Ns 96.08
|
||||||
|
newmtl Tree01:Material_004
|
||||||
|
illum 4
|
||||||
|
Kd 0.60 0.20 0.30
|
||||||
|
Ka 1.00 1.00 1.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
Ns 96.08
|
||||||
|
newmtl Tree02:Material_001
|
||||||
|
illum 4
|
||||||
|
Kd 0.01 0.00 0.00
|
||||||
|
Ka 1.00 1.00 1.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
Ns 96.08
|
||||||
|
newmtl Tree02:Material_004
|
||||||
|
illum 4
|
||||||
|
Kd 0.60 0.20 0.30
|
||||||
|
Ka 1.00 1.00 1.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
Ns 96.08
|
||||||
|
newmtl Tree03:Material_001
|
||||||
|
illum 4
|
||||||
|
Kd 0.01 0.00 0.00
|
||||||
|
Ka 1.00 1.00 1.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
Ns 96.08
|
||||||
|
newmtl Tree03:Material_004
|
||||||
|
illum 4
|
||||||
|
Kd 0.60 0.20 0.30
|
||||||
|
Ka 1.00 1.00 1.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
Ns 96.08
|
||||||
|
newmtl Tree04:Material_001
|
||||||
|
illum 4
|
||||||
|
Kd 0.01 0.00 0.00
|
||||||
|
Ka 1.00 1.00 1.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
Ns 96.08
|
||||||
|
newmtl Tree04:Material_004
|
||||||
|
illum 4
|
||||||
|
Kd 0.60 0.20 0.30
|
||||||
|
Ka 1.00 1.00 1.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
Ns 96.08
|
||||||
|
newmtl initialShadingGroup
|
||||||
|
illum 4
|
||||||
|
Kd 0.34 0.34 0.34
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert2SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 1.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert3SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd InktvisTextureRock.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl rock3:Material_016
|
||||||
|
illum 4
|
||||||
|
Kd 0.64 0.64 0.64
|
||||||
|
Ka 1.00 1.00 1.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
Ns 96.08
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
newmtl SquidRock:lambert3SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd InktvisTextureFire.png
|
||||||
|
Ni 1.00
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
newmtl Squid:lambert3SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd InktvisTextureRock.png
|
||||||
|
Ni 1.00
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
newmtl VincentRock:lambert23SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd VincentTextureFire.png
|
||||||
|
Ni 1.00
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
newmtl bob1:initialShadingGroup
|
||||||
|
illum 4
|
||||||
|
Kd 0.50 0.50 0.50
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl initialShadingGroup
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert2SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.20 0.32 0.50
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert5SG
|
||||||
|
illum 4
|
||||||
|
Kd 1.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert6SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert7SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd Screenshot_1.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert8SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd Screenshot_1.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert10SG
|
||||||
|
illum 4
|
||||||
|
Kd 1.00 1.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert12SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.58 0.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert13SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 1.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert14SG
|
||||||
|
illum 4
|
||||||
|
Kd 1.00 1.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert15SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd TheThing2.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert16SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd SkateboardwielThing.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert17SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.25 0.25 0.25
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
newmtl lambert18SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd BobStoneTexture.png
|
||||||
|
Ni 1.00
|
||||||
|
Ks 0.50 0.50 0.50
|
||||||
|
newmtl lambert19SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.85 0.85 0.85
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert20SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 0.64 0.64 0.64
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert21SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert22SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.50 0.50 0.50
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert23SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd VincentTexture.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__lambert2SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd Screenshot_1.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__lambert4SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.50 1.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__lambert5SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 1.00 1.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
After Width: | Height: | Size: 142 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 1.5 MiB |
@@ -1,73 +1,7 @@
|
|||||||
newmtl Rock1:pasted__pasted__lambert3SG1
|
newmtl Rock14:lambert6SG
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl Rock2:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl Rock3:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl Rock4:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl initialShadingGroup
|
|
||||||
illum 4
|
|
||||||
Kd 0.50 0.50 0.50
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert2SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.11 0.07 0.00
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert3SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.50 0.35 0.00
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert4SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.13 0.14 0.16
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert5SG
|
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.00 0.00 0.00
|
Kd 0.00 0.00 0.00
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
map_Kd Naamloos.png
|
map_Kd Stones.png
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert6SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.89 0.89 0.89
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl pasted__lambert4SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.13 0.14 0.16
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
# This file uses centimeters as units for non-parametric coordinates.
|
# This file uses centimeters as units for non-parametric coordinates.
|
||||||
|
|
||||||
mtllib Rock10.mtl
|
mtllib Rock10.mtl
|
||||||
g default
|
g Rock14:default1
|
||||||
v 4.941558 -0.000000 -3.356660
|
v 4.941558 0.000000 -3.356660
|
||||||
v 2.216577 -0.000000 -5.336667
|
v 2.216577 0.000000 -5.336667
|
||||||
v -1.151898 -0.000000 -6.543634
|
v -1.151898 0.000000 -6.543634
|
||||||
v -4.489141 -0.000000 -4.563631
|
v -4.489141 0.000000 -4.563631
|
||||||
v -5.530008 -0.000000 -0.153030
|
v -5.530008 0.000000 -0.153030
|
||||||
v -4.965517 -0.000000 3.266693
|
v -4.965517 0.000000 3.266693
|
||||||
v -2.240540 -0.000000 5.819403
|
v -2.240540 0.000000 5.819403
|
||||||
v 2.216577 -0.000000 5.603078
|
v 2.216577 0.000000 5.603078
|
||||||
v 5.729727 -0.000000 4.689539
|
v 5.729727 0.000000 4.689539
|
||||||
v 6.770609 -0.000000 1.485886
|
v 6.770609 0.000000 1.485886
|
||||||
v 4.725860 1.551832 -3.199978
|
v 4.725860 1.551832 -3.199978
|
||||||
v 2.134023 1.551832 -5.082932
|
v 2.134023 1.551832 -5.082932
|
||||||
v -1.069599 1.551832 -6.289903
|
v -1.069599 1.551832 -6.289903
|
||||||
@@ -40,15 +40,15 @@ v 2.430769 12.995994 0.244891
|
|||||||
v 3.408291 12.995994 2.984904
|
v 3.408291 12.995994 2.984904
|
||||||
v 5.654229 12.995994 4.427516
|
v 5.654229 12.995994 4.427516
|
||||||
v 7.268513 12.995994 4.606150
|
v 7.268513 12.995994 4.606150
|
||||||
v 9.888848 16.207620 4.064604
|
v 9.888848 16.207621 4.064604
|
||||||
v 11.050520 16.207620 1.225952
|
v 11.050520 16.207621 1.225952
|
||||||
v 11.146457 20.527525 -0.466318
|
v 11.146457 20.527525 -0.466318
|
||||||
v 6.799099 16.705383 -1.078148
|
v 6.799099 16.705383 -1.078148
|
||||||
v 5.113851 16.705383 -1.356947
|
v 5.113851 16.705383 -1.356947
|
||||||
v 6.527206 18.970071 -0.745113
|
v 6.527206 18.970072 -0.745113
|
||||||
v 3.950029 16.705383 0.244891
|
v 3.950029 16.705383 0.244891
|
||||||
v 4.271805 16.705383 1.234890
|
v 4.271805 16.705383 1.234890
|
||||||
v 8.013615 18.970071 2.125519
|
v 8.013615 18.970072 2.125519
|
||||||
v 10.304179 20.527525 2.125519
|
v 10.304179 20.527525 2.125519
|
||||||
v 11.146457 20.527525 1.513685
|
v 11.146457 20.527525 1.513685
|
||||||
v 11.467955 20.527525 0.523689
|
v 11.467955 20.527525 0.523689
|
||||||
@@ -97,109 +97,203 @@ v 3.411045 12.993238 2.980508
|
|||||||
v 5.651475 12.998750 4.431911
|
v 5.651475 12.998750 4.431911
|
||||||
v 8.016369 18.967314 2.121123
|
v 8.016369 18.967314 2.121123
|
||||||
v 4.269051 16.708139 1.239282
|
v 4.269051 16.708139 1.239282
|
||||||
vt 0.000000 0.500000
|
vt 0.747022 0.464579
|
||||||
vt 0.100000 0.500000
|
vt 0.853638 0.464579
|
||||||
vt 0.200000 0.500000
|
vt 0.853638 0.502091
|
||||||
vt 0.300000 0.500000
|
vt 0.750810 0.502091
|
||||||
vt 0.400000 0.500000
|
vt 0.936302 0.464579
|
||||||
vt 0.500000 0.500000
|
vt 0.932515 0.502091
|
||||||
vt 0.600000 0.500000
|
vt 0.853638 0.535931
|
||||||
vt 0.700000 0.500000
|
vt 0.790988 0.535931
|
||||||
vt 0.800000 0.500000
|
vt 0.699160 0.464579
|
||||||
vt 0.900000 0.500000
|
vt 0.705294 0.502091
|
||||||
vt 1.000000 0.500000
|
vt 0.998008 0.464579
|
||||||
vt 0.000000 0.600000
|
vt 0.991875 0.502091
|
||||||
vt 0.100000 0.600000
|
vt 0.937002 0.535931
|
||||||
vt 0.200000 0.600000
|
vt 0.854875 0.641299
|
||||||
vt 0.300000 0.600000
|
vt 0.794890 0.635607
|
||||||
vt 0.400000 0.600000
|
vt 0.795144 0.640797
|
||||||
vt 0.500000 0.600000
|
vt 0.861003 0.721782
|
||||||
vt 0.600000 0.600000
|
vt 0.935832 0.573675
|
||||||
vt 0.700000 0.600000
|
vt 0.923036 0.647250
|
||||||
vt 0.800000 0.600000
|
vt 0.931253 0.721782
|
||||||
vt 0.900000 0.600000
|
vt 0.833441 0.748612
|
||||||
vt 1.000000 0.600000
|
vt 0.773456 0.742920
|
||||||
vt 0.000000 0.700000
|
vt 0.975723 0.535931
|
||||||
vt 0.100000 0.700000
|
vt 0.973957 0.573675
|
||||||
vt 0.200000 0.700000
|
vt 0.970514 0.647250
|
||||||
vt 0.300000 0.700000
|
vt 0.967024 0.721782
|
||||||
vt 0.400000 0.700000
|
vt 0.929491 0.778727
|
||||||
vt 0.500000 0.700000
|
vt 0.863257 0.778727
|
||||||
vt 0.600000 0.700000
|
vt 0.834901 0.772846
|
||||||
vt 0.700000 0.700000
|
vt 0.777509 0.770000
|
||||||
vt 0.800000 0.700000
|
vt 0.964362 0.778727
|
||||||
vt 0.900000 0.700000
|
vt 0.887188 0.868393
|
||||||
vt 1.000000 0.700000
|
vt 0.863257 0.868393
|
||||||
vt 0.000000 0.800000
|
vt 0.851626 0.850914
|
||||||
vt 0.100000 0.800000
|
vt 0.775674 0.846534
|
||||||
vt 0.200000 0.800000
|
vt 0.908717 0.923136
|
||||||
vt 0.300000 0.800000
|
vt 0.839326 0.923136
|
||||||
vt 0.400000 0.800000
|
vt 0.001992 0.001895
|
||||||
vt 0.500000 0.800000
|
vt 0.079433 0.001895
|
||||||
vt 0.600000 0.800000
|
vt 0.079433 0.039407
|
||||||
vt 0.700000 0.800000
|
vt 0.005786 0.039407
|
||||||
vt 0.800000 0.800000
|
vt 0.196490 0.001895
|
||||||
vt 0.900000 0.800000
|
vt 0.192703 0.039407
|
||||||
vt 1.000000 0.800000
|
vt 0.102073 0.078457
|
||||||
vt 0.000000 0.900000
|
vt 0.016326 0.078457
|
||||||
vt 0.100000 0.900000
|
vt 0.244352 0.001895
|
||||||
vt 0.200000 0.900000
|
vt 0.238219 0.039407
|
||||||
vt 0.300000 0.900000
|
vt 0.200623 0.073247
|
||||||
vt 0.400000 0.900000
|
vt 0.099532 0.116201
|
||||||
vt 0.500000 0.900000
|
vt 0.016445 0.116201
|
||||||
vt 0.600000 0.900000
|
vt 0.195415 0.110991
|
||||||
vt 0.700000 0.900000
|
vt 0.094575 0.189775
|
||||||
vt 0.800000 0.900000
|
vt 0.016680 0.189775
|
||||||
vt 0.900000 0.900000
|
vt 0.185265 0.184565
|
||||||
vt 1.000000 0.900000
|
vt 0.089551 0.264307
|
||||||
vt 1.000000 0.776546
|
vt 0.016916 0.264307
|
||||||
vt 0.000000 0.776546
|
vt 0.174988 0.259097
|
||||||
vt 0.100000 0.776546
|
vt 0.085716 0.393676
|
||||||
vt 0.200000 0.776546
|
vt 0.017098 0.393676
|
||||||
vt 0.300000 0.776546
|
vt 0.167129 0.316043
|
||||||
vt 0.400000 0.776546
|
vt 0.102692 0.498100
|
||||||
vt 0.500000 0.776546
|
vt 0.078761 0.498100
|
||||||
vt 0.600000 0.776546
|
vt 0.126623 0.498100
|
||||||
vt 0.700000 0.776546
|
vt 0.063393 0.559036
|
||||||
vt 0.800000 0.776546
|
vt 0.108908 0.559036
|
||||||
vt 0.900000 0.776546
|
vt 0.108908 0.648702
|
||||||
vt 1.000000 0.745849
|
vt 0.084977 0.703446
|
||||||
vt 0.000000 0.745849
|
vt 0.057115 0.502091
|
||||||
vt 0.100000 0.745849
|
vt 0.106654 0.502091
|
||||||
vt 0.200000 0.745849
|
vt 0.035261 0.559036
|
||||||
vt 0.500000 0.745849
|
vt 0.070187 0.648702
|
||||||
vt 0.600000 0.745849
|
vt 0.026503 0.502091
|
||||||
vt 0.700000 0.745849
|
vt 0.163636 0.610527
|
||||||
vt 0.800000 0.745849
|
vt 0.207905 0.649700
|
||||||
vt 0.900000 0.745849
|
vt 0.229774 0.713018
|
||||||
vt 1.000000 0.715546
|
vt 0.153822 0.717397
|
||||||
vt 0.000000 0.715546
|
vt 0.167712 0.610430
|
||||||
vt 0.100000 0.715546
|
vt 0.202447 0.612058
|
||||||
vt 0.200000 0.715546
|
vt 0.210558 0.502091
|
||||||
vt 0.300000 0.715546
|
vt 0.231991 0.609403
|
||||||
vt 0.500000 0.715546
|
vt 0.227939 0.636484
|
||||||
vt 0.600000 0.715546
|
vt 0.144445 0.588265
|
||||||
vt 0.700000 0.715546
|
vt 0.193984 0.588265
|
||||||
vt 0.800000 0.715546
|
vt 0.270374 0.804930
|
||||||
vt 0.900000 0.715546
|
vt 0.214729 0.949340
|
||||||
vt 0.300000 0.715546
|
vt 0.214623 0.949273
|
||||||
vt 0.400000 0.715546
|
vt 0.270481 0.804997
|
||||||
vt 0.400000 0.745849
|
vt 0.424535 0.894663
|
||||||
vt 0.300000 0.745849
|
vt 0.382233 0.804997
|
||||||
vt 0.300000 0.715546
|
vt 0.382339 0.804930
|
||||||
vt 0.400000 0.715546
|
vt 0.424429 0.894729
|
||||||
vt 0.400000 0.745849
|
vt 0.087686 0.784877
|
||||||
vt 0.300000 0.745849
|
vt 0.042170 0.862323
|
||||||
vt 0.400000 0.745691
|
vt 0.001992 0.832383
|
||||||
vt 0.300000 0.730697
|
vt 0.040713 0.779090
|
||||||
vt 0.400000 0.730697
|
vt 0.058510 0.707437
|
||||||
vt 0.400000 0.745849
|
vt 0.040713 0.713219
|
||||||
vt 0.300000 0.745849
|
vt 0.486186 0.806273
|
||||||
vt 0.395018 0.745849
|
vt 0.487074 0.809006
|
||||||
vt 0.500000 0.800000
|
vt 0.483578 0.804930
|
||||||
vt 0.600000 0.800000
|
vt 0.339641 0.812702
|
||||||
vt 0.600000 0.900000
|
vt 0.276989 0.833062
|
||||||
vt 0.500000 0.900000
|
vt 0.291779 0.812702
|
||||||
|
vt 0.315710 0.804930
|
||||||
|
vt 0.346380 0.924361
|
||||||
|
vt 0.276989 0.888431
|
||||||
|
vt 0.263287 0.549953
|
||||||
|
vt 0.343957 0.502091
|
||||||
|
vt 0.425382 0.531267
|
||||||
|
vt 0.491252 0.579129
|
||||||
|
vt 0.535465 0.696186
|
||||||
|
vt 0.510305 0.773627
|
||||||
|
vt 0.425382 0.795709
|
||||||
|
vt 0.317642 0.800939
|
||||||
|
vt 0.251772 0.739233
|
||||||
|
vt 0.238127 0.656569
|
||||||
|
vt 0.468468 0.804930
|
||||||
|
vt 0.468468 0.886355
|
||||||
|
vt 0.430956 0.884366
|
||||||
|
vt 0.430956 0.806926
|
||||||
|
vt 0.312308 0.001895
|
||||||
|
vt 0.420049 0.001895
|
||||||
|
vt 0.418053 0.039407
|
||||||
|
vt 0.314304 0.039407
|
||||||
|
vt 0.504971 0.001895
|
||||||
|
vt 0.514707 0.039407
|
||||||
|
vt 0.412271 0.073247
|
||||||
|
vt 0.355235 0.073247
|
||||||
|
vt 0.505141 0.078457
|
||||||
|
vt 0.432467 0.110991
|
||||||
|
vt 0.378233 0.110991
|
||||||
|
vt 0.251653 0.039407
|
||||||
|
vt 0.301942 0.073247
|
||||||
|
vt 0.520740 0.116201
|
||||||
|
vt 0.471829 0.184565
|
||||||
|
vt 0.423055 0.184565
|
||||||
|
vt 0.551157 0.189775
|
||||||
|
vt 0.511701 0.259097
|
||||||
|
vt 0.468456 0.259097
|
||||||
|
vt 0.581965 0.264307
|
||||||
|
vt 0.542167 0.316043
|
||||||
|
vt 0.503146 0.316043
|
||||||
|
vt 0.605508 0.393676
|
||||||
|
vt 0.615548 0.498100
|
||||||
|
vt 0.560179 0.460452
|
||||||
|
vt 0.635908 0.498100
|
||||||
|
vt 0.830989 0.460588
|
||||||
|
vt 0.768338 0.460588
|
||||||
|
vt 0.762555 0.426748
|
||||||
|
vt 0.828179 0.426748
|
||||||
|
vt 0.782751 0.389004
|
||||||
|
vt 0.846103 0.389004
|
||||||
|
vt 0.696685 0.426748
|
||||||
|
vt 0.717257 0.389004
|
||||||
|
vt 0.822114 0.315429
|
||||||
|
vt 0.881052 0.315429
|
||||||
|
vt 0.739241 0.217105
|
||||||
|
vt 0.755845 0.240897
|
||||||
|
vt 0.797981 0.240897
|
||||||
|
vt 0.757358 0.315429
|
||||||
|
vt 0.643392 0.426748
|
||||||
|
vt 0.666225 0.321882
|
||||||
|
vt 0.665446 0.327072
|
||||||
|
vt 0.861985 0.240897
|
||||||
|
vt 0.916451 0.240897
|
||||||
|
vt 0.892452 0.183952
|
||||||
|
vt 0.943497 0.183952
|
||||||
|
vt 0.829020 0.183952
|
||||||
|
vt 0.881105 0.094286
|
||||||
|
vt 0.986192 0.001895
|
||||||
|
vt 0.840368 0.094286
|
||||||
|
vt 0.874533 0.039543
|
||||||
|
vt 0.095737 0.721389
|
||||||
|
vt 0.149894 0.721522
|
||||||
|
vt 0.207060 0.865798
|
||||||
|
vt 0.116477 0.811188
|
||||||
|
vt 0.564521 0.607459
|
||||||
|
vt 0.663878 0.709773
|
||||||
|
vt 0.664117 0.710123
|
||||||
|
vt 0.661509 0.710203
|
||||||
|
vt 0.693025 0.817074
|
||||||
|
vt 0.629799 0.739006
|
||||||
|
vt 0.606700 0.714772
|
||||||
|
vt 0.541601 0.502091
|
||||||
|
vt 0.475849 0.859220
|
||||||
|
vt 0.475849 0.804930
|
||||||
|
vt 0.475916 0.804997
|
||||||
|
vt 0.475782 0.859154
|
||||||
|
vt 0.117761 0.709773
|
||||||
|
vt 0.130946 0.502091
|
||||||
|
vt 0.138310 0.687942
|
||||||
|
vt 0.115043 0.710107
|
||||||
|
vt 0.117776 0.710123
|
||||||
|
vt 0.374527 0.804997
|
||||||
|
vt 0.352998 0.895446
|
||||||
|
vt 0.353105 0.895513
|
||||||
|
vt 0.374421 0.804930
|
||||||
vn 0.580093 0.161325 -0.798415
|
vn 0.580093 0.161325 -0.798415
|
||||||
vn 0.580093 0.161325 -0.798415
|
vn 0.580093 0.161325 -0.798415
|
||||||
vn 0.580093 0.161325 -0.798415
|
vn 0.580093 0.161325 -0.798415
|
||||||
@@ -300,10 +394,10 @@ vn -0.513202 0.342157 0.787116
|
|||||||
vn -0.513202 0.342157 0.787116
|
vn -0.513202 0.342157 0.787116
|
||||||
vn -0.513202 0.342157 0.787116
|
vn -0.513202 0.342157 0.787116
|
||||||
vn -0.513202 0.342158 0.787116
|
vn -0.513202 0.342158 0.787116
|
||||||
vn -0.103818 0.105609 0.988974
|
vn -0.103818 0.105609 0.988973
|
||||||
vn -0.103818 0.105609 0.988974
|
vn -0.103818 0.105609 0.988973
|
||||||
vn -0.103818 0.105609 0.988974
|
vn -0.103818 0.105609 0.988973
|
||||||
vn -0.103818 0.105609 0.988974
|
vn -0.103818 0.105609 0.988973
|
||||||
vn 0.242147 -0.055410 0.968656
|
vn 0.242147 -0.055410 0.968656
|
||||||
vn 0.242147 -0.055411 0.968656
|
vn 0.242147 -0.055411 0.968656
|
||||||
vn 0.242147 -0.055411 0.968656
|
vn 0.242147 -0.055411 0.968656
|
||||||
@@ -312,8 +406,8 @@ vn 0.913291 -0.166829 0.371576
|
|||||||
vn 0.913291 -0.166829 0.371576
|
vn 0.913291 -0.166829 0.371576
|
||||||
vn 0.913291 -0.166829 0.371575
|
vn 0.913291 -0.166829 0.371575
|
||||||
vn 0.913291 -0.166829 0.371576
|
vn 0.913291 -0.166829 0.371576
|
||||||
vn 0.908138 -0.217763 -0.357580
|
vn 0.908139 -0.217763 -0.357580
|
||||||
vn 0.908138 -0.217763 -0.357580
|
vn 0.908139 -0.217763 -0.357580
|
||||||
vn 0.908139 -0.217763 -0.357580
|
vn 0.908139 -0.217763 -0.357580
|
||||||
vn 0.908139 -0.217763 -0.357580
|
vn 0.908139 -0.217763 -0.357580
|
||||||
vn -0.010919 0.268649 -0.963176
|
vn -0.010919 0.268649 -0.963176
|
||||||
@@ -434,10 +528,10 @@ vn 0.282260 0.010754 -0.959278
|
|||||||
vn 0.282260 0.010754 -0.959278
|
vn 0.282260 0.010754 -0.959278
|
||||||
vn 0.282260 0.010754 -0.959278
|
vn 0.282260 0.010754 -0.959278
|
||||||
vn 0.282260 0.010754 -0.959278
|
vn 0.282260 0.010754 -0.959278
|
||||||
vn 0.007899 0.161210 -0.986888
|
vn 0.007899 0.161210 -0.986889
|
||||||
vn 0.007899 0.161210 -0.986888
|
vn 0.007899 0.161210 -0.986889
|
||||||
vn 0.007899 0.161210 -0.986888
|
vn 0.007899 0.161210 -0.986889
|
||||||
vn 0.007899 0.161210 -0.986888
|
vn 0.007899 0.161210 -0.986889
|
||||||
vn -0.544997 0.360368 0.757042
|
vn -0.544997 0.360368 0.757042
|
||||||
vn -0.544997 0.360368 0.757042
|
vn -0.544997 0.360368 0.757042
|
||||||
vn -0.544997 0.360368 0.757042
|
vn -0.544997 0.360368 0.757042
|
||||||
@@ -450,18 +544,18 @@ vn 0.248662 -0.093840 0.964034
|
|||||||
vn 0.248662 -0.093840 0.964034
|
vn 0.248662 -0.093840 0.964034
|
||||||
vn 0.248662 -0.093840 0.964034
|
vn 0.248662 -0.093840 0.964034
|
||||||
vn 0.248662 -0.093840 0.964034
|
vn 0.248662 -0.093840 0.964034
|
||||||
vn 0.868209 -0.359881 0.341614
|
|
||||||
vn 0.868209 -0.359881 0.341614
|
|
||||||
vn 0.868208 -0.359881 0.341614
|
vn 0.868208 -0.359881 0.341614
|
||||||
vn 0.868209 -0.359881 0.341614
|
vn 0.868208 -0.359881 0.341614
|
||||||
|
vn 0.868208 -0.359881 0.341614
|
||||||
|
vn 0.868208 -0.359881 0.341614
|
||||||
vn 0.820167 -0.305191 -0.483927
|
vn 0.820167 -0.305191 -0.483927
|
||||||
vn 0.820167 -0.305191 -0.483927
|
vn 0.820167 -0.305191 -0.483927
|
||||||
vn 0.820167 -0.305191 -0.483927
|
vn 0.820167 -0.305191 -0.483927
|
||||||
vn 0.820167 -0.305191 -0.483927
|
vn 0.820167 -0.305191 -0.483927
|
||||||
vn -0.901648 0.290351 -0.320509
|
vn -0.901649 0.290351 -0.320509
|
||||||
vn -0.901648 0.290351 -0.320509
|
vn -0.901649 0.290351 -0.320509
|
||||||
vn -0.901648 0.290351 -0.320509
|
vn -0.901649 0.290351 -0.320509
|
||||||
vn -0.901648 0.290351 -0.320509
|
vn -0.901649 0.290351 -0.320509
|
||||||
vn -0.153020 0.117402 0.981225
|
vn -0.153020 0.117402 0.981225
|
||||||
vn -0.153020 0.117402 0.981225
|
vn -0.153020 0.117402 0.981225
|
||||||
vn -0.153020 0.117402 0.981225
|
vn -0.153020 0.117402 0.981225
|
||||||
@@ -470,9 +564,9 @@ vn -0.153020 0.117402 0.981225
|
|||||||
vn -0.153020 0.117402 0.981225
|
vn -0.153020 0.117402 0.981225
|
||||||
vn -0.153020 0.117402 0.981225
|
vn -0.153020 0.117402 0.981225
|
||||||
vn 0.944190 -0.256454 0.206730
|
vn 0.944190 -0.256454 0.206730
|
||||||
vn 0.944189 -0.256454 0.206730
|
|
||||||
vn 0.944190 -0.256454 0.206730
|
vn 0.944190 -0.256454 0.206730
|
||||||
vn 0.944189 -0.256454 0.206730
|
vn 0.944190 -0.256454 0.206730
|
||||||
|
vn 0.944190 -0.256454 0.206730
|
||||||
vn 0.599743 -0.413652 -0.684982
|
vn 0.599743 -0.413652 -0.684982
|
||||||
vn 0.599743 -0.413652 -0.684982
|
vn 0.599743 -0.413652 -0.684982
|
||||||
vn 0.599743 -0.413652 -0.684982
|
vn 0.599743 -0.413652 -0.684982
|
||||||
@@ -510,7 +604,7 @@ vn 0.954339 0.279212 0.106194
|
|||||||
vn 0.954339 0.279212 0.106194
|
vn 0.954339 0.279212 0.106194
|
||||||
vn 0.033520 0.999426 0.005000
|
vn 0.033520 0.999426 0.005000
|
||||||
vn 0.033520 0.999426 0.005000
|
vn 0.033520 0.999426 0.005000
|
||||||
vn 0.033520 0.999425 0.005000
|
vn 0.033520 0.999426 0.005000
|
||||||
vn -0.805391 0.501883 0.315372
|
vn -0.805391 0.501883 0.315372
|
||||||
vn -0.805390 0.501883 0.315372
|
vn -0.805390 0.501883 0.315372
|
||||||
vn -0.805390 0.501883 0.315372
|
vn -0.805390 0.501883 0.315372
|
||||||
@@ -528,14 +622,16 @@ vn -0.412111 0.909837 0.048596
|
|||||||
vn -0.412111 0.909837 0.048596
|
vn -0.412111 0.909837 0.048596
|
||||||
vn -0.412111 0.909837 0.048596
|
vn -0.412111 0.909837 0.048596
|
||||||
vn -0.412111 0.909837 0.048596
|
vn -0.412111 0.909837 0.048596
|
||||||
vn 0.130679 0.969155 0.208951
|
vn 0.130679 0.969156 0.208951
|
||||||
vn 0.130679 0.969155 0.208951
|
vn 0.130679 0.969156 0.208951
|
||||||
vn 0.130679 0.969155 0.208951
|
vn 0.130679 0.969156 0.208951
|
||||||
vn 0.130679 0.969155 0.208951
|
vn 0.130679 0.969156 0.208951
|
||||||
vn 0.898657 -0.437843 0.026635
|
vn 0.898657 -0.437843 0.026635
|
||||||
vn 0.898657 -0.437843 0.026635
|
vn 0.898657 -0.437843 0.026635
|
||||||
vn 0.898657 -0.437843 0.026635
|
vn 0.898657 -0.437843 0.026635
|
||||||
vn 0.898657 -0.437843 0.026635
|
vn 0.898657 -0.437843 0.026635
|
||||||
|
vn -0.559499 0.786314 0.262050
|
||||||
|
vn -0.559500 0.786314 0.262050
|
||||||
vn 0.901532 -0.413238 -0.128352
|
vn 0.901532 -0.413238 -0.128352
|
||||||
vn 0.901532 -0.413238 -0.128352
|
vn 0.901532 -0.413238 -0.128352
|
||||||
vn 0.391848 0.919311 -0.036369
|
vn 0.391848 0.919311 -0.036369
|
||||||
@@ -553,93 +649,89 @@ vn 0.000000 -1.000000 0.000000
|
|||||||
vn 0.000000 -1.000000 0.000000
|
vn 0.000000 -1.000000 0.000000
|
||||||
vn 0.000000 -1.000000 0.000000
|
vn 0.000000 -1.000000 0.000000
|
||||||
s off
|
s off
|
||||||
g pasted__pasted__pSphere1 pasted__pasted__pSphere1SmoothProxyGroup pasted__group group1
|
g Rock14:group1 Rock14:pasted__group Rock14:pasted__pasted__pSphere1 Rock14:pasted__pasted__pSphere1SmoothProxyGroup Rock14:polySurface1
|
||||||
usemtl lambert6SG
|
usemtl Rock14:lambert6SG
|
||||||
f 1/1/1 2/2/2 12/13/3 11/12/4
|
f 1/42/1 2/46/2 12/47/3 11/43/4
|
||||||
f 2/2/5 3/3/6 13/14/7 12/13/8
|
f 2/117/5 3/118/6 13/119/7 12/120/8
|
||||||
f 3/3/9 4/4/10 14/15/11 13/14/12
|
f 3/9/9 4/1/10 14/4/11 13/10/12
|
||||||
f 4/4/13 5/5/14 15/16/15 14/15/16
|
f 4/1/13 5/2/14 15/3/15 14/4/16
|
||||||
f 5/5/17 6/6/18 16/17/19 15/16/20
|
f 5/2/17 6/5/18 16/6/19 15/3/20
|
||||||
f 6/6/21 7/7/22 17/18/23 16/17/24
|
f 6/5/21 7/11/22 17/12/23 16/6/24
|
||||||
f 7/7/25 8/8/26 18/19/27 17/18/28
|
f 7/121/25 8/122/26 18/123/27 17/124/28
|
||||||
f 8/8/29 9/9/30 19/20/31 18/19/32
|
f 8/122/29 9/125/30 19/126/31 18/123/32
|
||||||
f 9/9/33 10/10/34 20/21/35 19/20/36
|
f 9/38/33 10/39/34 20/40/35 19/41/36
|
||||||
f 10/10/37 1/11/38 11/22/39 20/21/40
|
f 10/39/37 1/42/38 11/43/39 20/40/40
|
||||||
f 11/12/41 12/13/42 22/24/43 21/23/44
|
f 11/147/41 12/148/42 22/149/43 21/150/44
|
||||||
f 12/13/45 13/14/46 23/25/47 22/24/48
|
f 12/96/45 13/92/46 23/95/47 22/97/48
|
||||||
f 13/14/49 14/15/50 24/26/51 23/25/52
|
f 13/92/49 14/93/50 24/94/51 23/95/52
|
||||||
f 14/15/53 15/16/54 25/27/55 24/26/56
|
f 14/4/53 15/3/54 25/7/55 24/8/56
|
||||||
f 15/16/57 16/17/58 26/28/59 25/27/60
|
f 15/3/57 16/6/58 26/13/59 25/7/60
|
||||||
f 16/17/61 17/18/62 27/29/63 26/28/64
|
f 16/132/61 17/124/62 27/128/63 26/133/64
|
||||||
f 17/18/65 18/19/66 28/30/67 27/29/68
|
f 17/124/65 18/123/66 28/127/67 27/128/68
|
||||||
f 18/19/69 19/20/70 29/31/71 28/30/72
|
f 18/123/69 19/126/70 29/129/71 28/127/72
|
||||||
f 19/20/73 20/21/74 30/32/75 29/31/76
|
f 19/41/73 20/40/74 30/44/75 29/45/76
|
||||||
f 20/21/77 11/22/78 21/33/79 30/32/80
|
f 20/40/77 11/43/78 21/48/79 30/44/80
|
||||||
f 51/57/81 52/58/82 32/35/83 31/34/84
|
f 51/165/81 52/164/82 32/166/83 31/167/84
|
||||||
f 52/58/85 53/59/86 33/36/87 32/35/88
|
f 52/164/85 53/159/86 33/168/87 32/166/88
|
||||||
f 54/60/89 55/61/90 35/38/91 34/37/92
|
f 54/68/89 55/69/90 35/65/91 34/64/92
|
||||||
f 55/61/93 56/62/94 36/39/95 35/38/96
|
f 55/17/93 56/20/94 36/27/95 35/28/96
|
||||||
f 56/62/97 57/63/98 37/40/99 36/39/100
|
f 56/20/97 57/26/98 37/31/99 36/27/100
|
||||||
f 57/63/101 58/64/102 38/41/103 37/40/104
|
f 57/139/101 58/138/102 38/141/103 37/142/104
|
||||||
f 58/64/105 59/65/106 39/42/107 38/41/108
|
f 58/138/105 59/140/106 39/143/107 38/141/108
|
||||||
f 59/65/109 60/66/110 40/43/111 39/42/112
|
f 59/56/109 60/55/110 40/58/111 39/59/112
|
||||||
f 60/66/113 51/56/114 31/44/115 40/43/116
|
f 60/55/113 51/57/114 31/60/115 40/58/116
|
||||||
f 31/34/117 32/35/118 42/46/119 41/45/120
|
f 31/167/117 32/166/118 42/169/119 41/170/120
|
||||||
f 32/35/121 33/36/122 43/47/123 42/46/124
|
f 32/166/121 33/168/122 43/171/123 42/169/124
|
||||||
f 33/36/125 34/37/126 44/48/127 43/47/128
|
f 33/70/125 34/64/126 44/67/127 43/71/128
|
||||||
f 34/37/129 35/38/130 45/49/131 44/48/132
|
f 34/64/129 35/65/130 45/66/131 44/67/132
|
||||||
f 35/38/133 36/39/134 46/50/135 45/49/136
|
f 35/28/133 36/27/134 46/32/135 45/33/136
|
||||||
f 92/100/137 93/101/138 94/102/139 95/103/140
|
f 92/173/137 93/174/138 94/175/139 95/176/140
|
||||||
f 37/40/141 38/41/142 48/52/143 47/51/144
|
f 37/142/141 38/141/142 48/144/143 47/145/144
|
||||||
f 38/41/145 39/42/146 49/53/147 48/52/148
|
f 38/141/145 39/143/146 49/146/147 48/144/148
|
||||||
f 39/42/149 40/43/150 50/54/151 49/53/152
|
f 39/59/149 40/58/150 50/61/151 49/62/152
|
||||||
f 40/43/153 31/44/154 41/55/155 50/54/156
|
f 40/58/153 31/60/154 41/63/155 50/61/156
|
||||||
f 34/37/157 33/36/158 53/59/159 54/60/160
|
f 34/64/157 33/70/158 53/72/159 54/68/160
|
||||||
s 1
|
f 47/36/161 44/37/162 45/33/163 46/32/164
|
||||||
f 47/51/161 44/48/162 45/49/163 46/50/164
|
f 61/156/165 62/155/166 52/164/167 51/165/168
|
||||||
s off
|
f 62/155/169 63/160/170 53/159/171 52/164/172
|
||||||
f 61/68/165 62/69/166 52/58/167 51/57/168
|
f 55/17/173 25/7/174 26/13/175 73/18/176 64/19/177 56/20/178
|
||||||
f 62/69/169 63/70/170 53/59/171 52/58/172
|
f 64/19/179 65/25/180 57/26/181 56/20/182
|
||||||
f 55/61/173 25/27/174 26/28/175 73/81/176 64/71/177 56/62/178
|
f 65/136/183 66/135/184 58/138/185 57/139/186
|
||||||
f 64/71/179 65/72/180 57/63/181 56/62/182
|
f 66/135/187 67/137/188 59/140/189 58/138/190
|
||||||
f 65/72/183 66/73/184 58/64/185 57/63/186
|
f 67/53/191 68/52/192 60/55/193 59/56/194
|
||||||
f 66/73/187 67/74/188 59/65/189 58/64/190
|
f 68/52/195 61/54/196 51/57/197 60/55/198
|
||||||
f 67/74/191 68/75/192 60/66/193 59/65/194
|
f 69/152/199 70/151/200 62/155/201 61/156/202
|
||||||
f 68/75/195 61/67/196 51/56/197 60/66/198
|
f 70/151/203 71/154/204 63/160/205 62/155/206
|
||||||
f 69/77/199 70/78/200 62/69/201 61/68/202
|
f 87/30/207 88/29/208 84/34/209 85/35/210
|
||||||
f 70/78/203 71/79/204 63/70/205 62/69/206
|
f 73/18/211 74/24/212 65/25/213 64/19/214
|
||||||
f 87/95/207 88/96/208 84/92/209 85/93/210
|
f 74/131/215 75/130/216 66/135/217 65/136/218
|
||||||
f 73/81/211 74/82/212 65/72/213 64/71/214
|
f 75/130/219 76/134/220 67/137/221 66/135/222
|
||||||
f 74/82/215 75/83/216 66/73/217 65/72/218
|
f 76/50/223 77/49/224 68/52/225 67/53/226
|
||||||
f 75/83/219 76/84/220 67/74/221 66/73/222
|
f 77/49/227 69/51/228 61/54/229 68/52/230
|
||||||
f 76/84/223 77/85/224 68/75/225 67/74/226
|
f 21/150/231 22/149/232 70/151/233 69/152/234
|
||||||
f 77/85/227 69/76/228 61/67/229 68/75/230
|
f 22/149/235 23/153/236 71/154/237 70/151/238
|
||||||
f 21/23/231 22/24/232 70/78/233 69/77/234
|
f 26/13/239 27/23/240 74/24/241 73/18/242
|
||||||
f 22/24/235 23/25/236 71/79/237 70/78/238
|
f 27/128/243 28/127/244 75/130/245 74/131/246
|
||||||
f 26/28/239 27/29/240 74/82/241 73/81/242
|
f 28/127/247 29/129/248 76/134/249 75/130/250
|
||||||
f 27/29/243 28/30/244 75/83/245 74/82/246
|
f 29/45/251 30/44/252 77/49/253 76/50/254
|
||||||
f 28/30/247 29/31/248 76/84/249 75/83/250
|
f 30/44/255 21/48/256 69/51/257 77/49/258
|
||||||
f 29/31/251 30/32/252 77/85/253 76/84/254
|
f 78/15/259 79/14/260 83/21/261 82/22/262
|
||||||
f 30/32/255 21/33/256 69/76/257 77/85/258
|
f 79/177/263 86/178/264 80/179/265 89/180/266 84/181/267 88/182/268 83/183/269
|
||||||
f 78/86/259 79/87/260 83/91/261 82/90/262
|
f 89/73/270 90/74/271 85/75/272 84/76/273
|
||||||
f 79/87/263 86/94/264 80/88/265 89/97/266 84/92/267 88/96/268 83/91/269
|
f 81/78/274 78/79/275 82/80/276 87/81/277 85/75/278 90/74/279
|
||||||
f 89/97/270 90/98/271 85/93/272 84/92/273
|
f 25/7/280 79/14/281 78/15/282 72/16/283 24/8/284
|
||||||
f 81/89/274 78/86/275 82/90/276 87/95/277 85/93/278 90/98/279
|
f 25/184/285 86/178/286 79/177/287
|
||||||
f 25/27/280 79/87/281 78/86/282 72/80/283 24/26/284
|
f 82/22/288 83/21/289 88/29/290 87/30/291
|
||||||
f 25/27/285 86/94/286 79/87/287
|
f 89/73/292 91/77/293 81/78/294 90/74/295
|
||||||
f 82/90/288 83/91/289 88/96/290 87/95/291
|
f 81/157/296 54/158/297 53/159/298 63/160/299 71/154/300 23/153/301 24/161/302 72/162/303 78/163/304
|
||||||
f 89/97/292 91/99/293 81/89/294 90/98/295
|
f 91/77/305 55/82/306 54/83/307 81/78/308
|
||||||
f 81/89/296 54/60/297 53/59/298 63/70/299 71/79/300 23/25/301 24/26/302 72/80/303 78/86/304
|
f 80/98/309 91/99/310 89/100/311
|
||||||
f 91/99/305 55/61/306 54/60/307 81/89/308
|
f 86/189/312 25/190/313 55/191/314 91/192/315 80/193/316
|
||||||
f 80/88/309 91/99/310 89/97/311
|
f 42/169/317 43/171/318 44/172/319 41/170/320
|
||||||
f 86/94/312 25/27/313 55/61/314 91/99/315 80/88/316
|
f 41/101/321 48/102/322 49/103/323 50/104/324
|
||||||
f 42/46/317 43/47/318 44/48/319 41/45/320
|
f 41/101/325 44/105/326 47/106/327 48/102/328
|
||||||
f 41/45/321 48/52/322 49/53/323 50/54/324
|
f 36/185/329 37/186/330 93/187/331 92/188/332
|
||||||
f 41/45/325 44/48/326 47/51/327 48/52/328
|
f 37/84/333 47/85/334 94/86/335 93/87/336
|
||||||
f 36/39/329 37/40/330 93/101/331 92/100/332
|
f 47/194/337 46/195/338 95/196/339 94/197/340
|
||||||
f 37/40/333 47/51/334 94/102/335 93/101/336
|
f 46/88/341 36/89/342 92/90/343 95/91/344
|
||||||
s 1
|
f 4/107/345 3/108/346 2/109/347 1/110/348 10/111/349 9/112/350 8/113/351 7/114/352 6/115/353 5/116/354
|
||||||
f 47/51/161 46/50/164 95/103/337 94/102/338
|
|
||||||
s off
|
|
||||||
f 46/50/339 36/39/340 92/100/341 95/103/342
|
|
||||||
f 4/4/343 3/3/344 2/2/345 1/11/346 10/10/347 9/9/348 8/8/349 7/7/350 6/6/351 5/5/352
|
|
||||||
|
|||||||
@@ -1,67 +1,26 @@
|
|||||||
newmtl Rock1:pasted__pasted__lambert3SG1
|
newmtl Rock5:pasted__pasted__lambert3SG1
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd Stones.png
|
||||||
|
Ni 1.00
|
||||||
|
newmtl Rock5:pasted__pasted__lambert3SG3
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.45 0.45 0.45
|
Kd 0.45 0.45 0.45
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl Rock2:pasted__pasted__lambert3SG1
|
newmtl Rock5:pasted__pasted__lambert3SG7
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.45 0.45 0.45
|
Kd 0.45 0.45 0.45
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl Rock3:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl Rock4:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl initialShadingGroup
|
|
||||||
illum 4
|
|
||||||
Kd 0.50 0.50 0.50
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert2SG
|
newmtl lambert2SG
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.11 0.07 0.00
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert3SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.50 0.35 0.00
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert4SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.13 0.14 0.16
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert5SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.00 0.00 0.00
|
Kd 0.00 0.00 0.00
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
map_Kd Naamloos.png
|
map_Kd Stones.png
|
||||||
Ni 1.00
|
|
||||||
newmtl pasted__lambert4SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.13 0.14 0.16
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
|
|||||||
@@ -1,67 +1,32 @@
|
|||||||
newmtl Rock1:pasted__pasted__lambert3SG1
|
newmtl Rock6:pasted__pasted__lambert3SG1
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.45 0.45 0.45
|
Kd 0.45 0.45 0.45
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl Rock2:pasted__pasted__lambert3SG1
|
newmtl Rock6:pasted__pasted__lambert3SG3
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.45 0.45 0.45
|
Kd 0.45 0.45 0.45
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl Rock3:pasted__pasted__lambert3SG1
|
newmtl Rock6:pasted__pasted__lambert3SG7
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.45 0.45 0.45
|
Kd 0.45 0.45 0.45
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl Rock4:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl initialShadingGroup
|
|
||||||
illum 4
|
|
||||||
Kd 0.50 0.50 0.50
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert2SG
|
newmtl lambert2SG
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.11 0.07 0.00
|
Kd 0.00 0.00 0.00
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd Stones.png
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl lambert3SG
|
newmtl lambert3SG
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.50 0.35 0.00
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert4SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.13 0.14 0.16
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert5SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.00 0.00 0.00
|
Kd 0.00 0.00 0.00
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
map_Kd Naamloos.png
|
map_Kd Stones.png
|
||||||
Ni 1.00
|
|
||||||
newmtl pasted__lambert4SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.13 0.14 0.16
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
|
|||||||
@@ -1,67 +1,135 @@
|
|||||||
newmtl Rock1:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl Rock2:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl Rock3:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl Rock4:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl initialShadingGroup
|
newmtl initialShadingGroup
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.50 0.50 0.50
|
Kd 0.22 0.22 0.22
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl lambert2SG
|
newmtl lambert2SG
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.11 0.07 0.00
|
Kd 0.50 0.32 0.25
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl lambert3SG
|
newmtl lambert3SG
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.50 0.35 0.00
|
Kd 0.45 0.45 0.45
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl lambert4SG
|
newmtl lambert4SG
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.13 0.14 0.16
|
Kd 0.12 0.12 0.12
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl lambert5SG
|
newmtl lambert5SG
|
||||||
illum 4
|
illum 4
|
||||||
|
Kd 0.10 0.05 0.02
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl lambert7SG
|
||||||
|
illum 4
|
||||||
Kd 0.00 0.00 0.00
|
Kd 0.00 0.00 0.00
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
map_Kd Naamloos.png
|
map_Kd Stones.png
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl pasted__lambert4SG
|
newmtl pasted__lambert4SG
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.13 0.14 0.16
|
Kd 0.12 0.12 0.12
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
newmtl pasted__pasted__lambert3SG1
|
newmtl pasted__lambert4SG1
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.45 0.45 0.45
|
Kd 0.12 0.12 0.12
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__lambert4SG2
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd DH4m07o.gif
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__lambert5SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.10 0.05 0.02
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__lambert5SG1
|
||||||
|
illum 4
|
||||||
|
Kd 0.10 0.05 0.02
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__lambert5SG2
|
||||||
|
illum 4
|
||||||
|
Kd 0.00 0.00 0.00
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
map_Kd kappa.jpg
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__pasted__lambert4SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.12 0.12 0.12
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__pasted__lambert4SG1
|
||||||
|
illum 4
|
||||||
|
Kd 0.12 0.12 0.12
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__pasted__lambert4SG2
|
||||||
|
illum 4
|
||||||
|
Kd 0.12 0.12 0.12
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__pasted__lambert4SG3
|
||||||
|
illum 4
|
||||||
|
Kd 0.12 0.12 0.12
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__pasted__lambert5SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.10 0.05 0.02
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__pasted__lambert5SG1
|
||||||
|
illum 4
|
||||||
|
Kd 0.10 0.05 0.02
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__pasted__lambert5SG2
|
||||||
|
illum 4
|
||||||
|
Kd 0.10 0.05 0.02
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__pasted__lambert5SG3
|
||||||
|
illum 4
|
||||||
|
Kd 0.10 0.05 0.02
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__pasted__pasted__lambert4SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.12 0.12 0.12
|
||||||
|
Ka 0.00 0.00 0.00
|
||||||
|
Tf 1.00 1.00 1.00
|
||||||
|
Ni 1.00
|
||||||
|
newmtl pasted__pasted__pasted__lambert5SG
|
||||||
|
illum 4
|
||||||
|
Kd 0.10 0.05 0.02
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
|
|||||||
@@ -1,73 +1,7 @@
|
|||||||
newmtl Rock1:pasted__pasted__lambert3SG1
|
newmtl Rock16:lambert6SG
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl Rock2:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl Rock3:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl Rock4:pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl initialShadingGroup
|
|
||||||
illum 4
|
|
||||||
Kd 0.50 0.50 0.50
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert2SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.11 0.07 0.00
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert3SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.50 0.35 0.00
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert4SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.13 0.14 0.16
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert5SG
|
|
||||||
illum 4
|
illum 4
|
||||||
Kd 0.00 0.00 0.00
|
Kd 0.00 0.00 0.00
|
||||||
Ka 0.00 0.00 0.00
|
Ka 0.00 0.00 0.00
|
||||||
Tf 1.00 1.00 1.00
|
Tf 1.00 1.00 1.00
|
||||||
map_Kd Naamloos.png
|
map_Kd Stones.png
|
||||||
Ni 1.00
|
|
||||||
newmtl lambert6SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.89 0.89 0.89
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl pasted__lambert4SG
|
|
||||||
illum 4
|
|
||||||
Kd 0.13 0.14 0.16
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
|
||||||
newmtl pasted__pasted__lambert3SG1
|
|
||||||
illum 4
|
|
||||||
Kd 0.45 0.45 0.45
|
|
||||||
Ka 0.00 0.00 0.00
|
|
||||||
Tf 1.00 1.00 1.00
|
|
||||||
Ni 1.00
|
Ni 1.00
|
||||||
|
|||||||