Location>code7788 >text

Project practice: Qt + OSG blasting dynamics simulation 3D engine test tool v1.1.0 (load .K model, bullet trajectory simulation animation, support windows, linux, domestic Kirin system)

Popularity:644 ℃/2024-09-24 20:57:24

demand (economics)

  1. Use osg 3D engine to perform simulation performance testing of dynamics models;
  2. Open the dynamics simulation model file with .k suffix and test the loading and parsing process;
  3.Solve the problem that the 3D engine made by the third party company's opengl has more drawing surfaces and the projectile path simulation is more stuttering;
  4. At the time of testing, the model used was a public model with more than 1.6 million base surfaces;
  5. During the test, the simulation animation was used when 1 million projectile paths were shot out in parallel;

 

Demo V1.1.0

  1. New open dual model, the first model in the original position, the second model in the offset position
  2. Optimize the process of opening closing and reopening the model
  3. For 1,000,000 lines of animated shots, used to test performance
  4. The current model is 1.6 million surfaces, and more than 3.2 million elemental base surfaces when dual modeled
  请添加图片描述
  请添加图片描述

  请添加图片描述

  请添加图片描述

 

Demo v1.0.0

  Test interaction smoothness, no lag in interaction!!!!
  请添加图片描述

 

Modular Deployment

  在这里插入图片描述

 

key source code

#ifndef OSGWIDGET_H
#define OSGWIDGET_H

#include <QWidget>
#include ""
#include ""
#include "osg/PolygonMode"

class AnimationPathCameraMainpulator;

namespace Ui {
class OsgWidget;
}

class OsgWidget : public QWidget
{
    Q_OBJECT
public:
    // Model Structures
struct Element_Shell    // *ELEMENT_SHELL
    {
        Element_Shell() {
        }
        qint64 eid;         // Unit id
        qint64 pid;         // Material id
        qint64 n1;          // Node 1, defining the geometry
        qint64 n2;          // Node 2, defining the geometry
        qint64 n3;          // Node 3, defining the geometry
        qint64 n4;          // Node 4, defining the geometry
        qint64 n5;          // Thickness, extra nodes are meaningless in the standard LS-DYNA quadrilateral shell cell definition.
        qint64 n6;          // Integral points, extra nodes are meaningless in the standard LS-DYNA quadrilateral shell cell definition.
        qint64 n7;          // Extra nodes are meaningless in the standard LS-DYNA quadrilateral shell cell definition.
        qint64 n8;          // The extra nodes have no meaning in the standard LS-DYNA quadrilateral shell unit definition.
};
    struct Part             // *PART
    {
        Part() {
        }
        qint64 pid;         // Part id number, unique
        qint64 secid;       // The id number of the section defined with the *section keyword.
        QList<Element_Shell> listElementShell;  // Part slice element
        qint64 mid;         // Material number of the component
        qint64 eosid;       // Equation of state number of the material to which the part belongs, defined by the *EOS keyword
        qint64 hgid;        // Hourglass or volumetric viscosity parameter number, defined by the *HOURGLASS keyword; taking 0 means that the default value will be used:
        qint64 grav;        // Valid for entity units only, take 0 to indicate gravity initialization for all PARTs, take 1 to indicate initialization for current material only
        qint64 adpopt;      // Identifies whether the part uses adaptive meshing, 0 means no
        qint64 tmid;        // Identifies if the part uses adaptive meshing, 0 means no.
};
    struct Node {
        Node() {
        }
        qint64 nid;         // Node number, unique
double x;           // 3D x-coordinates (global)
double y;           // 3D y-coordinate (global)
double z;           // 3D z-coordinate (global)
int tc;             // Constrained state of the translational degrees of freedom, enumeration: 0 - no translational constraints, 1 - translational constraints in the x-direction, 2 - translational constraints in the y-direction.
int rc;             // Constraint state of the rotational degrees of freedom, enumerated values: 0 - no rotation constraint, 1 - rotation constraint in X direction, 2 - rotation constraint in Y direction.
};
    struct K_Mode
    {
        K_Mode() {}
        QList<Part> listPart;
        QList<Node> listNode;
        QHash<int, Node> hashNid2Node;
    };

    // Add model
    K_Mode kMode;

public:
    explicit OsgWidget(QWidget *parent = 0);
    ~OsgWidget();

public:
    bool getFixXAxis() const;               // Get the X-axis fixed state
bool getFixYAxis() const;               // Get the Y-axis fixed state
bool getFixZAxis() const;               // Get the Z-axis fixed state
void getCenter(double &x, double &y, double &z);
                                            // Get the coordinates of the engine's center point
void getPersonPoint(double &x, double &y, double &z);
                                            // Get the angle of the initialized human eye (looking towards the center of the engine)

public:
    void setFixXAxis(bool fixXAxis);        // Set fixed X-axis
void setFixYAxis(bool fixYAxis);        // Set the fixed Y-axis
void setFixZAxis(bool fixZAxis);