Search Results

Search found 558 results on 23 pages for 'varying'.

Page 14/23 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Python - a clean approach to this problem?

    - by Seafoid
    Hi, I am having trouble picking the best data structure for solving a problem. The problem is as below: I have a nested list of identity codes where the sublists are of varying length. li = [['abc', 'ghi', 'lmn'], ['kop'], ['hgi', 'ghy']] I have a file with two entries on each line; an identity code and a number. abc 2.93 ghi 3.87 lmn 5.96 Each sublist represents a cluster. I wish to select the i.d. from each sublist with the highest number associated with it, append that i.d. to a new list and ultimately write it to a new file. What data structure should the file with numbers be read in as? Also, how would you iterate over said data structure to return the i.d. with the highest number that matches the i.d. within a sublist? Thanks, S :-)

    Read the article

  • Why do we need Web-Api? [closed]

    - by user437973
    I was just wondering what the deal is with Asp.net Web-Api. Why did we need a separate type of controller in order to facilitate varying content types for action results? Why wasn't this capability just baked into the ASP.Net MVC base controller? Anyway, I was just wondering if there was a compelling reason to use both types of controllers within the same project, assuming that the project was being freshly created, or if this project structure was due to an inherent technical limitation. Would it be possible to have ApiControllers fulfill the purpose of an MVC Controller in all cases by just serving HTML when that is the specified accept type? It just seems to me like a lot of unnecessary repetition to have to re-implement the same types of actions using both types of controllers if you want those actions to be available to your web application through the API and through the web interface.

    Read the article

  • question abouut string sort

    - by davit-datuashvili
    i have question from programming pearls problem is following show how to use lomuto's partitioning scheme to sort varying length bit strings in time proportional to the sum oof their length and algorithm is following each record in x[0..n-1] has an integer length and pointer to the array bit[0..length-1] code void bsort(l,u,depth){ if (l>=u) return; for (int i=l;i<u;i++) if (x[i].length<depth) swap(i,l++); m=l; if (x[i].bit[depth] ==0) swap(i,m++); bsort(l,m-1,depth+1); bsort(m,u,depth+1); please help me i need following things 1. how this algorith works 2.how implement in java?

    Read the article

  • select from multiple tables with different columns

    - by Qaiser Iftikhar
    Say I got this sql schema. Table Job: id,title, type, is_enabled Table JobFileCopy: job_id,from_path,to_path Table JobFileDelete: job_id, file_path Table JobStartProcess: job_id, file_path, arguments, working_directory There are many other tables with varying number of columns and they all got foreign key job_id which is linked to id in table Job. My questions: Is this the right approach? I don't have requirement to delete anything at anytime. I will require to select and insert mostly. Secondly, what is the best approach to get the list of jobs with relevant details from all the different tables in a single database hit? e.g I would like to select top 20 jobs with details, their details can be in any table (depends on column type in table Job) which I don't know until runtime. Thanks in advance. Regards,

    Read the article

  • func_get_args detect context

    - by Steve
    I have a script where it accepts a varying number of arguments. I want to use func_get_args to perform operations on said arguments. If I have one function like this: function Something() { foreach(func_get_args($this) as $functions) { // Do something } // Return.. } I want to be able to call this function in, for example, another function to add/save entries. The add/save function would have arguments 'title', 'description' etc.. I basically want to know if there is a way to detect the context of a function call. Can I pass something to func_get_args that will let it know that its called in a certain function? So if I do: function Save($title, $desc) { $vars = $this->Something(); } I want $vars to contain $title and $desc after modifying them.

    Read the article

  • The *right* JSON content type?

    - by Oli
    Right I've been messing around with JSON for some time, just pushing it out as text and it hasn't hurt anybody (I know of), but I'd like to start doing things properly. I have seen so many purported "standards" for the JSON content type: application/json application/x-javascript text/javascript text/x-javascript text/x-json But which is right? Or best? I gather that there are security and browser support issues varying between them... (I know there's a similar question, What MIME type if JSON is being returned by a REST API?, but I'd like a slightly more targeted answer.)

    Read the article

  • UiScrollView with scrolling content

    - by objektivs
    I have a detail page of type UIScrollView. On it I want an optional UIImageView and a mandatory UITextView. If no image is available then the image view should not take any space. The text for the text view can be of varying sizes. When the view is loaded with, say, the image and the text I need to be able to scroll through all the contents. So the image slips off the top of the screen. I just can't get this work and I feel it ought to be easy. Any ideas?

    Read the article

  • Distribution of many small classes

    - by Moo-Juice
    Hi All, I have a base class called EventArgs. Derived from this are many, many specializations that represent event arguments for a particular kind of event. Consumers of these events may need some, many, or very few of these argument classes. My question is, would you provide a header file for each type (e.g, 50+ header files for the varying ones), would you try to group them in to families and have a 'common' header file for those, or would you throw caution to the window and throw them in to one easy-of-use header file that can just be included? Another approach might be to have 50 header files, and then I could introduce some "family" header files that included particular ones. Not sure about the naming conventions for these kinds of things so it is obvious what is where. I know there may not be a hard and fast rule, but wondering what other developers have done when they find themselves writing many little classes. Thanks in advance.

    Read the article

  • how to dynamically (re)position an element according to the bottom of the page using JS / Jquery?

    - by jon
    Hi All, the back story: i have a tab section on a page which when navigated through displays sections (divs) of varying height. the result, is that certain inputs (which are strangely positioned for reasons i can't change) on this page reposition themselves problematically. the proposed solution: as the page height changes, have these problem inputs repositioned according to the page bottom (from which their appropriate distances are always a constant). what i'm thinking is that i need some js that does something like, page height change triggers input position from bottom to = x. there are two inputs if that's at all relevant. :) if only there was css for this (i know there is under normal circumstances, but trust me -- not in this case). thanks for your time & help i've been struggling with this for weeks!

    Read the article

  • cocos2dx - Custom Fragment Shader and CCRenderTexture

    - by saiy2k
    I have a CCRenderTexture that is filled with a sprite when the scene is loaded, as follows, canvas = CCRenderTexture::create(this->getContentSize().width, this->getContentSize().height); canvas->setPosition(data->position); canvas->beginWithClear(0.0, 0.0, 0.0, 0); this->visit(); canvas->end(); The above code is written within a class, which derives from CCSprite (Hence this). Then, in another function applyShader(), I create a sprite named splat, from the texture of CCRenderTexture *canvas. Thus splat will contain the whole texture of canvas. Now I apply a custom fragment shader to the splat by calling the function splat->renderShader(), which will modify some small portion of the whole texture. Then I draw the modified texture back to the CCRenderTexture *canvas. Hence, applyShader() will * take a texture from CCRenderTexture, * create a sprite based on it, * apply a fragment shader to it * and draw the modified texture back to CCRenderTexture. This applyShader() will be called repetitively and its code is as follows: splat = Splat::createWithTexture(art->canvas->getSprite()->getTexture()); splat->renderShader(); art->canvas->begin(); splat->visit(); art->canvas->end(); My shader code is (nothing fancy) precision mediump float; varying vec2 v_texCoord; uniform sampler2D u_texture; uniform sampler2D u_colorRampTexture; uniform float params[5]; void main() { gl_FragColor = texture2D(u_texture, v_texCoord); return; } So, with the above code I expect the original sprite this to get rendered over and over again without any visual changes. But on each call to applyShader(), the texture is getting stretched a little and the stretched image is getting rendered. After some 10 calls, the image gets so distorted. Can someone please tell me where I am going wrong? Thanks :-) PS: All code shown here is partial, not complete code. Edit: Adding Screens Update: The problem has nothing to do with shaders it seems. It happens even when I dont call renderShader(). The actual lines of code is: splat = Splat::createWithTexture(art->canvas->getSprite()->getTexture()); splat->setPosition( ccp( art->getContentSize().width * 0.5, art->getContentSize().height * 0.5 ) ); splat->setFlipY(true); art->canvas->begin(); splat->visit(); art->canvas->end();

    Read the article

  • Oracle VM Deep Dives

    - by rickramsey
    "With IT staff now tasked to deliver on-demand services, datacenter virtualization requirements have gone beyond simple consolidation and cost reduction. Simply provisioning and delivering an operating environment falls short. IT organizations must rapidly deliver services, such as infrastructure-as-a-service (IaaS), platform-as-a-service (PaaS), and software-as-a-service (SaaS). Virtualization solutions need to be application-driven and enable:" "Easier deployment and management of business critical applications" "Rapid and automated provisioning of the entire application stack inside the virtual machine" "Integrated management of the complete stack including the VM and the applications running inside the VM." Application Driven Virtualization, an Oracle white paper That was published in August of 2011. The new release of Oracle VM Server delivers significant virtual networking performance improvements, among other things. If you're not sure how virtual networks work or how to use them, these two articles by Greg King and friends might help. Looking Under the Hood at Virtual Networking by Greg King Oracle VM Server for x86 lets you create logical networks out of physical Ethernet ports, bonded ports, VLAN segments, virtual MAC addresses (VNICs), and network channels. You can then assign channels (or "roles") to each logical network so that it handles the type of traffic you want it to. Greg King explains how you go about doing this, and how Oracle VM Server for x86 implements the network infrastructure you configured. He also describes how the VM interacts with paravirtualized guest operating systems, hardware virtualized operating systems, and VLANs. Finally, he provides an example that shows you how it all looks from the VM Manager view, the logical view, and the command line view of Oracle VM Server for x86. Fundamental Concepts of VLAN Networks by Greg King and Don Smerker Oracle VM Server for x86 supports a wide range of options in network design, varying in complexity from a single network to configurations that include network bonds, VLANS, bridges, and multiple networks connecting the Oracle VM servers and guests. You can create separate networks to isolate traffic, or you can configure a single network for multiple roles. Network design depends on many factors, including the number and type of network interfaces, reliability and performance goals, the number of Oracle VM servers and guests, and the anticipated workload. The Oracle VM Manager GUI presents four different ways to create an Oracle VM network: Bonds and ports VLANs Both bond/ports and VLANS A local network This article focuses the second option, designing a complex Oracle VM network infrastructure using only VLANs, and it steps through the concepts needed to create a robust network infrastructure for your Oracle VM servers and guests. More Resources Virtual Networking for Dummies Download Oracle VM Server for x86 Find technical resources for Oracle VM Server for x86 -Rick Follow me on: Blog | Facebook | Twitter | Personal Twitter | YouTube | The Great Peruvian Novel

    Read the article

  • How do you structure computer science University notes?

    - by Sai Perchard
    I am completing a year of postgraduate study in CS next semester. I am finishing a law degree this year, and I will use this to briefly explain what I mean when I refer to the 'structure' of University notes. My preferred structure for authoring law notes: Word Two columns 0.5cm margins (top, right, bottom, middle, left) Body text (10pt, regular), 3 levels of headings (14/12/10pt, bold), 3 levels of bulleted lists Color A background for cases Color B background for legislation I find that it's crucial to have a good structure from the outset. My key advice to a law student would be to ensure styles allows cases and legislation to be easily identified from supporting text, and not to include too much detail regarding the facts of cases. More than 3 levels of headings is too deep. More than 3 levels of a bulleted list is too deep. In terms of CS, I am interested in similar advice; for example, any strategies that have been successfully employed regarding structure, and general advice regarding note taking. Has latex proved better than Word? Code would presumably need to be stylistically differentiated, and use a monospaced font - perhaps code could be written in TextMate so that it could be copied to retain syntax highlighting? (Are notes even that useful in a CS degree? I am tempted to simply use a textbook. They are crucial in law.) I understand that different people may employ varying techniques and that people will have personal preferences, however I am interested in what these different techniques are. Update Thank you for the responses so far. To clarify, I am not suggesting that the approach should be comparable to that I employ for law. I could have been clearer. The consensus so far seems to be - just learn it. Structure of notes/notes themselves are not generally relevant. This is what I was alluding to when I said I was just tempted to use a textbook. Re the comment that said textbooks are generally useless - I strongly disagree. Sure, perhaps the recommended textbook is useless. But if I'm going to learn a programming language, I will (1) identify what I believe to be the best textbook, and (2) read it. I was unsure if the combination of theory with code meant that lecture notes may be a more efficient way to study for an exam. I imagine that would depend on the subject. A subject specifically on a programming language, reading a textbook and coding would be my preferred approach. But I was unsure if, given a subject containing substantive theory that may not be covered in a single textbook, people may have preferences regarding note taking and structure.

    Read the article

  • iOS - pass UIImage to shader as texture

    - by martin pilch
    I am trying to pass UIImage to GLSL shader. The fragment shader is: varying highp vec2 textureCoordinate; uniform sampler2D inputImageTexture; uniform sampler2D inputImageTexture2; void main() { highp vec4 color = texture2D(inputImageTexture, textureCoordinate); highp vec4 color2 = texture2D(inputImageTexture2, textureCoordinate); gl_FragColor = color * color2; } What I want to do is send images from camera and do multiply blend with texture. When I just send data from camera, everything is fine. So problem should be with sending another texture to shader. I am doing it this way: - (void)setTexture:(UIImage*)image forUniform:(NSString*)uniform { CGSize sizeOfImage = [image size]; CGFloat scaleOfImage = [image scale]; CGSize pixelSizeOfImage = CGSizeMake(scaleOfImage * sizeOfImage.width, scaleOfImage * sizeOfImage.height); //create context GLubyte * spriteData = (GLubyte *)malloc(pixelSizeOfImage.width * pixelSizeOfImage.height * 4 * sizeof(GLubyte)); CGContextRef spriteContext = CGBitmapContextCreate(spriteData, pixelSizeOfImage.width, pixelSizeOfImage.height, 8, pixelSizeOfImage.width * 4, CGImageGetColorSpace(image.CGImage), kCGImageAlphaPremultipliedLast); //draw image into context CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, pixelSizeOfImage.width, pixelSizeOfImage.height), image.CGImage); //get uniform of texture GLuint uniformIndex = glGetUniformLocation(__programPointer, [uniform UTF8String]); //generate texture GLuint textureIndex; glGenTextures(1, &textureIndex); glBindTexture(GL_TEXTURE_2D, textureIndex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //create texture glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixelSizeOfImage.width, pixelSizeOfImage.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, spriteData); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textureIndex); //"send" to shader glUniform1i(uniformIndex, 1); free(spriteData); CGContextRelease(spriteContext); } Uniform for texture is fine, glGetUniformLocation function do not returns -1. The texture is PNG file of resolution 2000x2000 pixels. PROBLEM: When the texture is passed to shader, I have got "black screen". Maybe problem are parameters of the CGContext or parameters of the function glTexImage2D Thank you

    Read the article

  • Naming Convention for Dedicated Thread Locking objects

    - by Chris Sinclair
    A relatively minor question, but I haven't been able to find official documentation or even blog opinion/discussions on it. Simply put: when I have a private object whose sole purpose is to serve for private lock, what do I name that object? class MyClass { private object LockingObject = new object(); void DoSomething() { lock(LockingObject) { //do something } } } What should we name LockingObject here? Also consider not just the name of the variable but how it looks in-code when locking. I've seen various examples, but seemingly no solid go-to advice: Plenty of usages of SyncRoot (and variations such as _syncRoot). Code Sample: lock(SyncRoot), lock(_syncRoot) This appears to be influenced by VB's equivalent SyncLock statement, the SyncRoot property that exists on some of the ICollection classes and part of some kind of SyncRoot design pattern (which arguably is a bad idea) Being in a C# context, not sure if I'd want to have a VBish naming. Even worse, in VB naming the variable the same as the keyword. Not sure if this would be a source of confusion or not. thisLock and lockThis from the MSDN articles: C# lock Statement, VB SyncLock Statement Code Sample: lock(thisLock), lock(lockThis) Not sure if these were named minimally purely for the example or not Kind of weird if we're using this within a static class/method. Several usages of PadLock (of varying casing) Code Sample: lock(PadLock), lock(padlock) Not bad, but my only beef is it unsurprisingly invokes the image of a physical "padlock" which I tend to not associate with the abstract threading concept. Naming the lock based on what it's intending to lock Code Sample: lock(messagesLock), lock(DictionaryLock), lock(commandQueueLock) In the VB SyncRoot MSDN page example, it has a simpleMessageList example with a private messagesLock object I don't think it's a good idea to name the lock against the type you're locking around ("DictionaryLock") as that's an implementation detail that may change. I prefer naming around the concept/object you're locking ("messagesLock" or "commandQueueLock") Interestingly, I very rarely see this naming convention for locking objects in code samples online or on StackOverflow. Question: What's your opinion generally about naming private locking objects? Recently, I've started naming them ThreadLock (so kinda like option 3), but I'm finding myself questioning that name. I'm frequently using this locking pattern (in the code sample provided above) throughout my applications so I thought it might make sense to get a more professional opinion/discussion about a solid naming convention for them. Thanks!

    Read the article

  • Java Certification Exams and Their Move to Pearson VUE

    - by Harold Green
    You may be aware that Oracle recently migrated all Sun-branded certification exams from Prometric to Pearson VUE. Below are answers to some frequently-asked questions that we've been getting recently: What changes to the exams should I be aware of?Only minor changes were made to the exams during the transition to Pearson VUE: Renumbering of all exams to the Oracle exam numbering structure (i.e. 1Z0...). Most exam score reports were enhanced to provide more detailed feedback. Score reports now list every exam objective for which a question (or questions) were answered incorrectly. The previous format provided only section-level performance feedback. For three Java exams, some lengthy (time-consuming) questions were removed & replaced with shorter (less time-consuming) questions. This was done in order to shorten the required exam time (to 150 minutes). Some interactive question types were removed from several Java and Solaris exams (including "matching" and "drag-and-drop" questions). The passing scores (for the exams that were revised) were statistically adjusted to make them equal to their prior passing scores, thus ensuring that the exams maintained the same level of difficulty as before. The exam objectives and the exam questions themselves did not change. Candidates should study the same material and objectives. Are there also new testing practices I should be aware of?Oracle follows a common industry practice of placing occasional un-scored questions on our certification exams. Candidates will not know which questions are unscored. At the time of this blog post, only one of the migrated exams (1Z0-898) contains unscored questions.I started the Master certification path through Prometric, and now I need to complete the requirements through Pearson VUE. Where can I get guidance on this process?Visit our Vendor Transition FAQs to find comprehensive instructions. Oracle has created several specific paths to accommodate candidates who were at at varying stages of completion of their master path when the transition occurred. Make sure to follow the specific path designed for your case, as you will need to know which exam number to select in order to submit/re-submit your requirements. QUICK LINKS Oracle Certification Blog Post: Java, Oracle Solaris, MySQL and Other Former Sun Certification Exams Now Being Delivered At Pearson VUE Oracle Certification Website: Vendor Transition Announcement

    Read the article

  • Using Oracle BPM to Extend Oracle Applications

    - by Michelle Kimihira
    Author: Srikant Subramaniam, Senior Principal Product Manager, Oracle Fusion Middleware Customers often modify applications to meet their specific business needs - varying regulatory requirements, unique business processes, product mix transition, etc. Traditional implementation practices for such modifications are typically invasive in nature and introduce risk into projects, affect time-to-market and ease of use, and ultimately increase the costs of running and maintaining the applications. Another downside of these traditional implementation practices is that they literally cast the application in stone, making it difficult for end-users to tailor their individual work environments to meet specific needs, without getting IT involved. For many businesses, however, IT lacks the capacity to support such rapid business changes. As a result, adopting innovative solutions to change the economics of customization becomes an imperative rather than a choice. Let's look at a banking process in Siebel Financial Services and Oracle Policy Automation (OPA) using Oracle Business Process Management. This approach makes modifications simple, quick to implement and easy to maintain/upgrade. The process model is based on the Loan Origination Process Accelerator, i.e., a set of ready to deploy business solutions developed by Oracle using Business Process Management (BPM) 11g, containing customizable and extensible pre-built processes to fit specific customer requirements. This use case is a branch-based loan origination process. Origination includes a number of steps ranging from accepting a loan application, applicant identity and background verification (Know Your Customer), credit assessment, risk evaluation and the eventual disbursal of funds (or rejection of the application). We use BPM to model all of these individual tasks and integrate (via web services) with: Siebel Financial Services and (simulated) backend applications: FLEXCUBE for loan management, Background Verification and Credit Rating. The process flow starts in Siebel when a customer applies for loan, switches to OPA for eligibility verification and product recommendations, before handing it off to BPM for approvals. OPA Connector for Siebel simplifies integration with Siebel’s web services framework by saving directly into Siebel the results from the self-service interview. This combination of user input and product recommendation invokes the BPM process for loan origination. At the end of the approval process, we update Siebel and the financial app to complete the loop. We use BPM Process Spaces to display role-specific data via dashboards, including the ability to track the status of a given process (flow trace). Loan Underwriters have visibility into the product mix (loan categories), status of loan applications (count of approved/rejected/pending), volume and values of loans approved per processing center, processing times, requested vs. approved amount and other relevant business metrics. Summary Oracle recommends the use of Fusion Middleware as an extensions platform for applications. This approach makes modifications simple, quick to implement and easy to maintain/upgrade applications (by moving customizations away from applications to the process layer). It is also easier to manage processes that span multiple applications by using Oracle BPM. Additional Information Product Information on Oracle.com: Oracle Fusion Middleware Follow us on Twitter and Facebook Subscribe to our regular Fusion Middleware Newsletter

    Read the article

  • "sr0" I/O read boot error in Xubuntu 12.10

    - by Entropicurity
    Just recently upgraded Xubuntu 12.10 after having installed 12.04 originally. Ever since that happened, any time I inserted a disk into my DVD/CD reader/writer I would end up getting a number of error messages from my DVD player/Audio player softer, typically with any of them either crashing or returning a GStreamer backend error. So doing some research I tried to mount it manually, and it typically returned the error messages you'll see below: (using the dmesg | grep "sr0" command) [17545.435584] end_request: I/O error, dev sr0, sector 0 [17545.492968] sr 3:0:0:0: >[sr0] [17545.492981] sr 3:0:0:0: >[sr0] [17545.492992] sr 3:0:0:0: >[sr0] [17545.493003] sr 3:0:0:0: >[sr0] CDB: [17545.493020] end_request: I/O error, dev sr0, sector 0 [17545.493058] EXT3-fs (sr0): error: unable to read superblock [17545.553224] sr 3:0:0:0: >[sr0] [17545.553237] sr 3:0:0:0: >[sr0] [17545.553247] sr 3:0:0:0: >[sr0] [17545.553258] sr 3:0:0:0: >[sr0] CDB: [17545.553275] end_request: I/O error, dev sr0, sector 0 [17545.553312] EXT4-fs (sr0): unable to read superblock [17545.611482] sr 3:0:0:0: >[sr0] [17545.611494] sr 3:0:0:0: >[sr0] [17545.611504] sr 3:0:0:0: >[sr0] [17545.611514] sr 3:0:0:0: >[sr0] CDB: [17545.611531] end_request: I/O error, dev sr0, sector 0 [17545.611568] FAT-fs (sr0): unable to read boot sector When I grepped this, the number of error messages just seemed to spill all over the screen, and typically all revolve around the I/O error. I then went into VLC and tried to run the stuff through there, but for some reason it won't read with the default devices. Instead I have to manually input sr0 into each of the /dev/ references and it will play just fine, until I exit out of the program, at which point I have to re-input everything. I have already installed all the media dependencies, both open source and restricted, through the software center. I just found this strange, as out of the box 12.04 there wasn't any problem what so ever. At this point, it could be that all my audio CD's are not in a format that is familiar with the OS (I've read in some places that EXTF4 has issues with this) but I don't see how that could be a problem when the above error messages even tested to see if it is EXT3 as well? I've tried my best to troubleshoot this up till now using existing topics, but it seems that this is a regular problem with a multitude of varying factors that incorporate into it, including but not limited to read/write problems with the format of the CD and right protection. Is there something integral that I am missing?

    Read the article

  • Producing a smooth mesh from density cloud and marching cubes

    - by Wardy
    Based on my results from this question I decided to build myself a 3D noise map containing float values in place of my existing boolean point values. The effect I'm trying to produce is something like this, rather than typical rolling hills; which should explain the "missing cubes" in the image below. If I render my density map in normal "minecraft mode" (1 block per point in the density map) varying the size of the cube based on the value in my density map (floats in the range 0 to 1) I get something like this: I'm now happy that I can produce a density map for the marching cubes algorithm (which will need a little tweaking) but for some reason when I run it through my implementation it's not producing what I expect. My problem is that I'm getting something like the first image in this answer to my previous question, when I want to achieve the effect in the second image. Upon further investigation I can't see how marching cubes does the "move vertex along the edge" type logic (i.e. the difference between the two images on my previous link). I see that it does do some interpolation, but I'm not convinced I have the correct understanding of what I think it should do, because the code in question appears to give the same result regardless of whether I use boolean or float values. I took the code from here which is a C# implementation of marching cubes, but instead of using the MarchingCubesPrimitive I modified it to accept an object of type IDrawable, containing lists for the various collections (vertices, normals, UVs, indices), the logic was otherwise untouched. My understanding is that given a very low isovalue the accuracy level of the surface being rendered should increase, so in short "less 45 degree slows more rolling hills" type mesh output. However this isn't what I'm seeing. Have I missed something or is the implementation flawed and need to be fixed? EDIT: A little more detail on what I am seeing when I "marching cube" the data. Ok so firstly, ignore the fact that the meshes created by the chunks don't "connect" (i'll probably raise another question about this later). Then look at the shaping of the island, it's too ... square, from the voxels rendered as boxes you get the impression there's a clean soft gradual hill and yet from the image there are sharp falling edges even in the most central areas where the gradient in the first image looks the most smooth. The data is "regenerated" each time I run this so no 2 islands come out the same, and it's purely random so not based on noise, but still, how can it look so smooth in 1 image and so not smooth in the other?

    Read the article

  • Why do some user agents have spam urls in them?

    - by Erx_VB.NExT.Coder
    If you go to (say) the last 100 entries (visits) to the botsvsbrowsers.com website (exact link, feel free to take a look: http://www.botsvsbrowsers.com/recent/listings/index.html ), you'd notice that almost every User Agent that has the keywords "Opera" and "Presto" inside them, will almost certainly have a web link (URL/Web Address) inside it, and it won't just be a normal web address, but a HTML anchor tag/link to that address. Why is this so, I could not even find a single discussion about it on the internet, nowhere, I tried varying my search terms many times. If the user agent contains the words "Opera" and "Presto" it doesnt mean it will have this weblink, but it means there is about an 80% change that it will. A typical anchor tag/link inside a user agent will look like this: Mozilla/4.0 <a href="http://osis-uk.co.uk/disabled-equipment">disability equipment</a> (Windows NT 5.1; U; en) Presto/2.10.229 Version/11.60 If you check it out at the website, http://www.botsvsbrowsers.com/recent/listings/index.html you will notice that the back and forward arrows are in there unescaped format. This isn't just true for botsvsbrowsers, but several other user agent listing sites. I'm really confused and feel line I'm in a room full of 10,000 people and am the only one seeing this ghost :). If I'm doing statistical analysis, should I include or exclude this type of user agent from my listing (ie: are these just normal users who've set their user agents to attempt to drive some traffic to their sites as they browser the web), or is there something else going on? The fact that it is so consistent in terms of its format leads me to believe that it is an automated process (the setting or alteration of the user agent) so I cannot decide or understand the process by which this change is made (I know how to change a user agent), but unsure which program or facility is doing this, especially since it is exclusive to Opera (Presto) user agents that are beyond I think an 8 or 9 point something browser version. I've run some statistical tests, parsing entries from all over the place, writing custom programs, to get a better understanding of this. Keep in mind that I see normal URL's in user agents infrequently, they are just text such as +http://www.someSite.com appended to a user agent normally, especially if its a crawler or bot it provided its service URL, this is normal and isnt done with an embedded link (A HREF=) etc, so I'm not talking about "those".

    Read the article

  • Subterranean IL: Volatile

    - by Simon Cooper
    This time, we'll be having a look at the volatile. prefix instruction, and one of the differences between volatile in IL and C#. The volatile. prefix volatile is a tricky one, as there's varying levels of documentation on it. From what I can see, it has two effects: It prevents caching of the load or store value; rather than reading or writing to a cached version of the memory location (say, the processor register or cache), it forces the value to be loaded or stored at the 'actual' memory location, so it is then immediately visible to other threads. It forces a memory barrier at the prefixed instruction. This ensures instructions don't get re-ordered around the volatile instruction. This is slightly more complicated than it first seems, and only seems to matter on certain architectures. For more details, Joe Duffy has a blog post going into the details. For this post, I'll be concentrating on the first aspect of volatile. Caching field accesses To demonstrate this, I created a simple multithreaded IL program. It boils down to the following code: .class public Holder { .field public static class Holder holder .field public bool stop .method public static specialname void .cctor() { newobj instance void Holder::.ctor() stsfld class Holder Holder::holder ret }}.method private static void Main() { .entrypoint // Thread t = new Thread(new ThreadStart(DoWork)) // t.Start() // Thread.Sleep(2000) // Console.WriteLine("Stopping thread...") ldsfld class Holder Holder::holder ldc.i4.1 stfld bool Holder::stop call instance void [mscorlib]System.Threading.Thread::Join() ret}.method private static void DoWork() { ldsfld class Holder Holder::holder // while (!Holder.holder.stop) {} DoWork: dup ldfld bool Holder::stop brfalse DoWork pop ret} If you compile and run this code, you'll find that the call to Thread.Join() never returns - the DoWork spinlock is reading a cached version of Holder.stop, which is never being updated with the new value set by the Main method. Adding volatile to the ldfld fixes this: dupvolatile.ldfld bool Holder::stopbrfalse DoWork The volatile ldfld forces the field access to read direct from heap memory, which is then updated by the main thread, rather than using a cached copy. volatile in C# This highlights one of the differences between IL and C#. In IL, volatile only applies to the prefixed instruction, whereas in C#, volatile is specified on a field to indicate that all accesses to that field should be volatile (interestingly, there's no mention of the 'no caching' aspect of volatile in the C# spec; it only focuses on the memory barrier aspect). Furthermore, this information needs to be stored within the assembly somehow, as such a field might be accessed directly from outside the assembly, but there's no concept of a 'volatile field' in IL! How this information is stored with the field will be the subject of my next post.

    Read the article

  • Live CD has black screen HP DV6

    - by Shaun Killingbeck
    Attempting to install/try ubuntu (11.10, 12.04) on my new laptop, using a liveCD (and tried USB). I get the purple screen (with the man/keyboard at the bottom) and after that the screen flashes bright white before going black. Ubuntu continues to load in the background, with login sound etc but the screen is off. I have tried as many different solutions as I could find including: using nomodestep, xforcevesa, i915.modeset=0, and also now i915.modeset=1 in boot options (seperately): varying consequences, but either I end up at a blinking cursor with no prompt, a command line (startx fails: no screen found), or the original blank screen again Tried booting from VirtualBox - it crashes at the same place the screen would go blank when using a CD/USB tried 11.04: I don't have this problem BUT when trying to install, I get a ubi-partman error 141 (possibly down to the three partitions that came on my laptop... not sure why HP needed there own separate partition for HP Tools...) Model: HP Pavillion DV6 6B08SA Processor: AMD Quad-Core A6-3410MX APU with Radeon HD 6545G2 Dual Graphics (1.6 GHZ 4 MB L2 cache ) Chipset: AMD RS880M Any help would be greatly appreciated. I just want to be able to partition the drive and install Ubuntu. I'm assuming the issue is graphics card related, although I have no confirmation of that. Update: Tried the ?orkarounds on https://wiki.ubuntu.com/X/Troubleshooting/BlankScreen - set gfxpayload=text changed nothing, removing splash did nothing and setting vesafb.nonsense=1 did nothing either. I'd like to be able to collect some log information somehow, but I can't get to a command line from the liveCD. tried using the latest 12.04 beta, same issue tried nomodeset without splash or quiet. get the following (tail of) output before it freezes on that screen: * Starting configure network device security [OK] * Starting configure network device [OK] [ 25.720899] ieee80211 phy0: w1_ops_config: change monitor mode: false (implement) [ 25.720923] ieee80211 phy0: w1_ops_config: change power-save mode: false (implement) * Starting restore sound card(s') mixer state(s) [fail] [ 25.721849] ieee80211 phy0: w1_ops_bss_info_changed: qos enabled: false (implement) * Stopping save kernel messages [OK] * Starting bluetooth [OK] * PulseAudio configured for per-user sessions saned disabled; edit /etc/default/saned [ 25.988016] hci_cmd_timer: hci0 command tx timeout [ 26.207225] bad LUN (0:1) [ 26.223735] bad target number (1:0) [ 26.252111] bad target number (2:0) [ 26.272170] bad target number (3:0) [ 26.300154] bad target number (4:0) [ 26.328162] bad target number (5:0) [ 26.344180] bad target number (6:0) [ 26.368142] bad target number (7:0) * Checking battery state... [OK] * Stopping System V runlevel capability [OK] Does this give any indication of the problem? the false (implement) messages also reappear when I press the power button to ask it to shutdown, followed by a [fail] status for killing remaining processes.

    Read the article

  • cocos2d-x simple shader usage [on hold]

    - by Narek
    I want to obtain color ramp effect from this tutorial: http://www.raywenderlich.com/10862/how-to-create-cool-effects-with-custom-shaders-in-opengl-es-2-0-and-cocos2d-2-x Here is my code in cocos2d-x 3: bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } Vec2 origin = Director::getInstance()->getVisibleOrigin(); sprite = Sprite::create("HelloWorld.png"); sprite->setAnchorPoint(Vec2(0, 0)); sprite->setRotation(3); sprite->setPosition(origin); addChild(sprite); std::string str = FileUtils::getInstance()->getStringFromFile("CSEColorRamp.fsh"); const GLchar * fragmentSource = str.c_str(); GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureA8Color_vert, fragmentSource); p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD); p->link(); p->updateUniforms(); sprite->setGLProgram(p); // 3 colorRampUniformLocation = glGetUniformLocation(sprite->getGLProgram()->getProgram(), "u_colorRampTexture"); glUniform1i(colorRampUniformLocation, 1); // 4 colorRampTexture = Director::getInstance()->getTextureCache()->addImage("colorRamp.png"); colorRampTexture->setAliasTexParameters(); // 5 sprite->getGLProgram()->use(); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, colorRampTexture->getName()); glActiveTexture(GL_TEXTURE0); return true; } And here is the fragment shader as it is in the tutorial: #ifdef GL_ES precision mediump float; #endif // 1 varying vec2 v_texCoord; uniform sampler2D u_texture; uniform sampler2D u_colorRampTexture; void main() { // 2 vec3 normalColor = texture2D(u_texture, v_texCoord).rgb; // 3 float rampedR = texture2D(u_colorRampTexture, vec2(normalColor.r, 0)).r; float rampedG = texture2D(u_colorRampTexture, vec2(normalColor.g, 0)).g; float rampedB = texture2D(u_colorRampTexture, vec2(normalColor.b, 0)).b; // 4 gl_FragColor = vec4(rampedR, rampedG, rampedB, 1); } As a result I get a black screen with 2 draw calls. What is wrong? Do I miss something?

    Read the article

  • Masking OpenGL texture by a pattern

    - by user1304844
    Tiled terrain. User wants to build a structure. He presses build and for each tile there is an "allow" or "disallow" tile sprite added to the scene. FPS drops right away, since there are 600+ tiles added to the screen. Since map equals screen, there is no scrolling. I came to an idea to make an allow grid covering the whole map and mask the disallow fields. Approach 1: Create allow and disallow grid textures. Draw a polygon on screen. Pass both textures to the fragment shader. Determine the position inside the polygon and use color from allowTexture if the fragment belongs to the allow field, disallow otherwise Problem: How do I know if I'm on the field that isn't allowed if I cannot pass the matrix representing the map (enum FieldStatus[][] (Allow / Disallow)) to the shader? Therefore, inside the shader I don't know which fragments should be masked. Approach 2: Create allow texture. Create an empty texture buffer same size as the allow texture Memset the pixels of the empty texture to desired color for each pixel that doesn't allow building. Draw a polygon on screen. Pass both textures to the fragment shader. Use texture2 color if alpha 0, texture1 color otherwise. Problem: I'm not sure what is the right way to manipulate pixels on a texture. Do I just make a buffer with width*height*4 size and memcpy the color[] to desired coordinates or is there anything else to it? Would I have to call glTexImage2D after every change to the texture? Another problem with this approach is that it takes a lot more work to get a prettier effect since I'm manipulating the color pixels instead of just masking two textures. varying vec2 TexCoordOut; uniform sampler2D Texture1; uniform sampler2D Texture2; void main(void){ vec4 allowColor = texture2D(Texture1, TexCoordOut); vec4 disallowColor = texture2D(Texture2, TexCoordOut); if(disallowColor.a > 0){ gl_FragColor= disallowColor; }else{ gl_FragColor= allowColor; }} I'm working with OpenGL on Windows. Any other suggestion is welcome.

    Read the article

  • Finding furthermost point in game world

    - by user13414
    I am attempting to find the furthermost point in my game world given the player's current location and a normalized direction vector in screen space. My current algorithm is: convert player world location to screen space multiply the direction vector by a large number (2000) and add it to the player's screen location to get the distant screen location convert the distant screen location to world space create a line running from the player's world location to the distant world location loop over the bounding "walls" (of which there are always 4) of my game world check whether the wall and the line intersect if so, where they intersect is the furthermost point of my game world in the direction of the vector Here it is, more or less, in code: public Vector2 GetFurthermostWorldPoint(Vector2 directionVector) { var screenLocation = entity.WorldPointToScreen(entity.Location); var distantScreenLocation = screenLocation + (directionVector * 2000); var distantWorldLocation = entity.ScreenPointToWorld(distantScreenLocation); var line = new Line(entity.Center, distantWorldLocation); float intersectionDistance; Vector2 intersectionPoint; foreach (var boundingWall in entity.Level.BoundingWalls) { if (boundingWall.Intersects(line, out intersectionDistance, out intersectionPoint)) { return intersectionPoint; } } Debug.Assert(false, "No intersection found!"); return Vector2.Zero; } Now this works, for some definition of "works". I've found that the further out my distant screen location is, the less chance it has of working. When digging into the reasons why, I noticed that calls to Viewport.Unproject could result in wildly varying return values for points that are "far away". I wrote this stupid little "test" to try and understand what was going on: [Fact] public void wtf() { var screenPositions = new Vector2[] { new Vector2(400, 240), new Vector2(400, -2000), }; var viewport = new Viewport(0, 0, 800, 480); var projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, viewport.Width / viewport.Height, 1, 200000); var viewMatrix = Matrix.CreateLookAt(new Vector3(400, 630, 600), new Vector3(400, 345, 0), new Vector3(0, 0, 1)); var worldMatrix = Matrix.Identity; foreach (var screenPosition in screenPositions) { var nearPoint = viewport.Unproject(new Vector3(screenPosition, 0), projectionMatrix, viewMatrix, worldMatrix); var farPoint = viewport.Unproject(new Vector3(screenPosition, 1), projectionMatrix, viewMatrix, worldMatrix); Console.WriteLine("For screen position {0}:", screenPosition); Console.WriteLine(" Projected Near Point = {0}", nearPoint.TruncateZ()); Console.WriteLine(" Projected Far Point = {0}", farPoint.TruncateZ()); Console.WriteLine(); } } The output I get on the console is: For screen position {X:400 Y:240}: Projected Near Point = {X:400 Y:629.571 Z:599.0967} Projected Far Point = {X:392.9302 Y:-83074.98 Z:-175627.9} For screen position {X:400 Y:-2000}: Projected Near Point = {X:400 Y:626.079 Z:600.7554} Projected Far Point = {X:390.2068 Y:-767438.6 Z:148564.2} My question is really twofold: what am I doing wrong with the unprojection such that it varies so wildly and, thus, does not allow me to determine the corresponding world point for my distant screen point? is there a better way altogether to determine the furthermost point in world space given a current world space location, and a directional vector in screen space?

    Read the article

  • Unable to ping inside or outside network with default gateway 0.0.0.0

    - by agentroadkill
    I've been around here before and I could usually piece together everything to more or less get myself up and running, but this time I'm truly stumped. I'm trying to connect my new 14.04 install to a network, and I'm forced to be behind my college's router. Now I've tested the vary cable that is right now plugged into my Ubuntu box on a Windows, Mac OS X, and even my friend's Ubuntu 14.04 box, and they all connect no problem. I've been trying to track this down for about two days, but every time I get close to it, the bug jumps to some other piece of my connection. Anyway, as it sits ifconfig -a gives: eth2 Lninkencap:Ethernet HWaddr:00:1f:bc:08:31:1d inet addr:10.32.51.51 Bcast:10.32.51.155 Mask: 255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 RX bytes:0 TX bytes:0 as well as the local loopback, but I'm assuming that is not an issue here. sudo dhclient -v eth2 returns: Listening on LPF/<hardware address of my integrated NIC, above> Sending on <same> Sending on Socket/fallback DHCPREQUEST of 10.32.51.51 on eth2 to 255.255.255.255 port 67 (xid=0x6f4a66ba) <two more lines of same> DHCPDISCOVER on eth2 to 255.255.255.255 port 67 interval 3 (xid=0x156f9fb4) <many more of above with varying intervals> No DHCPOFFERS received. Trying recorded lease 10.32.51.51 RTNETLINK answers: File exists bound: renewal in <large number> seconds If I then try ping 8.8.8.8, I get: connect: Network is unreachable /etc/resolv.conf only contains the two lines telling you not to edit it, while /etc/network/interfaces only has the loopback interface block in it. I've tried commenting out the "option rfc3442" line in /etc/dhcp/dhclient.conf which seemed to fix this issue for many people, as well as adding the line send vendor-class-indentifier "MSFT5.0" to dhclient.conf as well to tell the router I'm a windows box, in case they don't like Linux. Finally, route -n reveals: Destination Gateway Genmask Flags Metric Ref Use Iface 10.32.51.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2 I would like to apologize in advance for the doubtless butchered text alignment, but I'm obviously typing this all by hand, reading from the terminal as I type commands. I'm hoping this is an interesting problem, and not something I blithely stumbled past in my (apparent) over-confidence. TIA! Quick addendum before posting: The activity light on the ethernet port are lit and one blinks during boot, but they rarely (and seemingly randomly) do so afterwards (both are dark) even while running dhclient in the foreground. When I had the Ubuntu box tethered to my MacBook earlier, I got what looked like a normal power/uplink blinking pattern, but was unable to ping one from the other.

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >