WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-16-2014, 04:54 AM
Majestic12 Majestic12 is offline
Member
 
Join Date: Apr 2014
Posts: 10
2d Map with Lines between points, help!

Hello everybody!

I'm a beginner in Vizard and I'm currently trying to create a visualization using a map.

Basically what I have is a 2d map and a set of points(from the map) I want to draw lines inbetween. The issue is that my points that I use for the lines are based on the texture coordinates of the map itself so that when I try to create vertices using these points they show up at the typical X, Y, Z coordinate system of Vizard instead of "on" the map.

My vision for this is to have the map and then see the lines in front of the map. Currently I have the map and then the lines elsewhere in the world.

Does anybody have any pointers / solutions for this? How would I solve this matter the best way? Is it possible?

M12
Reply With Quote
  #2  
Old 04-18-2014, 09:23 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use on-the-fly objects to create the points and lines then add them to a texture quad that is displaying the map. Here is an example:
Code:
import viz
viz.go()

# Points in texture coordinate system
POINTS = [ (0.1,0.2)
		, (0.9,0.2)
		, (0.5,0.8)
]

# Lines in texture coordinate system
LINES = [ [(0.1,0.2), (0.9,0.2)]
		, [(0.1,0.2), (0.5,0.8)]
		, [(0.5,0.8), (0.9,0.2)]
]


# Load map texture
texture = viz.addTexture('ball.jpg')

# Create quad to display texture
quad = viz.addTexQuad(texture=texture, pos=(0,1.5,3))
quad.zoffset(1,1)

# Create points and lines
viz.startLayer(viz.POINTS)
viz.vertexColor(viz.YELLOW)
viz.pointSize(3)
for p in POINTS:
	viz.vertex(p[0]-0.5, p[1]-0.5, 0)

viz.startLayer(viz.LINES)
viz.vertexColor(viz.GREEN)
for l1,l2 in LINES:
	viz.vertex(l1[0]-0.5, l1[1]-0.5, 0)
	viz.vertex(l2[0]-0.5, l2[1]-0.5, 0)

# Add points/lines to quad
viz.endLayer(parent=quad)
Reply With Quote
  #3  
Old 04-20-2014, 10:53 PM
Majestic12 Majestic12 is offline
Member
 
Join Date: Apr 2014
Posts: 10
Hello Farshizzo,

Thank you for the example.

Regarding loading a map onto a texture, is that only possible with TexQuads? I tried to do it with a quad I made in a Layer(QUADS) and could not wrap my texture onto it (it became white), but it worked fine with TexQuad.

Here is what I tried:

Code:
viz.startLayer(viz.QUADS) 
viz.vertex(0,0,0) 
viz.vertex(2048,0,0)
viz.vertex(2048,0,2048)
viz.vertex(0,0,2048)
mapQuad = viz.endLayer()

texture = viz.addTexture('1.png')
mapQuad.texture = texture
You see the coordinates I have are not specified in the Vizard coordinate system(0-1) but in the resolution of the actual image. For example, the map is 2048x2048 and one of the points is 1620,1. I wanted to try making a quad with that size, putting it in the 0-2048 Vizard coordinate system, wrapping the map texture onto it and then simply displaying points and lines on the map.

Do you know if that is possible? Are TexQuads customizable in that manner?

Thank you,
M12
Reply With Quote
  #4  
Old 04-21-2014, 06:48 PM
Majestic12 Majestic12 is offline
Member
 
Join Date: Apr 2014
Posts: 10
Hello again,

I've tried the following too:

Code:
viz.startLayer(viz.QUADS) 
viz.vertex(0,0,0) 
viz.vertex(2048,0,0)
viz.vertex(2048,0,2048)
viz.vertex(0,0,2048)
mapQuad = viz.endLayer()

mapQuad.zoffset(1,1)
mapQuad.texture(viz.add('1.png'))
Using that code I get a flat purple surface. The one in my prior post had a white surface instead.
Reply With Quote
  #5  
Old 04-22-2014, 02:46 AM
Majestic12 Majestic12 is offline
Member
 
Join Date: Apr 2014
Posts: 10
Hey again,

Sorry for so many replies in a row. I realized that I had forgotten my texcoords in front of my vertices, I fixed it and now I can see the map image.

Thanks!
M12
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Create an arc between two points hotshotiguana Vizard 5 03-22-2012 11:07 AM
black lines with render to texture Darkmax Vizard 5 03-07-2011 11:23 AM
Why I need two points for viz.startlayer(viz.POINTS) jincheker Vizard 1 01-28-2011 08:46 AM
Draw Line between Points Chrissy2009 Vizard 2 05-13-2009 04:42 AM
Track Eye Gaze with Lines enkeli Vizard 1 05-02-2006 02:06 PM


All times are GMT -7. The time now is 07:13 PM.


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