Search Results

Search found 1510 results on 61 pages for 'barycentric coordinates'.

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

  • Getting geographical coordinates from web application

    - by user51151
    I want to learn a user's location from his mobile device by web application. When user opens the website, with the help of a script we will learn if the device has a gps hardware.And if the device has gps hardware what are the current coordinates? I'm developing my project using ASP.NET Is this possible or not? Thanks.

    Read the article

  • Get coordinates of beads covering the surface of a protein

    - by Hefeweizen
    Given a protein structure from the PDB, I would like to generate NS spheres of radius Rs which cover totally the protein surface. Given RS there, NS is the maximum number of spheres so they do not overlap. I would need the coordinates of the center of each sphere. Does anybody know if this has been implemented in some method / program? Or how to do it with scripting. Thanks

    Read the article

  • Imitating Mouse click - point with known coordinates on a fusion table layer - google maps

    - by Yavor Tashev
    I have been making a script using a fusion table's layer in google maps. I am using geocoder and get the coordinates of a point that I need. I put a script that changes the style of a polygon from the fusion table when you click on it, using the google.maps.event.addListener(layer, "click", function(e) {}); I would like to use the same function that I call in the case of a click on the layer, but this time with a click with the coordinates that I got. I have tried google.maps.event.trigger(map, 'click', {latLng: new google.maps.LatLng(42.701487,26.772308)}); As well as the example here Google Fusion Table Double Click (dblClick) I have tried changing map with layer... I am sorry if my question is quite stupid, but I have tried many options. P.S. I have seen many post about getting the info from the table, but I do not need that. I want to change the style of the KML element in the selected row, so I do not see it happening by a query. Here is the model of my script: function initialize() { geocoder = new google.maps.Geocoder(); map = new google.maps.Map(document.getElementById("map_canvas"),myOptions); layer = new google.maps.FusionTablesLayer({ suppressInfoWindows:true, map : map, query : { select: '??????????????', from: '12ZoroPjIfBR4J-XwM6Rex7LmfhzCDJc9_vyG5SM' } }); google.maps.event.addListener(layer, "click", function(e) { SmeniStilRaionni(layer,e); marker.setMap(null); }); } function SmeniStilRaionni(layer,e) { ... } function showAddress(address) { geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var point = results[0].geometry.location; //IMITATE THE CLICK } }); } In response to geocodezip This way you hide all the other elements... I do not wish that. It is like if I want to change the border of the selected element. And I do not wish for a new layer. In the function that I use now I push the style of the options of the layer and then set the option. I use the e from google.maps.event.addListener(layer, "click", function(e)); by inserting e.row['Name'].value inside the where rule. I would like to ask you if there is any info on the e variable in google.maps.event.addListener(layer, "click", function(e)); I found out how to get the results I wanted: For my query after I get the point I use this: var queryText ="SELECT '??????? ???','??????? ???','?????????? ???','??????????????' FROM "+FusionTableID+" WHERE ST_INTERSECTS(\'??????????????\', CIRCLE(LATLNG(" + point.toUrlValue(6) + "),0.5));"; queryText = encodeURIComponent(queryText); document.getElementById("vij query").innerHTML = queryText; var query = new google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq=' + queryText); And then I get these results: var rsyd = response.getDataTable().getValue(0,0); var osyd = response.getDataTable().getValue(0,1); var apsyd = response.getDataTable().getValue(0,2); And then, I use the following: where: "'??????? ???' = '"+rsyd+"'", Which is the same as: where: "'??????? ???' = '"+e.row['??????? ???'].value+"'", in the click function. This is a working solution for my problem. But still, I cannot find a way to Imitate a Mouse click.

    Read the article

  • pgf/tikz: String Symbols as Input Coordinates

    - by red_lynx
    Hi all, I'm new to pgf so i was trying out some examples from the pgfplot manual. One example is especially relevant for my current task but, alas, it would not compile. Here is the code: \documentclass[11pt]{article} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[symbolic x coords={a,b,c,d,e,f,g,h,i}] \addplot+[smooth] coordinates { (a,42) (b,50) (c,80) (f,60) (g,62) (i,90)}; \end{axis} \end{tikzpicture} \end{document} the compiler quits with the following error: ! Package PGF Math Error: Could not parse input 'a' as a floating point number, sorry. The unreadable part was near 'a'.. I have no clue how to correct this behavior. Other plots (smooth, scatter, bar), which contain only numerical data compile fine. Could anybody give me a hint? Cheers K.

    Read the article

  • Translate GPS coordinates to location on PDF Map

    - by christo16
    Hi everyone, I'd like to know (from a high level view) what would be required to take a pdf floor plan of a building and determine where exactly you are on that floor plan using GPS coordinates? In addition to location, the user would be presented with a "turn by turn" directions to another point on the map, navigating down hallways, between cubicles, etc. Use case: an iPhone app that determined a user's location and guided them to a conference room or person's office in the building. I realize that this is by no means trivial, but any help is appreciated. Thanks!

    Read the article

  • Extract text and image from a pdf in a selected area or coordinates

    - by yercaudARUN
    Hi All, I have a specific requirement of extracting text and images from a specific area in a pdf file.The area might be a selected or highlighted or from a given set of coordinates. When i went through, all the approaches are to extract images and text entirely from the PDF on not in a specified location. I tried with iTextSharp,Syncfussion,Apose but couldn figure out a better approach for this. If somebody could help me out in this it would be greatfull. Can you share your ideas and suggestion on how to implement this in .net. Regards, Arun.M

    Read the article

  • Getting object coordinates from camera

    - by user566757
    I've implemented a camera in Java using a position vector and three direction vectors so I can use gluLookAt(); moving around in `ghost mode' works fine enough, but I want to add collision detection. I can't seem to figure out how to transform my position vector to coordinates in which OpenGL draws my objects. A rough sketch of my drawing loop is this: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); camera.setView(); drawer.drawTheScene(); I'm at a loss of how to proceed; looking at the ModelView matrix between calls and my position vector, I haven't found any kind of correlation.

    Read the article

  • Latitude & longitude coordinates of Australian states/territories for database using Google Maps

    - by RMW
    Hi, We have a database which has location-based search using Google Maps API. However searching by state or territory in Australia is problematic because Google Maps locates these at the centre of the states and most population centres in Australia are on the coast. We need to hand code in the latitudes and longitudes so that when someone searches for the state 'NSW', for example, the database returns relevant results. Does anyone know where to find a list of the coordinates for the boundaries of Australian states & territories to code into the database? This will save our busy programmer a lot of time. Thanks in advance.

    Read the article

  • getting smallest of coordinates that differ by N or more in Python

    - by user248237
    suppose I have a list of coordinates: data = [[(10, 20), (100, 120), (0, 5), (50, 60)], [(13, 20), (300, 400), (100, 120), (51, 62)]] and I want to take all tuples that either appear in each list in data, or any tuple that differs from all tuples in lists other than its own by 3 or less. How can I do this efficiently in Python? For the above example, the results should be: [[(100, 120), # since it occurs in both lists (10, 20), (13, 20), # since they differ by only 3 (50, 60), (51, 60)]] (0, 5) and (300, 400) would not be included, since they don't appear in both lists and are not different from elements in lists other than their own by 3 or less. how can this be computed? thanks.

    Read the article

  • How can I move an object left and right with silverlight?

    - by Craig
    I currently have two buttons that say left and right, and I want them to move a square object left and right respectively. What its currently doing when i press left is moving the square to the left, and if I press left again, it resets from the center and goes left. I want it so that when I press left, from where ever it is currently to go left and right. I know the principle is something like get current objects position and add the canvas coordinates respectively but how do I do this?

    Read the article

  • Mapping Hashmap of Coordinates in Hibernate with Annotation

    - by paddydub
    I've just started using hibernate and I'm trying to map walking distance between two coordinates into a hashmap, There can be many connections from one "FromCoordinate" to another "ToCoordinate". I'm not sure if i've implemented this correctly, What annotations do i need to map this MashMap? Thanks HashMap coordWalkingConnections = new HashMap(); @Entity @Table(name = "COORDCONNECTIONS") public class CoordinateConnection implements Serializable{ private static final long serialVersionUID = -1624745319005591573L; /** auto increasing id number */ @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") @id private int id; @Embedded public FromCoordinate fromCoord; @Embedded public ToCoordinate toCoord; HashMap<FromCoordinate, ArrayList<ToCoordinate >> coordWalkingConnections = new HashMap<FromCoordinate, ArrayList<ToCoordinate >>(); } public class FromCoordinate implements ICoordinate { @Column(name = "FROM_LAT") private double latitude; @Column(name = "FROM_LNG") private double longitude; } public class ToCoordinate implements ICoordinate { @Column(name = "TO_LAT") private double latitude; @Column(name = "TO_LNG") private double longitude; @Column(name = "DISTANCE") private double distance; } DATABASE STRUCTURE id FROM_LAT FROM_LNG TO_LAT TO_LNG Dist 1 43.352669 -6.264341 43.350012 -6.260653 0.38 2 43.352669 -6.264341 43.352669 -6.264341 0.00 3 46.352669 -6.264341 43.353373 -6.262013 0.17 4 47.352465 -6.265865 43.351290 -6.261200 0.25 5 45.452578 -6.265768 43.352788 -6.264396 0.01 6 45.452578 -6.265768 45.782788 -6.234523 0.01 ..... ... . Example HashMap for HashMap<Coordinate, ArrayList<Coordinate>> <KEY{43.352669 -6.264341}, Arraylist VALUES{(43.350012,-6.260653,0.383657), (43.352669, -6.264341, 0.000095), (43.353373, -6.262013, 0.173201)}> <KEY{47.352465 -6.265865}, Arraylist VALUES{(43.351290,-6.261200,0.258781)}> <KEY{45.452578 -6.265768}, Arraylist VALUES{(43.352788,-6.264396,0.013726),(45.782788,-6.234523,0.017726)}>

    Read the article

  • Why aren't my coordinates matching my JFrame size?

    - by AsLanFromNarnia
    I want to do some drawing in a JPanel but the enclosing JFrame size doesn't seem to match where I've asked the coordinates to be drawn. In my example code, the JFrame size is set to (700, 700) and the last point is drawn at (600, 600). I would expect this point to be drawn 100 pixels away from the right and bottom edges but it isn't (please see screenshot). Here's the code I'm using: import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; public class Scratch extends JPanel { static int frameWidth = 700; static int frameHeight = 700; public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(frameWidth, frameHeight); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Scratch scratch = new Scratch(); frame.getContentPane().add(scratch); frame.setVisible(true); } @Override public void paintComponent(Graphics g) { g.drawRect(100, 100, 1, 1); g.drawString("100", 100, 100); g.drawRect(200, 200, 1, 1); g.drawString("200", 200, 200); g.drawRect(300, 300, 1, 1); g.drawString("300", 300, 300); g.drawRect(400, 400, 1, 1); g.drawString("400", 400, 400); g.drawRect(500, 500, 1, 1); g.drawString("500", 500, 500); g.drawRect(600, 600, 1, 1); g.drawString("600", 600, 600); } }

    Read the article

  • Getting coordinates when clicking anywhere on a MapView

    - by DixieFlatline
    I just cant get this working. I tried using the code below with onTouchEventand and it doesn't work. If i return true at the end of the method, i get the toast with the coordinates but can't move a map, and if i return false, i can move a map but cant display a toast after the user clicks on a map. If i get it right, the other onTap method is used only for clicking on a overlays. Has anybody figured this thiing out? public boolean onTouchEvent(MotionEvent arg0, MapView arg1) { //super.onTouchEvent(arg0); int akcija = arg0.getAction(); if(akcija == MotionEvent.ACTION_UP){ if(!premik) { Projection proj = mapView.getProjection(); GeoPoint loc = proj.fromPixels((int)arg0.getX(), (int)arg0.getY()); String sirina=Double.toString(loc.getLongitudeE6()/1000000); String dolzina=Double.toString(loc.getLatitudeE6()/1000000); Toast toast = Toast.makeText(getApplicationContext(), "Širina: "+sirina+" Dolzina: "+dolzina, Toast.LENGTH_LONG); toast.show(); } } else if (akcija == MotionEvent.ACTION_DOWN){ premik= false; } else if (akcija== MotionEvent.ACTION_MOVE){ premik = true; } return false; //return super.onTouchEvent(arg0); }

    Read the article

  • iOS MapKit: Selected MKAnnotation coordinates.

    - by Oh Danny Boy
    Using the code at the following tutorial, http://www.zenbrains.com/blog/en/2010/05/detectar-cuando-se-selecciona-una-anotacion-mkannotation-en-mapa-mkmapview/, I was able to add an observer to each MKAnnotation and receive a notification of selected/deselected states. I am attempting to add a UIView on top of the selection annotation to display relevant information about the location. This information cannot be conveyed in the 2 lines allowed (Title/Subtitle) for the pin's callout. - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { Annotation *a = (Annotation *)object; // Alternatively attempted using: //Annotation *a = (Annotation *)[mapView.selectedAnnotations objectAtIndex:0]; NSString *action = (NSString *)context; if ([action isEqualToString:ANNOTATION_SELECTED_DESELECTED]) { BOOL annotationSelected = [[change valueForKey:@"new"] boolValue]; if (annotationSelected) { // Actions when annotation selected CGPoint origin = a.frame.origin; NSLog(@"origin (%f, %f) ", origin.x, origin.y); // Test UIView *v = [[UIView alloc] init]; [v setBackgroundColor:[UIColor orangeColor]]; [v setFrame:CGRectMake(origin.x, origin.y , 300, 300)]; [self.view addSubview:v]; [v release]; }else { // Accions when annotation deselected } } } Results using Annotation *a = (Annotation *)object origin (154373.000000, 197135.000000) origin (154394.000000, 197152.000000) origin (154445.000000, 197011.000000) Results using Annotation *a = (Annotation *)[mapView.selectedAnnotations objectAtIndex:0]; origin (0.000000, 0.000000) origin (0.000000, 0.000000) origin (0.000000, 0.000000) The numbers are large. They are not relative to the view (1024 x 768). I believe they are relative to the entire map. How would I be able to detect the exact coordinates relative to the entire view so that I can appropriately position my view?

    Read the article

  • How do I determine the coordinates of controls in a WM_INITDIALOG message?

    - by René Nyffenegger
    I am having troubles to determine the (what I believe to be the) client coordinates of a (radio button) control in the WM_INITDIALOG message of a DlgProc. Here's what I try: // Retrieve coordinates of Control with respect to the screen. RECT rectOrthoButton; GetWindowRect(GetDlgItem(hWnd, IDC_ORTHO), &rectOrthoButton); // Translate coordinates to more useful coordinates: those that // are used on the dialog. // In order to do the translation we have to find the top left // point (coordinates) of the dialog's client: POINT dlgTopLeft; ClientToScreen(hWnd, &dlgTopLeft); // With these coordinates we can do the translation. // We're only interested in top and left, so we skip // bottom and right: rectOrthoButton.top -= dlgTopLeft.y; rectOrthoButton.left -= dlgTopLeft.x; use_top_and_left(rectOrthoButton.top, rectOrthoButton.left); I expected rectOrthoButton.top and .left to be the top left coordinates of my control with respect to the dialog's client area. It turns out they aren't and I am not sure what they point to as rectOrthoButton.left is equal to -40.

    Read the article

  • Vector math, finding coördinates on a planar between 2 vectors

    - by Will Kru
    I am trying to generate a 3d tube along a spline. I have the coördinates of the spline (x1,y1,z1 - x2,y2,z2 - etc) which you can see in the illustration in yellow. At those points I need to generate circles, whose vertices are to be connected at a later stadium. The circles need to be perpendicular to the 'corners' of two line segments of the spline to form a correct tube. Note that the segments are kept low for illustration purpose. [apparently I'm not allowed to post images so please view the image at this link] http://img191.imageshack.us/img191/6863/18720019.jpg I am as far as being able to calculate the vertices of each ring at each point of the spline, but they are all on the same planar ie same angled. I need them to be rotated according to their 'legs' (which A & B are to C for instance). I've been thinking this over and thought of the following: two line segments can be seen as 2 vectors (in illustration A & B) the corner (in illustraton C) is where a ring of vertices need to be calculated I need to find the planar on which all of the vertices will reside I then can use this planar (=vector?) to calculate new vectors from the center point, which is C and find their x,y,z using radius * sin and cos However, I'm really confused on the math part of this. I read about the dot product but that returns a scalar which I don't know how to apply in this case. Can someone point me into the right direction? [edit] To give a bit more info on the situation: I need to construct a buffer of floats, which -in groups of 3- describe vertex positions and will be connected by OpenGL ES, given another buffer with indices to form polygons. To give shape to the tube, I first created an array of floats, which -in groups of 3- describe control points in 3d space. Then along with a variable for segment density, I pass these control points to a function that uses these control points to create a CatmullRom spline and returns this in the form of another array of floats which -again in groups of 3- describe vertices of the catmull rom spline. On each of these vertices, I want to create a ring of vertices which also can differ in density (amount of smoothness / vertices per ring). All former vertices (control points and those that describe the catmull rom spline) are discarded. Only the vertices that form the tube rings will be passed to OpenGL, which in turn will connect those to form the final tube. I am as far as being able to create the catmullrom spline, and create rings at the position of its vertices, however, they are all on a planars that are in the same angle, instead of following the splines path. [/edit] Thanks!

    Read the article

  • JavaFX2: Drag Event start and end coordinates

    - by user
    I have one node(ImageView) that displays an image and another node(rectangle) that resides on top of it. The behavior I need is that when the mouse is dragged(press-drag-release gesture) over the rectangle, both the nodes should move coherently. My thought process goes in the following direction: • Move both the nodes by the same distance in the direction of the drag. For this option(maybe there are more options) I need the distance between the start and end of the mouse drags. I tried capturing the start and end coordinates of the drag but have been unsuccessful. I think I am getting lost in which handlers to implement. The code I have is below: import javafx.event.EventHandler; import javafx.geometry.Rectangle2D; import javafx.scene.image.ImageView; import javafx.scene.input.MouseEvent; public class MyView { double mouseDragStartX; double mouseDragEndX; double mouseDragStartY; double mouseDragEndY; ImageView imageView; public MyView() { imageView = new ImageView("C:\\temp\\test.png"); } private void setRectangleEvents(final MyObject myObject) { myObject.getRectangle().setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { mouseDragStartX = mouseEvent.getX(); mouseDragStartY = mouseEvent.getY(); mouseEvent.consume(); } }); myObject.getRectangle().setOnMouseReleased(new EventHandler<MouseEvent>() { public void handle(MouseEvent mouseEvent) { mouseDragEndX = mouseEvent.getX(); mouseDragEndY = mouseEvent.getY(); myObjectDraggedHandler(); } }); } private void myObjectDraggedHandler() { Rectangle2D viewport = this.imageView.getViewport(); double newX = this.imageView.getImage().getWidth() + (mouseDragEndX - mouseDragStartX); double newY = this.imageView.getImage().getHeight() + (mouseDragEndY - mouseDragStartY); this.imageView.setViewport(new Rectangle2D(newX, newY, viewport.getWidth(), viewport .getHeight())); } } P.S: This code is just for indicating what I am trying to implement and will not compile correctly. Or maybe my question should just have been: How to capture the length or span of a mouse drag?

    Read the article

  • Console App Mouse-Click X Y Coordinate Detection/Comparison

    - by Bloodyaugust
    I have a game that I am working on in a C# console application, purely as practice before going on to better methods. As opposed to using something such as a Windows Forms App, which has button functionality built in, I am endeavoring to grab the cursor position (which I know how to do) and compare it to a number of area's inside a console application as defined by perhaps pixel location, but I also do not know if there is some sort of built in unit of space other than pixels (this last bit is the part I am unable to figure). P.S. I know this is in general terms, with no code already provided, but I do not feel that it is needed as all I am asking for is a brief explanation of how to grab X Y coordinates inside a console application, and stick them in int variables. Many Thanks in advance! :D

    Read the article

  • How to partition a plane

    - by puls200
    Let's say I have a fixed number (X) of points, e.g. coordinates within a given plane (I think you can call it a 2-D point cloud). These points should be partitioned into Y polygons where Y < X. The polygons should not overlap. It would be wonderful if the polygons were konvex (like a Voronoi diagram). Imagine it like locations forming countries. For example, I have 12 points and want to create 3 polygons with 4 points each. I thought about creating a grid which covers the points. Then iterate across the points, assigning them to the closest grid cells. Maybe I miss the obvious? I am sure there are better solutions. Thanks, Daniel I just found an optimization (kmeans++) .Maybe this will yield better results..

    Read the article

  • C# Executing timed commands with varying times

    - by Gio Borje
    I have a timer control and a grid with a List of coordinates for the grid. I was wondering how I could use the timer control or any other control in order to execute code in the interval, coordinate.Time as it varies for each coordinate. Also, thread.sleep(time) is not an option for me. foreach (Coordinate coordinate in this.Macro) { coordinate.Time; coordinate.Initial; coordinate.Final; ... executecode @ coordinate.Time. }

    Read the article

  • problem with my texture coordinates on a square.

    - by Evan Kimia
    Im very new to OpenGL ES, and have been doing a tutorial to build a square. The square is made, and now im trying to map a 256 by 256 image onto it. The problem is, im only seeing a very zoomed in portion of this bitmap; Im fairly certain my texture coords are whats wrong here. Thanks! package se.jayway.opengl.tutorial; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.ShortBuffer; import javax.microedition.khronos.opengles.GL10; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.opengl.GLUtils; public class Square { // Our vertices. private float vertices[] = { -1.0f, 1.0f, 0.0f, // 0, Top Left -1.0f, -1.0f, 0.0f, // 1, Bottom Left 1.0f, -1.0f, 0.0f, // 2, Bottom Right 1.0f, 1.0f, 0.0f, // 3, Top Right }; //Our texture. private float texture[] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, }; // The order we like to connect them. private short[] indices = { 0, 1, 2, 0, 2, 3 }; // Our vertex buffer. private FloatBuffer vertexBuffer; // Our index buffer. private ShortBuffer indexBuffer; //texture buffer. private FloatBuffer textureBuffer; //Our texture pointer. private int[] textures = new int[1]; public Square() { // a float is 4 bytes, therefore we multiply the number if // vertices with 4. ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4); vbb.order(ByteOrder.nativeOrder()); vertexBuffer = vbb.asFloatBuffer(); vertexBuffer.put(vertices); vertexBuffer.position(0); // a float is 4 bytes, therefore we multiply the number of // vertices with 4. ByteBuffer tbb = ByteBuffer.allocateDirect(texture.length * 4); vbb.order(ByteOrder.nativeOrder()); textureBuffer = tbb.asFloatBuffer(); textureBuffer.put(texture); textureBuffer.position(0); // short is 2 bytes, therefore we multiply the number if // vertices with 2. ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2); ibb.order(ByteOrder.nativeOrder()); indexBuffer = ibb.asShortBuffer(); indexBuffer.put(indices); indexBuffer.position(0); } /** * This function draws our square on screen. * @param gl */ public void draw(GL10 gl) { // Counter-clockwise winding. gl.glFrontFace(GL10.GL_CCW); // Enable face culling. gl.glEnable(GL10.GL_CULL_FACE); // What faces to remove with the face culling. gl.glCullFace(GL10.GL_BACK); //Bind our only previously generated texture in this case gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); // Enabled the vertices buffer for writing and to be used during // rendering. gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); //Enable texture buffer array gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); // Specifies the location and data format of an array of vertex // coordinates to use when rendering. gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer); // Disable the vertices buffer. gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); //Disable the texture buffer. gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); // Disable face culling. gl.glDisable(GL10.GL_CULL_FACE); } /** * Load the textures * * @param gl - The GL Context * @param context - The Activity context */ public void loadGLTexture(GL10 gl, Context context) { //Get the texture from the Android resource directory InputStream is = context.getResources().openRawResource(R.drawable.test); Bitmap bitmap = null; try { //BitmapFactory is an Android graphics utility for images bitmap = BitmapFactory.decodeStream(is); } finally { //Always clear and close try { is.close(); is = null; } catch (IOException e) { } } //Generate one texture pointer... gl.glGenTextures(1, textures, 0); //...and bind it to our array gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); //Create Nearest Filtered Texture gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); //Different possible texture parameters, e.g. GL10.GL_CLAMP_TO_EDGE gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT); //Use the Android GLUtils to specify a two-dimensional texture image from our bitmap GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); //Clean up bitmap.recycle(); } }

    Read the article

  • OpenGL true coordinates and glutTimerFunc() problem C++

    - by Meko
    HI I am starting to learn openGl for C++.but at stating point I stucked. I have 2 question that is the coordinates for drawing some objects? I mean where is X, Y and Z? Second one I am making tutorial from some sites. and I am trying to animate my triangle.In tutorial it works but on my computer not.I Also downloaded source codes but It doesnt move. Here sample codes. I thougt that problem is glutTimerFunc(). #include #include #ifdef APPLE #include #include #else #include #endif using namespace std; //Called when a key is pressed void handleKeypress(unsigned char key, int x, int y) { switch (key) { case 27: //Escape key exit(0); } } //Initializes 3D rendering void initRendering() { glEnable(GL_DEPTH_TEST); } //Called when the window is resized void handleResize(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, (double)w / (double)h, 1.0, 200.0); } float _angle = 30.0f; float _cameraAngle = 0.0f; //Draws the 3D scene void drawScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective glLoadIdentity(); //Reset the drawing perspective glRotatef(-_cameraAngle, 0.0f, 1.0f, 0.0f); //Rotate the camera glTranslatef(0.0f, 0.0f, -5.0f); //Move forward 5 units glPushMatrix(); //Save the transformations performed thus far glTranslatef(0.0f, -1.0f, 0.0f); //Move to the center of the trapezoid glRotatef(_angle, 0.0f, 0.0f, 1.0f); //Rotate about the z-axis glBegin(GL_QUADS); //Trapezoid glVertex3f(-0.7f, -0.5f, 0.0f); glVertex3f(0.7f, -0.5f, 0.0f); glVertex3f(0.4f, 0.5f, 0.0f); glVertex3f(-0.4f, 0.5f, 0.0f); glEnd(); glPopMatrix(); //Undo the move to the center of the trapezoid glPushMatrix(); //Save the current state of transformations glTranslatef(1.0f, 1.0f, 0.0f); //Move to the center of the pentagon glRotatef(_angle, 0.0f, 1.0f, 0.0f); //Rotate about the y-axis glScalef(0.7f, 0.7f, 0.7f); //Scale by 0.7 in the x, y, and z directions glBegin(GL_TRIANGLES); //Pentagon glVertex3f(-0.5f, -0.5f, 0.0f); glVertex3f(0.5f, -0.5f, 0.0f); glVertex3f(-0.5f, 0.0f, 0.0f); glVertex3f(-0.5f, 0.0f, 0.0f); glVertex3f(0.5f, -0.5f, 0.0f); glVertex3f(0.5f, 0.0f, 0.0f); glVertex3f(-0.5f, 0.0f, 0.0f); glVertex3f(0.5f, 0.0f, 0.0f); glVertex3f(0.0f, 0.5f, 0.0f); glEnd(); glPopMatrix(); //Undo the move to the center of the pentagon glPushMatrix(); //Save the current state of transformations glTranslatef(-1.0f, 1.0f, 0.0f); //Move to the center of the triangle glRotatef(_angle, 1.0f, 2.0f, 3.0f); //Rotate about the the vector (1, 2, 3) glBegin(GL_TRIANGLES); //Triangle glVertex3f(0.5f, -0.5f, 0.0f); glVertex3f(0.0f, 0.5f, 0.0f); glVertex3f(-0.5f, -0.5f, 0.0f); glEnd(); glPopMatrix(); //Undo the move to the center of the triangle glutSwapBuffers(); } void update(int value) { _angle += 2.0f; if (_angle 360) { _angle -= 260; } glutPostRedisplay(); //Tell GLUT that the display has changed //Tell GLUT to call update again in 25 milliseconds glutTimerFunc(25, update, 0); } int main(int argc, char** argv) { //Initialize GLUT glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(400, 400); //Create the window glutCreateWindow("Transformations and Timers - videotutorialsrock.com"); initRendering(); //Set handler functions glutDisplayFunc(drawScene); glutKeyboardFunc(handleKeypress); glutReshapeFunc(handleResize); glutTimerFunc(24, update, 0); //Add a timer glutMainLoop(); return 0; }

    Read the article

  • Retrieve the coordinates of the *occluding* (closest/drawn) pixels during 3D overlap, using OpenGL?

    - by Big Rich
    Hi, Sorry if the question is not worded well, I'm a new to both 3D and OpenGL. How could I go about obtaining the 3D coordinates of the occluding object, at the point where occlusion is happening (i.e. the 'intersection' of the object in front/closest to the screen)? Just to offer a [very] rudimentary, visual, example, if you were to form an index-finger cross, with your right hand closest to your face, I'd like to know the coordinates of the part of your right finger which obscures the other finger (obviously back within the OpenGL context - no jokers ;-) ). If there is a way to find out both about the occluder (hider) and the occluded (hidden) objects in OpenGL, then that would be of great use, also. Cheers Rich

    Read the article

  • Possible to map mouse coordinates to isometric tiles with this coordinate system?

    - by plukich
    I'm trying to implement mouse interaction in a 2d isometric game, but I'm not sure if it's possible given the coordinate system used for tile maps in the game. I've read some helpful articles like this one: How to convert mouse coordinates to isometric indexes? However, this game's coordinate system is "jagged" for lack of a better word, and looks like this: Is it even possible to map mouse coordinates to this successfully, since the y-axis can't be drawn on this tile-map as a straight line? I've thought about doing odd-y-value translations and even-y-value translations with two different matricies, but that only makes sense going from tile-screen.

    Read the article

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