C++ 向量存储器,不需要的0和x27的向量;s
我的代码适用于我的纯glut实现,但我正在尝试让它在qt中工作 我有一个金属丝网系统的质量点向量C++ 向量存储器,不需要的0和x27的向量;s,c++,qt,memory,vector,C++,Qt,Memory,Vector,我的代码适用于我的纯glut实现,但我正在尝试让它在qt中工作 我有一个金属丝网系统的质量点向量 std::vector<masspoint> m_particles; std::向量m_粒子; 问题是在我的qt版本中,我写的东西没有一个真正的坚持,我只剩下一个零数组。基本上我不明白为什么glut版本有正确的值,而qt版本没有给出基本相同的代码。qt代码有什么问题 是的,我在使用qDebug时只看到零。当我在qt版本中调用绘图函数时,所有组件中的所有顶点都是0,因此看不到任何东
std::vector<masspoint> m_particles;
std::向量m_粒子;
问题是在我的qt版本中,我写的东西没有一个真正的坚持,我只剩下一个零数组。基本上我不明白为什么glut版本有正确的值,而qt版本没有给出基本相同的代码。qt代码有什么问题
是的,我在使用qDebug时只看到零。当我在qt版本中调用绘图函数时,所有组件中的所有顶点都是0,因此看不到任何东西
int myboog = 1;
int county = 0;
// Constructors
Cloth::Cloth(float width, float height, int particles_in_width, int particles_in_height):
m_width(particles_in_width),
m_height(particles_in_height),
m_dimensionWidth(width),
m_dimensionHeight(height),
m_distanceX(width/(float)particles_in_width),
m_distanceY(height/(float)particles_in_height)
{
//Set the particle array to the given size
//Height by width
//mparticles is the name of our vector
m_particles.resize(m_width*m_height);
qDebug() << m_particles.size();
// Create the point masses to simulate the cloth
for (int x = 0; x < m_width; ++x)
{
for (int y=0; y < m_height; ++y)
{
// Place the pointmass of the cloth, lift the edges to give the wind more effect as the cloth falls
Vector3f position = Vector3f(m_dimensionWidth * (x / (float)m_width),
((x==0)||(x==m_width-1)||(y==0)||(y==m_height-1)) ? m_distanceY/2.0f:0,
m_dimensionHeight * (y / (float)m_height));
// The gravity effect is applied to new pmasspoints
m_particles[y * m_width + x] = masspoint(position,Vector3f(0,-0.06,0));
}
}
int num = (int)m_particles.size();
for (int i=0; i<num; ++i)
{
masspoint* p = &m_particles[i];
if(myboog)
{
qDebug() << "test " << *p->getPosition().getXLocation() << county;
county++;
}
}
myboog = 0;
// Calculate the normals for the first time so the initial draw is correctly lit
calculateClothNormals();
}
int myboog=1;
int县=0;
//建设者
Cloth::Cloth(浮动宽度、浮动高度、整数粒子\u英寸宽度、整数粒子\u英寸高度):
m_宽度(粒子的宽度),
m_高度(粒子在高度中),
m_尺寸宽度(宽度),
m_尺寸高度(高度),
m_距离x(宽度/(浮动)粒子的宽度),
m_距离(高度/(浮动)粒子的高度)
{
//将粒子阵列设置为给定大小
//宽高
//mparticles是向量的名称
m_粒子。调整大小(m_宽度*m_高度);
qDebug()所以qDebug()是的,我刚刚添加了qt,因为它完全适用于glut,但现在在qt中,我只得到0。
#ifndef MASSPOINT_H
#define MASSPOINT_H
#include <QGLWidget>
#include "vector3f.h"
class masspoint
{
private:
Vector3f m_position; // Current Location of the pointmass
Vector3f m_velocity; // Direction and speed the pointmass is traveling in
Vector3f m_acceleration; // Speed at which the pointmass is accelerating (used for gravity)
Vector3f m_forceAccumulated; // Force that has been accumulated since the last update
Vector3f m_normal; // Normal of this pointmass, used to light the cloth when drawing
float m_damping; // Amount of velocity lost per update
bool m_stationary; // Whether this pointmass is currently capible of movement
public:
masspoint& operator= (const masspoint& particle);
//Some constructors
masspoint();
masspoint(const masspoint& particle);
masspoint(Vector3f position, Vector3f acceleration);
//Like eulur integration
void integrate(float duration);
// Accessor functions
//Get the position of the point mass
inline Vector3f getPosition() const {return m_position;}
#ifndef VECTOR3F_H
#define VECTOR3F_H
#include <math.h>
// Vector library to be used
class Vector3f
{
private:
float m_x, m_y, m_z;
public:
const float* getXLocation() const { return &m_x; }