Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperLicht
Mesh Color

mysqlerror
Registered User
Quote
2012-12-26 15:16:50

Hello I'm new to CopperLitch and here is one thing which i wasn't able to find anywhere

how can I set color to mesh which doesn't have texture on it
I need it because I want to build something with random colors and make some operations on colors to get new colors and dynamically change them

thanks


niko
Moderator
Quote
2012-12-26 16:35:12

You can change the color of each vertex individually, if you like. So if you want to color a mesh, change all colors of all vertices. Use the color member of the vertex: http://www.ambiera.com/copperlic...


mysqlerror
Registered User
Quote
2012-12-26 17:54:04

thank you
the documentation says that Color is {int}
should it be a CL3D.ColorF ?

I tried this approach but it didn't worked

this.MyMesh = new CL3D.Mesh();
var buf = new CL3D.MeshBuffer();
this.MyMesh.AddMeshBuffer(buf);

buf.Indices = [0,2,3, 2,1,3, 1,0,3, 2,0,1];

buf.Vertices.push(createVertex( 0, 0, 10, 0, 0));
buf.Vertices.push(createVertex( 10,0, -10, 1, 0));
buf.Vertices.push(createVertex( 0, 20, 0, 0, 1));
buf.Vertices.push(createVertex(-10,20,-10, 1, 1));

var vertices = buf.Vertices;
for (var v=0; v<vertices.length; ++v)
{
var vtx = vertices[v];
vtx.Color = CL3D.createColor(255, 255, 0, 0);
}


where {this} is CL3D.SceneNode


niko
Moderator
Quote
2012-12-27 07:44:28

.MyMesh won't work, it's probably only usable if you implemented your own scene node and are using a property named 'MyMesh'. If you have a MeshSceneNode, you can get the current mesh using yourNode.getMesh();. But apart from this, setting the colors as you do should work.


mysqlerror
Registered User
Quote
2012-12-27 11:35:34

I'm editing working example
Custom Scene Nodes example from
http://www.ambiera.com/copperlicht/tutorials.html

I'm using derived object from SceneNode


MySceneNode.prototype = new CL3D.SceneNode();

MySceneNode.prototype.OnRegisterSceneNode = function(scene)
{
scene.registerNodeForRendering(this, CL3D.Scene.RENDER_MODE_DEFAULT);
CL3D.SceneNode.prototype.OnRegisterSceneNode.call(this, scene);
}

MySceneNode.prototype.render = function(renderer)
{
renderer.setWorld(this.getAbsoluteTransformation());
renderer.drawMesh(this.MyMesh);
}


is there anything in this way which may conflict setting vertex colors ?


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inter?ational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact