Daily Archives

Articles indexed Sunday November 25 2012

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

  • In HLSL pixel shader , why is SV_POSITION different to other semantics?

    - by tina nyaa
    In my HLSL pixel shader, SV_POSITION seems to have different values to any other semantic I use. I don't understand why this is. Can you please explain it? For example, I am using a triangle with the following coordinates: (0.0f, 0.5f) (0.5f, -0.5f) (-0.5f, -0.5f) The w and z values are 0 and 1, respectively. This is the pixel shader. struct VS_IN { float4 pos : POSITION; }; struct PS_IN { float4 pos : SV_POSITION; float4 k : LOLIMASEMANTIC; }; PS_IN VS( VS_IN input ) { PS_IN output = (PS_IN)0; output.pos = input.pos; output.k = input.pos; return output; } float4 PS( PS_IN input ) : SV_Target { // screenshot 1 return input.pos; // screenshot 2 return input.k; } technique10 Render { pass P0 { SetGeometryShader( 0 ); SetVertexShader( CompileShader( vs_4_0, VS() ) ); SetPixelShader( CompileShader( ps_4_0, PS() ) ); } } Screenshot 1: http://i.stack.imgur.com/rutGU.png Screenshot 2: http://i.stack.imgur.com/NStug.png (Sorry, I'm not allowed to post images until I have a lot of 'reputation') When I use the first statement (result is first screenshot), the one that uses the SV_POSITION semantic, the result is completely unexpected and is yellow, whereas using any other semantic will produce the expected result. Why is this?

    Read the article

  • Looking for 2D Cross platform suggestions based on requirements specified

    - by MannyG
    I am an intermediate developer with minor experience on enterprise mobile applications for iphone, android and blackberry looking to build my first ever mobile game. I did a google search for some game dev forums and this popped up so I thought I would try posting here as I lack luck elsewhere. If you have ever heard of the game for the iphone and android platform entitled avatar fight then you will have an idea of the graphic capabilities I require. Basically the battles which are automated one sprite attacking another doing cool animations but all in 2d. My buddy and I have two motivations, one is to jump into mobile Dev as my experience is limited as is his so we would like some trending knowledge (html5 would be nice to learn) . The other is to make some money on the side, don't expect much but polishing the game and putting our all will hopefully reward us a bit. We have looked into corona engine, however a lot of people are saying it is limited in the graphics department, we are open to learning new languages like lua, c++, python etc. Others we have looked at include phonegap, rhomobile, unity, and the list goes on. I really have no idea what the pros and cons of these are but for a basic battle sequence and some mini games we want to chose the right one. Some more things that we will be doing include things like card games, side scrolling flying object based games, maybe fishing stuff. We want to start small with these minigames and work our way up to the idea we would like to implement in the future. We only want to work in 2D. So with these requirements please help me chose a platform to work on (cross platform is what we are ideally leaning towards). Please feel free to throw in some pieces of advice you may have for newbie game developers like myself too. Thank you for reading!

    Read the article

  • reading a random access file

    - by user1067332
    The file I create has text in it, but when i try to read it, the output is null. here is the file the creates the text file, it creates the file and puts it in the right postion import java.util.*; import java.io.*; public class CreateCustomerFile { public static void main(String[] args) throws IOException { int pos; RandomAccessFile it = new RandomAccessFile("CustomerFile.txt", "rw"); Scanner input = new Scanner(System.in); int id; String name; int zip; final int RECORDSIZE = 100; final int NUMRECORDS = 1000; final int STOP = 99; try { for(int x = 0; x < NUMRECORDS; ++x) { it.writeInt(0); it.writeUTF(""); it.writeInt(0); } } catch(IOException e) { System.out.println("Error: " + e.getMessage()); } finally { it.close(); } it = new RandomAccessFile("CustomerFile.txt","rw"); try { System.out.print("Enter ID number" + " or " + STOP + " to quit "); id = input.nextInt(); while(id != STOP) { input.nextLine(); System.out.print("Enter last name"); name = input.nextLine(); System.out.print("Enter zipcode "); zip = input.nextInt(); pos = id - 1; it.seek(pos * RECORDSIZE); it.writeInt(id); it.writeUTF(name); it.writeInt(zip); System.out.print("Enter ID number" + " or " + STOP + " to quit "); id = input.nextInt(); } } catch(IOException e) { System.out.println("Error: " + e.getMessage()); } finally { it.close(); } } } Here is the file to read, the pos is correct but ouput always goes to the error: null. import javax.swing.*; import java.io.*; public class CustomerItemOrder { public static void main(String[] args) throws IOException { int pos; RandomAccessFile it = new RandomAccessFile("CustomerFile.txt","rw"); String inputString; int id, zip; String name; final int RECORDSIZE = 100; final int STOP = 99; inputString = JOptionPane.showInputDialog(null, "Enter id or "+ STOP + " to quit"); id = Integer.parseInt(inputString); try { while(id != STOP) { pos = id -1 ; it.seek(pos * RECORDSIZE ); id = it.readInt(); name = it.readLine(); zip = it.readInt(); JOptionPane.showMessageDialog(null, "ID:" + id + " last name is " + name + " and zipcode is " + zip); inputString = JOptionPane.showInputDialog(null, "Enter id or " + STOP + " to quit"); id = Integer.parseInt(inputString); } } catch(IOException e) { System.out.println("Error: " + e.getMessage()); } finally { it.close(); } } }

    Read the article

  • how to disable on click event

    - by user1819709
    function insertQuestion(form) { var x = "<img src='Images/plussigndisabled.jpg' width='30' height='30' alt='Look Up Previous Question' class='plusimage' name='plusbuttonrow'/><span id='plussignmsg'>(Click Plus Sign to look <br/> up Previous Questions)</span>" ; if (qnum == <?php echo (int)$_SESSION['textQuestion']; ?>) { $('#mainPlusbutton').replaceWith(x); } //append rows into a table code, not needed for this question } .... $('.plusimage').live('click', function() { plusbutton($(this)); }); function plusbutton(plus_id) { // Set global info plusbutton_clicked = plus_id; // Display an external page using an iframe var src = "previousquestions.php"; $.modal('<iframe src="' + src + '" style="border:0;width:100%;height:100%;">'); return false; } <form id="QandA" action="<?php echo htmlentities($action); ?>" method="post"> <table id="question"> <tr> <td colspan="2"> <a onclick="return plusbutton();"> <img src="Images/plussign.jpg" width="30" height="30" alt="Look Up Previous Question" class="plusimage" id="mainPlusbutton" name="plusbuttonrow"/> </a> <span id="plussignmsg">(Click Plus Sign to look up Previous Questions)</span> </td> </tr> </table> <table id="questionBtn" align="center"> <tr> <th> <input id="addQuestionBtn" name="addQuestion" type="button" value="Add Question" onClick="insertQuestion(this.form)" /> </th> </tr> </table> </form> In the code above I am able to replace an image with another image when the if statement is met. But my problem is that when the image is replaced, it does not disable the on click event. My question is that when the image is replaced, how do I disable the onclick event onclick="return plusbutton();? Could unbind click work in this situation. I don't want to use href=# because I don't want to include # at the end of the url

    Read the article

  • Jqplot ajax request

    - by Moozy
    I'm trying to do a dynamic content load for JQplot charts, but something is wrong: this is my javascript code: $(document).ready(function(){ var ajaxDataRenderer = function(url, plot, options) { var ret = null; $.ajax({ // have to use synchronous here, else the function // will return before the data is fetched async: false, url: url, dataType:"json", success: function(data) { ret = data; console.warn(data); } }); return ret; }; // The url for our json data var jsonurl = "getData.php"; var plot1 = $.jqplot('chart1', jsonurl, { title:'Data Point Highlighting', dataRenderer: ajaxDataRenderer, dataRendererOptions: { unusedOptionalUrl: jsonurl }, axes:{ xaxis: { renderer:$.jqplot.DateAxisRenderer, min: '11/01/2012', max: '11/30/2012', tickOptions:{formatString:'%b %#d'}, tickInterval:'5 days' }, yaxis:{ tickOptions:{ formatString:'%.2f' } } }, highlighter: { show: true, sizeAdjust: 7.5 }, cursor: { show: false } }); }); </script> and it is displaying the chart, but it is not displaying the values, looklike its not getting my data. output of: console.warn(data); is: [["11-01-2012",0],["11-02-2012",0],["11-03-2012",0],["11-04-2012",0],["11-05-2012",0],["11-06-2012",0],["11-07-2012",0],["11-08-2012",0],["11-09-2012",0],["11-10-2012",0],["11-11-2012",0],["11-12-2012",0],["11-13-2012",0],["11-14-2012",0],["11-15-2012",2],["11-16-2012",5],["11-17-2012",0],["11-18-2012",1],["11-19-2012",0],["11-20-2012",0],["11-21-2012",0],["11-22-2012",0],["11-23-2012",0],["11-24-2012",0],["11-25-2012",1],["11-26-2012",0],["11-27-2012",0],["11-28-2012",0],["11-29-2012",0],["11-30-2012",0]]

    Read the article

  • unrecognized selector sent to instance while trying to add an object to a mutable array

    - by madpoet
    I'm following the "Your Second iOS App" and I decided to play with the code to understand Objective C well... What I'm trying to do is simply adding an object to a mutable array in a class. Here are the classes: BirdSighting.h #import <Foundation/Foundation.h> @interface BirdSighting : NSObject @property (nonatomic, copy) NSString *name; @property (nonatomic, copy) NSString *location; @property (nonatomic, copy) NSDate *date; -(id) initWithName: (NSString *) name location:(NSString *) location date:(NSDate *) date; @end BirdSighting.m #import "BirdSighting.h" @implementation BirdSighting -(id) initWithName:(NSString *)name location:(NSString *)location date:(NSDate *)date { self = [super init]; if(self) { _name = name; _location = location; _date = date; return self; } return nil; } @end BirdSightingDataController.h #import <Foundation/Foundation.h> @class BirdSighting; @interface BirdSightingDataController : NSObject @property (nonatomic, copy) NSMutableArray *masterBirdSightingList; - (NSUInteger) countOfList; - (BirdSighting *) objectInListAtIndex: (NSUInteger) theIndex; - (void) addBirdSightingWithSighting: (BirdSighting *) sighting; @end BirdSightingDataController.m #import "BirdSightingDataController.h" @implementation BirdSightingDataController - (id) init { if(self = [super init]) { NSMutableArray *sightingList = [[NSMutableArray alloc] init]; self.masterBirdSightingList = sightingList; return self; } return nil; } -(NSUInteger) countOfList { return [self.masterBirdSightingList count]; } - (BirdSighting *) objectInListAtIndex: (NSUInteger) theIndex { return [self.masterBirdSightingList objectAtIndex:theIndex]; } - (void) addBirdSightingWithSighting: (BirdSighting *) sighting { [self.masterBirdSightingList addObject:sighting]; } @end And this is where I'm trying to add a BirdSighting instance to the mutable array: #import "BirdsMasterViewController.h" #import "BirdsDetailViewController.h" #import "BirdSightingDataController.h" #import "BirdSighting.h" @implementation BirdsMasterViewController - (void)awakeFromNib { [super awakeFromNib]; BirdSightingDataController *dataController = [[BirdSightingDataController alloc] init]; NSDate *date = [NSDate date]; BirdSighting *sighting = [[[BirdSighting alloc] init] initWithName:@"Ebabil" location:@"Ankara" date: date]; [dataController addBirdSightingWithSighting: sighting]; NSLog(@"dataController: %@", dataController.masterBirdSightingList); self.dataController = dataController; } .......... @end It throws NSInvalidArgumentException in BirdSightingDataController addBirdSightingWithSighting method... What am I doing wrong?

    Read the article

  • font-smoothing not applied to buttons

    - by David
    I have used this snippet to prevent webkit from changing antialiasing when using CSS transforms: html{ -webkit-font-smoothing: antialiased; } This works fine for most cases, however I noticed some weirdness in chrome when playing around with Bootstrap using this HTML: <button class="btn btn-inverse">John Doe</button> <a class="btn btn-inverse">John Doe</a>? This is how it looks in OSX/Chrome: Fiddle: http://jsfiddle.net/hY2J7/. In fact, it seems that it is not applied to buttons at all. Is there a safer technique to trigger the same antialiasing in webkit for all elements?

    Read the article

  • how to save state of dynamically created editTexts

    - by user922531
    I'm stuck at how to save the state of my EditTexts on screen orientation. Currently if text is inputted into the EditTexts and the screen is orientated, the fields are wiped (as expected). I am already calling onSaveInstanceState and saving a String, but I have no clue on how to save the EditTexts which are created in code and then retrieve them and add them to the EditTexts when redrawing the activity. Snippet of my code: My main activity is as follows: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // get the multidim array b = getIntent().getBundleExtra("obj"); m = (Methods) b.getSerializable("Methods"); // method to draw the layout InitialiseUI(); // Restore UI state from the savedInstanceState. if (savedInstanceState != null) { String strValue = savedInstanceState.getString("light"); if (strValue != null) { FLight = strValue; } } try { mCamera = Camera.open(); if (FLight.equals("true")) { flashLight(); } } catch (Exception e) { Log.d(TAG, "Thrown exception onCreate() camera: " + e); } } // end onCreate /** Called when the back button is pressed. */ @Override public void onResume() { super.onResume(); try { mCamera = Camera.open(); if (FLight.equals("true")) { flashLight(); } } catch (Exception e) { Log.d(TAG, "Thrown exception onCreate() camera: " + e); } } // end onCreate /** saves data before leaving the screen */ @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString("light", FLight); } /** called when exiting / leaving the screen */ @Override protected void onPause() { super.onPause(); Log.d(TAG, "onPause()"); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); mCamera = null; } } /* * set up the UI elements - add click listeners to buttons used in * onCreate() and onConfigurationChanged() * * Set the editTexts fields to show the previous readings as Hints */ public void InitialiseUI() { Log.d(TAG, "Start of InitialiseUI, Main activity"); // get a reference to the TableLayout final TableLayout myTLreads = (TableLayout) findViewById(R.id.myTLreads); // Create arrays to hold the TVs and ETs final TextView[] myTextViews = new TextView[m.getNoRows()]; // create an empty array; final EditText[] myEditTexts = new EditText[m.getNoRows()]; // create an empty array; for(int i =0; i<=m.getNoRows()-1;i++ ){ TableRow tr=new TableRow(this); tr.setLayoutParams(new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); // create a new textview / editText final TextView rowTextView = new TextView(this); final EditText rowEditText = new EditText(this); // setWidth is needed otherwise my landscape layout is OFF rowEditText.setWidth(400); // this stops the keyboard taking up the whole screen in landscape layout rowEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); // add some padding to the right of the TV rowTextView.setPadding(0,0,10,0); // set colors to white rowTextView.setTextColor(Color.parseColor("#FFFFFF")); rowEditText.setTextColor(Color.parseColor("#FFFFFF")); // if readings already sent today set color to yellow if(m.getTransmit(i+1)==false){ rowEditText.setEnabled(false); rowEditText.setHintTextColor(Color.parseColor("#FFFF00")); } // set the text of the TV to the meter name rowTextView.setText(m.getMeterName(i+1)); // set the hint of the ET to the last submitted reading rowEditText.setHint(m.getLastReadString(i+1)); // add the textview to the linearlayout rowEditText.setInputType(InputType.TYPE_CLASS_PHONE);//InputType.TYPE_NUMBER_FLAG_DECIMAL); tr.addView(rowTextView); tr.addView(rowEditText); myTLreads.addView(tr); // add a reference to the textView myTextViews[i] = rowTextView; myEditTexts[i] = rowEditText; } final Button submit = (Button) findViewById(R.id.submitReadings); // add a click listener to the button try { submit.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Log.d(TAG, "Submit button clicked, Main activity"); preSubmitCheck(m.getAccNo(), m.getPostCode(), myEditTexts); // method to do HTML getting and sending } }); } catch (Exception e) { Log.d(TAG, "Exceptions (submit button)" + e.toString()); } }// end of InitialiseUI I don't need to do anything with these values until a button is clicked. Would it be easier if they were a ListView, i'm guessing I would still have the problem of saving them and retrieving them on rotation. If it helps I have an object m which is a string[][] I could temporarily somehow store them in

    Read the article

  • App-Engine Parse a UrlFetch UTF-8 encoded stream

    - by Davidrd91
    I am trying to parse an XML from a URL using the xml.sax parser. I know there are other libraries to use but coming from Java this is the one I am most familiar with and seems the least complicated to me. The code I'm using to parse is as follows: parser = xml.sax.make_parser() handler = MangaHandler() parser.setContentHandler(handler) url = urlfetch.Fetch('http://www.mangapanda.com/alphabetical', allow_truncated = False, follow_redirects = False, deadline = False) xml.sax.parseString(url.content, handler) This returns a SaxException (invalid token) once the parser reaches the first & sign: SAXParseException: <unknown>:582:34: not well-formed (invalid token) Because urlfetch returns a string and not a stream I cannot use the parse() (which only works with streams) and am left to use parseString() instead. To see if parsing as a stream would fix this I tried: parser.parse(io.StringIO(url.content).encode('utf-8')) but this returns: TypeError: initial_value must be unicode or None, not str I have also tried to use the urllib2 libraries which do return a stream instead of urlfetch but the file is too large and is automatically truncated, leaving me with missing data. Any Sort of work-around for this would be greatly appreciated as I've spent days getting around one obstacle just to be stopped by another.

    Read the article

  • A better and faster way for eval?

    - by user1707250
    I want to build my queries dynamically and use the following snippet: --snip-- module.exports = { get : function(req, res, next) { var queryStr = "req.database.table('locations').get(parseInt(req.params.id))"; if (req.params.id) { if (req.fields) { queryStr += '.pick(' + req.fieldsStr + ')'; } console.log(queryStr); eval(queryStr).run(function(result) { console.log(result); res.send(result); }); } else if (!req.params.id) { --snip-- However introducing eval opens up my code to injection (req.fields is filled with url parameters) and I see the response time of my app increase from 7 to 11ms Is there a smarter way to accomplish what I did here? Please advice.

    Read the article

  • Show div based on getDay and getHours + getMinutes

    - by Peta Reardon
    I am building a website for a radio station and want to show which presenter is currently on air. I have built a web app that contains data on the presenter: name, photo, bio and start/end times for each weekday. <div id="presenter1"> <div class="slot"> <div id="sunday-off"> - </div> <div id="monday-afternoon">12:00 - 15:59</div> <div id="tuesday-afternoon">12:00 - 15:59</div> <div id="wednesday-afternoon">12:00 - 15:59</div> <div id="thursday-afternoon">12:00 - 15:59</div> <div id="friday-afternoon">12:00 - 15:59</div> <div id="saturday-morning">06:00 - 08:59</div> </div> </div> What I would like to do is use Javascript functions getDay() and getHours() + getMinutes() to show only the presenter that is scheduled to be on air based on the times specified in the app. The main part I am having difficulty with is with determining whether this presenter falls within the current time and then showing/hiding the div as necessary. Any help or guidance on how I can acheive this would be greatly appreciated.

    Read the article

  • JavaScript audio not playing outside of jQuery function

    - by user1814016
    I know the question title doesn't make much sense, but I can't think of a better way to put it. I am a newbie to jQuery and I'm using this code to fade in a <div> and play a sound: $(document).ready(function(){ $('#speech').fadeIn('medium', function() { play('msg_appear'); var sptx = $('<p class="stext">').text('There is nothing here.'); $('#speech').append(sptx); $('.stext').typeOut({marker: '', delay: 22}); }); }); This code runs fine however the sound plays after the fade-in is complete. I wanted it to play while it was fading in, so I tried placing the play() call outside of the fade-in function like this: $(document).ready(function(){ play('msg_appear'); $('#speech').fadeIn('medium', function() { However, now it's not playing at all. There's no errors on the JavaScript console so I'm unsure if it's a syntax error, and probably something obvious, but I don't know what. play() is a function I found to play audio, here it is if it matters at all. I placed it in the same file the above code is; right above the $(document).ready(). function play(sound) { if (window.HTMLAudioElement) { var snd = new Audio(''); if(snd.canPlayType('audio/ogg')) { snd = new Audio(sound + '.ogg'); } else if(snd.canPlayType('audio/mp3')) { snd = new Audio(sound + '.mp3'); } snd.play(); } else { alert('HTML5 Audio is not supported by your browser!'); } }

    Read the article

  • JavaScript Prototype and Encapsulation

    - by Adam Davies
    Sorry I'm probably being a realy noob here...but: I have the following javascript object: jeeni.TextField = (function(){ var tagId; privateMethod = function(){ console.log("IN: privateMethod"); } publicMethod = function(){ console.log("IN: publicMethod: " + this.tagId); } jeeni.TextField = function(id){ console.log("Constructor"); this.tagId = id; } jeeni.TextField.prototype = { constructor: jeeni.TextField, foo: publicMethod }; return jeeni.TextField; }()); Now when I run the following code I get the corresponding result: var textField1 = new jeeni.TextField(21); // Outputs: Constructor textField1.foo(); // Outputs: IN: publicMethod: 21 console.log(textField1.tagId); // Outputs: 21 console.log(textField1.privateMethod); // Outputs: undefined So my question is why is privateMethod hidden and tagId is not. I want them both to be private scope. Please help a noob. Thanks

    Read the article

  • FakeTable with tSQLt remove triggers

    - by user1454695
    I have jsut started to use tSQLt and is about to test a trigger. I call the FakeTable procedure and do my test but the trigger is not executed. If don't use FakeTable the trigger is executed. That seems to be really bad and I canät find any info that there is any method to readded them. Then I thought the triggers are removed by FakeTable but I can recreate them after the call and did the following code in my test: DECLARE @createTrigger NVARCHAR(MAX); SELECT @createTrigger = OBJECT_DEFINITION(OBJECT_ID('MoveDataFromAToB')) EXEC tSQLt.FakeTable 'dbo.A'; EXEC(@createTrigger); I got the following error: "There is already an object named 'MoveDataFromAToB' in the database.{MoveDataFromAToB,14} (There was also a ROLLBACK ERROR -- The current transaction cannot be committed and cannot be rolled back to a savepoint. Roll back the entire transaction.{Private_RunTest,60})" Anyone that have any experience with tSQLt and know anyworkaround for this problem?

    Read the article

  • How to move a kinect skeleton to another position

    - by Ewerton
    I am working on a extension method to move one skeleton to a desired position in the kinect field os view. My code receives a skeleton to be moved and the destiny position, i calculate the distance between the received skeleton hip center and the destiny position to find how much to move, then a iterate in the joint applying this factor. My code, actualy looks like this. public static Skeleton MoveTo(this Skeleton skToBeMoved, Vector4 destiny) { Joint newJoint = new Joint(); ///Based on the HipCenter (i dont know if it is reliable, seems it is.) float howMuchMoveToX = Math.Abs(skToBeMoved.Joints[JointType.HipCenter].Position.X - destiny.X); float howMuchMoveToY = Math.Abs(skToBeMoved.Joints[JointType.HipCenter].Position.Y - destiny.Y); float howMuchMoveToZ = Math.Abs(skToBeMoved.Joints[JointType.HipCenter].Position.Z - destiny.Z); float howMuchToMultiply = 1; // Iterate in the 20 Joints foreach (JointType item in Enum.GetValues(typeof(JointType))) { newJoint = skToBeMoved.Joints[item]; // This adjust, try to keeps the skToBeMoved in the desired position if (newJoint.Position.X < 0) howMuchToMultiply = 1; // if the point is in a negative position, carry it to a "more positive" position else howMuchToMultiply = -1; // if the point is in a positive position, carry it to a "more negative" position // applying the new values to the joint SkeletonPoint pos = new SkeletonPoint() { X = newJoint.Position.X + (howMuchMoveToX * howMuchToMultiply), Y = newJoint.Position.Y, // * (float)whatToMultiplyY, Z = newJoint.Position.Z, // * (float)whatToMultiplyZ }; newJoint.Position = pos; skToBeMoved.Joints[item] = newJoint; //if (skToBeMoved.Joints[JointType.HipCenter].Position.X < 0) //{ // if (item == JointType.HandLeft) // { // if (skToBeMoved.Joints[item].Position.X > 0) // { // } // } //} } return skToBeMoved; } Actualy, only X position is considered. Now, THE PROBLEM: If i stand in a negative position, and move my hand to a positive position, a have a strange behavior, look this image To reproduce this behaviour you could use this code using (SkeletonFrame frame = e.OpenSkeletonFrame()) { if (frame == null) return new Skeleton(); if (skeletons == null || skeletons.Length != frame.SkeletonArrayLength) { skeletons = new Skeleton[frame.SkeletonArrayLength]; } frame.CopySkeletonDataTo(skeletons); Skeleton skeletonToTest = skeletons.Where(s => s.TrackingState == SkeletonTrackingState.Tracked).FirstOrDefault(); Vector4 newPosition = new Vector4(); newPosition.X = -0.03412333f; newPosition.Y = 0.0407479f; newPosition.Z = 1.927342f; newPosition.W = 0; // ignored skeletonToTest.MoveTo(newPosition); } I know, this is simple math, but i cant figure it out why this is happen. Any help will be apreciated.

    Read the article

  • how to disable an onclick event?

    - by user1819709
    <form id="QandA" action="<?php echo htmlentities($action); ?>" method="post"> <table id="question"> <tr> <td colspan="2"> <a onclick="return plusbutton();"> <img src="Images/plussign.jpg" width="30" height="30" alt="Look Up Previous Question" class="plusimage" id="mainPlusbutton" name="plusbuttonrow"/> </a> <span id="plussignmsg">(Click Plus Sign to look up Previous Questions)</span> </td> </tr> </table> </form> In the code above I am able to replace an image with another image when the if statement is met. But my problem is that when the image is replaced, it does not disable the on click event. My question is that when the image is replaced, how do I disable the onclick event onclick="return plusbutton();?

    Read the article

  • Python: Run a progess bar and work simultaneously?

    - by DanielTA
    I want to know how to run a progress bar and some other work simultaneously, then when the work is done, stop the progress bar in Python (2.7.x) import sys, time def progress_bar(): while True: for c in ['-','\\','|','/']: sys.stdout.write('\r' + "Working " + c) sys.stdout.flush() time.sleep(0.2) def work(): *doing hard work* How would I be able to do something like: progress_bar() #run in background? work() *stop progress bar* print "\nThe work is done!"

    Read the article

  • mysql true row merge... not just a union

    - by panofish
    What is the mysql I need to achieve the result below given these 2 tables: table1: +----+-------+ | id | name | +----+-------+ | 1 | alan | | 2 | bob | | 3 | dave | +----+-------+ table2: +----+---------+ | id | state | +----+---------+ | 2 | MI | | 3 | WV | | 4 | FL | +----+---------+ I want to create a temporary view that looks like this desired result: +----+---------+---------+ | id | name | state | +----+---------+---------+ | 1 | alan | | | 2 | bob | MI | | 3 | dave | WV | | 4 | | FL | +----+---------+---------+ I tried a mysql union but the following result is not what I want. create view table3 as (select id,name,"" as state from table1) union (select id,"" as name,state from table2) table3 union result: +----+---------+---------+ | id | name | state | +----+---------+---------+ | 1 | alan | | | 2 | bob | | | 3 | dave | | | 2 | | MI | | 3 | | WV | | 4 | | FL | +----+---------+---------+ First suggestion results: SELECT * FROM table1 LEFT OUTER JOIN table2 USING (id) UNION SELECT * FROM table1 RIGHT OUTER JOIN table2 USING (id) +----+---------+---------+ | id | name | state | +----+---------+---------+ | 1 | alan | | | 2 | bob | MI | | 3 | dave | WV | | 2 | MI | bob | | 3 | WV | dave | | 4 | FL | | +----+---------+---------+

    Read the article

  • deserialize system.outofmemoryexception

    - by clanier9
    I've got a serializeable class called Cereal with several public fields shown here <Serializable> Public Class Cereal Public id As Integer Public cardType As Type Public attacker As String Public defender As String Public placedOn As String Public attack As Boolean Public placed As Boolean Public played As Boolean Public text As String Public Sub New() End Sub End Class My client computer is sending a new Cereal to the host by serializing it shown here 'sends data to host stream (c1) Private Sub cSendText(ByVal Data As String) Dim bf As New BinaryFormatter Dim c As New Cereal c.text = Data bf.Serialize(mobjClient.GetStream, c) End Sub The host listens to the stream for activity and when something gets put on it, it is supposed to deserialize it to a new Cereal shown here 'accepts data sent from the client, raised when data on host stream (c2) Private Sub DoReceive(ByVal ar As IAsyncResult) Dim intCount As Integer Try 'find how many byte is data SyncLock mobjClient.GetStream intCount = mobjClient.GetStream.EndRead(ar) End SyncLock 'if none, we are disconnected If intCount < 1 Then RaiseEvent Disconnected(Me) Exit Sub End If Dim bf As New BinaryFormatter Dim c As New Cereal c = CType(bf.Deserialize(mobjClient.GetStream), Cereal) If c.text.Length > 0 Then RaiseEvent LineReceived(Me, c.text) Else RaiseEvent CardReceived(Me, c) End If 'starts listening for action on stream again SyncLock mobjClient.GetStream mobjClient.GetStream.BeginRead(arData, 0, 1024, AddressOf DoReceive, Nothing) End SyncLock Catch e As Exception RaiseEvent Disconnected(Me) End Try End Sub when the following line executes, I get a System.OutOfMemoryException and I cannot figure out why this isn't working. c = CType(bf.Deserialize(mobjClient.GetStream), Cereal) The stream is a TCPClient stream. I'm new to serialization/deserialization and using visual studio 11

    Read the article

  • Symfony 1.4 Layout footer glitch: Footer div is echoed out with $sf_content

    - by Parijat Kalia
    I have a very simple Layout for my application. A header, the main content, and a footer. Semantically, they are rendered like this: <body> <div id = "header"> </div> <div id = "content"> </div> <div id = "footer"> </div> </body> The corresponding CSS is very basic as well: #header{ width:100%; min-height:10%; } #center{ width:100%; min-height:80%; } #footer{ width:100%; min-height:10%: } As you would know in the layout page, here is how the content is rendered: <div id= "content"> <?php echo $sf_content; ?> </div> All of the above is very fine and it renders itself as it is supposed to. But there is a glitch with this, the moment i put in <?php echo $sf_content; ?> the footer is included as part of the content and not as a div that is after the #content markup. Essentially, I get this: <div id = "header"></div> <div id = "content> <div id ="symfony_template_to_be_rendered"> <!-- all web application related content like forms etc. --> </div> <div id = "footer">Footer material </div> </div> As you can see, for some weird reason, the footer moved up along with the symfony content. Clearly this is a glitch because if I remove the php hash $sf_content part from the div tags in my layouts, then the footer renders itself as and where it should be and everything takes up the required dimensions. What's going on here?

    Read the article

  • deserializing multiple types from a stream

    - by clanier9
    I have a card game program, and so far, the chat works great back and forth over the TCPClient streams between host and client. I want to make it do this with serializing and deserializing so that I can also pass cards between host and client. I tried to create a separate TCPClient stream for the passing of cards but it didn't work and figured it may be easier to keep one TCPClient stream that gets the text messages as well as cards. So I created a class, called cereal, which has the properties for the cards that will help me rebuild the card from an embedded database of cards on the other end. Is there a way to make my program figure out whether a card has been put in the stream or if it's just text in the stream so I can properly deserialize it to a string or to a cereal? Or should I add a string property to my cereal class and when that property is filled in after deserializing to the cereal, i'll know it's just text (if that field is empty after deserializing i'll know it's a card)? I'm thinking a try catch, where it tries to deserialize to a string, and if it fails it will catch and cast as a cereal. Or am I just way off base with this and should choose another route? I'm using visual studio 2011, am using a binaryformatter, and am new to serializing/deserializing.

    Read the article

  • Display another field in the referenced table for multiple columns with performance issues in mind

    - by israkir
    I have a table of edge like this: ------------------------------- | id | arg1 | relation | arg2 | ------------------------------- | 1 | 1 | 3 | 4 | ------------------------------- | 2 | 2 | 6 | 5 | ------------------------------- where arg1, relation and arg2 reference to the ids of objects in another object table: -------------------- | id | object_name | -------------------- | 1 | book | -------------------- | 2 | pen | -------------------- | 3 | on | -------------------- | 4 | table | -------------------- | 5 | bag | -------------------- | 6 | in | -------------------- What I want to do is that, considering performance issues (a very big table more than 50 million of entries) display the object_name for each edge entry rather than id such as: --------------------------- | arg1 | relation | arg2 | --------------------------- | book | on | table | --------------------------- | pen | in | bag | --------------------------- What is the best select query to do this? Also, I am open to suggestions for optimizing the query - adding more index on the tables etc... EDIT: Based on the comments below: 1) @Craig Ringer: PostgreSQL version: 8.4.13 and only index is id for both tables. 2) @andrefsp: edge is almost x2 times bigger than object.

    Read the article

  • User has many computers, computers have many attributes in different tables, best way to JOIN?

    - by krismeld
    I have a table for users: USERS: ID | NAME | ---------------- 1 | JOHN | 2 | STEVE | a table for computers: COMPUTERS: ID | USER_ID | ------------------ 13 | 1 | 14 | 1 | a table for processors: PROCESSORS: ID | NAME | --------------------------- 27 | PROCESSOR TYPE 1 | 28 | PROCESSOR TYPE 2 | and a table for harddrives: HARDDRIVES: ID | NAME | ---------------------------| 35 | HARDDRIVE TYPE 25 | 36 | HARDDRIVE TYPE 90 | Each computer can have many attributes from the different attributes tables (processors, harddrives etc), so I have intersection tables like this, to link the attributes to the computers: COMPUTER_PROCESSORS: C_ID | P_ID | --------------| 13 | 27 | 13 | 28 | 14 | 27 | COMPUTER_HARDDRIVES: C_ID | H_ID | --------------| 13 | 35 | So user JOHN, with id 1 owns computer 13 and 14. Computer 13 has processor 27 and 28, and computer 13 has harddrive 35. Computer 14 has processor 27 and no harddrive. Given a user's id, I would like to retrieve a list of that user's computers with each computers attributes. I have figured out a query that gives me a somewhat of a result: SELECT computers.id, processors.id AS p_id, processors.name AS p_name, harddrives.id AS h_id, harddrives.name AS h_name, FROM computers JOIN computer_processors ON (computer_processors.c_id = computers.id) JOIN processors ON (processors.id = computer_processors.p_id) JOIN computer_harddrives ON (computer_harddrives.c_id = computers.id) JOIN harddrives ON (harddrives.id = computer_harddrives.h_id) WHERE computers.user_id = 1 Result: ID | P_ID | P_NAME | H_ID | H_NAME | ----------------------------------------------------------- 13 | 27 | PROCESSOR TYPE 1 | 35 | HARDDRIVE TYPE 25 | 13 | 28 | PROCESSOR TYPE 2 | 35 | HARDDRIVE TYPE 25 | But this has several problems... Computer 14 doesnt show up, because it has no harddrive. Can I somehow make an OUTER JOIN to make sure that all computers show up, even if there a some attributes they don't have? Computer 13 shows up twice, with the same harddrive listet for both. When more attributes are added to a computer (like 3 blocks of ram), the number of rows returned for that computer gets pretty big, and it makes it had to sort the result out in application code. Can I somehow make a query, that groups the two returned rows together? Or a query that returns NULL in the h_name column in the second row, so that all values returned are unique? EDIT: What I would like to return is something like this: ID | P_ID | P_NAME | H_ID | H_NAME | ----------------------------------------------------------- 13 | 27 | PROCESSOR TYPE 1 | 35 | HARDDRIVE TYPE 25 | 13 | 28 | PROCESSOR TYPE 2 | 35 | NULL | 14 | 27 | PROCESSOR TYPE 1 | NULL | NULL | Or whatever result that make it easy to turn it into an array like this [13] => [P_NAME] => [0] => PROCESSOR TYPE 1 [1] => PROCESSOR TYPE 2 [H_NAME] => [0] => HARDDRIVE TYPE 25 [14] => [P_NAME] => [0] => PROCESSOR TYPE 1

    Read the article

  • SQL: GROUP BY after JOIN without overriding rows?

    - by krismeld
    I have a table of basketball leagues, a table af teams and a table of players like this: LEAGUES ID | NAME | ------------------ 1 | NBA | 2 | ABA | TEAMS: ID | NAME | LEAGUE_ID ------------------------------ 20 | BULLS | 1 21 | KNICKS | 2 PLAYERS: ID | TEAM_ID | FIRST_NAME | LAST_NAME | --------------------------------------------- 1 | 21 | John | Starks | 2 | 21 | Patrick | Ewing | Given a League ID, I would like to retrieve all the players' names and their team ID from all the teams in that league, so I do this: SELECT t.id AS team_id, p.id AS player_id, p.first_name, p.last_name FROM teams AS t JOIN players AS p ON p.team_id = t.id WHERE t.league_id = 1 which returns: [0] => stdClass Object ( [team_id] => 21 [player_id] => 1 [first_name] => John [last_name] => Starks ) [1] => stdClass Object ( [team_id] => 21 [player_id] => 2 [first_name] => Patrick [last_name] => Ewing ) + around 500 more objects... Since I will use this result to populate a dropdown menu for each team containing each team's list of players, I would like to group my result by team ID, so the loop to create these dropdowns will only have to cycle through each team ID instead of all 500+ players each time. But when I use the GROUP BY like this: SELECT t.id AS team_id, p.id AS player_id, p.first_name, p.last_name FROM teams AS t JOIN players AS p ON p.team_id = t.id WHERE t.league_id = 1 GROUP BY t.id it only returns one player from each team like this, overriding all the other players on the same team because of the use of the same column names. [0] => stdClass Object ( [team_id] => 21 [player_id] => 2 [first_name] => Patrick [last_name] => Ewing ) [1] => stdClass Object ( [team_id] => 22 [player_id] => 31 [first_name] => Shawn [last_name] => Kemp ) etc... I would like to return something like this: [0] => stdClass Object ( [team_id] => 2 [player_id1] => 1 [first_name1] => John [last_name1] => Starks [player_id2] => 2 [first_name2] => Patrick [last_name2] => Ewing +10 more players from this team... ) +25 more teams... Is it possible somehow?

    Read the article

  • How do you save compare options in Visual Studio 2010 > SQL 2012 Database Project

    - by profMamba
    Been using the new SQL 2012 Data Tools SQL Server Database Project in VS 2010. Every time we do a schema compare we have to set the options for the current compare. This does not seem to be tied back to the global compare options you can set in Tools Options. Does anybody know where to set the 'new' global compare options. NOTE: This is the new SQL 2012 compare from Data Tools, and not the old 2005/2008 compare that comes standard with Studio 2010.

    Read the article

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