phyheightfield.cpp
1 /********************************************************************************
2  * WorldSim -- library for robot simulations *
3  * Copyright (C) 2008-2013 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
20 // #include "phyheightfield.h"
21 // #include "private/phyobjectprivate.h"
22 // #include "private/worldprivate.h"
23 //
24 // namespace farsa {
25 //
26 // PhyHeightField::PhyHeightField( real side_x, real side_y, World* w, QString name, const wMatrix& tm )
27 // : PhyObject( w, name, tm, false ) {
28 // sidex = side_x;
29 // sidey = side_y;
30 // w->pushObject( this );
31 // createPrivateObject();
32 // changedMatrix();
33 // }
34 //
35 // PhyHeightField::~PhyHeightField() {
36 // #ifdef WORLDSIM_USE_NEWTON
37 // /* nothing to do */
38 // #endif
39 // }
40 //
41 // void PhyHeightField::createPrivateObject() {
42 // #ifdef WORLDSIM_USE_NEWTON
43 // // creating for now a structure for creating a simple box with no elevations at all
44 // real cellSize = 0.25f; //0.01f;
45 // real elevationScaling = 0.001f;
46 // int xCells = ceil(sidex/cellSize);
47 // int yCells = ceil(sidey/cellSize);
48 // unsigned short* elevations = new uint16_t[xCells*yCells];
49 // char* attributes = new char[xCells*yCells];
50 // qDebug() << "HEIGHTFIELD" << xCells << yCells;
51 // for( int i=0; i<(xCells*yCells); i++ ) {
52 // elevations[i] = 0;
53 // attributes[i] = 1;
54 // }
55 // NewtonCollision* c = NewtonCreateHeightFieldCollision(worldpriv->world, xCells, yCells, 0, elevations, attributes, cellSize, elevationScaling, 0);
56 // wMatrix initialTransformationMatrix = wMatrix::identity(); // The transformation matrix is set in other places
57 // priv->body = NewtonCreateBody( worldpriv->world, c, &initialTransformationMatrix[0][0] );
58 // priv->collision = c;
59 //
60 // //NewtonBodySetAutoSleep( priv->body, 0 );
61 // //setMass( 1 );
62 // NewtonBodySetUserData( priv->body, this );
63 // //NewtonBodySetLinearDamping( priv->body, 0.0 );
64 // //wVector zero = wVector(0,0,0,0);
65 // //NewtonBodySetAngularDamping( priv->body, &zero[0] );
66 // //NewtonBodySetAutoSleep( priv->body, 0 );
67 // //NewtonBodySetFreezeState( priv->body, 0 );
68 // // Sets the signal-wrappers callback
69 // NewtonBodySetTransformCallback( priv->body, (PhyObjectPrivate::setTransformHandler) );
70 // //NewtonBodySetForceAndTorqueCallback( priv->body, (PhyObjectPrivate::applyForceAndTorqueHandler) );
71 //
72 // // storing information about the mesh of collision
73 // mesh = NewtonMeshCreateFromCollision(c);
74 // NewtonMeshTriangulate( mesh );
75 // #endif
76 // }
77 //
78 // void PhyHeightField::changedMatrix() {
79 // #ifdef WORLDSIM_USE_NEWTON
80 // //qDebug() << "SYNC POSITION" << tm[3][0] << tm[3][1] << tm[3][2];
81 // wMatrix mtr = tm.rotateAround( wVector(1,0,0), wVector(0,0,0), toRad(-90) );
82 // mtr.w_pos[0] -= sidex/2.0;
83 // mtr.w_pos[1] -= sidey/2.0;
84 // NewtonBodySetMatrix( priv->body, &mtr[0][0] );
85 // #endif
86 // }
87 //
88 // } // end namespace farsa