Maya C++ Creating Custom Material - maya-api

How in maya C++ do I create custom shaders/materials?
I also need to obviously also attach the shader code to this material.
I know how to access Materials with the API just creating seems difficult.

You can create your own dependency graph node with mpxnode and create your own function to do you shader calculations. There are enough example shader codes in maya devkit. Here is the very basic lambert shader code from devkit. You can take a look in this.
Light Shader
And here is full list of example codes

Related

Chisel and Timing Constraints files

Apologies in advance for the perhaps stupid question. Is it possible to integrate into the CHISEL flow a Scala script that generate timing constraint specifications (SDC) for a given design? e.g. press a button and you get your CHISEL design converted to Verilog along with an SDC file, ready for synthesis.
I currently have such a toolflow in place for VHDL (using python to generate the constraints files). But in VHDL the naming conventions are quite clear, not so sure about the CHISEL backend (also I couldn't find any reference on the web doing this)
Is it possible, or this is just not how CHISEL was intended to be used ?
Thanks in advance !
Chisel has an annotation system to support tracking and linking against signals in the emitted Verilog. I've described this system in a previous question here on StackOverflow: Chisel: getting signal name in final Verilog
There is existing work to leverage this support and build physical design flows, see Hammer which is used by Chipyard.

Is It Possible To Write WebGL in the Chrome Javascript REPL?

Usually when using WebGL one writes most of the graphics code in a function bound to window.onload. For the sake of REPL-style graphics development, is it possible to write that OpenGL code interactively in the javascript console?
Of course it is but WebGL is a very verbose API. You have to upload, compile and link shaders, look up attributes and uniforms, create buffers and textures and upload data into each, then bind all textures, buffers, set attributes, and set uniforms and finally call a one of the draw functions
Doing that all from a REPL would be pretty tedious and error prone.
That said when I'm debugging I often paste something like this into the devtools REPL
gl = document.querySelector("canvas").getContext("webgl");
Which will give me the WebGLRenderingContext for the first canvas in the page (which is usually what I want). I can then for example check if there's an error
gl.getError();
Another common thing I do is check the available extensions
document.createElements("canvas").getContext("webgl").getSupportedExtensions().join("\n");
Otherwise if you're looking for editing WebGL in real time that's usually limited to things like glslsandbox.com or vertexshaderart.com where you're just editing a single shader that's used in a single way and not using the entire WebGL API in a REPL. There's also shdr which gives you a single model and a both a vertex and fragment shaders to work with.
If you really want a REPL you probably need some engine above it in which case it would be a name-of-engine REPL and not a WebGL REPL.

Javascript based UML diagrams editor

I'm looking for a HTML5/JS based UML editor library, able to support custom UML editor development, for basically Class Diagrams, eventually Package and Component diagrams.
My concrete requeriments:
support of basic elements of UML class diagram (mandatory) and components and packages (optional): classes, attributes, methods, stereotypes, associations (in all flavours), generalization, etc.
Drag & Drop capability from the toolbox (optional)
XMI supprt (optional)
pure JS/HTML5 with eventually some well-known libraries usage
a good control over the model's logical structure and a nice interface to iterate the model
I've already seen a couple of them (GoJS, Jointjs, etc) but would like to see all possible options and maybe some recommendations.
Thanks!
There are libraries to generate UML diagram with those requirements.
JointJs core library is open source under Mozilla Public License, which mean you must include copyright, but you can use it for commercial purposes. It has dependency to jQuery 3.1.1, Lodash 3.10.1, Backbone 1.3.3. (Rapppid is using this library)
It provides many ready-to-use diagram elements, which are responsive and
interactive. User can move blocks, add and remove relationships and
joints, zoom in and out.
Draw2D is library to create Visio like drawings, diagrams or workflows. The community version is almost 5 euro to buy. It indeed provides Visio like blocks and diagrams, which are interactive to resize, move blocks and modify the text and relationships, and grouping blocks, zooming in and out. This can be a good choice to build a graph editor tool.
mxgraph is a library to
build a UML editor like draw.io.
Created blocks are interactive, so the user can move or resize the
block, modify the text, add or remove relationships.
gojs is another library, which is commercial but it provides free licenses available for academic purposes. It is also suitable choice to create UML editor, with many ready-made diagrams available. After creating blocks, user can move them, modify the text and relationships; and many other features for different other diagrams.
UmlCanvas by Christophe VG as js library which provides UML diagram from textual information. The diagrams are responsive in a way that you can move the blocks; and relationship lines are smart to keep the design pretty. But not more than that.
PlantUML is a UML tool that can provide UML diagram from textual information by jQuery libraries (libraries in other languages are also available), however the diagrams are not responsive.
Raphaƫl is a small JavaScript library that can simplify your work with vector graphics on the web. This is not the best tool to create graph editor, but it provides shiny and beautiful diagrams for simple user interaction (such as movement and bending)
There are other libraries such as:
D3
FabricJS
paperJS
JsPlumb
p5.js
Cytoscape.js
mermaid
They provide basic components for diagrams, but most of them don't have functionality for built-in editor such as drag and drop, and block editing. On the other hand, developer can create different chart and drawing components, which are available by those libraries. They may not be the best option to create fully interactive and editable diagrams for the users.
Take a look at "jsUML2: HTML5/javascript library for UML2 modeling". A short intro can be read here

Is it possible to write an AS3 library with Haxe that uses type parameters?

First a little background: I'm looking for a way to create a "collection" library that abstracts the Flash Player version based implementation (Vector on FP10, Array on FP9) away from the calling code. I've already written a small AS3 lib doing that but...
...the performance is bad (especially because of two levels of indirection and the runtime type checks on the Array implementation)
...the code is ugly (since Vector types need to be defined at compiletime I needed a factory returning concrete Vector instances based on an Enum that contains only the supported types)
I'm currently looking into Haxe as a possible solution since it supports type parameters and is able to compile to various Flash Player versions (and apparently compiles into mmore optimized bytecode).
Now, my question is: Is there a way to write a library in Haxe that can be used like this in AS3 code
var foo:IMyInterface = new MyImplementation(int);
var bar:IMyInterface = new MyImplementation(getDefinitionByName("my.package.MyClass"));
with IMyInterface exposing the required methods (push, pop, ...)?
The basic idea is that I want to provide the type information at runtime and get a typesafe Flash Player version independent "collection" for use in the calling code without having to bother with conditional compilation fragments all over the place.
Can Haxe do something like that and if yes, how can I make it work?
There's an opportunity in Haxe to override native classes (e.g. int) in Haxe. take a look at the Metadata manual. Metadata has been added in version 2.06.
As for analogue of getDefinitionByName() method. Take a look at resolveClass() method of the Type class.

How do they write different language wrappers for same library?

Generally a library will be released in a single language (for example C). If the library tuns out to be useful then many language wrappers for that library will be written. How exactly do they do it?
Kindly someone throw little light on this topic. If it is too language dependent pick language of your choice and explain it.
There are a few options that come to mind:
Port the original C library to the language/platform of your choice
Compile the C library into something (like a DLL) that can be invoked from other components
Put the library on the web, expose an API over HTTP and wrap that on the client
If I wanted to wrap a C library with a managed (.NET) layer, I'd compile the library into a DLL, exposing the APIs I wanted. Then, I'd use P/Invoke to call those APIs from my C# code.