Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: "Attempted to write or read protected memory..."HE  (Read 2462 times)
Coffei
Community Member
*
Posts: 12


« on: January 09, 2007, 09:50:18 AM »

Please excuse my English, I'm only 15 years old and I'm from Czech Republic Cheesy ...
I'v tried to make simple code in VB.NET (Visual studio 2005)  with small terrain. I wrote the code, and I started it. Then the Visual Studio marked this part of the code: "Engine.clear()" in Looping phase and it threw out small window with error description: "Attempted to write or read protected memory..". I'v tried minimized textured size and minimized terrain size, but nothing helped me. I really don't know what's the problem here. Please anybody who knows something about this error, answer me to my E-mail or just here on this forum...
Logged
amadrias
Customers
Community Member
*****
Posts: 155


« Reply #1 on: January 09, 2007, 09:55:13 AM »

Hi, you should post your code so we can see what is wrong.

Regards
Logged

AriusMyst
Guest
« Reply #2 on: January 09, 2007, 09:59:46 AM »

Sounds like you haven't instantiated CTVEngine. But as Amadrias said, post your code otherwise its just guess work.  Smiley

Welcome to the TV3D forum. Wink

Edit: Yea, ignore my post. It makes no sense. Thats what I get for posting before i've awoken properly.  :oops:
Logged
324
Customers
Community Member
*****
Posts: 65


« Reply #3 on: January 09, 2007, 10:00:49 AM »

Your code is not thread safe. Make some debugging and in the lines which throw this exception use try and catch. I had the same problem!!! Try to load your textures in deferent sequence of function call or load all of them in one function. It's a matter of threading
Logged

The Blog of Greek Game Developers.
www.blog.game-developer.gr/
BlindSide
Customers
Community Member
*****
Posts: 759


WWW
« Reply #4 on: January 09, 2007, 12:03:09 PM »

/* ignore */
Logged

Blind's Dev Blog - www.smithbower.com/devblog/

Irc.Desolation.Org :: #TV3DLicensed :: Moderated IRC channel for all your TV3D needs :: Non-Licensed users welcome.
mikeyj21
Customers
Community Member
*****
Posts: 20


« Reply #5 on: January 10, 2007, 06:43:38 AM »

Hi!

Usually if I get this error, it is because I am trying to perform an action upon a missing resource.
For example, If I try setting a splatting texture for a terrain which hasn't been loaded (because I have the path to it wrong or soemthing!).

--Mike--
Logged
Coffei
Community Member
*
Posts: 12


« Reply #6 on: January 10, 2007, 11:41:30 AM »

Ok.. I really don't know what to do, so i post my code here:

Option Strict Off
Option Explicit On
Public Class Form1

    Inherits System.Windows.Forms.Form





    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Show()
       
        Kamera = New TrueVision3D.TVCamera
        Engine = New TrueVision3D.TVEngine
        Land = New TrueVision3D.TVLandscape
        Atmo = New TrueVision3D.TVAtmosphere
        Inp = New TrueVision3D.TVInputEngine
        TextFac = New TrueVision3D.TVTextureFactory
        Scena = New TrueVision3D.TVScene
        Sound = New TV3DMedia.TVSoundEngine
        Grafic = New TrueVision3D.TVGraphicEffect

        Engine.SetDebugFile("C:/Debugator.txt")

        Engine.Init3DWindowedMode(Me.Handle.ToInt32)
        Engine.DisplayFPS = True
        Engine.SetAngleSystem(TrueVision3D.CONST_TV_ANGLE.TV_ANGLE_DEGREE)


        TextFac.LoadBumpTexture(   path to texture   , "Sky")
        TextFac.LoadTexture(   path to texture   , "Zem")
        TextFac.LoadTexture(   path to texture   , "Skydyna")



        Scena.SetMipMappingPrecision(-4)
        Scena.SetViewFrustum(90, 100000)
        Scena.SetTextureFilter(TrueVision3D.CONST_TV_TEXTUREFILTER.TV_FILTER_ANISOTROPIC)



        Land.GenerateHugeTerrain(   path to heightmap   , TrueVision3D.CONST_TV_LANDSCAPE_PRECISION.TV_PRECISION_LOW, 10, 10, 0, 0, True)
        Land.SetTexture(TrueVision3DTVGlobals_definst.GetTex("Zem"))
        Land.SetTextureScale(10, 10, -1)
        Land.InitClouds(TrueVision3DTVGlobals_definst.GetTex("Skydyna"), TrueVision3D.CONST_TV_LAND_CLOUDMODE.TV_CLOUD_MOVE, 250, 1, 1, 1, 1, 2048)
        Land.SetCloudVelocity(1, 0.1, 0.1)

        Atmo.SkyBox_Enable(True)
        Scena.SetSceneBackGround(0.4, 0.6, 0.9)


        sngPositionX = 0
        sngPositionY = 20
        sngPositionZ = 0
        snglookatX = 0
        snglookatY = 20
        snglookatZ = 50
        sngAngleX = 0
        sngAngleY = 0

        Walk = 0
        Strafe = 0
        loopign = True

        Do_looping()

    End Sub
______________________________________________________________________________________________________________________________

    Private Sub Do_looping()
        Do
            System.Windows.Forms.Application.DoEvents()
            If Inp.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_ESCAPE) = True Then
               looping = False
            End If

            Input_check()

            Input_do()

            Engine.Clear()

            Atmo.Atmosphere_Render()

            Scena.RenderAllMeshes()

            Engine.RenderToScreen()
        Loop Until looping = True

        Quit_main()
    End Sub
____________________________________________________________________________________________________________________________

    Private Sub Input_check()
        With Inp
            If .IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_W) = True Then
                Walk = 1

            ElseIf .IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_S) = True Then
                Walk = -1
            End If

            If .IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_A) = True Then
                Strafe = -1
            ElseIf .IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_D) = True Then
                Strafe = 1
            End If

            Dim tmpMouseX, tmpMouseY As Integer
            Dim tmpMouseB2, tmpMouseB1, tmpMouseB3 As Short
            Dim tmpMouseScrollOld, tmpMouseScrollNew As Integer
            tmpMouseScrollOld = tmpMouseScrollNew
            .GetMouseState(tmpMouseX, tmpMouseY, tmpMouseB1, tmpMouseB2, tmpMouseB3, tmpMouseScrollNew)

            sngAngleX = sngAngleX - (tmpMouseY / 100)
            sngAngleY = sngAngleY - (tmpMouseX / 100)
        End With
    End Sub

    Private Sub Input_do()
        If sngAngleX > 1.3 Then sngAngleX = 1.3
        If sngAngleX < -1.3 Then sngAngleX = -1.3

        sngPositionX = sngPositionX + (System.Math.Cos(sngAngleY) * Walk / 5) + (System.Math.Cos(sngAngleY + 3.141596 / 2) * Strafe / 5 * Engine.TimeElapsed)
        sngPositionZ = sngPositionZ + (System.Math.Sin(sngAngleY) * Walk / 5) + (System.Math.Sin(sngAngleY + 3.141596 / 2) * Strafe / 5 * Engine.TimeElapsed)
        sngPositionY = 10

        snglookatX = sngPositionX + System.Math.Cos(sngAngleY)
        snglookatY = sngPositionY + System.Math.Tan(sngAngleX)
        snglookatZ = sngPositionZ + System.Math.Sin(sngAngleY)


        Kamera.SetPosition(sngPositionX, sngPositionY, sngPositionZ)
        Kamera.SetRotation(snglookatX, snglookatY, snglookatZ)
    End Sub

_______________________________________________________________________________________________________________________________
    Private Sub Quit_main()
     
      Here I destroy everything what i declared before...

    End Sub
End Class


It's long, but I'm really amater, so i don't know what do you want see...
PLEASE help..
Logged
Virtual X
Community Member
*
Posts: 1


« Reply #7 on: January 17, 2007, 03:46:54 PM »

I've had this problem before, the problem was caused by calling a function before the video display was initialized - atleast in my case.

as a rule of thumb, I always initialize the video display BEFORE calling anything else, well... apart from variables, objects etc...

in your case,

Code:

 Me.Show()

Kamera = New TrueVision3D.TVCamera
Engine = New TrueVision3D.TVEngine
Land = New TrueVision3D.TVLandscape
Atmo = New TrueVision3D.TVAtmosphere
Inp = New TrueVision3D.TVInputEngine
TextFac = New TrueVision3D.TVTextureFactory
Scena = New TrueVision3D.TVScene
Sound = New TV3DMedia.TVSoundEngine
Grafic = New TrueVision3D.TVGraphicEffect

Engine.SetDebugFile("C:/Debugator.txt")

Engine.Init3DWindowedMode(Me.Handle.ToInt32)
Engine.DisplayFPS = True
Engine.SetAngleSystem(TrueVision3D.CONST_TV_ANGLE.TV_ANGLE_DEGREE)



try swapping Engine.SetDebugFile(blah blah) and Engine Init3DWindowedMode

e.g.

Code:

Engine.Init3DWindowedMode(Me.Handle.ToInt32)
Engine.SetDebugFile("C:/Debugator.txt")


again, initialize the 3D window BEFORE any other calls to the truevision engine.
Logged
BlindSide
Customers
Community Member
*****
Posts: 759


WWW
« Reply #8 on: January 17, 2007, 05:17:26 PM »

Actually, you can set the debug path before engine init without problems (this is because as soon as you init the engine output is dumped to the debug file). However, you are right, it is good practice to init the engine before doing anything else.
Logged

Blind's Dev Blog - www.smithbower.com/devblog/

Irc.Desolation.Org :: #TV3DLicensed :: Moderated IRC channel for all your TV3D needs :: Non-Licensed users welcome.
darqSHADOW
Administrator
Community Member
*****
Posts: 2737


« Reply #9 on: January 17, 2007, 06:10:57 PM »

The problem with the code you posted is as the others have said.  You should first create and init the 3D engine, then you can create your other objects.  (Calling New on these objects prior to init'ing of the engine will cause a crash, as you described.)

DS
Logged

TrueVision3D Project Manager
The fast and simple way of 3D development.
Hypnotron
Customers
Community Member
*****
Posts: 820


« Reply #10 on: January 18, 2007, 12:13:12 AM »

also

Land = New TrueVision3D.TVLandscape

is no longer correct way to init landscape.  You must use Land = Scene.CreateLandScape()
Logged
jmaddox
Customers
Community Member
*****
Posts: 525


« Reply #11 on: January 18, 2007, 03:39:41 PM »

That change only applies to 6.5, no?

Jim
Logged
Hypnotron
Customers
Community Member
*****
Posts: 820


« Reply #12 on: January 19, 2007, 02:35:58 AM »

yeah.  i dont know why i assumed he was using 6.5.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks