How can i create materiallibrary and freeform in runtime in GLScene? - delphi

i want to write a ModelViewer to load many models in my Scene.
so how can i create GLMaterialLibrary in run time and assign it to FreeForms Objects in RunTime?
and i want to know how can i find the name of submodel's texture.
TanX for Help.

First of all, you do not need to create GlMaterialLibrary at run time as you can use single instance of GLMaterialLibriary for all scene GLFreeForms and dynamicaly link it to a new freeform. A TFreeForm or TActor can automatically setup the materials and load the textures from a 3DS files. You must first add a material library component to a form (which will store the materials, once the 3DS is loaded), then link the FreeForm to this material library and set
UseMeshMaterials := true;
After doing this, when loading the 3DS mesh, the importer will add new materials to the material library (using the names defined in the 3DS file), which you can later alter if you so wish.
Be aware that the image formats must be supported, for instance if your textures are JPeg files, you must add "JPeg" to your uses. And least but not last: GLScene comes with a very good pack of demos that you can check for refference. ..\Demos\materials\ folder contains everything what you need.

Related

How can I implement multiple material colours across multiple .JSON files

I have a MASTER.JSON file that is my main part, I then have multiple parts that DOCK into the MASTER part, each of these parts is called as a SUBCOMPONENT and is in it's own .JSON file, for example have a SUB_CUBBY.JSON, SUB_SHELF.JSON etc. The subcomponents have Material Colours set with in their JSON files, which works fine but we periodically need to add additional colours, which at the moment means opening each subcomponent file and updating the Material / Colour and resaving. Is there a way to have a Global File that contains the Material / Colours that can be CALLED from within each of the subcomponent files, so I would only need to update the 1 file and it would add the colours to all the files??
There are two ways:
Store the material parameter in another component, called for example material_carrier, supersede the parameter wherever you need it.
Load materials not via validValues, but validGroups or conditionalGroups. This will allow you to add or remove parameter by tagging the materials with the respective tags. See very end of this page https://docs.roomle.com/scripting/resources/200_140_getmaterialproperty.html
Note: I recommend NOT referring to "docked parts" as subcomponents.

Edit Photos via Photoshop on a server

I wart to create a web app where a user enters certain data via a form and then receives a custom rendered image. The image is from a smart object in a psd. It's kind of like a mock-up which definitely requires needs some photoshop filters to be properly rendered.
This should all happen in real time and should be doable from my understanding since the rendering of a single images doesn't need much computing power
I've done some research and haven't really found a solution the matches my problem. Is it necessary to run Photoshop on a server and then remotely run a photoshop script and then upload the generated image somewhere else?
I've used The After Effects Plugin Template by DataClay in the past which offers similar functionality but for video.
Looking forward to hearing your ideas.
Thanks
You can use the Dataclay plugin to handle still image exports out of After Effects. Make a single-frame duration composition in After Effects and rig the layers with the Templater plugin. Then use the PNG Sequence output module to render out a single frame.
From Dataclay's forums:
Exporting
A few extra steps are required to correctly render a project file as a PNG sequence using Templater. By default, a file rendered as a PNG sequence will have the frame number appended to the end of the file name, i.e.:
filename.png00000, filename.png00001, filename.png00002, etc.
In order to designate where in the filename the frame number should be added, we’ll need to use the output column. First, add a column named output to your data source. Next, add a filename with a set of brackets with five # signs to designate where the frame numbering should be added. For example:
filename[#####] would result in filename00001.png
or
[#####]filename would result in 00001filename.png

OBJ File for ARCore Application Development

What is the significance of the andy.obj file in the ARCore Sample?
Let's say if we replace the andy.png with a new image, how can we generate .obj file for the new image?
The OBJ file describes the geometry, the png file the texture to "stretch" over this 3D object. You have to use a 3D modelling program like Blender to create a new model.
This is how you export OBJ files in Blender: https://blender.stackexchange.com/questions/121/how-do-i-export-a-model-to-obj-format
The sample code only can handle the simplest OBJ models that only have 1 texture file.
Fo those complicated OBJ models, they usually come with a MTL file that refers to several different texture files. To be able to handle that ,you need some extra work on the existing code. Please check the code I implement for this case if you are interested #https://github.com/JohnLXiang/arcore-sandbox . Specifially ,you can take a look at ObjectRenderer.createOnGlThread().
To export a texture as image in Blender do the following:
Select your object and enter in edit mode. Select all vertices/faces (press 'a'). Then start the UV Mapping, press 'u'. And Select one of the options of the UVMapping. You must test the best option for your model. I'm not sure which UV Mapping mapping option the ARCore uses.
Then go to the UV/Image Editor:
Export UV Layout at the menu, and save your image.
For creating a new .obj model for your AR app you need to use 3D authoring software like Autodesk Maya, Autodesk 3dsMax, Blender, SideFx Houdini, Cinema 4D, etc. These applications can help you create a high quality polygonal model with corresponding .mtl texture file.
But you should know that Sceneform supports 3D assets not only in OBJ format (where animations aren't supported) but also in FBX (with animations) and in glTF (animations not supported).
.obj
.fbx
.glTF
Sceneform's ASCII and Binary Asset Definitions are also welcome:
.sfa
.sfb
Supported material files (aka textures for your 3D assets) have the following extensions: MTL, BIN, PNG, JPG and native Sceneform's SFM.
.mtl
.bin
.png
.jpg
.sfm
Hope this helps.

Rolling custom control buttons

do you have a reference or tutorial on customizing skins graphics/css for mejs?
here's what i've hacked on:
i copied the mejs-ted block in the mejs-skins.css file and renamed its elements to mejs-custom. i created a new PNG file similar to the existing control-ted.png and noted the coordinates of each control. with those coordinates i changed the x/y offsets in mejs-custom (i could really use help with that, too).
but now how to activate this skin? and can you confirm the technique above is correct procedure to create skins?
http://mediaelementjs.com source has switchable skins, but the switching mechanism is pretty well obfuscated in the code, and the mediaelementplayer-skins.html file is missing from the demos section of the mu distribution.
Set up your player then use the changeSkin() method to add the class of your skin to the container div, which is reflected in your skin css file
var player = new MediaElementPlayer('#player-ID');
player.changeSkin('skin-container-class');
Then you can style all the elements.
.skin-container-class .mejs-controls {
/*stylez*/
}

XNA File Load

In XNA, how do I load in a texture or mesh from a file without using the content pipeline?
The .FromFile method will not work on xbox or zune. You have two choices:
Just use the content pipeline ... on xbox or zune (if you care about them), you can't have user-supplied content anyways, so it doesn't matter if you only use the content pipeline.
Write code to load the texture (using .SetData), or of course to parse the model file and load the appropriate vertexbuffers, etc.
For anyone interested in loading a model from a file check out this tutorial:
http://creators.xna.com/en-us/sample/winforms_series2
This is a windows only Way to load a texture without loading it through the pipeline, As Cory stated above, all content must be compiled before loading it on the Xbox, and Zune.
Texture2D texture = Texture2D.FromFile(GraphicsDeviceManager.GraphicsDevice, #Location of your Texture Here.png);
I believe Texture2D.FromFile(); is what you are looking for.
It does not look like you can do this with a Model though.
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.texture2d.fromfile.aspx
If you really want to load an Xna Xna.Framework.Graphics.Model on PC without the content pipeline (eg for user generated content), there is a way. I used SlimDX to load an X file, and avoid the parsing code, the some reflection tricks to instantiate the Model (it is sealed and has a private constructor so wasn't meant to be extended or customised). See here: http://contenttracker.codeplex.com/SourceControl/changeset/view/20704#346981

Resources