I am creating an FBX file through Assimp which makes too much size.
Sample source code:
scene->mRootNode = new aiNode();
scene->mMaterials = new aiMaterial*[1];
scene->mMaterials[0] = nullptr;
scene->mNumMaterials = 1;
scene->mMaterials[0] = new aiMaterial();
scene->mMeshes = new aiMesh*[numMesh];
scene->mNumMeshes = numMesh;
scene->mRootNode->mMeshes = new unsigned int[numMesh];
scene->mRootNode->mNumMeshes = numMesh;
Please let me know if anyone has encountered the same problem.
Related
I'm currently trying to use Vulkan memory allocator with the meta loader Volk
here is the link of the two: https://github.com/zeux/volk
https://gpuopen.com/vulkan-memory-allocator/
But I have trouble with creating the VmaAllocator, here is my code:
void VulkApp::Init(PipelineFlags t_Conf, entt::registry& t_reg)
{
volkInitialize();
WindowProps props = {};
props.Height = 600;
props.Width = 800;
props.Title = "Engine";
currentWindow = EngWindow::Create(props);
//Create all physical, logical, instance for vulkan
Prepare();
VolkDeviceTable test;
volkLoadDeviceTable(&test, m_LogicalDevice->GetVkDevice());
VmaAllocatorCreateInfo allocatorCreateInfo = {};
allocatorCreateInfo.vulkanApiVersion = VK_API_VERSION_1_2;
allocatorCreateInfo.physicalDevice = m_PhysicalDevice->GetVkPhysicalDevice();
allocatorCreateInfo.device = m_LogicalDevice->GetVkDevice();
allocatorCreateInfo.instance = m_Instance->GetRawVkInstance();
allocatorCreateInfo.pVulkanFunctions = reinterpret_cast<const VmaVulkanFunctions*> (&test);
VmaAllocator allocator;
vmaCreateAllocator(&allocatorCreateInfo, &allocator);
BuildRenderPipelines(t_Conf, t_reg);
}
void VulkApp::Prepare()
{
m_Instance = std::make_unique<VulkInst>();
volkLoadInstance(m_Instance->GetRawVkInstance());
currentWindow->CreateSurface(m_Instance->GetRawVkInstance(), &m_Surface);
m_PhysicalDevice = std::make_unique<PhysicalDevice>(*m_Instance);
m_LogicalDevice = std::make_unique<LogicalDevice>(*m_Instance, *m_PhysicalDevice, m_Surface);
volkLoadDevice(m_LogicalDevice->GetVkDevice());
m_SwapChain = std::make_unique<SwapChain>(ChooseSwapExtent(), *m_LogicalDevice, *m_PhysicalDevice, m_Surface);
GraphicsHelpers::CreateCommandPool(m_CommandPool, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); //TODO: added Transient bit
CreateFrameSyncResources();
/*
Create Camera
*/
BuildSwapChainResources();
}
I don't have any error when i build, but when i execute, the VmaCreateAllocator return an error:
Exception raised at 0x00007FFAB0CD836B (VkLayer_khronos_validation.dll) in My_Game.exe : 0xC0000005 : access violation reading location 0x0000000000000120.
Not very useful, but it stops on the line 14082 of the file vk_mem_alloc.h:
(*m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties)(m_PhysicalDevice, &m_MemProps);
The program check all the vulkan validation function so my vulkan function table must be good. But still the allocation fail.
I'm sorry i don't put a 'minimal' code, but with vulkan, even the minimum is really long. So, as a first test, maybe some of you have an insight of the error?
If you use a loader like Volk, you need to provide all memory related Vulkan function pointers used by VMA yourself.
This is done via the pVulkanFunctions member of the VmaAllocatorCreateInfo structure.
So when creating your VmaAllactor you set the function pointer in that to those fetched via Volk like this:
VmaVulkanFunctions vma_vulkan_func{};
vma_vulkan_func.vkAllocateMemory = vkAllocateMemory;
vma_vulkan_func.vkBindBufferMemory = vkBindBufferMemory;
vma_vulkan_func.vkBindImageMemory = vkBindImageMemory;
vma_vulkan_func.vkCreateBuffer = vkCreateBuffer;
vma_vulkan_func.vkCreateImage = vkCreateImage;
vma_vulkan_func.vkDestroyBuffer = vkDestroyBuffer;
vma_vulkan_func.vkDestroyImage = vkDestroyImage;
vma_vulkan_func.vkFlushMappedMemoryRanges = vkFlushMappedMemoryRanges;
vma_vulkan_func.vkFreeMemory = vkFreeMemory;
vma_vulkan_func.vkGetBufferMemoryRequirements = vkGetBufferMemoryRequirements;
vma_vulkan_func.vkGetImageMemoryRequirements = vkGetImageMemoryRequirements;
vma_vulkan_func.vkGetPhysicalDeviceMemoryProperties = vkGetPhysicalDeviceMemoryProperties;
vma_vulkan_func.vkGetPhysicalDeviceProperties = vkGetPhysicalDeviceProperties;
vma_vulkan_func.vkInvalidateMappedMemoryRanges = vkInvalidateMappedMemoryRanges;
vma_vulkan_func.vkMapMemory = vkMapMemory;
vma_vulkan_func.vkUnmapMemory = vkUnmapMemory;
vma_vulkan_func.vkCmdCopyBuffer = vkCmdCopyBuffer;
And then pass those to the create info:
VmaAllocatorCreateInfo allocator_info{};
...
allocator_info.pVulkanFunctions = &vma_vulkan_func;
I'm writing a windows forms application in visual studio with c++ and CLR.
And now, i got the following problem:
I read in a file and save all the important informations in a vector.
With a second step, i convert all items to a CLR array and set this array as DataSource.
array<System::String^>^ PREDEFINED = gcnew array <System::String^>(OP->CIS_Values[OP->selectedCIS]->PREDEFINED_order.size());
for (int i = 0; i < OP->CIS_Values[OP->selectedCIS]->PREDEFINED_order.size(); i++) {
PREDEFINED[i] = msclr::interop::marshal_as<System::String^>(OP->CIS_Values[OP->selectedCIS]->PREDEFINED_order[i]);
}
this->comboBox_header_predefinedtypes->DataSource = PREDEFINED;
this->comboBox_header_predefinedtypes->SelectedIndex = -1;
delete PREDEFINED;
After setting the DataSource, it must be possible to remove it. In C# i can do this with
comboBox.DataSource = null;
but how does it work in C++?
I tried the following cases:
comboBox_header_predefinedtypes->DataSource = NULL;
comboBox_header_predefinedtypes->DataSource = 0;
comboBox_header_predefinedtypes->DataSource = -1;
comboBox_header_predefinedtypes->DataBindings->Clear();
comboBox_header_predefinedtypes->Items->Clear();
I tried it with DataBindings before and after DataSource, but i always get the same exception:
System.ArgumentException: "The complex DataBinding accepts as a data source either IList or IListSource"
How can i fix this issue ?
Thx for help.
In C++ CLR you only need to write:
comboBox_header_predefinedtypes->DataSource = nullptr;
and you don't need to write
comboBox_header_predefinedtypes->Items->Clear();
after removing the DateSource to delete the items.
I am new to using the FBX SDK and I am trying to convert an OBJ file to an FBX ASCII file in C++. However, when running the following code it outputs a Binary FBX file and the file seems to be incorrect/"corrupted." The reason I say it is corrupted is because when I insert it into the FBX conversion program that Autodesk provides, it says the input binary file I got as an output from my program is corrupted. Can anyone help me solve this issue please? Thank you in advance.
//Creates a SDK manager
FbxManager* fbxmanager = FbxManager::Create();
//Set the Input/Output Settings for the SDK Manager
//EXP_ = export settings; IMP_ = import setting
FbxIOSettings* ios_settings = FbxIOSettings::Create(fbxmanager, IOSROOT);
ios_settings->SetBoolProp(EXP_ASCIIFBX, true);
fbxmanager->SetIOSettings(ios_settings);
//Creates a Scene
FbxScene* fbxscene = FbxScene::Create(fbxmanager, "");
//Creates an importer object
FbxImporter* fbximporter = FbxImporter::Create(fbxmanager, "");
//Path to the obj file
const char* obj_path = "objs/airboat.obj";
//Path to the saved fbx file
const char* fbx_path = "fbxs/global_mesh.fbx";
//Initilaize the Importer Object with the path and name of the file
bool import_stat = fbximporter->Initialize(obj_path, -1, fbxmanager->GetIOSettings());
import_stat = fbximporter->Import(fbxscene);
//Creates an exporter object
FbxExporter* fbxexporter = FbxExporter::Create(fbxmanager, "");
//Initilaize the Exporter Object with the path and name of the file
bool export_stat = fbxexporter->Initialize(fbx_path, -1,fbxmanager->GetIOSettings());
export_stat = fbxexporter->Export(fbxscene);
EDIT: Sorry forgot to provide debugging output:
All boolean functions result in true.
I want to create power-point presentation using power-point-template(which may be already exists or may be generated by poi.) for creating power point template file which have a background image in the slides, I write the following code which creates template file which opens in open-office but giving error to opening in Microsoft-power-point.
The Code is
private static void generatePOTX() throws IOException, FileNotFoundException {
String imgPathStr = System.getProperty("user.dir") + "/src/resources/images/TestSameChnl_001_t.jpeg";
File imgFile = new File(imgPathStr);
File potxFile = new File(System.getProperty("user.dir") + "/src/resources/Examples/layout.potx");
FileOutputStream out = new FileOutputStream(potxFile);
HSLFSlideShow ppt = new HSLFSlideShow();
HSLFSlide slide = ppt.createSlide();
slide.setFollowMasterBackground(false);
HSLFFill fill = slide.getBackground().getFill();
HSLFPictureData pd = ppt.addPicture(imgFile, PictureData.PictureType.JPEG);
fill.setFillType(HSLFFill.FILL_PICTURE);
fill.setPictureData(pd);
ppt.write(out);
out.close();
}
After that I tried to create a PPT file using the generated POTX file but
But it's giving error. I am trying bellow code for this.
And the code is
private static void GeneratePPTXUsingPOTX() throws FileNotFoundException, IOException {
File imgFile = new File(System.getProperty("user.dir")+"/src/resources/images/TestSameChnl_001_t.jpeg");
File potx_File = new File(System.getProperty("user.dir") + "/src/resources/Examples/layout.potx" );
File pptx_File = new File(System.getProperty("user.dir") + "/src/resources/Examples/PPTWithTemplate.pptx" );
File movieFile = new File(System.getProperty("user.dir") + "/src/resources/movie/Dummy.mp4");
FileInputStream ins = new FileInputStream(potx_File);
FileOutputStream out = new FileOutputStream(pptx_File);
HSLFSlideShow ppt = new HSLFSlideShow(ins);
List<HSLFSlide> slideList = ppt.getSlides();
int movieIdx = ppt.addMovie(movieFile.getAbsolutePath(), MovieShape.MOVIE_MPEG);
HSLFPictureData pictureData = ppt.addPicture(imgFile, PictureData.PictureType.JPEG);
MovieShape shape = new MovieShape(movieIdx, pictureData);
shape.setAnchor(new java.awt.Rectangle(300,225,420,280));
slideList.get(0).addShape(shape);
shape.setAutoPlay(true);
ppt.write(out);
out.close();
}
And the exception which is coming is as fallows:
java.lang.NullPointerException
at org.apache.poi.hslf.usermodel.HSLFPictureShape.afterInsert(HSLFPictureShape.java:185)
at org.apache.poi.hslf.usermodel.HSLFSheet.addShape(HSLFSheet.java:189)
I'm trying to get ID3D11VideoDecoder Decoder with h264 decoder profile but catching exception on Windows Phone 8.
Using this code:
DX::ThrowIfFailed(device.Get()->QueryInterface(__uuidof(ID3D11VideoDevice), (void**)&videoDevice));
GUID guid = {0x1b81be68, 0xa0c7,0x11d3,{0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5}};
D3D11_VIDEO_DECODER_DESC *desc = new D3D11_VIDEO_DECODER_DESC();
desc->Guid = guid;
desc->OutputFormat = DXGI_FORMAT_420_OPAQUE;
desc->SampleHeight = 480;
desc->SampleWidth = 800;
D3D11_VIDEO_DECODER_CONFIG *conf = new D3D11_VIDEO_DECODER_CONFIG();
ID3D11VideoDecoder *decoder;
DX::ThrowIfFailed(videoDevice.Get()->CreateVideoDecoder(desc, conf, &decoder));
PS. I tried SharpDX for this and got the same issue.
It seems you didn't pass in a valid D3D11_VIDEO_DECODER_CONFIG variable. you just define a pointer of struct D3D11_VIDEO_DECODER_CONFIG and didn't set the values of it before calling function CreateVideoDecoder.
D3D11_VIDEO_DECODER_CONFIG *conf = new D3D11_VIDEO_DECODER_CONFIG();
DX::ThrowIfFailed(videoDevice.Get()->CreateVideoDecoder(desc, conf, &decoder));
You can try it as below.
D3D11_VIDEO_DECODER_CONFIG conf
ZeroMemory(&conf, sizeof(conf));
conf.guidConfigBitstreamEncryption = xxx;
...
conf.ConfigDecoderSpecific = xxx;
DX::ThrowIfFailed(videoDevice.Get()->CreateVideoDecoder(desc, conf, &decoder));
So, I found solution.
for H264 decoder ConfigBitstreamRaw field must be "2". Not "1", not "0". Only "2". Like this
VideoDecoderDescription decoderDescription = new VideoDecoderDescription();
decoderDescription.OutputFormat = Format.Opaque420;
decoderDescription.SampleHeight = 480;
decoderDescription.SampleWidth = 800;
decoderDescription.Guid = _formatGuid;
VideoDecoderConfig config = new VideoDecoderConfig();
config.ConfigMinRenderTargetBuffCount = 1;
config.ConfigBitstreamRaw = 2;