Search Results

Search found 383 results on 16 pages for 'polygon'.

Page 11/16 | < Previous Page | 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • How to setup OpenGL camera for a racing game

    - by vian
    I need the view to show the road polygon (a rectangle 3.f * 100.f) with a vanishing point for a road being at 3/4 height of the viewport and the nearest road edge as a viewport's bottom side. See Crazy Taxi game for an example of what I wish to do. I'm using iPhone SDK 3.1.2 default OpenGL ES project template. I setup the projection matrix as follows: glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustumf(-2.25f, 2.25f, -1.5f, 1.5f, 0.1f, 1000.0f); Then I use glRotatef to adjust for landscape mode and setup camera. glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(-90, 0.0f, 0.0f, 1.0f); const float cameraAngle = 45.0f * M_PI / 180.0f; gluLookAt(0.0f, 2.0f, 0.0f, 0.0f, 0.0f, 100.0f, 0.0f, cos(cameraAngle), sin(cameraAngle)); My road polygon triangle strip is like this: static const GLfloat roadVertices[] = { -1.5f, 0.0f, 0.0f, 1.5f, 0.0f, 0.0f, -1.5f, 0.0f, 100.0f, 1.5f, 0.0f, 100.0f, }; And I can't seem to find the right parameters for gluLookAt. My vanishing point is always at the center of the screen.

    Read the article

  • Is it possible to execute a function in Mongo that accepts any parameters?

    - by joshua.clayton
    I'm looking to write a function to do a custom query on a collection in Mongo. Problem is, I want to reuse that function. My thought was this (obviously contrived): var awesome = function(count) { return function() { return this.size == parseInt(count); }; } So then I could do something along the lines of: db.collection.find(awesome(5)); However, I get this error: error: { "$err" : "error on invocation of $where function: JS Error: ReferenceError: count is not defined nofile_b:1" } So, it looks like Mongo isn't honoring scope, but I'm really not sure why. Any insight would be appreciated. To go into more depth of what I'd like to do: A collection of documents has lat/lng values, and I want to find all documents within a concave or convex polygon. I have the function written but would ideally be able to reuse the function, so I want to pass in an array of points composing my polygon to the function I execute on Mongo's end. I've looked at Mongo's geospatial querying and it currently on supports circle and box queries - I need something more complex.

    Read the article

  • How to keep Java Frame from waiting?

    - by pypmannetjies
    I am writing a genetic algorithm that approximates an image with a polygon. While going through the different generations, I'd like to output the progress to a JFrame. However, it seems like the JFrame waits until the GA's while loop finishes to display something. I don't believe it's a problem like repainting, since it eventually does display everything once the while loop exits. I want to GUI to update dynamically even when the while loop is running. Here is my code: while (some conditions) { //do some other stuff gui.displayPolygon(best); gui.displayFitness(fitness); gui.setVisible(true); } public void displayPolygon(Polygon poly) { BufferedImage bpoly = ImageProcessor.createImageFromPoly(poly); ImageProcessor.displayImage(bpoly, polyPanel); this.setVisible(true); } public static void displayImage(BufferedImage bimg, JPanel panel) { panel.removeAll(); panel.setBounds(0, 0, bimg.getWidth(), bimg.getHeight()); JImagePanel innerPanel = new JImagePanel(bimg, 25, 25); panel.add(innerPanel); innerPanel.setLocation(25, 25); innerPanel.setVisible(true); panel.setVisible(true); }

    Read the article

  • Database/Object Mapping

    - by Eric
    Hello everyone, This is a beginner question, but it's been frustrating me... I am using C#, by the way. I'd like to make a few classes, each with their own properties and methods. I would also like to have a database to store certain instances of these classes in case I would ever need to look at them again. So, for example... class Polygon { String name; Double perimiter; int numSides; public Double GetArea() { // ... } } class Circle { String name; Double radius; public void PrintName() { // ... } } Say I've got these classes. I also want a database that has the TABLES "Polygon" and "Circle" with the COLUMNS "name" "perimeter" "radius" etc. And I want an easy way to save a class instance into the database, or pull a class instance out of the database. I have previously been using MS Access for my database stuff, which I don't mind using, but I would prefer if nothing other than .NET need to be installed. I've been researching online a bit, but I wanted to get some opinions on here. I have looked at Linq-to-Sql, but it seems you need Sql-Server. Is this true? If so, I'd really rather not use it because I don't want to have to have it installed everywhere. Anway, I'm just fishing for some ideas/insights/suggestions/etc. so please help me out if you can. Thanks.

    Read the article

  • Alpha interpolation in a pixel shader

    - by c4sh
    How does the interpolation in a fragment shader work when it comes to the alpha parameter? I'm programming a shader with SharpDX, DirectX11. My idea is to interpolate 2 3d points of a segment, so that I'll have the position interpolated in between in the pixel shader. But I want to know what happens with the alpha parameter when that position is blocked by another polygon. For instance, if alpha is 1.0 at the left end of my segment and 0.0 at the other one. What is the value of alpha in the middle, 0.5? Or does it depend on the visibility at that point (meaning it could be, for instance, 1.0 OR 0.0 depending on if that part of the segment is hidden by a poolygon?

    Read the article

  • OpenGL ES 2.0: Vertex and Fragment Shader for 2D with Transparency

    - by Bunkai.Satori
    Could I knindly ask for correct examples of OpenGL ES 2.0 Vertex and Fragment shader for displaying 2D textured sprites with transparency? I have fairly simple shaders that display textured polygon pairs but transparency is not applied despite: texture map contains transparency information Blending is enabled: glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); My Vertex Shader: uniform mat4 uOrthoProjection; uniform vec3 Translation; attribute vec4 Position; attribute vec2 TextureCoord; varying vec2 TextureCoordOut; void main() { gl_Position = uOrthoProjection * (Position + vec4(Translation, 0)); TextureCoordOut = TextureCoord; } My Fragment Shader: varying mediump vec2 TextureCoordOut; uniform sampler2D Sampler; void main() { gl_FragColor = texture2D(Sampler, TextureCoordOut); }

    Read the article

  • How to move a sprite on a slope in chipmunk Spacemanager

    - by Anil gupta
    I have used one polygon shape image (terrain) in my game. It's just like a mountain, and now I want to move the tanker on a mountain path from one side to the other and then turn around at the edge of the screen and go back. I don't understand the method to move the tanker on the slope (image) path in chipmunk spacemanager. When collision detection happens like that, if any bomb falls on the slope (image of mountain) then I want to do a little damage to the slope (image of mountain) like this video.

    Read the article

  • Collision library for bullet hell in Python

    - by darkfeline
    I am making a bullet hell game in Python and am looking for a suitable collision library, taking the following into consideration: The library should do 2D polygon collision. It should be very fast. As a bullet hell game, I expect to do collision checks between hundreds, likely thousands of objects every frame at a consistent 60fps. Good documentation Permissive license (like MIT, not GPL) I am also considering writing my own library in C/C++ and wrapping with python ctypes in the event that no such library exists, though I do not have experience with collision detection algorithms, so I am not sure if this would be more trouble than it's worth. Could someone provide some guidance on this matter?

    Read the article

  • coloring box2d body in LibGDX

    - by ved
    I want to color polygon of box2d in LibGDX. Found below useful class for that. http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html But, it is not coloring the body instead making colored shapes. I want colored bodies having all the property like gravity, restitution etc. In brief, I want to make colored ball and surface.And i don't want to attach sprite on bodies. Want just fill color in bodies. Need some guidance????

    Read the article

  • Cocos2dx- Draw primitives(polygons) on Update

    - by Haider
    In my game I'm trying to draw polygons on on each step i.e. update method. I call draw() method to draw new polygon with dynamic vertices. Following is my code: void HelloWorld::draw(){glLineWidth(1);CCPoint filledVertices[] = {ccp(drawX1,drawY1),ccp(drawX2,drawY2), ccp(drawX3,drawY3), ccp(drawX4,drawY4)};ccDrawSolidPoly( filledVertices, 4, ccc4f(0.5f, 0.5f, 1, 1 ));} I call the draw() method from the update(float dt) method. The engine is behaving inconsistently i.e. sometimes it displays the polygons and on other occasions it does not. Is it the right approach to do such a task? If not what is the best way to display large number of primitives?

    Read the article

  • Finding the contact point with SAT

    - by Kai
    The Separating Axis Theorem (SAT) makes it simple to determine the Minimum Translation Vector, i.e., the shortest vector that can separate two colliding objects. However, what I need is the vector that separates the objects along the vector that the penetrating object is moving (i.e. the contact point). I drew a picture to help clarify. There is one box, moving from the before to the after position. In its after position, it intersects the grey polygon. SAT can easily return the MTV, which is the red vector. I am looking to calculate the blue vector. My current solution performs a binary search between the before and after positions until the length of the blue vector is known to a certain threshold. It works but it's a very expensive calculation since the collision between shapes needs to be recalculated every loop. Is there a simpler and/or more efficient way to find the contact point vector?

    Read the article

  • PyGame QIX clone, filling areas

    - by astropanic
    I'm playing around with PyGame. Now I'm trying to implement a QIX clone. I have my game loop, and I can move the player (cursor) on the screen. In QIX, the movment of the player leaves a trace (tail) on the screen, creating a polyline. If the polyline with the screen boundaries creates a polygon, the area is filled. How I can accomplish this behaviour ? How store the tail in memory ? How to detect when it build a closed shape that should be filled ? I don't need an exact working solution, some pointers, algo names would be cool.

    Read the article

  • Farseer: How can I crush Mario? [on hold]

    - by Homer_Simpson
    I want that Mario dies if the box is crushing him. My game has a similar level like this level from New Super Mario Bros. Wii: http://www.youtube.com/watch?v=tYyu6tFAa2M At the beginning of the level, you see some boxes falling to the ground. If a box crushes Mario, he dies. I want to do exactly the same in my game, but I don't know how to do that in Farseer. How can I do that in Farseer 3.3.1? Do you have any suggestions? I don't know how to do the collision detection. I use rectangles for the boxes and ground in Farseer. Mario is a polygon.

    Read the article

  • Car Modelling for race game

    - by Mert Toka
    I am taking Computer Graphics course this semester and we have a video game competition. I am making racing game with simulated dynamics. Our professor told us that we don't have to do much of a modelling but since we haven't started the gaming part and since I have free time I want to model the car. My question is firstly which software do you recommend to design game components? I know Maya right now. Secondly, if I design the car or any other part, what should its polygon count in order to run game smoothly? I can design pretty much everything but I assume that it is hard to design low-poly models.

    Read the article

  • Lighting a Voxel World Realistically

    - by sharethis
    I am new to game development and never implemented a complicated (and realistic) lighting. My game uses a 3d voxel terrain world (like Minecraft). To hold the data I use octrees. My goal is to render a more realistic world scene like in most voxel games. For that I want to use a bezier algorithm to round out the blocky world. Assume that I already have a large generated polygon of my terrain (or some of them). I heard of some techniques like volumetric light, global illumination, ... What approaches of a very realistic lighting are there for my "organic shaped" voxel game?

    Read the article

  • Moving a body in a specific direction using XNA with Farseer Physics

    - by Code Assasssin
    I have a custom polygon attached to a body, which looks like this: What I am trying to accomplish is getting the body to move according to wherever the tip of the body is. So far this is what I've tried: if (ks.IsKeyDown(Keys.Up)) { body.ApplyForce(new Vector2(0, -20),body.GetLocalPoint(new Vector2(0,0))); } if (ks.IsKeyDown(Keys.Left)) { body.ApplyTorque(-500); } if (ks.IsKeyDown(Keys.Right)) { body.ApplyTorque(500); } The body rotates fine - but when I try making the body accelerate according to the tip of the body - assuming I have specified the tip correctly(I am pretty sure I haven't), it just spins around, as if I have applied Torque to it. Can anyone point me in the right direction of how to fix this problem?

    Read the article

  • How to properly add texture to multi-fixture/shape b2Body

    - by Blazej Wdowikowski
    Hello to everyone this is my first poste here I hope that will be not fail start. At start I must say I make part 1 in Ray's Tutorial "How To Make A Game Like Fruit Ninja With Box2D and Cocos2D". But I wonder what when I want make more complex body with texture? Simple just add n b2FixtureDef to the same body. OK but what about texture? If I will take code from that tutorial it only fill last fixture. Probably it does not takes every b2Vec2 point. I was right, it did not. So quick refactor and from that -(id)initWithTexture:(CCTexture2D*)texture body:(b2Body*)body original:(BOOL)original { // gather all the vertices from our Box2D shape b2Fixture *originalFixture = body->GetFixtureList(); b2PolygonShape *shape = (b2PolygonShape*)originalFixture->GetShape(); int vertexCount = shape->GetVertexCount(); NSMutableArray *points = [NSMutableArray arrayWithCapacity:vertexCount]; for(int i = 0; i < vertexCount; i++) { CGPoint p = ccp(shape->GetVertex(i).x * PTM_RATIO, shape->GetVertex(i).y * PTM_RATIO); [points addObject:[NSValue valueWithCGPoint:p]]; } if ((self = [super initWithPoints:points andTexture:texture])) { _body = body; _body->SetUserData(self); _original = original; // gets the center of the polygon _centroid = self.body->GetLocalCenter(); // assign an anchor point based on the center self.anchorPoint = ccp(_centroid.x * PTM_RATIO / texture.contentSize.width, _centroid.y * PTM_RATIO / texture.contentSize.height); } return self; } I came up with that -(id)initWithTexture:(CCTexture2D*)texture body:(b2Body*)body original:(BOOL)original { int vertexCount = 0; //gather total number of b2Vect2 points b2Fixture *currentFixture = body->GetFixtureList(); while (currentFixture) { //new b2PolygonShape *shape = (b2PolygonShape*)currentFixture->GetShape(); vertexCount += shape->GetVertexCount(); currentFixture = currentFixture->GetNext(); } NSMutableArray *points = [NSMutableArray arrayWithCapacity:vertexCount]; // gather all the vertices from our Box2D shape b2Fixture *originalFixture = body->GetFixtureList(); while (originalFixture) { //new NSLog((NSString*)@"-"); b2PolygonShape *shape = (b2PolygonShape*)originalFixture->GetShape(); int currentVertexCount = shape->GetVertexCount(); for(int i = 0; i < currentVertexCount; i++) { CGPoint p = ccp(shape->GetVertex(i).x * PTM_RATIO, shape->GetVertex(i).y * PTM_RATIO); [points addObject:[NSValue valueWithCGPoint:p]]; } originalFixture = originalFixture->GetNext(); } if ((self = [super initWithPoints:points andTexture:texture])) { _body = body; _body->SetUserData(self); _original = original; // gets the center of the polygon _centroid = self.body->GetLocalCenter(); // assign an anchor point based on the center self.anchorPoint = ccp(_centroid.x * PTM_RATIO / texture.contentSize.width,_centroid.y * PTM_RATIO / texture.contentSize.height); } return self; } I was working for simple two fixtures body like b2BodyDef bodyDef; bodyDef.type = b2_dynamicBody; bodyDef.position = position; bodyDef.angle = rotation; b2Body *body = world->CreateBody(&bodyDef); b2FixtureDef fixtureDef; fixtureDef.density = 1.0; fixtureDef.friction = 0.5; fixtureDef.restitution = 0.2; fixtureDef.filter.categoryBits = 0x0001; fixtureDef.filter.maskBits = 0x0001; b2Vec2 vertices[] = { b2Vec2(0.0/PTM_RATIO,50.0/PTM_RATIO), b2Vec2(0.0/PTM_RATIO,0.0/PTM_RATIO), b2Vec2(50.0/PTM_RATIO,30.1/PTM_RATIO), b2Vec2(60.0/PTM_RATIO,60.0/PTM_RATIO) }; b2PolygonShape shape; shape.Set(vertices, 4); fixtureDef.shape = &shape; body->CreateFixture(&fixtureDef); b2Vec2 vertices2[] = { b2Vec2(20.0/PTM_RATIO,50.0/PTM_RATIO), b2Vec2(20.0/PTM_RATIO,0.0/PTM_RATIO), b2Vec2(70.0/PTM_RATIO,30.1/PTM_RATIO), b2Vec2(80.0/PTM_RATIO,60.0/PTM_RATIO) }; shape.Set(vertices2, 4); fixtureDef.shape = &shape; body->CreateFixture(&fixtureDef); But if I try put secondary shape upper than first it starting wierd, texture goes crazy. For example not mention about more complex shapes. What's more if shapes have one common point texture will not render for them at all [For that I use Physics Edytor like in tutorial part1] BTW. I use PolygonSprite and in method createWithWorld... another shapes. Uff.. Question So my question is, why texture coords are in such a mess up? It's my modify method or just wrong approach? Maybe I should remove duplicated from points array?

    Read the article

  • Drawing an outline around an arbitrary group of hexagons

    - by Perky
    Is there an algorithm for drawing an outline around around an arbitrary group of hexagons? The polygon outline drawn may be concave. See the images below, the green line is what I am trying to achieve. The hexagons are stored as vertices and drawn as polygons. Edit: I've uploaded images that should explain more. I want to favour convex hulls because it's conveys an area of control more quickly. Each hexagon is stored in a multidimensional array so they all have x and y coordinates, I can easily find adjacent hexagons and the opposite vertex, i.e. adjacentHexagon = getAdjacentHexagon( someHexagon, NORTHWEST ) if there isn't a hexagon immediately adjacent it will continue to search in that direction until it finds one or hits the map edges.

    Read the article

  • Low complexity shader to indicate the sides of a polyline

    - by Pris
    I have a bunch of polylines that I draw using GL_LINES. They can have thousands of points. They actually represent the separation of land and water on a map. I don't have complete polygons, just the ordered set of points. I'm looking for a neat but efficient way to visually convey Side A and Side B as being different. For example I could offset the polyline in one direction a few times and fade it out (but every offset is doubling the number of points), or offset it once to make a "ribbon" and give one side a 'glow' like effect to mimic the outer glow or shadow of a polygon). This is for a mobile application and I'm using OpenGL ES 2. I'd like to keep the effect as simple as possible from a complexity stand point. I'm looking for some additional ideas; maybe there's a clever shader technique out there or a visual effect I haven't considered.

    Read the article

  • How to make Pokémon White 3D effect?

    - by Pipo
    I just wondered how to create a 3D effect similar to Pokemon White/Black? It seems to be not polygon based, but created just with sprites. If the perspective changes the sprites stay sharp and don't get blurred. How can I archive this? Source: https://www.youtube.com/watch?v=fZEPUPYOnRc&feature=youtube_gdata_player Edit: Wow, two downvotes because I used a video instead of screenshots? Don't get me wrong, I thank you, because you want to help me, but the 3D effect can be better understand in motion. Anyway, here is a screenshot: http://wearearcade.com/wp-content/uploads/2011/03/pokemon-black-white-starter-town.jpg So, if this is a hardware limitation, how can I archive this o na different hardware, e.g. a HTML5 game? Thank you.

    Read the article

  • How do I get my polygons to be lighted by either side?

    - by Molmasepic
    Okay, I am using Ogre3D and Gorilla(2D library for ogre3D) and I am making Gorilla::Screenrenderables in the open scene. The problem that I am having is that when I make a light and have my SR(screenrenderable) near it, it does not light up unless the face of the SR is facing the light... I am wondering if there is a way to maybe set the material or code(which would be harder) so the SR is lit up whether the vertices of the polygon are facing the light or not. I feel it is possible but the main obstacle is how I would go about doing this.

    Read the article

  • Selection of a mesh with arbitrary region

    - by Tigran
    Considering example: I have a mesh(es) on the OpenGL screen and would like to select a part of it (say for delete purpose). There is a clear way to do the selction via Ray Tracing, or via Selection provided by OpenGL itself. But, for my users, considering that meshes can get wired surfaces, I need to implement a selection via a Arbitrary closed region, so all triangles that appears present inside that region has to be selected. To be more clear, here is screen shot: I want all triangles inside black polygon to be selected, identified, whatever in some way. How can I achieve that ?

    Read the article

  • What library should I use for 2D Geometry? [closed]

    - by Luka
    I've been working on a 2D game in java, but found that java just didn't cut it for me and had forced me to a lot of bad design choices, so I've decided to port all my work to c++. The main reason I've decided change to c++ is that i had reached a point where i had 3 geometry libraries (the native, one from the game engine and one to handle "complex" polygons), none of witch worked very well together and i couldn't keep track of them. I'm new to c++, but i know all the basics. My question is, what would be a good geometry library to use, ideally it should be able to handle integer and decimal data types, have point, line, and polygon classes witch are able to check for intersection and contains. Thanks in advance, Luka

    Read the article

  • Collision: Vector class (java)

    - by user8363
    When handling collision detection / response and you need a Vector class, do you need to create that class yourself or is there a java class you can use? A vector class should have methods like: subtract(Vector v), normalize(), dotProduct(Vector v), ... At the moment it seems logical to use classes like java.awt.Rectangle and java.awt.Polygon to calculate collisions. Would I be right to use these classes for this purpose? My question is not about how to implement collision detection, I know how that works. However I'm wondering what would be a correct and clean way to implement it in java since I'm fairly new to the language and to application development in general.

    Read the article

  • Will my game engine be compatible with physics engines?

    - by Bane
    My engine supports Scene handling, Cameras, and has a Renderer. Also, it has a class called Drawable, which has the position, the shape and the picture of an object. The picture property has width, height, rotation and a draw method. All game objects are supposed to inherit from this Drawable class, and are added to the Scene, along with a Map (collection of Tiles, that also inherit from Drawable), lights, and so on and so forth. The shape property of a Drawable is a Polygon, a collection of user defined vertices around the position of a Drawable (this is a relative coordinate system, so [0, 0] is the position of the Drawable. With this setup, will the users of my engine (probably only me) still be able to intergrate physics engines such as Box2DJS into their games?

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16  | Next Page >