Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


plainoldcj

Member Since 18 Apr 2013
Offline Last Active Today, 02:33 AM

Posts I've Made

In Topic: Calculating UV coordinates of a point in a convex 4-sided polygon

27 June 2015 - 05:39 AM

Hey, maybe reading this helps with your scewed texture problem: the q-coordiante


In Topic: Find the missing edges of a voronoi map inside a square

18 June 2015 - 08:55 AM

Okay, here's my code:
view on github.

I'm using the graph data structure and Voronoi algorithm of the LEDA library.
The LEDA API is actually pretty good, so you should have no trouble reading the code, even if you are unfamiliar
with the library.

The output of LEDA's Voronoi algorithm is a planar graph. Every edge is labeled with the site on its left side,
and every proper node is labeled with CIRCLE(a, b, c), where a, b, c are sites closest to that node.
The target nodes of unbounded edges have nodes at ,,infinity'' that store degenerated circles.
More information here.

The idea to bound the Voronoi Diagram, i.e., to intersect it with a quad, is as follows.
First of all, assume that we only want to get rid of unbounded regions. Then we can choose the quad so large
that is only intersects unbounded edges of the Voronoi Diagram.
The basic idea is to traverse all unbounded edges and move their target nodes from ,,infinity'' to the border
of the quad. So, for each unbounded edge you compute the intersection point with the quad. That's pretty cheap,
because the quad consists of only four segments. Also, you don't need to create new nodes or something like that.

You can efficiently find the next unbounded edge (in counter-clockwise order) by following the face cycle of
the unbounded ,,backface'' region.

While traversing, you could simply connect the target nodes of two adjacent unbounded edges with a new edge.

In addition, you have to add the four ,,corner nodes'' of the bounding quad.
In essence, I check for every pair of adjacent edges if there is a quad node between them. If that is the case,
I add it.
Because I traverse the backface in stricly counter-clockwise order, the quad nodes are added in that order, too.
So at any time, there is only one possible candidate node that I have to test.

For my particular application, I needed to bound the Voronoi Diagram with a fix-sized quad,
which might intersect edges of proper regions (I wanted to render a fix-sized section of the diagram).
Therefore, the code I show you first loops over all nodes and edges.
Every edge that intersects the quad is subdivided into two new edges: one new edge is outside the quad and can
be discarded. The other new edge is treated like an additional unbounded edge.

I implemented this algorithm because a naive approach using general segment intersection algorithms turned out
to be too slow.

In Topic: Find the missing edges of a voronoi map inside a square

17 June 2015 - 09:46 AM

I'm not entirely sure I understood your question correctly,
but to me it sounds like you want a ,,bounded voronoi diagram''.
Or, put differently, you want the intersection of the vornoi diagram
and a rectangle.

If that's what you want, I'll gladly tell how I've done it in one
of my projects.

In Topic: Problem with Quaternion. Instantiate does not work properly

22 April 2015 - 09:19 AM

Okay, I'm tired and maybe I'm missing something.
However, it appears that you simply adopt the orientation of firePoint for the
newly instantiated game object. I assume firePoint is the tip of the gun and its a child
of the player game object.
So, I'd say you turn the player in direction of the mouse, the firePoint turns accordingly
and then you instantiate the bullet with the same orientation.

What you want to do is shoot the bullet in direction (mousePos - firePoint.pos).
If I recall the Unity API correctly, you could simply assign that direction
to transform.forward. Alternatively, there is a method Quaternion.LookRotation.

In Topic: Give me your Java and Python code

28 February 2015 - 07:29 AM

Hey guys,

great links, thanks! I find pygame.org especially useful, because it shows screenshot
of the games.

PARTNERS