Advertisement Jump to content
  • Advertisement

Catch_0x16

Member
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

3 Neutral

About Catch_0x16

  • Rank
    Newbie

Personal Information

  • Interests
    Programming

Recent Profile Visitors

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

  1. Hello folks, In my company we use Unity on both Windows desktop machines, and Android tablets/phones. We have a requirement to be able to stream raw imagery from these devices over the network during their use (so that we can run algorithms on the image data). On a Windows machine, running DirectX9 this was really easy, I just wrote a C++ native plugin that created an offscreen surface and copied the contents of the backbuffer into it. However I'm having difficulty in working out how we can do this for OpenglES (phones and tablets). I have two main questions: Does the Native C++ plugin API work on android devices? (does Unity build the .so files into the .apk?) How do I scrape the backbuffer in OpenGL ES? And also, I am curious as to whether there is a quick and efficient way to do this via script in Unity itself? I managed to get the buffer pixels, but had trouble running a separate network thread and getting the two working in sync without issues surrounding having to do everything on the rendering thread. Any help and advice would be much appreciated. Thanks!
  2. Catch_0x16

    Simple trig problem driving me crazy

    I agree, this is actually what I'm doing. I was previous passing down the position and rotation of the parent object, and moving the sub-objects around to suit the new position. Having a proper transformation matrix makes this really easy now as I simply pass a reference to the parent transform, far fewer lines of code!
  3. Catch_0x16

    Simple trig problem driving me crazy

    Thanks all, as promised a working gif. I ended up using transforms in the end, I didn't realize they were implemented so well in SFML (doh!) Thanks also to @Scouting Ninja for a great response
  4. Catch_0x16

    Simple trig problem driving me crazy

    Yeah I feel like I really should've been using transforms from the beginning - didn't know SFML had them! (Didn't look for them to be fair). Oh well silly me Thanks for the input folks, will post a working image once I've fixed it
  5. Catch_0x16

    Simple trig problem driving me crazy

    Hey mate, No probs, I should've explained. So basically the offset parameters are supplied via a config file, and describe the offset in pixels, from the centre of the sprite, that the component sprite(s) should be rendered. So for example, the exhaust jet for this particular sprite is at offset (-50,-14) from the center of the sprite. When the sprite rotates, the sub-sprite should too
  6. Catch_0x16

    Simple trig problem driving me crazy

    This sounds entirely like a good idea, I'll look into transforms, thanks!
  7. Catch_0x16

    Simple trig problem driving me crazy

    Hah, Thanks! yeah I think you're right. Problem still persists though sadly. Still wonky but better! Anyone else have any ideas what might be causing this?
  8. Hello folks, I am fighting with a really simple problem that has been driving me nuts. I'm usually fairly confident with trigonometry and I'm pretty sure the issue here is not the math but in some behavior behind the scenes. A bit of background - basically I'm developing my own little 2D game engine using C++, in my free-time for fun. I work with game technology and simulation products IRL so for the most part this has been plain sailing. I am using Box2D for physics, and SFML for rendering. My game at current has a few space ships flying around via keyboard and AI input. These space ships need exhausts! So I'm currently in the process of getting a 'component' system in place, however my problem is that the animated exhaust sprites are not going where I want them to. When the base GameObject class runs it's update method, it does the following: Queries the physics object for a position Converts the physics position to a pixel position (x10 scale factor) Moves the sprite to the new position Passes new position to all 'component' objects into their 'UpdateComponent' method Components move their sprite to the correct position However the exhaust sprites seem to wander around all over the place, in no way representing where I actually want them to be! This should have been a simple case of: newPosition = (sin(rotationRadians) * offsetX, cos(rotationRadians) * offsetY) + oldPosition Here is the current code: void Exhaust::UpdateComponent(const Vec2f & position, float rotationDegrees, float deltaTime) { float angleRad = DEGREES_TO_RADIANS(rotationDegrees); float offsetX = sin(angleRad) * mOffset.x; float offsetY = cos(angleRad) * mOffset.y; sf::Vector2f newPos(position.x + offsetX, position.y + offsetY); mSprite->SetRotation(rotationDegrees); mSprite->SetPosition(newPos); mSprite->Update(deltaTime); #ifdef _DEBUG sf::Vector2f p(position.x, position.y); stringstream ss; ss << rotationDegrees; DebugUtils::DrawCross(p, 8, sf::Color::Green, ss.str()); DebugUtils::DrawCross(newPos, 8, sf::Color::Green); DebugUtils::DrawLine(p, newPos, sf::Color::Green); cout << rotationDegrees << endl; DebugUtils::DrawSpriteOutline(*mSprite->GetGraphic(), sf::Color::Green); #endif // _DEBUG } And here is a gif of it all going wrong! (link below) Gif of game engine problem Any help would be much appreciated, even if it is just a thought of where the problem might be originating from! Thanks!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!