Jump to content

outlining a cube


Rick
 Share

Recommended Posts

So what are some options for drawing an outline on a cube? Basically what I'm thinking is if I have my cursor over a cube I want to draw a line on each visible edge so it becomes outlined.

 

I could swap materials/textures that have an outline on the edge

- Don't have to worry about finding edges that aren't seen like I would if I went 2D drawing method

- Have to have 2 sets of each texture

- Is there a way to dynamically have more than 1 texture on the model where I could just add an outlined texture on top of the base textures?

I could use the 2D drawing

- Have to find which edges are visible and only draw those

- Have to find the edges

- Nice in that I wouldn't have to swap any textures on the previously mouse over cube

 

Any other ideas? Seems the texture swapping method would be nice if I could overlay another texture that just had an outline and transparent for everything else, but not sure if that's possible or how to go about that if it is.

Link to comment
Share on other sites

The way I find visible outlines in CSG calculations is as follows:

 

Each edge occurs between two faces, right? And each face has a normal. A normal either faces towards or away from the camera (or perpindicular to, but we'll call that "away"). For each edge, if one face's normal points towards the camera and one points away from the camera, that edge is a visible outline edge.

 

For arbitrary geometry, this will require some more detailed data structures than just a vertex and indice array, but for cubes you can probably figure out something simpler.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...