Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Mesh Setcolor  (Read 2538 times)
smartmine
Community Member
*
Posts: 9


« on: July 02, 2007, 01:44:24 PM »

when im migrating my application to 6.5 version i cannot make this piece of code work... the mesh aways appears white, can someone help?

thnx

Code:
Set objMesh = Scene.CreateMeshBuilder(strLayerName)
objMesh.SetPrimitiveType TV_LINELIST
objMesh.SetColor RGBA(1, 0, 0, 1)
objMesh.SetCollisionEnable False
...
Logged
WEst
Customers
Community Member
*****
Posts: 945

Daniel Martinek


WWW
« Reply #1 on: July 02, 2007, 02:13:25 PM »

try to add this:
Code:
objMesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED)
Logged

Greetings

Daniel Martinek
Technical Director
23 Volts
smartmine
Community Member
*
Posts: 9


« Reply #2 on: July 02, 2007, 02:24:55 PM »

i did what you said, but nothing happened
i also tried with TV_LIGHTING_NORMAL but nothing happened either

Code:
Set objMesh = Scene.CreateMeshBuilder(strLayerName)
objMesh.SetPrimitiveType TV_LINELIST

objMesh.SetColor RGBA(1, 0, 0, 1)
objMesh.SetLightingMode  CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED
       
objMesh.SetCollisionEnable False
Logged
smartmine
Community Member
*
Posts: 9


« Reply #3 on: July 03, 2007, 08:16:53 AM »

bump
Logged
Eric
Customers
Community Member
*****
Posts: 807


« Reply #4 on: July 03, 2007, 10:39:00 AM »

try setting a material instead of just setcolor
Logged
smartmine
Community Member
*
Posts: 9


« Reply #5 on: July 03, 2007, 12:57:27 PM »

I changed my code to:

Code:
MaterialFactory.CreateMaterialQuick 1, 0, 0, 1, strMatName
Set objMesh = Scene.CreateMeshBuilder
objMesh.SetPrimitiveType TV_LINELIST
objMesh.SetMaterial GetMat(strMatName)
objMesh.SetCollisionEnable False
.. Add vertexs ...


but the problem continue...  Sad

another suggestion?
Logged
newborn
Customers
Community Member
*****
Posts: 2451


WWW
« Reply #6 on: July 03, 2007, 03:29:32 PM »

using a material wont fix it ! actually, when you use .setcolor, it creates a temp material which is then applyed to the mesh

just a quick checkup, do you have at least one light in your scene?
Logged

SylvainTV
Administrator
Community Member
*****
Posts: 4946


WWW
« Reply #7 on: July 03, 2007, 05:51:32 PM »

Maybe a bug, Maybe i don't apply lighting/material for line lists..
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
smartmine
Community Member
*
Posts: 9


« Reply #8 on: July 04, 2007, 11:16:29 AM »

Quote from: "newborn"
using a material wont fix it ! actually, when you use .setcolor, it creates a temp material which is then applyed to the mesh

just a quick checkup, do you have at least one light in your scene?


Here is my code with one light:

Code:
LightEngine.CreatePointLight Vector(0, 0, 100), 1, 1, 1, 100, "Light1"
LightEngine.EnableLight GetLight("Light1"), True

...

Set objMesh = Scene.CreateMeshBuilder(strName)
objMesh.SetPrimitiveType TV_LINELIST

objMesh.SetColor RGBA(1, 0, 0, 1)
objMesh.SetLightingMode TV_LIGHTING_MANAGED
       
objMesh.SetCollisionEnable False

... Add Vertex...


but still not working... did i miss something?

Quote from: "SylvainTV"
Maybe a bug, Maybe i don't apply lighting/material for line lists..


SylvainTV how can i confirm that this is a bug? Is there another way to set my TV_LINELIST color?

Thanks
Logged
SylvainTV
Administrator
Community Member
*****
Posts: 4946


WWW
« Reply #9 on: July 04, 2007, 01:16:17 PM »

Another way would be to add the color per vertex.

int CTVMesh::AddVertex(float x, float y, float z, float nx, float ny, float nz, float tu1, float tv1, float tu2 , float tv2 , int color)

(see the color here)

However you must have diffuse in the vertex format, before adding a color  :
Mesh.SetMeshformat TV_MESHFORMAT_DIFFUSE + TV_MESHFORMAT_NOLIGHTING

I'm checking the code here to see why a material doesn't work.
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
smartmine
Community Member
*
Posts: 9


« Reply #10 on: July 04, 2007, 02:01:54 PM »

Quote from: "SylvainTV"
Another way would be to add the color per vertex.

int CTVMesh::AddVertex(float x, float y, float z, float nx, float ny, float nz, float tu1, float tv1, float tu2 , float tv2 , int color)

(see the color here)

However you must have diffuse in the vertex format, before adding a color  :
Mesh.SetMeshformat TV_MESHFORMAT_DIFFUSE + TV_MESHFORMAT_NOLIGHTING

I'm checking the code here to see why a material doesn't work.


It works SylvainTV thanks  Cheesy

The final code:

Code:
Set objMesh = Scene.CreateMeshBuilder(strName)
objMesh.SetPrimitiveType TV_LINELIST
objMesh.SetMeshFormat TV_MESHFORMAT_DIFFUSE + TV_MESHFORMAT_NOLIGHTING
objMesh.SetCollisionEnable False

... Add vetexes with color (last parameter of AddVertex method) ...


Thanks all Smiley
Logged
DanDixon
Customers
Community Member
*****
Posts: 213


« Reply #11 on: March 08, 2008, 11:46:17 PM »

This was very helpful. Adding some more info for those searching how to work with Vertex Color (like I did today):

In 6.5 the right mesh format is (where theMesh is a TVMesh):
Code:
theMesh.SetMeshFormat CONST_TV_MESHFORMAT.TV_MESHFORMAT_DIFFUSE + CONST_TV_MESHFORMAT.TV_MESHFORMAT_NOLIGHTING

And don't set a lighting mode or set it to this one:
Code:
theMesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_NONE)

I also was trying to use vertex created by AddFloorGrid. This didn't seem to work. I had to create my plane manually using AddVertex (in this case it's a trianglestrip):
Code:
theMesh.SetPrimitiveType(CONST_TV_PRIMITIVETYPE.TV_TRIANGLESTRIP)
theMesh.AddVertex(-0.5, 0, 0, 0, 1, 0, 0, 0)
theMesh.AddVertex(-0.5, 0, 1, 0, 1, 0, 0, 1)
theMesh.AddVertex(0.5, 0, 0, 0, 1, 0, 1, 0)
theMesh.AddVertex(0.5, 0, 1, 0, 1, 0, 1, 1)

Later I use GetVertex and SetVertex to change the color and just recopy all of the other values.
Code:
Dim NewCol as Interger = TVGlobals.RGBA(1, 0, 0, 1)
theMesh.GetVertex(vertexID, X, Y, Z, nX, nY, nZ, TU1, TV1, TU2, TV2, OldCol)
theMesh.SetVertex(vertexID, X, Y, Z, nX, nY, nZ, TU1, TV1, TU2, TV2, NewCol)
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks