Why does MDLMesh have unnamed default attributes? - metal

I am discovering Model I/O and I would like to use it to generate vertices to create a sphere, so I created a MDLMesh object using this class method :
let sphere = MDLMesh.newEllipsoidWithRadii(vector_float3(1, 1, 1), radialSegments: 300, verticalSegments: 300, geometryType: MDLGeometryType.KindTriangles, inwardNormals: false, hemisphere: false, allocator: MTKMeshBufferAllocator(device: device))
Then, to understand how it works, I want to inspect the attributes of my this MDLMesh so I am reading them this way :
for attribute in sphere.vertexDescriptor.attributes {
if let vertexAttribute = attribute as? MDLVertexAttribute {
print("Attribute named : \(vertexAttribute.name), of format \(vertexAttribute.format.rawValue)")
}
}
Here is the output :
Attribute named : position, of format 786435
Attribute named : normal, of format 786435
Attribute named : textureCoordinate, of format 786434
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
Attribute named : , of format 0 Attribute named : , of format 0
I believe position and normals were automatically generated but why is there a texture coordinate ? What rules were used to generate those ? Most of all, why is there all of those unnamed attributes of invalid format ?
Thank you
EDIT : It would seem that there is a fixed number of attributes (31 in my case) because even if I add new, custom attributes (for instance by generating normals), the attributes that were invalid are replaced with those new attributes and the total number of attributes is still 31.

It seems Apple configured the default vertexDescriptor to be created with those first 3 attributes ready for you to use. They happen to also be the most common attributes one would need to use. You have 28 more attribute "holders" in case you need to use more than those 3. Btw, they are not of invalid format, they just occupy 0 bytes currently because they were not yet created and named. In total, there are 15 types of vertex attributes you can create, and you can also have more of the same type if needed. For more information about the name and format, you can read the MDLVertexAttribute Class Reference document.

Related

Pages PrintOut Word VBS [duplicate]

This question already has answers here:
Print certain pages only
(2 answers)
Closed 2 years ago.
I can't seem to get Words PrintOut to accept/honor the parameter for PAGES when run in VBScript. Weirdly, it honors COPIES just fine. Any ideas?
Code:
Dim ObjWord
Set ObjWord = CreateObject("Word.Application")
ObjWord.Visible = True
'Open Document
Dim ObjDoc
'https://learn.microsoft.com/en-us/office/vba/api/word.documents.open
'.Open (FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format, Encoding, Visible, OpenConflictDocument, OpenAndRepair, DocumentDirection, NoEncodingDialog)
Set ObjDoc = ObjWord.Documents.Open("C:\tmp\test.docx", ,TRUE, , , , , , , , ,TRUE)
'PageRange
'https://learn.microsoft.com/en-us/office/vba/api/word.application.printout
'.PrintOut (Background, Append, Range, OutputFileName, From, To, Item, Copies, Pages, PageType, PrintToFile, Collate, FileName, ActivePrinterMacGX, ManualDuplexPrint, PrintZoomColumn, PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight)
Dim ObjPrint
ObjPrint = ObjDoc.PrintOut(FALSE, , , , , , , ,"1", , ,TRUE) ' No Error, but Pages not honored
'ObjPrint = ObjDoc.PrintOut(FALSE, , , , , , ,"2", , , ,TRUE) ' Corretly Printes Two Copies
objDoc.Saved = TRUE
objWord.Quit
Set ObjDoc = Nothing
Set objWord = Nothing
So I had to pass an additional param for it to honour the Pages value which was Range.
https://learn.microsoft.com/en-us/office/vba/api/word.document.printout
https://documentation.help/MS-Office-Word-VB/womthPrintOut1.htm
It required a CONSTANT declaration. Eg:
https://learn.microsoft.com/en-us/office/vba/api/word.wdprintoutrange
Specifies a range to print.
WDPRINTOUTRANGE ENUMERATION (WORD)
Name Value Description
wdPrintAllDocument 0 The entire document.
wdPrintCurrentPage 2 The current page.
wdPrintFromTo 3 A specified range.
wdPrintRangeOfPages 4 A specified range of pages.
wdPrintSelection 1 The current selection.
In my case, I believe it will always be 4.
Therefore this worked as expected. (Print Only Page 2)
ObjPrint = ObjDoc.PrintOut(FALSE, ,"4", , , , , ,"2", , ,TRUE)
Further Reading on Printing Word via VBScript. Disclaimer: This is my personal blog --> https://www.freesoftwareservers.com/display/FREES/Print+Microsoft+Word+via+Batch+-+WINWORD.EXE+Switches+-+VBScript+Print+Specific+Pages

issue with arguments to messages.properties, all numbers except zero work correctly

In my Grails 2.4.4 app I am using messages.properties for internationalization, with the following value:
my.app.thing.allowance(s)={0} Allowance(s)
and it is being using in a gsp like so:
<g:message code="my.app.thing.allowance(s)" args="${item.allowances.size()}"/>
the message is correctly displayed for any values greater than 0, for example if item.allowances.size() == 4 then the message displayed is 4 Allowances(s)
the issue is that if item.allowances.size() == 0 then the message displayed is {0} Allowance(s)
I have tried to write the args in several different ways, for example:
<g:message code="my.app.thing.allowance(s)" args="${item.allowances.isEmpty() ? 0.intValue() : item.allowances.size()}"/>
I have debugged things and I am sure that item.allowances.size() == 0 but for some reason it can not handle a value of 0 properly. What is the correct way to pass an argument with an int value of 0 to messages.properties?
In g.message arguments are always passed as an List.
From: http://docs.grails.org/3.0.17/ref/Tags/message.html
args (optional) - A list of argument values to apply to the message when code is used.
Try this code instead:
<g:message code="my.app.thing.allowance(s)" args="[item.allowances.size()]"/>
The Bharat's answer is correct, but I want to add why it happened so:
You have passed args=0
And here it is code from message tag lib:
List args = []
if (attrs.args) {
args = attrs.encodeAs ? attrs.args as List : encodeArgsIfRequired(attrs.args)
}
In groovy 0 is false, that's why you didn't have filled in message in case of ZERO

Flume morphline interceptor-split command

Hi I'm trying to use morphline inteceptor and convert my syslog to JSON
for start i tried to use split command for splitting my string ,but im getting error as below:
"" Source r1 has been removed due to an error during configuration
com.typesafe.config.ConfigException$WrongType: /root/flume.17/conf/morph.conf: 21: Cannot concatenate object or list with a non-object-or-list, ConfigString("split") and SimpleConfigObject({"outputFields":"substrings","inputField":"message","addEmptyStrings":false,"isRegex":false,"trim":true,"separator":" "}) are not compatible""
my morphline configuration file:
morphlines : [
{
# Name used to identify a morphline. E.g. used if there are multiple
# morphlines in a morphline config file
id : morphline1
# Import all morphline commands in these java packages and their
# subpackages. Other commands that may be present on the classpath are
# not visible to this morphline.
importCommands : ["org.kitesdk.**"]
commands : [
{
# Parse input attachment and emit a record for each input line
readLine {
charset : UTF-8
}
}
,split {
inputField : message
outputFields : "substrings"
separator : " "
isRegex : false
addEmptyStrings : false
trim : true }
}
}
]
}
]
what do i have to do?I'm new to this
From morhpline documentation
outputField - The name of the field to add output values to, i.e. a single string. Example: tokens. One of outputField or outputFields must be present, but not both.
outputFields - The names of the fields to add output values to, i.e. a list of strings. Example: [firstName, lastName, "", age]. An empty string in a list indicates omit this column in the output. One of outputField or outputFields must be present, but not both.
So you should just specify
outputField : substrings
instead of
outputFields : "substrings"
http://kitesdk.org/docs/1.1.0/morphlines/morphlines-reference-guide.html#split

Grails excel-import plugin Numbers populated as real with exponent

I am trying to import a ms-excel 2007 sheet using excel-import plugin. It was simple to integrate with my project and I found it working as expected until I noticed that the number values in the cells are populated as real numbers with exponent.
For example if the cell contains value 9062831150099 -(populated as)->9.062831150099E12 i.e.
A |
_____________________
Registration Number |
____________________
9062831150099
Is populated as: [RegNum:9.062831150099E12]
Anyone could suggest me how I can change this representation back to its original format keeping its type as number?
Missed it at the first attempt but I figured out how to to achieve it:
When invoking the key methods (the ones that process cellMap and columnMaps) for example List bookParamsList = excelImportService.columns(workbook, CONFIG_BOOK_COLUMN_MAP) or Map bookParams = excelImportService.cells(workbook, CONFIG_BOOK_CELL_MAP )
There is also ability to pass in configuration information, i.e. to specify what to do if a cell is empty (i.e. to provide a default value), to make sure a cell is of expected type, etc.
So in my case I created a configuration parameter Map of properties of the object and passed it to the above methods. i.e.
Class UploadExcelDataController {
def excelImportService
static Map CONFIG_BOOK_COLUMN_MAP = [
sheet:'Sheet1',
startRow: 2,
columnMap: [
'A':'registrationNumber',
'B':'title',
'C':'author',
'D':'numSold',
]
]
static Map configBookPropertyMap = [
registrationNumber: ([expectedType: ExpectedPropertyType.IntType, defaultValue:0])
]
def uploadFile(){
...
List bookParamsList = excelImportService.columns(workbook, CONFIG_BOOK_COLUMN_MAP,configBookPropertyMap )
...
}
}

Lua how to assign default array value to '0' not nil

I was getting lately an error in Lua saying cannot assign arithmetic value of '?'. then I realized that I need to define how many storage are in my array and assigning them to a value,
this gave me Error : locator = {}
this Worked fine : locator = {0,0,0,0,0,0,0,0,0,0}
So now I have another array that I need a loop to store 200 values in it, so how to define the storage and values within it without something like this : a = {0,0,0,0,0,...... etc}
Any Ideas ?
this is what worked for me :
locator = {}
for i = 1, 200 do
locator[i] = 0
end
just assigning all to 0 inside a loop Before using them
Credits : Egor Skriptunoff

Resources