Caricamento v0.2
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#include "piece_interface.hpp"
|
||||
|
||||
#ifndef CAVIGLIA_H
|
||||
#define CAVIGLIA_H
|
||||
|
||||
const sf::Vector2f caviglia_Dim = {60, 200};
|
||||
const sf::Color caviglia_Col = sf::Color(230,160,11,255);
|
||||
|
||||
|
||||
class Caviglia : public PieceInterface{
|
||||
public:
|
||||
|
||||
Caviglia(rb::Vector3 coords, _Float16 mass);
|
||||
~Caviglia();
|
||||
|
||||
void update(sf::Clock cl) override;
|
||||
sf::Shape* draw(ReferencePlane plane) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,17 +1,12 @@
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <math.h>
|
||||
#include "../../rigidbody/headers/rb.hpp"
|
||||
//#include "../../joints/headers/joint_interface.hpp"
|
||||
|
||||
|
||||
#ifndef PIECE_INTERFACE_H
|
||||
#define PIECE_INTERFACE_H
|
||||
|
||||
|
||||
// costanti
|
||||
|
||||
const sf::Vector2f caviglia_Dim = {50, 200};
|
||||
const sf::Color caviglia_Col = sf::Color::Red;
|
||||
|
||||
enum class ReferencePlane {
|
||||
XY,
|
||||
YZ,
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "../headers/caviglia.hpp"
|
||||
|
||||
Caviglia::Caviglia(rb::Vector3 coords, _Float16 mass){
|
||||
size = caviglia_Dim;
|
||||
rb::Vector3 com = {size.x/2,0, size.y/2};
|
||||
body = rb::rigidbody(coords, com, mass);
|
||||
color = caviglia_Col;
|
||||
shape = new sf::RectangleShape(size);
|
||||
shape->setOrigin({size.x/2,size.y/2});
|
||||
globalPos = {0,0,0};
|
||||
}
|
||||
|
||||
Caviglia::~Caviglia(){
|
||||
delete shape;
|
||||
}
|
||||
|
||||
void Caviglia::update(sf::Clock cl){
|
||||
//body.step(cl);
|
||||
}
|
||||
|
||||
sf::Shape* Caviglia::draw(ReferencePlane plane){
|
||||
shape->setFillColor(color);
|
||||
rb::Vector3 tmpPos = body.getPos();
|
||||
rb::Vector3_s tmpRot = body.getRot();
|
||||
|
||||
switch (plane)
|
||||
{
|
||||
case ReferencePlane::XZ:
|
||||
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
|
||||
shape->setRotation(sf::Angle(sf::radians(tmpRot[2])));
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return shape;
|
||||
}
|
||||
@@ -4,10 +4,10 @@
|
||||
Sensore::Sensore(rb::Vector3 coords, _Float16 mass){
|
||||
size = sensore_Dim;
|
||||
rb::Vector3 com = {size.x/2,0, size.y/2};
|
||||
body = rb::rigidbody({0,0,0}, com, mass);
|
||||
body = rb::rigidbody(coords, com, mass);
|
||||
color = sensore_Col;
|
||||
shape = new sf::RectangleShape(size);
|
||||
globalPos = coords;
|
||||
globalPos = {0,0,0};
|
||||
}
|
||||
|
||||
Sensore::Sensore(rb::Vector3 coords, _Float16 mass, unsigned int st, unsigned int dataIntvl, std::vector<std::vector<float>> data) : Sensore(coords, mass){
|
||||
|
||||
Reference in New Issue
Block a user