WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-07-2013, 10:10 AM
hzhao hzhao is offline
Member
 
Join Date: Sep 2012
Posts: 18
object on the fly--how to change color of particular vertex

With the following code, I created an object on-the-fly, a green polygon. Then I want to create a vertical transparent stripe, that is, set vertex 2 and 5 to be transparent. But the code doesn't work this way. Why? Thanks!

viz.startLayer(viz.POLYGON)
viz.vertexColor(viz.GREEN)

viz.vertex(0.0,0.0,0.0)
viz.vertex(0.5,0.0,0.0)
viz.vertex(0.6,0.0,0.0)
viz.vertex(1.0,0.0,0.0)
viz.vertex(1.0,1.0,0.0)
viz.vertex(0.6,1.0,0.0)
viz.vertex(0.5,1.0,0.0)
viz.vertex(0.0,1.0,0.0)
target=viz.endLayer()

target.dynamic()

target.setVertexColor(2,[0,0,1,0.2])
target.setVertexColor(5,[0,0,1,0.2])
Reply With Quote
  #2  
Old 03-07-2013, 01:36 PM
hzhao hzhao is offline
Member
 
Join Date: Sep 2012
Posts: 18
What I want to do is to vary transparency within an object. How to do that ?
Reply With Quote
  #3  
Old 03-20-2013, 09:42 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Many OpenGL drivers will internally break up POLYGON shapes into triangles. Try using QUADS instead.
Code:
viz.startLayer(viz.QUADS)
viz.vertexColor(viz.GREEN)
viz.vertex(0.0,0.0,0.0)
viz.vertex(0.5,0.0,0.0)
viz.vertex(0.5,1.0,0.0)
viz.vertex(0.0,1.0,0.0)

viz.vertex(0.5,0.0,0.0)
viz.vertex(0.6,0.0,0.0)
viz.vertex(0.6,1.0,0.0)
viz.vertex(0.5,1.0,0.0)

viz.vertex(0.6,0.0,0.0)
viz.vertex(1.0,0.0,0.0)
viz.vertex(1.0,1.0,0.0)
viz.vertex(0.6,1.0,0.0)
target=viz.endLayer()

target.dynamic()

target.setVertexColor(5,[0,0,1,0.2])
target.setVertexColor(6,[0,0,1,0.2])
target.setVertexColor(8,[0,0,1,0.2])
target.setVertexColor(11,[0,0,1,0.2])
Depending on your needs, you might be able to just use an alpha texture on a single quad to achieve the transparency.
Reply With Quote
Reply

Tags
object on-the-fly, transparent, vertex


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I change the text size of slider object? jincheker Vizard 1 08-26-2011 12:20 PM
Possible to change size of a vizshape.addBox object? Renato Lima Vizard 1 10-18-2010 10:51 AM
retrieve Object names Geoffrey Vizard 11 12-11-2009 05:26 AM
Randomly and Continuously Change Avatar's Face Texture Karla Vizard 4 08-22-2008 01:14 PM
get vertex with on the fly object enkeli Vizard 9 05-25-2006 09:27 PM


All times are GMT -7. The time now is 05:06 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC