Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

  • Days Won


TheComet last won the day on April 19 2018

TheComet had the most liked content!

Community Reputation

3925 Excellent

About TheComet

  • Rank
    Advanced Member

Personal Information

  • Role
  • Interests


  • Github
  • Twitch

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I don't know how many of you are familiar with driver code, but I'll leave this little treat here. #include "hal/mux.h" #include <msp430.h> /* * The following macros define the bits that would enable the connection from * the MSP430 USS output Tx or input Rx to the sensor. * * C\d[AB]\d[RT] * | | | | * Channel idx --+ | | | * Group A or B ---+ | | * Subsensor index ----+ | * Transmit or receive --+ */ /* Vertical channel 0, mapped to port 4 */ #define C0A0T (1u << 0) #define C0A0R (1u << 1) #define C0B0T (1u << 2) #define C0B0R (1u << 5) /* Sensor group A, channel 1, mapped to port C (ports 5 and 6) */ #define C1A0T (1u << 15) #define C1A0R (1u << 12) #define C1A1T (1u << 3) #define C1A1R (1u << 5) #define C1A2T (1u << 9) #define C1A2R (1u << 13) #define C1A3T (1u << 1) #define C1A3R (1u << 7) /* Sensor group B, channel 1, mapped to port C (ports 5 and 6) */ #define C1B0T (1u << 2) #define C1B0R (1u << 4) #define C1B1T (1u << 10) #define C1B1R (1u << 8) #define C1B2T (1u << 0) #define C1B2R (1u << 6) #define C1B3T (1u << 11) #define C1B3R (1u << 14) /* * Maps the entries in the mux_mode_e enum as offsets so table lookup is O(1) * c - Channel index * s - Subsensor index */ #define CHANNEL_MAPPING(c, s) \ C##c##A##s##T | C##c##B##s##R, /* MUX_UP | MUX_TRANS = 0x00 */ \ C##c##B##s##T | C##c##A##s##R, /* MUX_DOWN | MUX_TRANS = 0x01 */ \ C##c##B##s##T | C##c##B##s##R, /* MUX_UP | MUX_RECV = 0x02 */ \ C##c##A##s##T | C##c##A##s##R /* MUX_DOWN | MUX_RECV = 0x03 */ #define CHANNEL_T_MODES(c, s) \ C##c##A##s##T, /* MUX_UP | MUX_TRANS = 0x00 */ \ C##c##B##s##T, /* MUX_DOWN | MUX_TRANS = 0x01 */ \ C##c##B##s##T, /* MUX_UP | MUX_RECV = 0x02 */ \ C##c##A##s##T /* MUX_DOWN | MUX_RECV = 0x03 */ #define CHANNEL_R_MODES(c, s) \ C##c##B##s##R, /* MUX_UP | MUX_TRANS = 0x00 */ \ C##c##A##s##R, /* MUX_DOWN | MUX_TRANS = 0x01 */ \ C##c##B##s##R, /* MUX_UP | MUX_RECV = 0x02 */ \ C##c##A##s##R /* MUX_DOWN | MUX_RECV = 0x03 */ static const uint16_t map_to_port_4[4] = { CHANNEL_MAPPING(0, 0) }; static const uint16_t map_T_to_port_c[16] = { CHANNEL_T_MODES(1, 0), CHANNEL_T_MODES(1, 1), CHANNEL_T_MODES(1, 2), CHANNEL_T_MODES(1, 3) }; static const uint16_t map_R_to_port_c[16] = { CHANNEL_R_MODES(1, 0), CHANNEL_R_MODES(1, 1), CHANNEL_R_MODES(1, 2), CHANNEL_R_MODES(1, 3) }; /* * Multiplexer state can be stored in a uint16_t, such that the lower * byte directly indexes an array offset for the transmitter state and the * upper byte directly indexes an array offset for the receiver state. * * Usage: * --> Gives you the mux state as a uint16_t * state.group_a.[mode|subchannel_idx] --> mode and subchannel index access for group A * state.group_b.[mode|subchannel_idx] --> mode and subchannel index access for group B * state.group_a.offset --> Array offset for map_T_to_port_c[] * state.group_b.offset --> Array offset for map_R_to_port_c[] * state.channel_idx --> Access to channel index * * See mux.h for a detailed overview of what is meant by "Group A" and "Group B", * what subsensors are, and what the different mode bits are supposed to do. */ union mux_state_u { struct { union { struct { union { struct { unsigned mode : 2; unsigned subchannel_idx : 2; unsigned pad_1 : 4; }; struct { unsigned offset : 4; unsigned pad_2 : 4; }; } group_a; union { struct { unsigned mode : 2; unsigned subchannel_idx : 2; unsigned pad_1 : 4; }; struct { unsigned offset : 4; unsigned pad_2 : 4; }; } group_b; }; struct { unsigned pad_0 : 4; unsigned channel_idx : 4; unsigned pad_1 : 8; }; }; }; uint16_t data; }; /* -------------------------------------------------------------------------- */ void mux_init(void) { PCDIR = 0xFFFF; PCOUT = 0x0000; P4DIR |= 0x27; P4OUT &= ~0x27; } /* -------------------------------------------------------------------------- */ uint8_t mux_channel_count(void) { return 2; } /* -------------------------------------------------------------------------- */ mux_state_t mux_convert_to_state(uint8_t channel_idx, uint8_t group_a_subsensor_idx, uint8_t group_b_subsensor_idx, uint8_t mode) { union mux_state_u state; state.channel_idx = channel_idx; state.group_a.subchannel_idx = group_a_subsensor_idx; state.group_b.subchannel_idx = group_b_subsensor_idx; state.group_a.mode = mode; state.group_b.mode = mode; return; } /* -------------------------------------------------------------------------- */ void mux_convert_from_state(mux_state_t state_u16, uint8_t* channel_idx, uint8_t* group_a_subsensor_idx, uint8_t* group_b_subsensor_idx, uint8_t* mode) { union mux_state_u state; = state_u16; *channel_idx = state.channel_idx; *group_a_subsensor_idx = state.group_a.subchannel_idx; *group_b_subsensor_idx = state.group_b.subchannel_idx; *mode = state.group_a.mode; } /* -------------------------------------------------------------------------- */ void mux_set_state(mux_state_t state_u16) { union mux_state_u state; = state_u16; if (state.channel_idx == 0) { uint8_t bits = map_to_port_4[state.group_a.mode]; /* vertical sensor only has one subsensor */ PCOUT = 0x0000; P4OUT = (P4OUT & ~bits) | bits; } else { P4OUT &= ~0x27; PCOUT = map_T_to_port_c[state.group_a.offset] | map_R_to_port_c[state.group_b.offset]; } } /* -------------------------------------------------------------------------- */ void mux_disable(void) { PCOUT = 0x0000; P4OUT &= ~0x27; }
  2. TheComet

    Linux gamedev?

    All of my projects are cross platform C++ or C :
  3. You said it was 2D, so the velocity vector is either in homogeneous coordinates in which case z=1, or it's a product of using DX structures which are always 3D, even when you're making a 2D game, in which case z=0.
  4. I assume each bullet has a velocity vector (x,y), so set all three to equal the rotation of the player + some offset. bullet_velocity.x = cos(player_angle+45)*bullet_speed bullet_velocity.y = sin(player_angle+45)*bullet_speed
  5. The formula you're looking for is If the vector A or B are of unit length, you can omit dividing by their respective norm. If they are both of unit length, then the angle is simply arccos(dot(A, B)).
  6. TheComet

    What are you working on?

    An update on my project wavesim: I successfully implemented the stepping scheme outlined in the paper for a 2D rectangle: 2d-wavesim-test-2.webm The next step is to support transmission between multiple domains. I also stress-tested my octree with a 10 million polygon sphere, here is the structure imported into blender (since I don't have any graphics support at the moment): It's an 8 level deep tree, it builds in about 1 second and there are less than 500 calls to malloc(). The octree is needed for faster AABB/polygon collision checks during voxelization.
  7. TheComet

    What are you working on?

    I'm working on wavesim, a tool for simulating acoustics in static meshes. Realistic sounding environments are grossly overlooked, even in the most modern AAA games, where the state of the art is to slap some crude reverb filters into the environment. This tool will take a static scene as an input, perform a physically accurate wave simulation, and synthesize a lattice of digital filters which can be applied back to reproduce accurate acoustic behaviour in realtime. This eliminates the laborious job of having to manually assign reverb filters and yields far better-sounding results. Currently, I'm working on an algorithm for efficiently decomposing a scene into rectangular domains. Unlike most acoustic wave simulators which typically use Finite Difference methods (FDTD), the algorithm used in this project abuses the well known analytical solution of the wave equation in rectangular domains, enabling error free propagation within the domain. This means the accuracy of the results at worst will be equal to those of an FDTD simulation, and at best be error free. As great as this sounds, development is slow and I don't really have much to show yet. I think the biggest challenge will be to support domains of different densities, which will allow you to simulate what it would sound like e.g. if you're listening to a sound originating on land while being under water.
  8. TheComet

    Manual syntax trees

    Honestly? It was probably about 5-10 minutes.
  9. This isn't something I'm trying to implement (yet), it's just a curiosity I've had. If you watch the following video from 14:30-14:50 you will see that Banjo is "mounted" (is this the correct term?) on a deforming mesh. Here is another example in Spyro the Dragon, from 1:45-2:05: This seems simple but the more I think about it, the more I am stumped as to how one would achieve this. A moving platform is pretty simple to handle, because you can just calculate an offset to the platform object's center. But that doesn't work for a skinned mesh. Yes, you can to determine which triangle your character is colliding with, but then what? Keeping track of the triangle's position isn't enough, because the vertices may change relative to one another. So you'd have to keep track of a point P on a triangle as it changes shape. What happens when you walk from one triangle over to another triangle? How do you handle the frame in which this occurs? To sum it up, I'm interested in answers to the following questions: In general, what is this even called? "Mounting" a character to a mesh? I can't find anything under that term if I google it. How does the performance of this technique compare between today's games and games made 10 years ago? Does the increase in polygons make it not worth it because it's too computationally expensive now? Do you know of any papers that describe different ways to implement this technique?
  10. Okay I think I have a solution cozzie. This works on paper but I didn't actually "simulate" it to verify that it works. First, let's actually forget about the arrow for a second and also forget about "rotation" and "translation" and "scale". Try to focus on what this problem is really about: It's a change of basis. You have a set of points that exist in the standard basis for R^3 (aka "model space"): You are looking for a matrix M : R^3 -> R^3 which maps the standard basis to a new basis B: Given points p0 and p1 of the arrow in world space, you can calculate the new basis vectors: The new "Z" basis is the arrow's direction: p1-p0. The new "X" basis can be obtained via the cross product with the world's "UP" direction. The new "Y" basis can be calculated with the cross product of the two new basis vectors. Now, because there is also a translation involved, it is necessary to first translate to (0,0,0), apply matrix M, then translate back. Because the standard basis is already at (0,0,0) it makes things quite a bit easier. The matrix M is simply: In your code that would look something like this: bool CDebugDraw::AddArrow(const CR_VECTOR3 &pPos1, const CR_VECTOR3 &pPos2, const CR_VECTOR3 &pColor, const bool pDepthEnabled, const bool pPersistent, const uint64_t pLifeTime) { if(!AddLine(pPos1, pPos2, pColor, pDepthEnabled, pPersistent, pLifeTime)) return false; /* p1 ------- X / | \ | / | \ | / | \ | p2 -----|-----p3 | Z | | | | p0 */ // Form new basis vectors CR_VECTOR3 e3 = pPos2 - pPos1; CR_VECTOR3 e1 = CMathHelper::CrossVec3(e3, CR_VECTOR3(0, 1, 0)); CR_VECTOR3 e2 = CMathHelper::CrossVec3(e1, e3); // Fill in basis vectors into our "B" matrix (note it is transposed because your library uses row major) CR_MATRIX4X4 M; B.m11 = e1.x; B.m12 = e1.y; B.m13 = e1.z; B.m14 = 0; B.m21 = e2.x; B.m22 = e2.y; B.m23 = e2.z; B.m24 = 0; B.m31 = e3.x; B.m32 = e3.y; B.m33 = e3.z; B.m34 = 0; B.m41 = 0; B.m42 = 0; B.m43 = 0; B.m44 = 0; // Create translation matrix "T" (note it is transposed because your library uses row major) CR_MATRIX4X4 T; T.m11 = 1; M.m12 = 0; M.m13 = 0; M.m14 = 0; T.m11 = 0; M.m12 = 1; M.m13 = 0; M.m14 = 0; T.m11 = 0; M.m12 = 0; M.m13 = 1; M.m14 = 0; T.m11 = pPos1.x; M.m12 = pPos1.y; M.m13 = pPos1.z; M.m14 = pPos1.1; // Combine both matrices into the final transformation matrix "M" CR_MATRIX4x4 M = CMathHelper::MultiplyMatrix4x4(T, B); // Define the arrow vertices in model space CR_VECTOR3 p1 = CR_VECTOR3( 0, 0, -1); CR_VECTOR3 p2 = CR_VECTOR3(-0.1, 0, -0.9); CR_VECTOR3 p3 = CR_VECTOR3( 0.1, 0, -0.9); // Do transformation p1 = CMathHelper::TransformVec3Coord(p1, M); p2 = CMathHelper::TransformVec3Coord(p2, M); p3 = CMathHelper::TransformVec3Coord(p3, M); if(!AddLine(pPos1, pPos2, pColor, pDepthEnabled, pPersistent, pLifeTime)) return false; if(!AddLine(p1, p2, CR_VECTOR3(1.0f, 0.0f, 0.0f), pDepthEnabled, pPersistent, pLifeTime)) return false; if(!AddLine(p1, p3, CR_VECTOR3(1.0f, 0.0f, 0.0f), pDepthEnabled, pPersistent, pLifeTime)) return false; if(!AddCross(p2, 0.02f, CR_VECTOR3(0.0f, 0.0f, 1.0f), pDepthEnabled, pPersistent, pLifeTime)) return false; if(!AddCross(p3, 0.02f, CR_VECTOR3(0.0f, 0.0f, 1.0f), pDepthEnabled, pPersistent, pLifeTime)) return false; return true; }
  11. enum class Thing { FOO = 0x01, BAR = 0x02 }; Thing thing = Thing::FOO | Thing::BAR; // doesn't compile This is an age old problem. What is the proper way to achieve what I'm trying to do here? As far as I can tell, using enum class is more a hindrance than a useful tool with flags. I end up typing less with a normal enum: enum Thing { FOO = 0x01, BAR = 0x02 }; unsigned char thing = FOO | BAR;
  12. TheComet

    Who's your intellectual idol?

    For me at the moment it would have to be Joe Rogan. While he's not particularly intellectual in any specific field, the discussions he has lead in his podcasts are often highly intellectual. He is really good at asking the right questions and extracting all of the information out of someone on a particular subject.
  13. TheComet

    FPP Game

    Who upvoted
  14. TheComet

    Ways to avoid Subconscious Prejudice

    By talking to the person you've judged and seeing if what you believed to be true about them is true or not. When I do this, I feel like the majority of the times my initial judgement of the person was correct. I don't know if there is some confirmation bias here though (there probably is). There's a reason why stereotypes exist, it's because there is some truth to them. A very easy example I can think of is: Can you pick the weak, submissive person out of a crowd? These people typically correlate with long hair, eyes to the ground, head tucked into their shoulders, weak posture, etc. The ability to quickly measure others against yourself is built into our monkey brains. It's instinctual to avoid punching a muscly guy two times your size in the face and picking on the weaker guy. Is this a bad thing and should you train yourself to ignore your instincts? I think it depends on the situation. Social gathering? Yeah you should probably ignore your prejudgments. Drinking at a bar? Definitely listen to them.
  15. When I was born, the doctor accidentally handed me a computer keyboard. It took only a few seconds for him to realize the mistake he had made but it was too late; I had already logged on to and downloaded DarkBASIC Classic, a horribly written software package for developing DirectX 7 based games in the BASIC language. I spent the next 6 years of my life learning the unfathomable number of quirks of DarkBASIC instead of learning how to walk and interact with other humans. My parents were worried, so they bought me a football. Finally, I had a chair to sit on and write games properly. After having worked on over 200 projects, I realized how bad DarkBASIC was, so I downloaded Ogre3D 1.7.8 and compiled it in 2 hours. I had no idea what the hell was going on. C++ was difficult and strange and really, really complicated. The next 5 years were all C++ centered, I learned the language, I developed a multitude of different applications but still haven't made a single game yet, even to this day. Somehow, C++ has made me worry about all of the little things that didn't matter in DarkBASIC: Design patters, memory considerations, build systems, unit testing, performance considerations... I am being bogged down by all of this crap and it is preventing me from just having fun and writing games. This is what I miss most about DarkBASIC, as horrible as it was.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!