Daily Archives

Articles indexed Friday June 6 2014

Page 3/17 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How do you deal with monotony of certain tasks? [on hold]

    - by aaronmallen
    I love programming methods, and functions. The if {}, while {}, etc... logic behind them is so much fun. I also love making commits, merging branches, solving merge conflicts. Unfortunately these activities usually require that I create classes which I find tedious and monotonous. The simple action of defining properties, is getting in the way of me writing the logic on what to do with those properties. I can't be alone here there has to be a part of coding for everyone that they dread or at least severely dislike doing compared to other parts of coding. How do you deal with the code based tasks that you find tedious?

    Read the article

  • Appropriate design / technologies to handle dynamic string formatting?

    - by Mark W
    recently I was tasked with implementing a way of adding support for versioning of hardware packet specifications to one of our libraries. First a bit of information about the project. We have a hardware library which has classes for each of the various commands we support sending to our hardware. These hardware modules are essentially just lights with a few buttons, and a 2 or 4 digit display. The packets typically follow the format {SOH}AADD{ETX}, where AA is our sentinel action code, and DD is the device ID. These packet specs are different from one command to the next obviously, and the different firmware versions we have support different specifications. For example, on version 1 an action code of 14 may have a spec of {SOH}AADDTEXT{ETX} which would be AA = 14 literal, DD = device ID, TEXT = literal text to display on the device. Then we come out with a revision with adds an extended byte(s) onto the end of the packet like this {SOH}AADDTEXTE{ETX}. Assume the TEXT field is fixed width for this example. We have now added a new field onto the end which could be used to say specify the color or flash rate of the text/buttons. Currently this java library only supports one version of the commands, the latest. In our hardware library we would have a class for this command, say a DisplayTextArgs.java. That class would have fields for the device ID, the text, and the extended byte. The command class would expose a method which generates the string ("{SOH}AADDTEXTE{ETX}") using the value from the class. In practice we would create the Args class as needed, populate the fields, call the method to get our packet string, then ship that down across the CAN. Some of our other commands specification can vary for the same command, on the same version, depending on some runtime state. For example, another command for version 1 may be {SOH}AA{ETX}, where this action code clears all of the modules behind a specific controller device of their text. We may overload this packet to have option fields with multiple meanings like {SOH}AAOC{ETX} where OC is literal text, which tells the controller to only clear text on a specific module type, and to leave the others alone, or the spec could also have an option format of {SOH}AADD{ETX} to clear the text off a a specific device. Currently, in the method which generates the packet string, we would evaluate fields on the args class to determine which spec we will be using when formatting the packet. For this example, it would be along the lines of: if m_DeviceID != null then use {SOH}AADD{ETX} else if m_ClearOCs == true then use {SOH}AAOC{EXT} else use {SOH}AA{ETX} I had considered using XML, or a database to store String.format format strings, which were linked to firmware version numbers in some table. We would load them up at startup, and pass in the version number of the hardwares firmware we are currently using (I can query the devices for their firmware version, but the version is not included in all packets as part of the spec). This breaks down pretty quickly because of the dynamic nature of how we select which version of the command to use. I then considered using a rule engine to possibly build out expressions which could be interpreted at runtume, to evaluate the args class's state, and from that select the appropriate format string to use, but my brief look at rule engines for java scared me away with its complexity. While it seems like it might be a viable solution, it seems overly complex. So this is why I am here. I wouldn't say design is my strongest skill, and im having trouble figuring out the best way to approach this problem. I probably wont be able to radically change the args classes, but if the trade off was good enough, I may be able to convince my boss that the change is appropriate. What I would like from the community is some feedback on some best practices / design methodologies / API or other resources which I could use to accomplish: Logic to determine which set of commands to use for a given firmware version Of those command, which version of each command to use (based on the args classes state) Keep the rules logic decoupled from the application so as to avoid needing releases for every firmware version Be simple enough so I don't need weeks of study and trial and error to implement effectively.

    Read the article

  • Transfer a ssh session between the same physical devices from one network to another

    - by Vivek V K
    My server has 2 IP addresses via two networks. Due to some restrictions,my client will be able to access only one of the network at a time. Hence, I want a way to transfer a live ssh session with all the open applications seamlessly from one network to another. The physical devices (client and the server) are the same. What changes is the network through which it connects. can this be done? Thanks!

    Read the article

  • Error when compiling bochs

    - by Isaac D.
    I'm trying to compile bochs. Here is my configure command: ./configure --enable-fpu --enable-3dnow --enable-x86-64 --enable-a20-pin --enable-cdrom --enable-debugger --enable-debugger-gui --enable-disasm Then I enter the "make" command and it compiles for some time. But then comes an error. /usr/bin/ld: gui/libgui.a(gtk_enh_dbg_osdep.o): undefined reference to symbol 'pthread_create@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [bochs] Error 1 Can anybody help me with this error? Thank you in advance.

    Read the article

  • Make it so you can't stop command with CTRL+C

    - by Xero
    So, I was playing some Zork 1, and I went to copy some text to show a friend of mine I accidentally forgot to hold the shift key when pressing CTRL+C. This stopped the command and I lost my Zork data, is there some sort of "helpful" tip out their that I can to prevent from stopping the command when press the keys CTRL+C? Note that I'm running the game zork via Terminal (emulator), I installed it with these steps: http://www.eugenemdavis.com/playing-zork-linux-frotz

    Read the article

  • In a pinch, is it worthwhile to run a bootable USB drive for my primary PC for an extended period?

    - by jason
    My hard drive has crashed, and I won't be able to buy a new one for a month or two. I've got a 16GB USB 3.0 flash drive that I'd like to have running a persistent ubuntu or ubuntu gnome distro. While it's not the best solution, is it a solution, or is it just a good way to wear out a flash drive? I plan on mostly storing things in Google Drive, so other than wearing out the flash drive, are there any risks involved?

    Read the article

  • Two Home and Boot partitions after installing Ubuntu 14.04 and Downgrading to Ubuntu 12.04

    - by Jatttt
    I have Ubuntu 12.04 LTS and I am experiencing some problems. I didn't have Ubuntu 12.04 on a drive to install it but I did have Ubuntu 14.04. So I installed it and downloaded Ubuntu 12.04 using Ubuntu 14. Now, I have 2 home partitions and 2 boot partitions. One home and boot is mounted at /media and the other one is /home and /boot. I cannot get rid of /media/HOME and /media/BOOT even using Gparted. How do I get remove them?

    Read the article

  • Setting up programs to startup at login

    - by Dhartman3076
    Have a new ponder hoping someone can answer. Keep in mind I am very new at linux and Ubuntu 14.04. What I would like to setup is setting certain programs to load at login to my account. I have not found a startup folder or setup options for programs to load at startup. Any Ideas? Please remember I am very new to linux and Ubuntu desktop. I am still learning my way around and the code for terminal sessions. So please be very descriptive in responses. Thank you...

    Read the article

  • Cannot boot from SD card/flash drive on Macbook Pro 13" - boot fails after purple screen

    - by user3512567
    It's my first time using Ubuntu and I have run into some problems. I have a 16GB USB Flash drive and 16GB SDHC Card. I would prefer to use the SD card but either will do just fine if it helps with the solution. I Have a 13" Macbook Pro with no hard drive deeming the machine useless without an OS. I thought I could substitute the hard drive for a 16GB SD card with an Ubuntu ISO on it. I would like to plug in my SD card into my Macbook Pro, boot the Ubuntu ISO and do simple things such as use the browser for internet. The Problem: Whenever I boot my Macbook pro with the SD card that has the Ubuntu ISO, it loads at the purple logo screen and does not function. How can I resolve this issue?

    Read the article

  • How to disable framebuffer in initramfs in 14.04 server?

    - by Blangero
    Recently I'm working on ubuntu 14.04 server. While using plymouth, I have late splash and tried to fix it, I googled and got lots of suggestions on doing this: vi /etc/initramfs-tools/conf.d/splash and add: FRAMEBUFFER=y and update-initramfs -u After doing this, I got no splash at all.So I deleted the FRAMEBUFFER=y and re-update initramfs, splash came back. But after that I installed something, maybe it's remastersys or n86v or their dependencies, or something else, I got splash gone again and according to the boot.log, I think it's due to framebuffer enabled in initramfs again. I tried FRAMBUFFER=n in /etc/initramfs-tools/conf.d/splash but failed. Now I got no splash and still can't get it back. Does anyone know how to disable framebuffer in initramfs? Thanks a lot!

    Read the article

  • “psmouse.ko' not found” installing ALPS touchpad in a Lenovo Ideapad Flex 14

    - by user279806
    I was following this instructions with Ubuntu 14.04. https://github.com/he1per/psmouse-dkms-alpsv7 and psmouse serio1: alps: Unknown ALPS touchpad in a Lenovo Ideapad Flex 15 And after many tries I received the following error message: root@alisson-Lenovo-Ideapad-Flex14:/tmp/psmouse-dkms-alpsv7# ./install.sh ------ Building with dkms ------- Error! DKMS tree already contains: psmouse-dkms-alpsv7-1.0 You cannot add the same module/version combo more than once. Module psmouse-dkms-alpsv7/1.0 already built for kernel 3.13.0-24-generic/4 ------ Installing with dkms ------- Module psmouse-dkms-alpsv7/1.0 already installed on kernel 3.13.0-24-generic/x86_64 ???? Error: dkms install failed:\n '/usr/lib/modules/3.13.0-24-generic//updates/psmouse.ko' not found. root@alisson-Lenovo-Ideapad-Flex14:/tmp/psmouse-dkms-alpsv7# than, searching for "psmouse.ko": alisson@alisson-Lenovo-Ideapad-Flex14:~$ locate psmouse.ko /lib/modules/3.13.0-24-generic/kernel/drivers/input/mouse/psmouse.ko /lib/modules/3.13.0-24-generic/updates/dkms/psmouse.ko /var/lib/dkms/psmouse-dkms-alpsv7/1.0/3.13.0-24-generic/x86_64/module/psmouse.ko /var/lib/dkms/psmouse-dkms-alpsv7/1.0/build/src/.psmouse.ko.cmd /var/lib/dkms/psmouse-dkms-alpsv7/1.0/build/src/psmouse.ko alisson@alisson-Lenovo-Ideapad-Flex14:~$ What should I do?

    Read the article

  • Need help partitioning when reinstalling Ubuntu 14.04

    - by Chris M.
    I upgraded to 14.04 about a month ago on my HP Mini netbook (about 16 GB hard disk). A few days ago the system crashed (I don't know why but I was using internet at the time). When I restarted the computer, Ubuntu would not load. Instead, I got a message from the BIOS saying Reboot and Select proper Boot device or Insert Boot Media in selected Boot device and press a key I took this to mean that I needed to reinstall 14.04. When I try to reinstall Ubuntu from the USB stick, I choose "Erase disk and install Ubuntu" but then I get a message: Some of the partitions you created are too small. Please make the following partitions at least this large: / 3.3 GB If you do not go back to the partitioner and increase the size of these partitions, the installation may fail. At first I hit Continue to see if it would install anyway, and it gave the message: The attempt to mount a file system with type ext4 in SCSI1 (0,0,0), partition # 1 (sda) at / failed. You may resume partitioning from the partitioning menu. The second time I hit Go Back, and it took me to the following partitioning table: Device Type Mount Point Format Size Used System /dev/sda /dev/sda1 ext4 (checked) 3228 MB Unknown /dev/sda5 swap (not checked) 1063 MB Unknown + - Change New Partition Table... Revert Device for boot loader installation: /dev/sda ATA JM Loader 001 (4.3 GB) At this point I'm not sure what to do. I've never partitioned my hard drive before and I don't want to screw things up. (I'm not particularly tech savvy.) Can you instruct me what I should do. (P.S. I'm afraid the table might not appear as I typed it in.) Results from fdisk: ubuntu@ubuntu:~$ sudo fdisk -l Disk /dev/sda: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders, total 8388608 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sda doesn't contain a valid partition table Disk /dev/sdb: 7860 MB, 7860125696 bytes 155 heads, 31 sectors/track, 3194 cylinders, total 15351808 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0009a565 Device Boot Start End Blocks Id System /dev/sdb1 * 2768 15351807 7674520 b W95 FAT32 ubuntu@ubuntu:~$ Here is what it displays when I open the Disks utility (I tried the screenshot terminal command you suggested but it didn't seem to do anything): 4.3 GB Hard Disk /dev/sda Model: JM Loader 001 (01000001) Size: 4.3 GB (4,294,967,296 bytes) Serial Number: 01234123412341234 Assessment: SMART is not supported Volumes Size: 4.3 GB (4,294,967,296 bytes) Device: /dev/sda Contents: Unknown (There is a button in the utility that when you click it gives the following options: Format... Create Disk Image... Restore Disk Image... Benchmark but SMART Data & Self-Tests... is dimmed out) When I hit F9 Change Boot Device Order, it shows the hard drive as: SATA:PM-JM Loader 001 When I hit F10 to get me into the BIOS Setup Utility, under Diagnostic it shows: Primary Hard Disk Self Test Not Support NetworkManager Tool State: disconnected Device: eth0 Type: Wired Driver: atl1c State: unavailable Default: no HW Address: 00:26:55:B0:7F:0C Capabilities: Carrier Detect: yes Wired Properties Carrier: off When I run command lshw -C network, I get: WARNING: you should run this program as super-user. *-network description: Network controller product: BCM4312 802.11b/g LP-PHY vendor: Broadcom Corporation physical id: 0 bus info: pci@0000:01:00.0 version: 01 width: 64 bits clock: 33MHz capabilities: bus_master cap_list configuration: driver=b43-pci-bridge latency=0 resources: irq:16 memory:feafc000-feafffff *-network description: Ethernet interface product: AR8132 Fast Ethernet vendor: Qualcomm Atheros physical id: 0 bus info: pci@0000:02:00.0 logical name: eth0 version: c0 serial: 00:26:55:b0:7f:0c capacity: 100Mbit/s width: 64 bits clock: 33MHz capabilities: bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=atl1c driverversion=1.0.1.1-NAPI latency=0 link=no multicast=yes port=twisted pair resources: irq:43 memory:febc0000-febfffff ioport:ec80(size=128) WARNING: output may be incomplete or inaccurate, you should run this program as super-user.

    Read the article

  • Eclipse not launching

    - by user274959
    I have installed Ubuntu 14.04, I have installed Eclipse using Ubuntu Software Center. But Eclipse is not opening, when I click it is not opening or showing any error message it is very silent. Output for java -version: java version "1.7.0_55" Java(TM) SE Runtime Environment (build 1.7.0_55-b13) Java HotSpot(TM) Server VM (build 24.55-b03, mixed mode) uname -a: Linux Lenovo-IdeaPad-Z510 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:08:14 UTC 2014 i686 i686 i686 GNU/Linux When I give Eclipse in terminal I am getting The program 'eclipse' is currently not installed. You can install it by typing: sudo apt-get install eclipse-platform And when I give sudo apt-get install eclipse-platform Reading package lists... Done Building dependency tree Reading state information... Done eclipse-platform is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

    Read the article

  • Where I can find /sbin/hotplug in my kernel source

    - by Rahul
    I am reading hotplug events. And I want to enable automatic loading unloading module, when a new device is added. For that I read that kernel does it using /sbin/hotplug script, but I am not able to find it in my source code, can someone help me out where can I find it? Also when I tried to do cat /proc/sys/kernel/hotplug there is nothing coming in output, I am running the same kernel which I downloaded and built.

    Read the article

  • PCI hotplug doesn't seem to work

    - by user245454
    In virsh I detach a PCI bus from host and attach it to a VM. I don't see any errors in these steps. But I don't see the PCI device listed in the VM. virsh # nodedev-dettach pci_0000_01_00_0 Device pci_0000_01_00_0 dettached virsh # attach-device VM1 pci_add.xml Device attached successfully $ cat pci_add.xml <hostdev mode='subsystem' type='pci' managed='yes'> <source> <address domain='0x000' bus='0x01' slot='0x00' function='0x0'/> </source> </hostdev> Is PCI hot plug not supported? I am using Ubuntu 12.04.3(kernel 3.8.0-34). I can add the same PCI device through virsh edit VM1 and start the VM1. This way I am able to see the device.

    Read the article

  • AutoKey inserts blank lines

    - by Mike Pretzlaw
    Situation GNOME Shell AutoKey / autokey-gtk it has a predefined shortcut "adr" which should write an address after hitting space and a shortcut "date" which should write the current date (after hitting tab) Problem no matter what I define, "adr" or "date" it always inserts as much blank lines as the template uses Example: "date" should autocomplete after pressing space to "13/08/01" but it inserts one empty line "adr" should do my full address but it inserts 4 empty lines Question What could be wrong with my AutoKey? Do you need additional information?

    Read the article

  • Use hotplug and turn on/off PCI device for replacing NIC

    - by Ryota Hashimoto
    How can I turn off the PCI slots and change the device (especially NIC) without shutting the server down? I found a similar question (How do I turn off PCI devices?) but there are no /sys/bus/pci/slot and no files in /sys/bus/pci/slots. I'm using 12.04 LTS. $ uname -a Linux d1-c1-r1-p1 3.2.0-38-generic #61-Ubuntu SMP Tue Feb 19 12:18:21 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux $ lspci | grep Eth 04:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01) 04:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01) 09:00.0 Ethernet controller: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection (rev 01) 09:00.1 Ethernet controller: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection (rev 01) $ ls /sys/bus/pci/ devices/ drivers_probe slots/ drivers/ rescan uevent drivers_autoprobe resource_alignment $ ls /sys/bus/pci/devices/0000\:04\:00.0/ broken_parity_status driver modalias rescan subsystem class enable msi_bus reset subsystem_device config firmware_node net resource subsystem_vendor consistent_dma_mask_bits irq numa_node resource0 uevent device local_cpulist power resource2 vendor dma_mask_bits local_cpus remove resource3

    Read the article

  • My cpus are powered down periodically

    - by mgiammarco
    I post here because I am using Ubuntu but this is probably an hardware problem. Since I bought my new setup with AMD Athlon(tm) II X4 635 Processor and asus m4a89td pro/usb3 motherboard with ecc ram I have stuttering on videos. I was using ubuntu 11.10 now ubuntu 12.10. Looking at syslog I have found that periodically (I notice only on videos but it happens always) this thing happens: Mar 6 23:36:42 virtual1 kernel: [28564.375548] smpboot: CPU 1 is now offline Mar 6 23:36:42 virtual1 kernel: [28564.380751] smpboot: CPU 2 is now offline Mar 6 23:36:42 virtual1 kernel: [28564.394947] smpboot: CPU 3 is now offline Mar 6 23:36:48 virtual1 kernel: [28569.917021] smpboot: Booting Node 0 Processor 1 APIC 0x1 Mar 6 23:36:48 virtual1 kernel: [28569.928015] LVT offset 0 assigned for vector 0xf9 Mar 6 23:36:48 virtual1 kernel: [28569.928372] [Firmware Bug]: cpu 1, try to use APIC500 (LVT offset 0) for vector 0x400, but the register is already in use for vector 0xf9 on another cpu Mar 6 23:36:48 virtual1 kernel: [28569.928378] perf: IBS APIC setup failed on cpu #1 Mar 6 23:36:48 virtual1 kernel: [28569.931305] process: Switch to broadcast mode on CPU1 Mar 6 23:36:48 virtual1 kernel: [28569.934255] smpboot: Booting Node 0 Processor 2 APIC 0x2 Mar 6 23:36:48 virtual1 kernel: [28569.945554] [Firmware Bug]: cpu 2, try to use APIC500 (LVT offset 0) for vector 0x400, but the register is already in use for vector 0xf9 on another cpu Mar 6 23:36:48 virtual1 kernel: [28569.945558] perf: IBS APIC setup failed on cpu #2 Mar 6 23:36:48 virtual1 kernel: [28569.948124] process: Switch to broadcast mode on CPU2 Mar 6 23:36:48 virtual1 kernel: [28569.949644] smpboot: Booting Node 0 Processor 3 APIC 0x3 Mar 6 23:36:48 virtual1 kernel: [28569.960838] [Firmware Bug]: cpu 3, try to use APIC500 (LVT offset 0) for vector 0x400, but the register is already in use for vector 0xf9 on another cpu Mar 6 23:36:48 virtual1 kernel: [28569.960840] perf: IBS APIC setup failed on cpu #3 Mar 6 23:36:48 virtual1 kernel: [28569.962953] process: Switch to broadcast mode on CPU3 I have: updated bios; tried all (really) bios options; changed ram; changed psu and cpu cooler; tried 3.8.1 kernel. What can I do now? Please help me! Thanks, Mario

    Read the article

  • How do I turn off PCI devices?

    - by ethana2
    With the purchase of an Intel SSD and 85WHr Li-ion battery and the linking of wifi and bluetooth to my laptop's wireless switch, extensive Intel PowerTop usage, switching from compiz to metacity, stopping of the desktop-couch daemon, removal of Ubuntu One and several other services from my startup, disabling of everything possible in my BIOS, and physical removal of my optical drive, I've gotten my battery life up fairly high, but I think there's still more to be done. Specifically, when I'm in class taking notes, I want to temporarily but completely power down: Ethernet Firewire USB ports SD card reader Optical drive Webcam Sound card PCMCIA slot ..without turning them off in my BIOS like they are now, if possible, because then I have to restart my computer to use any of them. As it stands, I still haven't managed to power down: Firewire USB connection to webcam sound card How do I tell Linux to disable and power down these devices? Is it true that any PCI slot can be physically powered down? My current idle power consumption is 7.9 watts plus the screen. (10.0W at min. brightness) Also, how do I set the screen timeout to ten seconds? gconf editor isn't honoring it when I set it to that. Will switching from nVidia to Nouveau save any significant amount of power?

    Read the article

  • Is it possible to transfer Google Authorship?

    - by Stephanus Yanaputra
    Is it possible to transfer Google Authorship from one account to another? Scenario: I have user A who is a legitimate Google Author in my WordPress site. When I search the 'keyword' in Google, his name and photo will show up in the search result. One day A left the company, so we don't want to use his name again as an author, and transfer it to another person which is B. Technically speaking, I can just alter the display name and Google+ Profile URL of A to B. And then I probably can notify Google of the changes happening. But what will happen then? Will Google get confused and think that I'm doing scam? Is doing this action even correct in the first place?

    Read the article

  • Ad Service That Lets You Choose Your Ad, and Then Some [on hold]

    - by user3634450
    I'm trying to build an app for both Android and/or iOS where part of the gameplay actually involves ads as a texture. I need to be able to choose which ads I would like to use. I need to be able to be able to identify the ads (which if I can choose which ads show up in the app shouldn't be that hard). I need to be able to swap in and out new ads on what could possibly be a daily basis (and don't want to have to update the app to do it). And as if that wasn't too needy a list, I need to be able to load 50 ads from the pool of ads I deem fit, all to each and every user of the app at least every couple of days. I don't care if the ads pay, I'm not looking for clicks, but I don't want to have to make 50 fake ads every couple of days, from an "artistic" level I don't want the content to feel phony or fake, and I don't really have a way to load content to each user via some internet source (if anyone could name one that would be great). I'm not sure what kind of ad provider would like or even approve of this, in fact just what I've described might be against Google Play's or iTunes' content developer policies, but if anyone could give me any advice to steer me in the right direction it would be greatly appreciated, thank you.

    Read the article

  • Point in Polygon, Ray Method: ending infinite line

    - by user2878528
    Having a bit of trouble with point in polygon collision detection using the ray method i.e. http://en.wikipedia.org/wiki/Point_in_polygon My problem is I need to give an end to the infinite line created. As with this infinite line I always get an even number of intersections and hence an invalid result. i.e. ignore or intersection to the right of the point being checked what I have what I want My current code based of Mecki awesome response for (int side = 0; side < vertices.Length; side++) { // Test if current side intersects with ray. // create infinite line // See: http://en.wikipedia.org/wiki/Linear_equation a = end_point.Y - start_point.Y; b = start_point.X - end_point.X; c = end_point.X * start_point.Y - start_point.X * end_point.Y; //insert points of vector d2 = a * vertices[side].Position.X + b * vertices[side].Position.Y + c; if (side - 1 < 0) d1 = a * vertices[vertices.Length - 1].Position.X + b * vertices[vertices.Length - 1].Position.Y + c; else d1 = a * vertices[side-1].Position.X + b * vertices[side-1].Position.Y + c; // If points have opposite sides, intersections++; if (d1 > 0 && d2 < 0 ) intersections++; if (d1 < 0 && d2 > 0 ) intersections++; } //if intersections odd inside = true if ((intersections % 2) == 1) inside = true; else inside = false;

    Read the article

  • Problems with 3D transformation - (SharpDX)

    - by Morphex
    First of all , I have been trying to get this right for a couple of day already, I have read so much info and still fail miserably to understand this. So I am going to tell you that even though I have done fairly amount of research myself, I failed to implement it. I must say miserably I am trying to create a generic camera class for a game engine of sorts - for research purposes only - the thing is I have no idea how to go about it. I have read about quaternions and matrices, but when it comes to the actual implementation I suck at it. Sharpdx has already Matrices and QUaternions implemented. SO no big deal on the map behind it. How in the world would I go about creating a camera? I have seen so many camera examples and still can't make one that works as expected. I would like to implement diferent types too (Orbital, 6DoF, FPS). So what is need for a camera? UP, Forward and Right vectors I read they are needed, also a quaternion for rotations, and View and Projection matrices. I understand that a FPS camera for instance only rotates around the World Y and the Right Axis of the camera. the 6DoF rotates always around their own axis, and the orbital is just translating for set distance and making it look always at a fixed target point. The concepts are there, now implementing this is not trivial for me. Can anyone point me on what am I missing, what I got wrong? I would really enjoy if you could give a tutorial, some piece of code, or just plain explanation of the concepts. Thank you for readin, a frustrated coder.

    Read the article

  • 2D Tile Collision free movement

    - by andrepcg
    I'm coding a 3D game for a project using OpenGL and I'm trying to do tile collision on a surface. The surface plane is split into a grid of 64x64 pixels and I can simply check if the (x,y) tile is empty or not. Besides having a grid for collision, there's still free movement inside a tile. For each entity, in the end of the update function I simply increase the position by the velocity: pos.x += v.x; pos.y += v.y; I already have a collision grid created but my collide function is not great, i'm not sure how to handle it. I can check if the collision occurs but the way I handle is terrible. int leftTile = repelBox.x / grid->cellSize; int topTile = repelBox.y / grid->cellSize; int rightTile = (repelBox.x + repelBox.w) / grid->cellSize; int bottomTile = (repelBox.y + repelBox.h) / grid->cellSize; for (int y = topTile; y <= bottomTile; ++y) { for (int x = leftTile; x <= rightTile; ++x) { if (grid->getCell(x, y) == BLOCKED){ Rect colBox = grid->getCellRectXY(x, y); Rect xAxis = Rect(pos.x - 20 / 2.0f, pos.y - 20 / 4.0f, 20, 10); Rect yAxis = Rect(pos.x - 20 / 4.0f, pos.y - 20 / 2.0f, 10, 20); if (colBox.Intersects(xAxis)) v.x *= -1; if (colBox.Intersects(yAxis)) v.y *= -1; } } } If instead of reversing the direction I set it to false then when the entity tries to get away from the wall it's still intersecting the tile and gets stuck on that position. EDIT: I've worked with Flashpunk and it has a great function for movement and collision called moveBy. Are there any simplified implementations out there so I can check them out?

    Read the article

  • How would I go about updating my electronic circuit simulator's 'electricity'?

    - by liqwidice
    I have made an application which allows the user to place down wires, power sources, and inverters on a virtual circuit board. All connections between tiles are automatic, as shown here: As you can see in the last image, the updating of power throughout this grid is not yet functioning. I think I understand how to do this updating conceptually, but getting it to work in my program is appearing to be much more difficult than I first imagined. My source code can be found here. If you have any tips as to how to I might approach this monstrous task, please let me know. EDIT The goal here is to simply get a working application. Getting tiles to pass on power to their neighbors is quite easy, but the tricky part is getting wires to "unpower" after the removal of a power source. The size of the grid is just 18x18, so efficiency really isn't a factor, for those wondering.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >