Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How to do a interactive camera 3D view in C#

How to do a interactive camera 3D view in C#

Scheduled Pinned Locked Moved C#
csharpgraphicshelptutorial
6 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TeiUKei
    wrote on last edited by
    #1

    I have done a code on 3D office. I would like to do it in interactive way which by pressing the arrow button, the object can be viewed from different perspective. However, my result come out with static image and my objects all disappear. The object exists if i doesn't include the Checkmovement function inside. I wonder what mistake i have done. Could anyone please kindly help me review my code and give comment. Thanks. using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using MTV3D65; namespace TrueVisionTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Main_Quit(); Application.Exit(); } //Declare the TrueVision3D 'parts' TVMesh _meshRoom = null; TVMesh _meshFan = null; TVMesh _meshTable = null; TVMesh _meshSofa = null; TVMesh _meshComputer = null; TVMesh _Lamp = null; TVMesh _Cabinet = null; TVMesh _meshChair = null; TVEngine TV = null; TVScene _scene = null; TVGlobals global = new TVGlobals(); TVLightEngine _TVLightEngine = null; TVInputEngine InputEngine; TVTextureFactory TexFactory = new TVTextureFactory(); TVMaterialFactory MatFactory = new TVMaterialFactory(); TVLandscape Land; TVScene Scene; float sngPositionX; float sngPositionY; float sngPositionZ; float sngLookAtX; float sngLookAtY; float sngLookAtZ; float sngWalk; float sngStrafe; float sngAngleX, sngAngleY; int tmpMouseX, tmpMouseY; bool tmpMouseB1, tmpMouseB2, tmpMouseB3, tmpMouseB4; int tmpMouseScrollOld, tmpMouseScrollNew; float x_move = 30.0f, y_move = -30.0f, z_move = 150.0f; void InitializeTrueVision() { TV = new TVEngine(); TV.Init3DWindowed(this.pictureBox1.Handle, true); TV.SetSearchDirectory(System.Windows.Forms.Application.ExecutablePath); TV.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE); TV.DisplayFPS(true); } TV_LIGHT light;

    A A 2 Replies Last reply
    0
    • T TeiUKei

      I have done a code on 3D office. I would like to do it in interactive way which by pressing the arrow button, the object can be viewed from different perspective. However, my result come out with static image and my objects all disappear. The object exists if i doesn't include the Checkmovement function inside. I wonder what mistake i have done. Could anyone please kindly help me review my code and give comment. Thanks. using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using MTV3D65; namespace TrueVisionTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Main_Quit(); Application.Exit(); } //Declare the TrueVision3D 'parts' TVMesh _meshRoom = null; TVMesh _meshFan = null; TVMesh _meshTable = null; TVMesh _meshSofa = null; TVMesh _meshComputer = null; TVMesh _Lamp = null; TVMesh _Cabinet = null; TVMesh _meshChair = null; TVEngine TV = null; TVScene _scene = null; TVGlobals global = new TVGlobals(); TVLightEngine _TVLightEngine = null; TVInputEngine InputEngine; TVTextureFactory TexFactory = new TVTextureFactory(); TVMaterialFactory MatFactory = new TVMaterialFactory(); TVLandscape Land; TVScene Scene; float sngPositionX; float sngPositionY; float sngPositionZ; float sngLookAtX; float sngLookAtY; float sngLookAtZ; float sngWalk; float sngStrafe; float sngAngleX, sngAngleY; int tmpMouseX, tmpMouseY; bool tmpMouseB1, tmpMouseB2, tmpMouseB3, tmpMouseB4; int tmpMouseScrollOld, tmpMouseScrollNew; float x_move = 30.0f, y_move = -30.0f, z_move = 150.0f; void InitializeTrueVision() { TV = new TVEngine(); TV.Init3DWindowed(this.pictureBox1.Handle, true); TV.SetSearchDirectory(System.Windows.Forms.Application.ExecutablePath); TV.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE); TV.DisplayFPS(true); } TV_LIGHT light;

      A Offline
      A Offline
      Andrew Rissing
      wrote on last edited by
      #2

      I would assume you've just got some bad math going on in the camera position calculations. I would look at your values you're calculating for the following line of code and verify you're not moving the camera into a position/angle that is away from your 'office'. Scene.SetCamera(sngPositionX, sngPositionY, sngPositionZ, sngLookAtX, sngLookAtY, sngLookAtZ); Your initial values are: sngPositionX = 0; sngPositionY = 20; sngPositionZ = 0; sngLookAtX = 0; sngLookAtY = 20; sngLookAtZ = 50; So, see if you're pointing your camera in the wrong direction.

      T 1 Reply Last reply
      0
      • T TeiUKei

        I have done a code on 3D office. I would like to do it in interactive way which by pressing the arrow button, the object can be viewed from different perspective. However, my result come out with static image and my objects all disappear. The object exists if i doesn't include the Checkmovement function inside. I wonder what mistake i have done. Could anyone please kindly help me review my code and give comment. Thanks. using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using MTV3D65; namespace TrueVisionTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Main_Quit(); Application.Exit(); } //Declare the TrueVision3D 'parts' TVMesh _meshRoom = null; TVMesh _meshFan = null; TVMesh _meshTable = null; TVMesh _meshSofa = null; TVMesh _meshComputer = null; TVMesh _Lamp = null; TVMesh _Cabinet = null; TVMesh _meshChair = null; TVEngine TV = null; TVScene _scene = null; TVGlobals global = new TVGlobals(); TVLightEngine _TVLightEngine = null; TVInputEngine InputEngine; TVTextureFactory TexFactory = new TVTextureFactory(); TVMaterialFactory MatFactory = new TVMaterialFactory(); TVLandscape Land; TVScene Scene; float sngPositionX; float sngPositionY; float sngPositionZ; float sngLookAtX; float sngLookAtY; float sngLookAtZ; float sngWalk; float sngStrafe; float sngAngleX, sngAngleY; int tmpMouseX, tmpMouseY; bool tmpMouseB1, tmpMouseB2, tmpMouseB3, tmpMouseB4; int tmpMouseScrollOld, tmpMouseScrollNew; float x_move = 30.0f, y_move = -30.0f, z_move = 150.0f; void InitializeTrueVision() { TV = new TVEngine(); TV.Init3DWindowed(this.pictureBox1.Handle, true); TV.SetSearchDirectory(System.Windows.Forms.Application.ExecutablePath); TV.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE); TV.DisplayFPS(true); } TV_LIGHT light;

        A Offline
        A Offline
        Ashfield
        wrote on last edited by
        #3

        Why would anyone want to wade through over 400 lines of unformatted code to work out what you have done wrong? Try running in debug mode and see where things go wrong.

        Bob Ashfield Consultants Ltd

        A 1 Reply Last reply
        0
        • A Ashfield

          Why would anyone want to wade through over 400 lines of unformatted code to work out what you have done wrong? Try running in debug mode and see where things go wrong.

          Bob Ashfield Consultants Ltd

          A Offline
          A Offline
          Andrew Rissing
          wrote on last edited by
          #4

          Agreed. Reading the unformatted code is not easy, especially since you don't limit it down to what's important.

          1 Reply Last reply
          0
          • A Andrew Rissing

            I would assume you've just got some bad math going on in the camera position calculations. I would look at your values you're calculating for the following line of code and verify you're not moving the camera into a position/angle that is away from your 'office'. Scene.SetCamera(sngPositionX, sngPositionY, sngPositionZ, sngLookAtX, sngLookAtY, sngLookAtZ); Your initial values are: sngPositionX = 0; sngPositionY = 20; sngPositionZ = 0; sngLookAtX = 0; sngLookAtY = 20; sngLookAtZ = 50; So, see if you're pointing your camera in the wrong direction.

            T Offline
            T Offline
            TeiUKei
            wrote on last edited by
            #5

            Thanks to Andrew for kindly answer my question. Sorry to Ashfield if i have ask a stupid question but i have debugged it and it appeared no error. So, i just want to get what is wrong behind my logic. Anyway, thank you!

            A 1 Reply Last reply
            0
            • T TeiUKei

              Thanks to Andrew for kindly answer my question. Sorry to Ashfield if i have ask a stupid question but i have debugged it and it appeared no error. So, i just want to get what is wrong behind my logic. Anyway, thank you!

              A Offline
              A Offline
              Andrew Rissing
              wrote on last edited by
              #6

              There are no stupid questions. Regardless, by spending a little more time up front phrasing your question and making it easy to get a grasp of your problem, you'll find people are more willing to spend the time to answer you. It's just some helpful advice.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups