我尝试使用QSceneLoader加载在外部编辑器中创建的3d场景,但未成功。我总是在加载阶段得到断言。我使用OBJ模型qt的例子,它可以很容易地加载为QMesh。
测试回购https://bitbucket.org/ibnz/test_qt3d
<?php
namespace UserBundle\Form\Type;
use FOS\UserBundle\Util\LegacyFormHelper;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
//use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;
use UserBundle\Form\Type\RegistrationEmployeFormType as BaseType;
use Doctrine\ORM\EntityRepository;
class RegistrationEmployeFormType extends AbstractType {
/**
* @var string
*/
private $class;
/**
* @param string $class The User class name
*/
public function __construct($class) {
$this->class = $class;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('email', LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\EmailType' ), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))
->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))
->add('plainPassword', LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\RepeatedType'), array(
'type' => LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\PasswordType'),
'options' => array('translation_domain' => 'FOSUserBundle'),
'first_options' => array('label' => 'form.password'),
'second_options' => array('label' => 'form.password_confirmation'),
'invalid_message' => 'fos_user.password.mismatch',
))
->add('entreprise')
->add('firstName','text', array('required' => false))
->add('lastName','text', array('required' => false));
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(array(
'data_class' => $this->class,
'csrf_token_id' => 'registration',
// BC for SF < 2.8
'intention' => 'registration',
));
}
/**
* {@inheritdoc}
*/
public function getName() {
return $this->getBlockPrefix();
}
public function getParent() {
return 'fos_user_registration';
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix() {
return 'Employe_registration';
}
Qt3DRender :: QSceneLoader ::状态(加载) ASSERT:文件io \ qsceneloader.cpp中的“entities.size()== 1”,第215行 调试错误!
程序:C:\ Qt \ Qt5.8.0 \ 5.8 \ msvc2015 \ bin \ Qt5Cored.dll 模块:5.8.0 文件:global \ qglobal.cpp 行:3070
ASSERT:文件io \ qsceneloader.cpp中的“entities.size()== 1”,第215行
(按重试调试应用程序) Qt3DRender :: QSceneLoader ::状态(就绪)
答案 0 :(得分:0)
我使用http://code.qt.io/cgit/qt/qt3d.git/tree/tests/manual/assimp-cpp加载我自己的Collada机器人模型,该模型可以正常工作。重要的是:
// Root entity
Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity();
...
// Scene loader
Qt3DCore::QEntity *sceneLoaderEntity = new Qt3DCore::QEntity(sceneRoot);
Qt3DRender::QSceneLoader *sceneLoader = new Qt3DRender::QSceneLoader(sceneLoaderEntity);
SceneWalker sceneWalker(sceneLoader);
QObject::connect(sceneLoader, &Qt3DRender::QSceneLoader::statusChanged, &sceneWalker, &SceneWalker::onStatusChanged);
sceneLoaderEntity->addComponent(sceneLoader);
请用你的obj文件试试。