Game Development Community

ShapeBase::setNodeColor() not in T3D; alternatives? (Setting vertex color of entire node)

by Beef Churger · in Torque 3D Professional · 12/26/2014 (10:26 pm) · 11 replies

I've noticed that ShapeBase::setNodeColor() is not a thing in Torque 3D (it was in TGE).

It's fairly essential that I change the colour of specific nodes of my DTS model. How can I go about doing this?

Thanks.

Thread is locked
#1
12/27/2014 (6:49 am)
I just searched very old sources to latest Torque engine sources; TGE 1.1.0, TGE 1.3.x, TGE 1.4.x, and T3D 1.2 to T3D 3.6. setNodeColor() has never existed in stock Torque engine code. I can only assume you're talking about Blockland's SetNodeColor() considering that's the only place I see it related anyway possible to Torque and that I could find in Google search.
#2
12/27/2014 (8:06 am)
Do nodes even have colors? Did the function just set the color of all verts weighted to that node?
#3
12/27/2014 (12:29 pm)
Yeah, that's all it did.
#4
12/27/2014 (1:10 pm)
It shouldn't be too hard to make. When you call this command are you expecting the alterations to be unique to that particular object? Or does it apply to all instances of the model?

An example: if I load MyModel.dae and place it in the world five times and call setNodeColor() on one of them should they all change or just the one?
#5
12/27/2014 (2:03 pm)
Just the one.
#6
12/27/2014 (5:18 pm)
I have an idea on how you could do it. I'm still on vacation for a few more days so I don't have my desktop to try anything on. Check out this bit in tsMesh.cpp:

github.com/GarageGames/Torque3D/blob/7d376386d1e01790eb57300780d967e8ffcda347/En...

That render function is called per frame and if the skin is dirty (animation changed) it updates the vertex buffer for the mesh. What I would do is maintain some kind of table of node colors and a dirty flag and if it's dirty (from setNodeColor() being called) I'd update the color of all the verts weighted to that node by following the example set by updateSkin(), and finish it off by calling _updateVBIB() to push the updated vertex buffer to the GPU.

If I find time when I get back I'll take a shot at it if you or someone else hasn't got it working.
#7
07/03/2015 (4:27 pm)
Any update?
#8
07/09/2015 (1:07 pm)
To update the whole VB just for a single color is nonsense. This may lead to micro freezes depending on the buffer size, because you change the client data, lock the bus and recommit the buffer.
If the buffer is shared you will colorize all the meshes that share the buffer or break instancing at all.

Just inject a uniform color multiplier into ShaderGen or a color matrix, there are several resource on this topic.
#9
09/05/2015 (10:35 pm)
Do you think you could elaborate? In hindsight I probably should have posted this in 'Beginner'.
#10
11/14/2018 (7:27 pm)
You there?
#11
11/15/2018 (9:52 am)
@Beef - You should ask any T3D questions on the new forum