diff --git a/Engine/Android/GenesisLoader/Genesis/assets/Config.ini b/Engine/Android/GenesisLoader/Genesis/assets/Config.ini index 9c9d6c8..e8daae7 100644 --- a/Engine/Android/GenesisLoader/Genesis/assets/Config.ini +++ b/Engine/Android/GenesisLoader/Genesis/assets/Config.ini @@ -1,8 +1,8 @@ [webjet] assetname="asdasd" -scenename="asset:test_shader.scene" -gamedir="/test_shader" +scenename="asset:editorBox3.scene" +gamedir="/editorBox3" packagename="com.genesis" remotepath="" -usePrecompilerShader="true" +usePrecompilerShader="false" \ No newline at end of file diff --git a/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisActivity.java b/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisActivity.java index 2b6db8b..aad85a1 100644 --- a/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisActivity.java +++ b/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisActivity.java @@ -30,11 +30,13 @@ import org.genesis.lib.GenesisHelperListener; import com.genesis.R; import android.app.Activity; +import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.PaintDrawable; import android.os.Bundle; import android.os.Message; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.widget.FrameLayout; public abstract class GenesisActivity extends Activity implements GenesisHelperListener { @@ -44,6 +46,7 @@ public abstract class GenesisActivity extends Activity implements GenesisHelperL private static final String TAG = GenesisActivity.class.getSimpleName(); // =========================================================== private GenesisGLSurfaceView mGLSurefaceView; + private int s_topPos; public GenesisGLSurfaceView GetSurfaceView() { @@ -120,16 +123,90 @@ public abstract class GenesisActivity extends Activity implements GenesisHelperL ViewGroup.LayoutParams.FILL_PARENT); FrameLayout framelayout = new FrameLayout(this); framelayout.setLayoutParams(framelayout_params); + + + // Cocos2dxGLSurfaceView this.mGLSurefaceView = new GenesisGLSurfaceView(this); - - // ...add to FrameLayout framelayout.addView(mGLSurefaceView); + + //edittext view + // Cocos2dxEditText layout + FrameLayout.LayoutParams edittext_layout_params = + new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, + FrameLayout.LayoutParams.WRAP_CONTENT); + final GenesisEditText edittext = new GenesisEditText(this); + edittext.setLayoutParams(edittext_layout_params); + framelayout.addView(edittext); + mGLSurefaceView.setBackgroundResource(R.drawable.load); mGLSurefaceView.setGenesisRenderer(new GenesisRenderer(this)); + this.mGLSurefaceView.setGenesisEditText(edittext); + //!-- keyboardheight + final FrameLayout fframelayout = framelayout; + + fframelayout.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { + + @Override + public void onGlobalLayout() { + // TODO Auto-generated method stub + Rect r = new Rect(); + edittext.getWindowVisibleDisplayFrame(r); + + int screenHeight = edittext.getRootView().getHeight(); + int screenWidth = edittext.getRootView().getWidth(); + int heightDifference = screenHeight - (r.bottom - r.top); + + boolean visible = heightDifference > screenHeight / 3; + + //set edittext postion + int editBottom = edittext.getBottom(); + int editHeight = edittext.getHeight(); + //((EditText) edittext).setBottom(heightDifference); + + boolean keyboardVisible = false; + int topPos = screenHeight; + if(r.bottom < screenHeight) + { + keyboardVisible = true; + topPos = r.bottom - editHeight ; + } + if(s_topPos == topPos) + { + return; + } + s_topPos = topPos; + FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) edittext.getLayoutParams(); + params.leftMargin = 0; + params.topMargin = topPos; + params.width = screenWidth; + params.height = editHeight; +// params.rightMargin = screenWidth; +// params.bottomMargin = heightDifference; + edittext.setLayoutParams(params); + + if(keyboardVisible) + { + FrameLayout flayout = (FrameLayout) edittext.getParent(); + flayout.removeView(edittext); + flayout.addView(edittext); + + edittext.setFocusable(true); + edittext.setFocusableInTouchMode(true); + edittext.requestFocus(); + + } + + //edittext.getParent().bringChildToFront(edittext); + + + + + } + }); // Set framelayout as the content view setContentView(framelayout); } diff --git a/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisEditText.java b/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisEditText.java new file mode 100644 index 0000000..060c656 --- /dev/null +++ b/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisEditText.java @@ -0,0 +1,90 @@ +/**************************************************************************** +Copyright (c) 2006, Radon Labs GmbH +Copyright (c) 2011-2013,WebJet Business Division,CYOU + +http://www.genesis-3d.com.cn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +package org.genesis.lib; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.KeyEvent; +import android.widget.EditText; + +public class GenesisEditText extends EditText { + // =========================================================== + // Constants + // =========================================================== + + // =========================================================== + // Fields + // =========================================================== + + private GenesisGLSurfaceView mGenesisGLSurfaceView; + + // =========================================================== + // Constructors + // =========================================================== + + public GenesisEditText(final Context context) { + super(context); + } + + public GenesisEditText(final Context context, final AttributeSet attrs) { + super(context, attrs); + } + + public GenesisEditText(final Context context, final AttributeSet attrs, final int defStyle) { + super(context, attrs, defStyle); + } + + // =========================================================== + // Getter & Setter + // =========================================================== + + public void setGenesisGLSurfaceView(final GenesisGLSurfaceView pGenesisGLSurfaceView) { + this.mGenesisGLSurfaceView = pGenesisGLSurfaceView; + } + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + @Override + public boolean onKeyDown(final int pKeyCode, final KeyEvent pKeyEvent) { + super.onKeyDown(pKeyCode, pKeyEvent); + + /* Let GlSurfaceView get focus if back key is input. */ + if (pKeyCode == KeyEvent.KEYCODE_BACK) { + this.mGenesisGLSurfaceView.requestFocus(); + } + + return true; + } + + // =========================================================== + // Methods + // =========================================================== + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== +} diff --git a/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisGLSurfaceView.java b/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisGLSurfaceView.java index 5da4b19..34854b2 100644 --- a/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisGLSurfaceView.java +++ b/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisGLSurfaceView.java @@ -58,6 +58,7 @@ public class GenesisGLSurfaceView extends GLSurfaceView { private static Handler sHandler; private GenesisActivity mActivity; private static GenesisGLSurfaceView mGenesisGLSurfaceView; + private static GenesisTextInputWraper sGenesisTextInputWraper; private String gamedir; private String scenename; @@ -69,10 +70,23 @@ public class GenesisGLSurfaceView extends GLSurfaceView { private boolean usePrecompilerShader; private GenesisRenderer mGenesisRenderer; + private GenesisEditText mGenesisEditText; private ContextFactory mContextFactory; private AssetManager mMgr; + //get set methods===================================================================================== + public GenesisEditText getGenesisEditText() { + return this.mGenesisEditText; + } + public void setGenesisEditText(final GenesisEditText pGenesisEditText) { + this.mGenesisEditText = pGenesisEditText; + if (null != this.mGenesisEditText && null != GenesisGLSurfaceView.sGenesisTextInputWraper) { + this.mGenesisEditText.setOnEditorActionListener(GenesisGLSurfaceView.sGenesisTextInputWraper); + this.mGenesisEditText.setGenesisGLSurfaceView(this); + this.requestFocus(); + } + } private void GetStorageType(final Context context) { String sgamedir = gamedir; @@ -135,6 +149,7 @@ public class GenesisGLSurfaceView extends GLSurfaceView { return availableSize/(1024*1024); } + private void copyAllResFiles(final Context context,String Data,String Dest) { Log.d( "copy", "copy start"); @@ -430,17 +445,40 @@ public class GenesisGLSurfaceView extends GLSurfaceView { this.setFocusableInTouchMode(true); GenesisGLSurfaceView.mGenesisGLSurfaceView = this; + GenesisGLSurfaceView.sGenesisTextInputWraper = new GenesisTextInputWraper(this); GenesisGLSurfaceView.sHandler = new Handler() { @Override public void handleMessage(final Message msg) { switch (msg.what) { case HANDLER_OPEN_IME_KEYBOARD: - + { + + + if (null != GenesisGLSurfaceView.this.mGenesisEditText && GenesisGLSurfaceView.this.mGenesisEditText.requestFocus()) { + GenesisGLSurfaceView.this.mGenesisEditText.removeTextChangedListener(GenesisGLSurfaceView.sGenesisTextInputWraper); + GenesisGLSurfaceView.this.mGenesisEditText.setText(""); + final String text = (String) msg.obj; + GenesisGLSurfaceView.this.mGenesisEditText.append(text); + GenesisGLSurfaceView.sGenesisTextInputWraper.setOriginText(text); + GenesisGLSurfaceView.this.mGenesisEditText.addTextChangedListener(GenesisGLSurfaceView.sGenesisTextInputWraper); + final InputMethodManager imm = (InputMethodManager) GenesisGLSurfaceView.mGenesisGLSurfaceView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(GenesisGLSurfaceView.this.mGenesisEditText, 0); + Log.d("GLSurfaceView", "showSoftInput"); + } + } break; case HANDLER_CLOSE_IME_KEYBOARD: - + { + if (null != GenesisGLSurfaceView.this.mGenesisEditText) { + GenesisGLSurfaceView.this.mGenesisEditText.removeTextChangedListener(GenesisGLSurfaceView.sGenesisTextInputWraper); + final InputMethodManager imm = (InputMethodManager) GenesisGLSurfaceView.mGenesisGLSurfaceView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(GenesisGLSurfaceView.this.mGenesisEditText.getWindowToken(), 0); + GenesisGLSurfaceView.this.requestFocus(); + Log.d("GLSurfaceView", "HideSoftInput"); + } + } break; } } @@ -545,7 +583,7 @@ public class GenesisGLSurfaceView extends GLSurfaceView { } /* - * This function is called before Cocos2dxRenderer.nativeInit(), so the + * This function is called before GenesisRenderer.nativeInit(), so the * width and height is correct. */ @Override @@ -794,5 +832,34 @@ public class GenesisGLSurfaceView extends GLSurfaceView { private int[] mValue = new int[1]; } - + // called by c++========================================================================== + public static void openIMEKeyboard() { + final Message msg = new Message(); + msg.what = GenesisGLSurfaceView.HANDLER_OPEN_IME_KEYBOARD; + msg.obj = GenesisGLSurfaceView.mGenesisGLSurfaceView.mGenesisRenderer.getContentText(); + GenesisGLSurfaceView.sHandler.sendMessage(msg); + } + + public static void closeIMEKeyboard() { + final Message msg = new Message(); + msg.what = GenesisGLSurfaceView.HANDLER_CLOSE_IME_KEYBOARD; + GenesisGLSurfaceView.sHandler.sendMessage(msg); + } + //text input methods=================================================================================== + public void insertText(final String pText) { + this.queueEvent(new Runnable() { + @Override + public void run() { + GenesisGLSurfaceView.this.mGenesisRenderer.handleInsertText(pText); + } + }); + } + public void deleteBackward() { + this.queueEvent(new Runnable() { + @Override + public void run() { + GenesisGLSurfaceView.this.mGenesisRenderer.handleDeleteBackward(); + } + }); + } } \ No newline at end of file diff --git a/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisTextInputWraper.java b/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisTextInputWraper.java new file mode 100644 index 0000000..6958c0c --- /dev/null +++ b/Engine/Android/GenesisLoader/Genesis/src/org/genesis/lib/GenesisTextInputWraper.java @@ -0,0 +1,193 @@ +/**************************************************************************** +Copyright (c) 2006, Radon Labs GmbH +Copyright (c) 2011-2013,WebJet Business Division,CYOU + +http://www.genesis-3d.com.cn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +package org.genesis.lib; + +import android.content.Context; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.Log; +import android.view.KeyEvent; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.widget.TextView; +import android.widget.TextView.OnEditorActionListener; + +public class GenesisTextInputWraper implements TextWatcher, OnEditorActionListener { + // =========================================================== + // Constants + // =========================================================== + + private static final String TAG = GenesisTextInputWraper.class.getSimpleName(); + + // =========================================================== + // Fields + // =========================================================== + + private final GenesisGLSurfaceView mGenesisGLSurfaceView; + private String mText; + private String mOriginText; + private int mCurrentInputPos; + private int mCountChar; + + // =========================================================== + // Constructors + // =========================================================== + + public GenesisTextInputWraper(final GenesisGLSurfaceView pGenesisGLSurfaceView) { + this.mGenesisGLSurfaceView = pGenesisGLSurfaceView; + } + + // =========================================================== + // Getter & Setter + // =========================================================== + + private boolean isFullScreenEdit() { + final TextView textField = this.mGenesisGLSurfaceView.getGenesisEditText(); + final InputMethodManager imm = (InputMethodManager) textField.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + return imm.isFullscreenMode(); + } + + public void setOriginText(final String pOriginText) { + this.mOriginText = pOriginText; + } + + // =========================================================== + // Methods for/from SuperClass/Interfaces + // =========================================================== + + @Override + public void afterTextChanged(final Editable s) { + if (this.isFullScreenEdit()) { + return; + } + + if(this.mCountChar > 0) { + int start = this.mCurrentInputPos; + int end = start + this.mCountChar; + final String insertText = s.subSequence(start,end).toString(); + + if(insertText.equals("\n")) + { + String trueStr = s.subSequence(0,start).toString() + + s.subSequence(end,s.length()).toString(); + this.mGenesisGLSurfaceView.insertText( trueStr ); + } + + } + + return; + + +// int nModified = s.length() - this.mText.length(); +// if (nModified < 0) +// { +// for (; nModified < 0; ++nModified) { +// this.mGenesisGLSurfaceView.deleteBackward(); +// /* +// if (BuildConfig.DEBUG) { +// Log.d(TAG, "deleteBackward"); +// } +// */ +// } +// } +// else if(this.mCountChar > 0) { +// int start = this.mCurrentInputPos; +// int end = start + this.mCountChar; +// final String insertText = s.subSequence(start,end).toString(); +// this.mGenesisGLSurfaceView.insertText(insertText); +// +// //move cursor +// /* +// if (BuildConfig.DEBUG) { +// Log.d(TAG, "insertText(" + insertText + ")"); +// } +// */ +// } +// this.mText = s.toString(); + } + + @Override + public void beforeTextChanged(final CharSequence pCharSequence, final int start, final int count, final int after) { + /* + if (BuildConfig.DEBUG) { + Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after); + } + */ + this.mText = pCharSequence.toString(); + this.mCurrentInputPos = start; + } + + @Override + public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) { + + this.mCountChar = count; + } + + @Override + public boolean onEditorAction(final TextView pTextView, final int pActionID, final KeyEvent pKeyEvent) { + if (this.mGenesisGLSurfaceView.getGenesisEditText() == pTextView && this.isFullScreenEdit()) { + // user press the action button, delete all old text and insert new text + for (int i = this.mOriginText.length(); i > 0; i--) { + this.mGenesisGLSurfaceView.deleteBackward(); + /* + if (BuildConfig.DEBUG) { + Log.d(TAG, "deleteBackward"); + } + */ + } + String text = pTextView.getText().toString(); + + /* If user input nothing, translate "\n" to engine. */ + if (text.compareTo("") == 0) { + text = "\n"; + } + + if ('\n' != text.charAt(text.length() - 1)) { + text += '\n'; + } + + final String insertText = text; + this.mGenesisGLSurfaceView.insertText(insertText); + /* + if (BuildConfig.DEBUG) { + Log.d(TAG, "insertText(" + insertText + ")"); + } + */ + } + + if (pActionID == EditorInfo.IME_ACTION_DONE) { + this.mGenesisGLSurfaceView.requestFocus(); + } + return false; + } + + // =========================================================== + // Methods + // =========================================================== + + // =========================================================== + // Inner and Anonymous Classes + // =========================================================== +} \ No newline at end of file diff --git a/Engine/CMake_And_BuildAndroid.bat b/Engine/CMake_And_BuildAndroid.bat index 669713c..ce011c8 100644 --- a/Engine/CMake_And_BuildAndroid.bat +++ b/Engine/CMake_And_BuildAndroid.bat @@ -24,7 +24,7 @@ @rem 根据本机cmake的安装路径,修改cmakeExe变量 -set cmakeExe="D:\Program Files\cmake-2.8.8-win32-x86\bin\cmake.exe" +set cmakeExe="D:\Program Files\CMake 2.8\bin\cmake.exe" set curPath=%cd% diff --git a/Engine/GameApp/GameApp.xcodeproj/project.pbxproj b/Engine/GameApp/GameApp.xcodeproj/project.pbxproj index ccaeb34..8e2dc5f 100644 --- a/Engine/GameApp/GameApp.xcodeproj/project.pbxproj +++ b/Engine/GameApp/GameApp.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 587F8B4218FB8FB4007563A8 /* OCAndCPlusInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = 587F8B3F18FB8FB4007563A8 /* OCAndCPlusInterface.mm */; }; + 587F8B4318FB8FB4007563A8 /* TextViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 587F8B4118FB8FB4007563A8 /* TextViewController.mm */; }; F54D9A4418580A9D0007115E /* libGenesisEngineLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F54D9A3318580A840007115E /* libGenesisEngineLib.a */; }; F560C2F018111C0700487A7D /* ViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = F560C2EC18111C0700487A7D /* ViewController_iPad.xib */; }; F560C2F118111C0700487A7D /* ViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = F560C2EE18111C0700487A7D /* ViewController_iPhone.xib */; }; @@ -180,6 +182,9 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 587F8B3F18FB8FB4007563A8 /* OCAndCPlusInterface.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OCAndCPlusInterface.mm; sourceTree = ""; }; + 587F8B4018FB8FB4007563A8 /* TextViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextViewController.h; sourceTree = ""; }; + 587F8B4118FB8FB4007563A8 /* TextViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextViewController.mm; sourceTree = ""; }; F54D9A2C18580A810007115E /* GenesisEngineLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GenesisEngineLib.xcodeproj; path = ../GenesisEngineLib/GenesisEngineLib.xcodeproj; sourceTree = ""; }; F560C2ED18111C0700487A7D /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPad.xib; sourceTree = ""; }; F560C2EF18111C0700487A7D /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPhone.xib; sourceTree = ""; }; @@ -302,6 +307,9 @@ F5BC88A417F2959300F0D1DD /* IOSFramework */ = { isa = PBXGroup; children = ( + 587F8B3F18FB8FB4007563A8 /* OCAndCPlusInterface.mm */, + 587F8B4018FB8FB4007563A8 /* TextViewController.h */, + 587F8B4118FB8FB4007563A8 /* TextViewController.mm */, F560C2EC18111C0700487A7D /* ViewController_iPad.xib */, F560C2EE18111C0700487A7D /* ViewController_iPhone.xib */, F5BC88A517F2959300F0D1DD /* AppDelegate.h */, @@ -716,6 +724,7 @@ buildActionMask = 2147483647; files = ( F5EFE6C618BC444F00D585CC /* Mono.Security.dll in Sources */, + 587F8B4318FB8FB4007563A8 /* TextViewController.mm in Sources */, F5EFE6C718BC444F00D585CC /* mscorlib.dll in Sources */, F5EFE6C818BC444F00D585CC /* ScriptFrameworkLibrary.dll in Sources */, F5EFE6C918BC444F00D585CC /* ScriptGUILibrary.dll in Sources */, @@ -724,6 +733,7 @@ F5EFE6CC18BC444F00D585CC /* System.dll in Sources */, F5EFE6CD18BC444F00D585CC /* System.Security.dll in Sources */, F5EFE6CE18BC444F00D585CC /* System.Xml.dll in Sources */, + 587F8B4218FB8FB4007563A8 /* OCAndCPlusInterface.mm in Sources */, F5EFE6CF18BC444F00D585CC /* UserDefCSharp.dll in Sources */, F5BC88B617F2959400F0D1DD /* AppDelegate.mm in Sources */, F5BC88BE17F2959400F0D1DD /* main.mm in Sources */, diff --git a/Engine/GenesisEngineLib/GenesisEngineLib.xcodeproj/project.pbxproj b/Engine/GenesisEngineLib/GenesisEngineLib.xcodeproj/project.pbxproj index a7d60ab..7d4ed60 100644 --- a/Engine/GenesisEngineLib/GenesisEngineLib.xcodeproj/project.pbxproj +++ b/Engine/GenesisEngineLib/GenesisEngineLib.xcodeproj/project.pbxproj @@ -7,6 +7,13 @@ objects = { /* Begin PBXBuildFile section */ + 58548DAE19061FC400BA92A0 /* script_app.cc in Sources */ = {isa = PBXBuildFile; fileRef = 58548DAC19061FC400BA92A0 /* script_app.cc */; }; + 82C7DF6B192222D2002CE939 /* FileData.cc in Sources */ = {isa = PBXBuildFile; fileRef = 82C7DF5D192222D2002CE939 /* FileData.cc */; }; + 82C7DF6C192222D2002CE939 /* FileTable.cc in Sources */ = {isa = PBXBuildFile; fileRef = 82C7DF60192222D2002CE939 /* FileTable.cc */; }; + 82C7DF6D192222D2002CE939 /* Package.cc in Sources */ = {isa = PBXBuildFile; fileRef = 82C7DF63192222D2002CE939 /* Package.cc */; }; + 82C7DF6E192222D2002CE939 /* PackageSystem.cc in Sources */ = {isa = PBXBuildFile; fileRef = 82C7DF65192222D2002CE939 /* PackageSystem.cc */; }; + 82C7DF6F192222D2002CE939 /* PackageTool.cc in Sources */ = {isa = PBXBuildFile; fileRef = 82C7DF67192222D2002CE939 /* PackageTool.cc */; }; + 82C7DF70192222D2002CE939 /* PackageUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 82C7DF69192222D2002CE939 /* PackageUtil.cc */; }; F504B89B18BC39F800B7C723 /* SoundInterface.cc in Sources */ = {isa = PBXBuildFile; fileRef = F504B89918BC39F800B7C723 /* SoundInterface.cc */; }; F52905801830C2DC0081A084 /* CGTool.cc in Sources */ = {isa = PBXBuildFile; fileRef = F52905781830C2DC0081A084 /* CGTool.cc */; }; F52905811830C2DC0081A084 /* D3DCompiler.cc in Sources */ = {isa = PBXBuildFile; fileRef = F529057A1830C2DC0081A084 /* D3DCompiler.cc */; }; @@ -838,12 +845,6 @@ F5F49CEE17E1C5EE00361F45 /* spriteplayer.cc in Sources */ = {isa = PBXBuildFile; fileRef = F5F49CDD17E1C5EE00361F45 /* spriteplayer.cc */; }; F5F49CEF17E1C5EE00361F45 /* spriteutils.cc in Sources */ = {isa = PBXBuildFile; fileRef = F5F49CDF17E1C5EE00361F45 /* spriteutils.cc */; }; F5F49CF017E1C5EE00361F45 /* spritevertex.cc in Sources */ = {isa = PBXBuildFile; fileRef = F5F49CE117E1C5EE00361F45 /* spritevertex.cc */; }; - F5FD75DD1859ACB90029DB32 /* FileData.cc in Sources */ = {isa = PBXBuildFile; fileRef = F5FD75CF1859ACB90029DB32 /* FileData.cc */; }; - F5FD75DE1859ACB90029DB32 /* FileTable.cc in Sources */ = {isa = PBXBuildFile; fileRef = F5FD75D21859ACB90029DB32 /* FileTable.cc */; }; - F5FD75DF1859ACB90029DB32 /* Package.cc in Sources */ = {isa = PBXBuildFile; fileRef = F5FD75D41859ACB90029DB32 /* Package.cc */; }; - F5FD75E01859ACB90029DB32 /* PackageSystem.cc in Sources */ = {isa = PBXBuildFile; fileRef = F5FD75D61859ACB90029DB32 /* PackageSystem.cc */; }; - F5FD75E11859ACB90029DB32 /* PackageTool.cc in Sources */ = {isa = PBXBuildFile; fileRef = F5FD75D81859ACB90029DB32 /* PackageTool.cc */; }; - F5FD75E21859ACB90029DB32 /* PackageUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = F5FD75DA1859ACB90029DB32 /* PackageUtil.cc */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -859,6 +860,36 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 58548DAC19061FC400BA92A0 /* script_app.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = script_app.cc; sourceTree = ""; }; + 58548DAD19061FC400BA92A0 /* script_app.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = script_app.h; sourceTree = ""; }; + 587A3D9A18F68D15000ED13A /* OCAndCPlusInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCAndCPlusInterface.h; sourceTree = ""; }; + 82C7DF4C19221F92002CE939 /* cg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg.h; sourceTree = ""; }; + 82C7DF4D19221F92002CE939 /* cgGL_profiles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cgGL_profiles.h; sourceTree = ""; }; + 82C7DF4E19221F92002CE939 /* cg_bindlocations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg_bindlocations.h; sourceTree = ""; }; + 82C7DF4F19221F92002CE939 /* cg_datatypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg_datatypes.h; sourceTree = ""; }; + 82C7DF5019221F92002CE939 /* cg_enums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg_enums.h; sourceTree = ""; }; + 82C7DF5119221F92002CE939 /* cg_errors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg_errors.h; sourceTree = ""; }; + 82C7DF5219221F92002CE939 /* cg_profiles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg_profiles.h; sourceTree = ""; }; + 82C7DF5419221F92002CE939 /* glsl_optimizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glsl_optimizer.h; sourceTree = ""; }; + 82C7DF5619221F92002CE939 /* hlsl2glsl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hlsl2glsl.h; sourceTree = ""; }; + 82C7DF5819221F92002CE939 /* mojoshader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mojoshader.h; sourceTree = ""; }; + 82C7DF5919221F92002CE939 /* mojoshader_parser_hlsl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mojoshader_parser_hlsl.h; sourceTree = ""; }; + 82C7DF5A19221F92002CE939 /* mojoshader_version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mojoshader_version.h; sourceTree = ""; }; + 82C7DF5C192222D2002CE939 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; + 82C7DF5D192222D2002CE939 /* FileData.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileData.cc; sourceTree = ""; }; + 82C7DF5E192222D2002CE939 /* FileData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileData.h; sourceTree = ""; }; + 82C7DF5F192222D2002CE939 /* FileFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileFormat.h; sourceTree = ""; }; + 82C7DF60192222D2002CE939 /* FileTable.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileTable.cc; sourceTree = ""; }; + 82C7DF61192222D2002CE939 /* FileTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileTable.h; sourceTree = ""; }; + 82C7DF62192222D2002CE939 /* PackDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PackDef.h; sourceTree = ""; }; + 82C7DF63192222D2002CE939 /* Package.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Package.cc; sourceTree = ""; }; + 82C7DF64192222D2002CE939 /* Package.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Package.h; sourceTree = ""; }; + 82C7DF65192222D2002CE939 /* PackageSystem.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PackageSystem.cc; sourceTree = ""; }; + 82C7DF66192222D2002CE939 /* PackageSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PackageSystem.h; sourceTree = ""; }; + 82C7DF67192222D2002CE939 /* PackageTool.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PackageTool.cc; sourceTree = ""; }; + 82C7DF68192222D2002CE939 /* PackageTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PackageTool.h; sourceTree = ""; }; + 82C7DF69192222D2002CE939 /* PackageUtil.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PackageUtil.cc; sourceTree = ""; }; + 82C7DF6A192222D2002CE939 /* PackageUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PackageUtil.h; sourceTree = ""; }; F504B89918BC39F800B7C723 /* SoundInterface.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SoundInterface.cc; sourceTree = ""; }; F504B89A18BC39F800B7C723 /* SoundInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoundInterface.h; sourceTree = ""; }; F52905781830C2DC0081A084 /* CGTool.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CGTool.cc; sourceTree = ""; }; @@ -1583,18 +1614,6 @@ F5F48FA517E1A66000361F45 /* ShaderCompiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShaderCompiler.h; sourceTree = ""; }; F5F48FA817E1A66000361F45 /* stdneb.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stdneb.cc; sourceTree = ""; }; F5F48FA917E1A66000361F45 /* stdneb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stdneb.h; sourceTree = ""; }; - F5F48FBC17E1A66000361F45 /* cg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg.h; sourceTree = ""; }; - F5F48FBD17E1A66000361F45 /* cg_bindlocations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg_bindlocations.h; sourceTree = ""; }; - F5F48FBE17E1A66000361F45 /* cg_datatypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg_datatypes.h; sourceTree = ""; }; - F5F48FBF17E1A66000361F45 /* cg_enums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg_enums.h; sourceTree = ""; }; - F5F48FC017E1A66000361F45 /* cg_errors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg_errors.h; sourceTree = ""; }; - F5F48FC117E1A66000361F45 /* cg_profiles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cg_profiles.h; sourceTree = ""; }; - F5F48FC217E1A66000361F45 /* cgGL_profiles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cgGL_profiles.h; sourceTree = ""; }; - F5F48FC417E1A66000361F45 /* glsl_optimizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glsl_optimizer.h; sourceTree = ""; }; - F5F48FC617E1A66000361F45 /* hlsl2glsl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hlsl2glsl.h; sourceTree = ""; }; - F5F48FC817E1A66000361F45 /* mojoshader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mojoshader.h; sourceTree = ""; }; - F5F48FC917E1A66000361F45 /* mojoshader_parser_hlsl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mojoshader_parser_hlsl.h; sourceTree = ""; }; - F5F48FCA17E1A66000361F45 /* mojoshader_version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mojoshader_version.h; sourceTree = ""; }; F5F48FDE17E1A66000361F45 /* aldlist.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = aldlist.cc; sourceTree = ""; }; F5F48FDF17E1A66000361F45 /* aldlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aldlist.h; sourceTree = ""; }; F5F48FE017E1A66000361F45 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; @@ -2742,21 +2761,6 @@ F5F49CE017E1C5EE00361F45 /* spriteutils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spriteutils.h; sourceTree = ""; }; F5F49CE117E1C5EE00361F45 /* spritevertex.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = spritevertex.cc; sourceTree = ""; }; F5F49CE217E1C5EE00361F45 /* spritevertex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spritevertex.h; sourceTree = ""; }; - F5FD75CE1859ACB80029DB32 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; - F5FD75CF1859ACB90029DB32 /* FileData.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileData.cc; sourceTree = ""; }; - F5FD75D01859ACB90029DB32 /* FileData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileData.h; sourceTree = ""; }; - F5FD75D11859ACB90029DB32 /* FileFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileFormat.h; sourceTree = ""; }; - F5FD75D21859ACB90029DB32 /* FileTable.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileTable.cc; sourceTree = ""; }; - F5FD75D31859ACB90029DB32 /* FileTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileTable.h; sourceTree = ""; }; - F5FD75D41859ACB90029DB32 /* Package.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Package.cc; sourceTree = ""; }; - F5FD75D51859ACB90029DB32 /* Package.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Package.h; sourceTree = ""; }; - F5FD75D61859ACB90029DB32 /* PackageSystem.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PackageSystem.cc; sourceTree = ""; }; - F5FD75D71859ACB90029DB32 /* PackageSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PackageSystem.h; sourceTree = ""; }; - F5FD75D81859ACB90029DB32 /* PackageTool.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PackageTool.cc; sourceTree = ""; }; - F5FD75D91859ACB90029DB32 /* PackageTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PackageTool.h; sourceTree = ""; }; - F5FD75DA1859ACB90029DB32 /* PackageUtil.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PackageUtil.cc; sourceTree = ""; }; - F5FD75DB1859ACB90029DB32 /* PackageUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PackageUtil.h; sourceTree = ""; }; - F5FD75DC1859ACB90029DB32 /* PackDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PackDef.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -2771,6 +2775,89 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 587A3D9918F68D15000ED13A /* OCAndCPlusPlusInterface */ = { + isa = PBXGroup; + children = ( + 587A3D9A18F68D15000ED13A /* OCAndCPlusInterface.h */, + ); + path = OCAndCPlusPlusInterface; + sourceTree = ""; + }; + 82C7DF4A19221F92002CE939 /* win */ = { + isa = PBXGroup; + children = ( + 82C7DF4B19221F92002CE939 /* Cg */, + 82C7DF5319221F92002CE939 /* GlslOptimizer */, + 82C7DF5519221F92002CE939 /* hlsl2glslfork */, + 82C7DF5719221F92002CE939 /* mojoshader */, + ); + name = win; + path = ../../ExtIncludes/ShaderUtil; + sourceTree = ""; + }; + 82C7DF4B19221F92002CE939 /* Cg */ = { + isa = PBXGroup; + children = ( + 82C7DF4C19221F92002CE939 /* cg.h */, + 82C7DF4D19221F92002CE939 /* cgGL_profiles.h */, + 82C7DF4E19221F92002CE939 /* cg_bindlocations.h */, + 82C7DF4F19221F92002CE939 /* cg_datatypes.h */, + 82C7DF5019221F92002CE939 /* cg_enums.h */, + 82C7DF5119221F92002CE939 /* cg_errors.h */, + 82C7DF5219221F92002CE939 /* cg_profiles.h */, + ); + path = Cg; + sourceTree = ""; + }; + 82C7DF5319221F92002CE939 /* GlslOptimizer */ = { + isa = PBXGroup; + children = ( + 82C7DF5419221F92002CE939 /* glsl_optimizer.h */, + ); + path = GlslOptimizer; + sourceTree = ""; + }; + 82C7DF5519221F92002CE939 /* hlsl2glslfork */ = { + isa = PBXGroup; + children = ( + 82C7DF5619221F92002CE939 /* hlsl2glsl.h */, + ); + path = hlsl2glslfork; + sourceTree = ""; + }; + 82C7DF5719221F92002CE939 /* mojoshader */ = { + isa = PBXGroup; + children = ( + 82C7DF5819221F92002CE939 /* mojoshader.h */, + 82C7DF5919221F92002CE939 /* mojoshader_parser_hlsl.h */, + 82C7DF5A19221F92002CE939 /* mojoshader_version.h */, + ); + path = mojoshader; + sourceTree = ""; + }; + 82C7DF5B192222D2002CE939 /* packagetool */ = { + isa = PBXGroup; + children = ( + 82C7DF5C192222D2002CE939 /* CMakeLists.txt */, + 82C7DF5D192222D2002CE939 /* FileData.cc */, + 82C7DF5E192222D2002CE939 /* FileData.h */, + 82C7DF5F192222D2002CE939 /* FileFormat.h */, + 82C7DF60192222D2002CE939 /* FileTable.cc */, + 82C7DF61192222D2002CE939 /* FileTable.h */, + 82C7DF62192222D2002CE939 /* PackDef.h */, + 82C7DF63192222D2002CE939 /* Package.cc */, + 82C7DF64192222D2002CE939 /* Package.h */, + 82C7DF65192222D2002CE939 /* PackageSystem.cc */, + 82C7DF66192222D2002CE939 /* PackageSystem.h */, + 82C7DF67192222D2002CE939 /* PackageTool.cc */, + 82C7DF68192222D2002CE939 /* PackageTool.h */, + 82C7DF69192222D2002CE939 /* PackageUtil.cc */, + 82C7DF6A192222D2002CE939 /* PackageUtil.h */, + ); + name = packagetool; + path = ../../packagetool; + sourceTree = ""; + }; F52905931830CA550081A084 /* ShaderTemplate */ = { isa = PBXGroup; children = ( @@ -2883,6 +2970,7 @@ F5BC886217F28E0A00F0D1DD /* IOSObjectC */ = { isa = PBXGroup; children = ( + 587A3D9918F68D15000ED13A /* OCAndCPlusPlusInterface */, F5BC886317F28E0A00F0D1DD /* iosALSystem */, ); name = IOSObjectC; @@ -3006,9 +3094,9 @@ F5F48B3B17E1A61300361F45 /* GenesisEngineLib */ = { isa = PBXGroup; children = ( + 82C7DF5B192222D2002CE939 /* packagetool */, F5E8AB241867EAAB006C5348 /* profilesystem */, F5ECD9121862EE9900AFFB4E /* tinyxml */, - F5FD75CD1859ACB80029DB32 /* packageTool */, F5F49C0817E1B4C000361F45 /* CSharpAssembly */, F5F4966417E1A66400361F45 /* GenesisiOS */, F5F48B5017E1A65A00361F45 /* addons */, @@ -3789,6 +3877,7 @@ F5F48F9B17E1A66000361F45 /* shadercompiler */ = { isa = PBXGroup; children = ( + 82C7DF4A19221F92002CE939 /* win */, F5C42B3518B1E3A400F5144E /* Compilers */, F5C42B3E18B1E3A400F5144E /* ShadercompilerConfig.cc */, F5C42B3F18B1E3A400F5144E /* ShadercompilerConfig.h */, @@ -3815,7 +3904,6 @@ F5F48FA817E1A66000361F45 /* stdneb.cc */, F5F48FA917E1A66000361F45 /* stdneb.h */, F5F48FB117E1A66000361F45 /* Utility */, - F5F48FBA17E1A66000361F45 /* win */, ); path = shadercompiler; sourceTree = ""; @@ -3851,57 +3939,6 @@ path = Utility; sourceTree = ""; }; - F5F48FBA17E1A66000361F45 /* win */ = { - isa = PBXGroup; - children = ( - F5F48FBB17E1A66000361F45 /* Cg */, - F5F48FC317E1A66000361F45 /* GlslOptimizer */, - F5F48FC517E1A66000361F45 /* hlsl2glslfork */, - F5F48FC717E1A66000361F45 /* mojoshader */, - ); - path = win; - sourceTree = ""; - }; - F5F48FBB17E1A66000361F45 /* Cg */ = { - isa = PBXGroup; - children = ( - F5F48FBC17E1A66000361F45 /* cg.h */, - F5F48FBD17E1A66000361F45 /* cg_bindlocations.h */, - F5F48FBE17E1A66000361F45 /* cg_datatypes.h */, - F5F48FBF17E1A66000361F45 /* cg_enums.h */, - F5F48FC017E1A66000361F45 /* cg_errors.h */, - F5F48FC117E1A66000361F45 /* cg_profiles.h */, - F5F48FC217E1A66000361F45 /* cgGL_profiles.h */, - ); - path = Cg; - sourceTree = ""; - }; - F5F48FC317E1A66000361F45 /* GlslOptimizer */ = { - isa = PBXGroup; - children = ( - F5F48FC417E1A66000361F45 /* glsl_optimizer.h */, - ); - path = GlslOptimizer; - sourceTree = ""; - }; - F5F48FC517E1A66000361F45 /* hlsl2glslfork */ = { - isa = PBXGroup; - children = ( - F5F48FC617E1A66000361F45 /* hlsl2glsl.h */, - ); - path = hlsl2glslfork; - sourceTree = ""; - }; - F5F48FC717E1A66000361F45 /* mojoshader */ = { - isa = PBXGroup; - children = ( - F5F48FC817E1A66000361F45 /* mojoshader.h */, - F5F48FC917E1A66000361F45 /* mojoshader_parser_hlsl.h */, - F5F48FCA17E1A66000361F45 /* mojoshader_version.h */, - ); - path = mojoshader; - sourceTree = ""; - }; F5F48FDD17E1A66000361F45 /* soundsystem */ = { isa = PBXGroup; children = ( @@ -4439,6 +4476,8 @@ F5F492AE17E1A66200361F45 /* scriptfeature */ = { isa = PBXGroup; children = ( + 58548DAC19061FC400BA92A0 /* script_app.cc */, + 58548DAD19061FC400BA92A0 /* script_app.h */, F5F492AF17E1A66200361F45 /* editable_field_value.cc */, F5F492B017E1A66200361F45 /* editable_field_value.h */, F5F492B117E1A66200361F45 /* inc */, @@ -5992,29 +6031,6 @@ path = sprite; sourceTree = ""; }; - F5FD75CD1859ACB80029DB32 /* packageTool */ = { - isa = PBXGroup; - children = ( - F5FD75CE1859ACB80029DB32 /* CMakeLists.txt */, - F5FD75CF1859ACB90029DB32 /* FileData.cc */, - F5FD75D01859ACB90029DB32 /* FileData.h */, - F5FD75D11859ACB90029DB32 /* FileFormat.h */, - F5FD75D21859ACB90029DB32 /* FileTable.cc */, - F5FD75D31859ACB90029DB32 /* FileTable.h */, - F5FD75D41859ACB90029DB32 /* Package.cc */, - F5FD75D51859ACB90029DB32 /* Package.h */, - F5FD75D61859ACB90029DB32 /* PackageSystem.cc */, - F5FD75D71859ACB90029DB32 /* PackageSystem.h */, - F5FD75D81859ACB90029DB32 /* PackageTool.cc */, - F5FD75D91859ACB90029DB32 /* PackageTool.h */, - F5FD75DA1859ACB90029DB32 /* PackageUtil.cc */, - F5FD75DB1859ACB90029DB32 /* PackageUtil.h */, - F5FD75DC1859ACB90029DB32 /* PackDef.h */, - ); - name = packageTool; - path = ../../packageTool; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -6187,6 +6203,7 @@ F5F497C217E1A66500361F45 /* MyGUI_TabItem.cpp in Sources */, F5F497C317E1A66500361F45 /* MyGUI_TextBox.cpp in Sources */, F5F497C417E1A66500361F45 /* MyGUI_TextIterator.cpp in Sources */, + 82C7DF6B192222D2002CE939 /* FileData.cc in Sources */, F5F497C517E1A66500361F45 /* MyGUI_TextureUtility.cpp in Sources */, F5F497C617E1A66500361F45 /* MyGUI_TextView.cpp in Sources */, F5F497C717E1A66500361F45 /* MyGUI_TileRect.cpp in Sources */, @@ -6203,6 +6220,7 @@ F5F4980717E1A66500361F45 /* particleColorAffectorSerialization.cc in Sources */, F5F4980A17E1A66500361F45 /* particleFollowerAffector.cc in Sources */, F5F4980B17E1A66500361F45 /* particleFollowerAffectorSerialization.cc in Sources */, + 82C7DF6C192222D2002CE939 /* FileTable.cc in Sources */, F5F4980C17E1A66500361F45 /* particleGravityAffector.cc in Sources */, F5F4980D17E1A66500361F45 /* particleGravityAffectorSerialization.cc in Sources */, F5F4981017E1A66500361F45 /* particleLinearForceAffector.cc in Sources */, @@ -6504,6 +6522,7 @@ F5F49A6017E1A66500361F45 /* TerrainRenderComponent.cc in Sources */, F5F49A6117E1A66500361F45 /* TerrainRenderComponentSerialization.cc in Sources */, F5F49A6217E1A66500361F45 /* TerrainRenderObject.cc in Sources */, + 82C7DF6F192222D2002CE939 /* PackageTool.cc in Sources */, F5F49A6717E1A66500361F45 /* application.cc in Sources */, F5F49A6917E1A66500361F45 /* androidsysfunc.cc in Sources */, F5F49A6A17E1A66500361F45 /* coreserver.cc in Sources */, @@ -6561,6 +6580,7 @@ F5F49A9E17E1A66500361F45 /* archivefilesystem.cc in Sources */, F5F49A9F17E1A66500361F45 /* archivefilesystembase.cc in Sources */, F5F49AA017E1A66500361F45 /* assignregistry.cc in Sources */, + 82C7DF70192222D2002CE939 /* PackageUtil.cc in Sources */, F5F49AA117E1A66500361F45 /* gamecontentserverbase.cc in Sources */, F5F49AA217E1A66500361F45 /* binaryreader.cc in Sources */, F5F49AA317E1A66500361F45 /* binarywriter.cc in Sources */, @@ -6642,6 +6662,7 @@ F5F49AFA17E1A66500361F45 /* conebuilder.cc in Sources */, F5F49AFB17E1A66500361F45 /* meshbuilder.cc in Sources */, F5F49AFC17E1A66500361F45 /* parallelogrambuilder.cc in Sources */, + 82C7DF6E192222D2002CE939 /* PackageSystem.cc in Sources */, F5F49AFD17E1A66500361F45 /* asyncport.cc in Sources */, F5F49AFE17E1A66500361F45 /* asynhandlerthread.cc in Sources */, F5F49AFF17E1A66500361F45 /* batchmessage.cc in Sources */, @@ -6796,6 +6817,7 @@ F5F49CC217E1C55900361F45 /* vegetationfeature.cc in Sources */, F5F49CC317E1C55900361F45 /* vegetationfeatureprotocol.cc in Sources */, F5F49CE317E1C5EE00361F45 /* sprite.cc in Sources */, + 82C7DF6D192222D2002CE939 /* Package.cc in Sources */, F5F49CE417E1C5EE00361F45 /* spriteanimation.cc in Sources */, F5F49CE517E1C5EE00361F45 /* spriteanimationclip.cc in Sources */, F5F49CE617E1C5EE00361F45 /* spriteblock.cc in Sources */, @@ -6838,6 +6860,7 @@ F55211611856F90B003AC44B /* Animation.cc in Sources */, F55211621856F90B003AC44B /* AnimationLayer.cc in Sources */, F55211631856F90B003AC44B /* AnimationServer.cc in Sources */, + 58548DAE19061FC400BA92A0 /* script_app.cc in Sources */, F55211641856F90B003AC44B /* ClipControl.cc in Sources */, F55211A21856FC71003AC44B /* GenesisMakeGPUProgram.cc in Sources */, F55211A31856FC71003AC44B /* GenesisMakeMaterial.cc in Sources */, @@ -6876,12 +6899,6 @@ F55211FB1858015B003AC44B /* TerrainDataSource.cc in Sources */, F5DA5ADF185815370083349F /* ForwardShadingRenderPipeline.cc in Sources */, F5DA5AE1185826380083349F /* scriptbind_physicsshape.cc in Sources */, - F5FD75DD1859ACB90029DB32 /* FileData.cc in Sources */, - F5FD75DE1859ACB90029DB32 /* FileTable.cc in Sources */, - F5FD75DF1859ACB90029DB32 /* Package.cc in Sources */, - F5FD75E01859ACB90029DB32 /* PackageSystem.cc in Sources */, - F5FD75E11859ACB90029DB32 /* PackageTool.cc in Sources */, - F5FD75E21859ACB90029DB32 /* PackageUtil.cc in Sources */, F5ECD9021862E8D300AFFB4E /* particleMovementAffector.cc in Sources */, F5ECD9061862E90400AFFB4E /* particleGPUTarget.cc in Sources */, F5ECD9071862E90400AFFB4E /* particleGPUTargetSerialization.cc in Sources */, @@ -7028,7 +7045,7 @@ ../extlibs/IosLibs, ../graphicsystem, ../addons, - ../addons/shadercompiler/win, + ../ExtIncludes/ShaderUtil, ../addons/Utility, ../addons/shadercompiler, ../app, @@ -7067,7 +7084,7 @@ ../extlibs/IosLibs, ../graphicsystem, ../addons, - ../addons/shadercompiler/win, + ../ExtIncludes/ShaderUtil, ../addons/Utility, ../addons/shadercompiler, ../app, diff --git a/Engine/IOSObjectC/IOSFramework/AppDelegate.h b/Engine/IOSObjectC/IOSFramework/AppDelegate.h index f64bf7b..e949eba 100644 --- a/Engine/IOSObjectC/IOSFramework/AppDelegate.h +++ b/Engine/IOSObjectC/IOSFramework/AppDelegate.h @@ -26,11 +26,13 @@ THE SOFTWARE. #import @class ViewController; +@class TextViewController; @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) ViewController *viewController; +@property (strong, nonatomic) TextViewController *textviewController; @end diff --git a/Engine/IOSObjectC/IOSFramework/AppDelegate.mm b/Engine/IOSObjectC/IOSFramework/AppDelegate.mm index 6c1e0ce..04c0821 100644 --- a/Engine/IOSObjectC/IOSFramework/AppDelegate.mm +++ b/Engine/IOSObjectC/IOSFramework/AppDelegate.mm @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2011-2013,WebJet Business Division,CYOU + + http://www.genesis-3d.com.cn + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ // // AppDelegate.m // GenesisEngineIos @@ -8,6 +31,8 @@ #import "AppDelegate.h" #import "ViewController.h" +#import "TextViewController.h" + #include "MobClick.h" @implementation AppDelegate @@ -22,6 +47,15 @@ self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; } self.window.rootViewController = self.viewController; + + self.textviewController = [[TextViewController alloc]initWithNibName:nil bundle:nil ]; + [self.textviewController setupTextView]; + + //add child textviewcontroller and subview + [self.viewController addChildViewController:self.textviewController]; + [self.viewController.view addSubview:self.textviewController.view]; + + [self.window makeKeyAndVisible]; return YES; } diff --git a/Engine/IOSObjectC/IOSFramework/OCAndCPlusInterface.mm b/Engine/IOSObjectC/IOSFramework/OCAndCPlusInterface.mm new file mode 100644 index 0000000..41e9c11 --- /dev/null +++ b/Engine/IOSObjectC/IOSFramework/OCAndCPlusInterface.mm @@ -0,0 +1,47 @@ +/**************************************************************************** + Copyright (c) 2011-2013,WebJet Business Division,CYOU + + http://www.genesis-3d.com.cn + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +// +// OCAndCPlusInterface.cpp +// GameApp +// +// Created by xuhengjin on 4/8/14. +// Copyright (c) 2014 webJet. All rights reserved. +// +#import +//#import "EAGLView.h" +#import "TextViewController.h" + +#import "../OCAndCPlusPlusInterface/OCAndCPlusInterface.h" + + +void OCAndCPlusInterface::showKeyboard(bool bShow,const char* contentUtf8) +{ + //NSLog(@"showkeyboard11"); + if (bShow) { + [TextViewController setTextViewText:contentUtf8]; + } + [TextViewController showKeyboard:bShow]; + + +} \ No newline at end of file diff --git a/Engine/IOSObjectC/IOSFramework/TextViewController.h b/Engine/IOSObjectC/IOSFramework/TextViewController.h new file mode 100644 index 0000000..e7e061b --- /dev/null +++ b/Engine/IOSObjectC/IOSFramework/TextViewController.h @@ -0,0 +1,80 @@ +/**************************************************************************** + Copyright (c) 2011-2013,WebJet Business Division,CYOU + + http://www.genesis-3d.com.cn + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +/* + File: TextViewController.h + Abstract: The view controller for hosting the UITextView features of this sample. + Version: 2.11 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple + Inc. ("Apple") in consideration of your agreement to the following + terms, and your use, installation, modification or redistribution of + this Apple software constitutes acceptance of these terms. If you do + not agree with these terms, please do not use, install, modify or + redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2013 Apple Inc. All Rights Reserved. + + */ + +#import + +@interface MyUITextView : UITextView +@end + +@interface TextViewController : UIViewController ++ (void) showKeyboard: (bool) bShow ; ++ (void) setTextViewText:(const char*) content; +- (void)setupTextView; +@end diff --git a/Engine/IOSObjectC/IOSFramework/TextViewController.mm b/Engine/IOSObjectC/IOSFramework/TextViewController.mm new file mode 100644 index 0000000..e1eadda --- /dev/null +++ b/Engine/IOSObjectC/IOSFramework/TextViewController.mm @@ -0,0 +1,297 @@ +/**************************************************************************** + Copyright (c) 2011-2013,WebJet Business Division,CYOU + + http://www.genesis-3d.com.cn + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +/* + File: TextViewController.m + Abstract: The view controller for hosting the UITextView features of this sample. + Version: 2.11 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple + Inc. ("Apple") in consideration of your agreement to the following + terms, and your use, installation, modification or redistribution of + this Apple software constitutes acceptance of these terms. If you do + not agree with these terms, please do not use, install, modify or + redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2013 Apple Inc. All Rights Reserved. + + */ + +#import "TextViewController.h" +#import "AppDelegate.h" +#import "ViewController.h" + +#include "Shell/Genesis.h" +#ifdef DEBUG +CGRect g_rectPos = CGRectMake(0, -101, 300, 100); +#else +CGRect g_rectPos = CGRectMake(0, -101, 300, 100); +#endif +float g_textviewHeight = 60; +@implementation MyUITextView +@end + +MyUITextView* g_textEdit; +CGSize g_sizeDevice; +int g_maxCharCount = 100; +@interface TextViewController () +@property (nonatomic, strong) MyUITextView *textView; +@end + + + +#pragma mark - + + +@implementation TextViewController ++ (void) showKeyboard: (bool) bShow +{ + + NSString* empty = @""; + if (bShow) { + g_textEdit.frame = g_rectPos; + //[g_textEdit setText:empty]; + //[g_textEdit setText:@"edit"]; + [g_textEdit setKeyboardType:UIKeyboardTypeDefault]; + g_textEdit.hidden = FALSE; + [g_textEdit becomeFirstResponder]; + } else { + [g_textEdit resignFirstResponder]; + + g_textEdit.hidden = TRUE; + + [g_textEdit setText:empty]; + + + } +} + ++ (void) setTextViewText:(const char*) content +{ + NSString* nsContent = [[NSString alloc] initWithUTF8String:content]; + [g_textEdit setText:nsContent]; +} + + + +- (void)setupTextView +{ + self.textView = [[UITextView alloc] initWithFrame:self.view.frame]; + g_textEdit = self.textView; + self.textView.textColor = [UIColor blackColor]; + self.textView.font = [UIFont fontWithName:@"Arial" size:18.0]; + self.textView.delegate = self; + self.textView.backgroundColor = [UIColor whiteColor]; + self.textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + + NSString *textToAdd = @"Now is the time for all good developers to come to serve their country.\n\nNow is the time for all good developers to come to serve their country.\r\rThis text view can also use attributed strings."; + + NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:textToAdd]; + + // make red text +// [attrString addAttribute:NSForegroundColorAttributeName +// value:[UIColor redColor] +// range:NSMakeRange([attrString length] - 19, 19)]; +// +// // make blue text +// [attrString addAttribute:NSForegroundColorAttributeName +// value:[UIColor blueColor] +// range:NSMakeRange([attrString length] - 23, 3)]; +// [attrString addAttribute:NSUnderlineStyleAttributeName +// value:[NSNumber numberWithInteger:1] +// range:NSMakeRange([attrString length] - 23, 3)]; + + //[self.textView setAttributedText:attrString]; + + self.textView.returnKeyType = UIReturnKeyDefault; + self.textView.keyboardType = UIKeyboardTypeDefault; // use the default type input method (entire keyboard) + self.textView.scrollEnabled = YES; + + // note: for UITextView, if you don't like auto correction while typing use: + // myTextView.autocorrectionType = UITextAutocorrectionTypeNo; + + //[self.view addSubview:self.textView]; + self.view = self.textView; + + CGSize sizeDevice = [[UIScreen mainScreen] bounds].size; + g_sizeDevice = sizeDevice; + g_rectPos = CGRectMake(0, sizeDevice.height, sizeDevice.width, 60); + + self.view.frame = g_rectPos; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + self.title = NSLocalizedString(@"TextViewTitle", @""); + [self setupTextView]; +} + +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + // listen for keyboard hide/show notifications so we can properly adjust the table's height + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(keyboardWillShow:) + name:UIKeyboardWillShowNotification + object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(keyboardWillHide:) + name:UIKeyboardWillHideNotification + object:nil]; +} + + +#pragma mark - Notifications + +- (void)adjustViewForKeyboardReveal:(BOOL)showKeyboard notificationInfo:(NSDictionary *)notificationInfo +{ + // the keyboard is showing so resize the table's height + +} + +- (void)keyboardWillShow:(NSNotification *)notification +{ + //NSLog(@" textviewctrl keyboardWillShow"); + + [self adjustViewForKeyboardReveal:YES notificationInfo:[notification userInfo]]; + CGRect keyboardRect; + [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardRect]; + + AppDelegate* pApp = (AppDelegate*)[ [UIApplication sharedApplication] delegate ]; + CGRect finalRectRoot = [pApp.viewController.view convertRect:keyboardRect fromView:nil]; + + g_textviewHeight = keyboardRect.size.height/5; + + CGRect kbPos = CGRectMake(finalRectRoot.origin.x, finalRectRoot.origin.y-g_textviewHeight, finalRectRoot.size.width, finalRectRoot.size.height); + self.view.frame = kbPos; + + +} + +- (void)keyboardWillHide:(NSNotification *)aNotification +{ + [self adjustViewForKeyboardReveal:NO notificationInfo:[aNotification userInfo]]; +} + +- (void)viewDidDisappear:(BOOL)animated +{ + [super viewDidDisappear:animated]; + + [[NSNotificationCenter defaultCenter] removeObserver:self + name:UIKeyboardWillShowNotification + object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self + name:UIKeyboardWillHideNotification + object:nil]; +} + + +#pragma mark - UITextViewDelegate + +- (void)saveAction:(id)sender +{ + // finish typing text/dismiss the keyboard by removing it as the first responder + // + [self.textView resignFirstResponder]; + self.navigationItem.rightBarButtonItem = nil; // this will remove the "save" button +} + +- (void)textViewDidBeginEditing:(UITextView *)textView +{ + // provide my own Save button to dismiss the keyboard + UIBarButtonItem* saveItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone + target:self + action:@selector(saveAction:)]; + self.navigationItem.rightBarButtonItem = saveItem; +} +- (void)textViewDidEndEditing:(UITextView *)textView +{ + + NSString* strText = textView.text; + const char* pStr = [strText UTF8String]; + EngineShell::UIInsertText(pStr); + + [TextViewController showKeyboard:false ]; +} +- (BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text +{ + if([text isEqualToString:@"\n"]) + { + [g_textEdit resignFirstResponder]; + g_textEdit.hidden = TRUE; + + + return NO; + } + else if( range.location >= g_maxCharCount ) + { + return NO; + } + + return YES; + + +} + + + + + + +@end + + diff --git a/Engine/IOSObjectC/IOSFramework/ViewController.mm b/Engine/IOSObjectC/IOSFramework/ViewController.mm index 038dfba..0ee94c0 100644 --- a/Engine/IOSObjectC/IOSFramework/ViewController.mm +++ b/Engine/IOSObjectC/IOSFramework/ViewController.mm @@ -207,7 +207,7 @@ DeviceLevel GetDeviceLevel() NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; const char *appWriteableDic = [documentsDirectory UTF8String]; - EngineShell::InitEngine(g_Width,g_Height,resChar,appWriteableDic,"asset:BeginScene.scene",true); + EngineShell::InitEngine(g_Width,g_Height,resChar,appWriteableDic,"asset:editBox3.scene",false); } diff --git a/Engine/IOSObjectC/OCAndCPlusPlusInterface/OCAndCPlusInterface.h b/Engine/IOSObjectC/OCAndCPlusPlusInterface/OCAndCPlusInterface.h new file mode 100644 index 0000000..cd3f196 --- /dev/null +++ b/Engine/IOSObjectC/OCAndCPlusPlusInterface/OCAndCPlusInterface.h @@ -0,0 +1,41 @@ +/**************************************************************************** + Copyright (c) 2011-2013,WebJet Business Division,CYOU + + http://www.genesis-3d.com.cn + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +// +// OCAndCPlusInterface.h +// GameApp +// +// Created by xuhengjin on 4/8/14. +// Copyright (c) 2014 webJet. All rights reserved. +// + +#ifndef __GameApp__OCAndCPlusInterface__ +#define __GameApp__OCAndCPlusInterface__ + +class OCAndCPlusInterface +{ +public: + static void showKeyboard(bool bShow,const char* contentUtf8); +}; + +#endif /* defined(__GameApp__OCAndCPlusInterface__) */ diff --git a/Engine/Shell/Genesis.cc b/Engine/Shell/Genesis.cc index 5533b45..c5edbb9 100644 --- a/Engine/Shell/Genesis.cc +++ b/Engine/Shell/Genesis.cc @@ -34,7 +34,12 @@ #include "input/inputwindowsource.h" #include "input/osx/osxinputsource.h" #include "input/osx/osxtouchevent.h" +#include "input/mobilekeyboardevent.h" + #include "addons/shadercompiler/ShadercompilerConfig.h" +#include "addons/myguiengine/include/MyGUI_UString.h" + +#include "app/guifeature/scriptgui.h" using namespace RenderBase; @@ -120,5 +125,50 @@ void OnStopped() g_pApp->OnStopped(); } +void UIInsertText(const char* wstr) +{ +#if __OSX__ + MyGUI::UString uiStr(wstr); + + App::ScriptGui::SetFocusedEditboxCaption(uiStr); + MyGUI::InputManager::getInstance().setKeyFocusWidget(nullptr); +#elif __ANDROID__ + std::wstring stdWstr = uiStr.asWStr(); + for ( IndexT i = 0; i < stdWstr.length(); i++ ) + { + Input::MobileKeyboardEvent keyboardEvent; + keyboardEvent.SetType(Input::MoibleInputEvent::INPUT_EVENT_TYPE_KEY); + keyboardEvent.SetMotionType(Input::MobileKeyboardEvent::MOTION_EVENT_CHAR); + Input::Char characterCode = (Input::Char)stdWstr.at(i); + keyboardEvent.SetChar(characterCode); + + const GPtr& pInputSource = g_pApp->GetInputSource(); + if (pInputSource.isvalid()) + { + pInputSource.downcast()->OnOSXProc(&keyboardEvent); + } + } +#endif + +} +void UIDeleteBackward() +{ + Input::MobileKeyboardEvent keyboardEvent; + keyboardEvent.SetType(Input::MoibleInputEvent::INPUT_EVENT_TYPE_KEY); + keyboardEvent.SetMotionType(Input::MobileKeyboardEvent::MOTION_EVENT_KEY_DOWN); + keyboardEvent.SetKeycode(Input::InputKey::Back); + + const GPtr& pInputSource = g_pApp->GetInputSource(); + if (pInputSource.isvalid()) + { + pInputSource.downcast()->OnOSXProc(&keyboardEvent); + + //send keyrelease + keyboardEvent.SetMotionType(Input::MobileKeyboardEvent::MOTION_EVENT_KEY_UP); + pInputSource.downcast()->OnOSXProc(&keyboardEvent); + } +} + + } diff --git a/Engine/Shell/Genesis.h b/Engine/Shell/Genesis.h index 912e590..ab01107 100644 --- a/Engine/Shell/Genesis.h +++ b/Engine/Shell/Genesis.h @@ -10,7 +10,6 @@ #define GenesisEngineLib_Genesis_h #include - namespace EngineShell { enum InputAciton @@ -34,6 +33,8 @@ namespace EngineShell void TouchPoint( const TouchDataVector& touchDatas, const InputAciton& action ); void OnResumed(); void OnStopped(); + void UIInsertText(const char* wstr); + void UIDeleteBackward(); } #endif diff --git a/Engine/addons/input/CMakeLists.txt b/Engine/addons/input/CMakeLists.txt index ee64c7a..dd4a284 100644 --- a/Engine/addons/input/CMakeLists.txt +++ b/Engine/addons/input/CMakeLists.txt @@ -115,6 +115,7 @@ SET ( _HEADER_FILES inputmobileconfig.h mobileinputevent.h mobiletouchevent.h + mobilekeyboardevent.h ) # folder diff --git a/Engine/addons/input/android/androidinputsource.cc b/Engine/addons/input/android/androidinputsource.cc index b7f1e8d..197a336 100644 --- a/Engine/addons/input/android/androidinputsource.cc +++ b/Engine/addons/input/android/androidinputsource.cc @@ -29,6 +29,7 @@ THE SOFTWARE. #include "input/android/androidtouchevent.h" #include "graphicsystem/GraphicSystem.h" #include "input/inputmobileconfig.h" +#include "input/mobilekeyboardevent.h" namespace AndroidInput { @@ -102,14 +103,56 @@ int AndroidInputSource::OnAndroidProc(MoibleInputEvent* pEvent) break; case MoibleInputEvent::INPUT_EVENT_TYPE_KEY: - break; - default: + { + OnKeyboardEvent(pEvent); + } break; } return 0; } +void AndroidInputSource::OnKeyboardEvent(const Input::MoibleInputEvent* pEvent) +{ + //put event to eventProcessList + if ( !pEvent ) + { + return; + } + Input::MoibleInputEvent* punCEvent = const_cast(pEvent); + Input::MobileKeyboardEvent* pkeyEvent = dynamic_cast( punCEvent ); + if ( !pkeyEvent ) + { + return; + } + Input::InputEvent inputEvent; + switch(pkeyEvent->GetMotionType()) + { + case Input::MobileKeyboardEvent::MOTION_EVENT_KEY_DOWN: + { + inputEvent.SetType(Input::InputEvent::KeyDown); + inputEvent.SetKey(pkeyEvent->GetKeycode()); + } + break; + case Input::MobileKeyboardEvent::MOTION_EVENT_KEY_UP: + { + inputEvent.SetType(Input::InputEvent::KeyUp); + inputEvent.SetKey(pkeyEvent->GetKeycode()); + } + break; + case Input::MobileKeyboardEvent::MOTION_EVENT_CHAR: + { + inputEvent.SetType(Input::InputEvent::Character); + inputEvent.SetChar(pkeyEvent->GetChar()); + } + break; + default: + break; + } + + m_InputEventList.Append(inputEvent); + +} void AndroidInputSource::OnTouchEvent(const MobileTouchEvent* pEvent) { #if _DEBUG @@ -126,11 +169,8 @@ void AndroidInputSource::OnTouchEvent(const MobileTouchEvent* pEvent) case MobileTouchEvent::MOTION_EVENT_ACTION_DOWN: case MobileTouchEvent::MOTION_EVENT_ACTION_UP: - case MobileTouchEvent::MOTION_EVENT_ACTION_CANCEL: OnTouch(pEvent, actionType); break; - default: - break; } } @@ -169,12 +209,6 @@ void AndroidInputSource::OnTouch(const MobileTouchEvent* pEvent, const int type) inputEvent.SetType(InputEvent::TouchMotionUp); m_InputEventList.Append(inputEvent); break; - case MobileTouchEvent::MOTION_EVENT_ACTION_CANCEL: - inputEvent.SetType(InputEvent::TouchMotionCancel); - m_InputEventList.Append(inputEvent); - break; - default: - break; } } diff --git a/Engine/addons/input/android/androidinputsource.h b/Engine/addons/input/android/androidinputsource.h index e8a038f..298ce41 100644 --- a/Engine/addons/input/android/androidinputsource.h +++ b/Engine/addons/input/android/androidinputsource.h @@ -69,6 +69,7 @@ protected: void OnTouchMove(const Input::MobileTouchEvent* pEvent); void OnTouch(const Input::MobileTouchEvent* pEvent, const int type); + void OnKeyboardEvent(const Input::MoibleInputEvent* pEvent); protected: Util::Array m_InputEventList; diff --git a/Engine/addons/input/base/inputmousebase.cc b/Engine/addons/input/base/inputmousebase.cc index 9895007..a99682f 100644 --- a/Engine/addons/input/base/inputmousebase.cc +++ b/Engine/addons/input/base/inputmousebase.cc @@ -144,7 +144,7 @@ InputMouseBase::OnEvent(const InputEvent& inputEvent) case InputEvent::MouseMove: this->UpdateMousePositions(inputEvent.GetAbsMousePos(), inputEvent.GetNormMousePos()); - this->currentEvents.Append(MouseButtonEvent(InputMouseButton::InvalidMouseButton, inputEvent.GetType())); + this->currentEvents.Append(MouseButtonEvent(InputMouseButton::InvalidMouseButton, inputEvent.GetType(),inputEvent.GetAbsMousePos(), inputEvent.GetNormMousePos())); break; case InputEvent::RawMouseMove: @@ -159,7 +159,7 @@ InputMouseBase::OnEvent(const InputEvent& inputEvent) this->buttonStates[btn].down = true; this->buttonStates[btn].pressed = true; this->UpdateMousePositions(inputEvent.GetAbsMousePos(), inputEvent.GetNormMousePos()); - this->currentEvents.Append(MouseButtonEvent(btn, inputEvent.GetType())); + this->currentEvents.Append(MouseButtonEvent(btn, inputEvent.GetType(),inputEvent.GetAbsMousePos(), inputEvent.GetNormMousePos())); } } break; @@ -178,7 +178,7 @@ InputMouseBase::OnEvent(const InputEvent& inputEvent) // be cleared at the beginning of the next frame // when the button up flag was set this->UpdateMousePositions(inputEvent.GetAbsMousePos(), inputEvent.GetNormMousePos()); - this->currentEvents.Append(MouseButtonEvent(btn, inputEvent.GetType())); + this->currentEvents.Append(MouseButtonEvent(btn, inputEvent.GetType(),inputEvent.GetAbsMousePos(), inputEvent.GetNormMousePos())); } } break; @@ -190,19 +190,19 @@ InputMouseBase::OnEvent(const InputEvent& inputEvent) { this->buttonStates[btn].doubleClicked = true; this->UpdateMousePositions(inputEvent.GetAbsMousePos(), inputEvent.GetNormMousePos()); - this->currentEvents.Append(MouseButtonEvent(btn, inputEvent.GetType())); + this->currentEvents.Append(MouseButtonEvent(btn, inputEvent.GetType(),inputEvent.GetAbsMousePos(), inputEvent.GetNormMousePos())); } } break; case InputEvent::MouseWheelForward: this->wheelForward = true; - this->currentEvents.Append(MouseButtonEvent(InputMouseButton::MiddleButton, inputEvent.GetType())); + this->currentEvents.Append(MouseButtonEvent(InputMouseButton::MiddleButton, inputEvent.GetType(),inputEvent.GetAbsMousePos(), inputEvent.GetNormMousePos())); break; case InputEvent::MouseWheelBackward: this->wheelBackward = true; - this->currentEvents.Append(MouseButtonEvent(InputMouseButton::MiddleButton, inputEvent.GetType())); + this->currentEvents.Append(MouseButtonEvent(InputMouseButton::MiddleButton, inputEvent.GetType(),inputEvent.GetAbsMousePos(), inputEvent.GetNormMousePos())); break; default: diff --git a/Engine/addons/input/base/inputtouchscreenbase.cc b/Engine/addons/input/base/inputtouchscreenbase.cc index 84eab89..a4be814 100644 --- a/Engine/addons/input/base/inputtouchscreenbase.cc +++ b/Engine/addons/input/base/inputtouchscreenbase.cc @@ -117,7 +117,7 @@ bool InputTouchScreenBase::OnEvent(const Input::InputEvent& inputEvent) const IndexT id = inputEvent.GetPointerId(i); m_FingerStates[id].pressed = true; UpdateFingerPositions(inputEvent.GetAbsTouchPos(id), inputEvent.GetNormTouchPos(id), id); - m_CurrentEvents.Append(TouchEvent(id, inputEvent.GetType())); + m_CurrentEvents.Append(TouchEvent(id, inputEvent.GetType(),inputEvent.GetAbsTouchPos(id), inputEvent.GetNormTouchPos(id) )); } } @@ -132,7 +132,7 @@ bool InputTouchScreenBase::OnEvent(const Input::InputEvent& inputEvent) const IndexT id = inputEvent.GetPointerId(i); m_FingerStates[id].down = true; UpdateFingerPositions(inputEvent.GetAbsTouchPos(id), inputEvent.GetNormTouchPos(id), id); - m_CurrentEvents.Append(TouchEvent(id, inputEvent.GetType())); + m_CurrentEvents.Append(TouchEvent(id, inputEvent.GetType(),inputEvent.GetAbsTouchPos(id), inputEvent.GetNormTouchPos(id) )); } } break; @@ -146,7 +146,7 @@ bool InputTouchScreenBase::OnEvent(const Input::InputEvent& inputEvent) const IndexT id = inputEvent.GetPointerId(i); m_FingerStates[id].up = true; UpdateFingerPositions(inputEvent.GetAbsTouchPos(id), inputEvent.GetNormTouchPos(id), id); - m_CurrentEvents.Append(TouchEvent(id, inputEvent.GetType())); + m_CurrentEvents.Append(TouchEvent(id, inputEvent.GetType(),inputEvent.GetAbsTouchPos(id), inputEvent.GetNormTouchPos(id) )); } } break; @@ -161,7 +161,7 @@ bool InputTouchScreenBase::OnEvent(const Input::InputEvent& inputEvent) m_FingerStates[id].down = false; m_FingerStates[id].pressed = false; m_FingerStates[id].up = true; - m_CurrentEvents.Append(TouchEvent(id, inputEvent.GetType())); + m_CurrentEvents.Append(TouchEvent(id, inputEvent.GetType(),inputEvent.GetAbsTouchPos(id), inputEvent.GetNormTouchPos(id) )); } } } diff --git a/Engine/addons/input/inputeventtypes.h b/Engine/addons/input/inputeventtypes.h index 2782743..c8c3e5c 100644 --- a/Engine/addons/input/inputeventtypes.h +++ b/Engine/addons/input/inputeventtypes.h @@ -62,29 +62,37 @@ namespace Input struct TouchEvent : public EventBase { int id; + Math::float2 pixelPos; + Math::float2 screenPos; inline TouchEvent() :id(-1) { } - inline TouchEvent(int id, InputEvent::Type event) + inline TouchEvent(int id, InputEvent::Type event,Math::float2 pixelPos,Math::float2 screenPos) :EventBase(event) { this->id = id; + this->pixelPos = pixelPos; + this->screenPos = screenPos; } }; struct MouseButtonEvent : public EventBase { InputMouseButton::Code button; + Math::float2 pixelPos; + Math::float2 screenPos; inline MouseButtonEvent() :button(InputMouseButton::InvalidMouseButton) { } - inline MouseButtonEvent(InputMouseButton::Code button, InputEvent::Type event) + inline MouseButtonEvent(InputMouseButton::Code button, InputEvent::Type event,Math::float2 pixelPos,Math::float2 screenPos) :EventBase(event) { this->button = button; + this->pixelPos = pixelPos; + this->screenPos = screenPos; } }; diff --git a/Engine/addons/input/inputwindowsource.cc b/Engine/addons/input/inputwindowsource.cc index 4950b65..65af632 100644 --- a/Engine/addons/input/inputwindowsource.cc +++ b/Engine/addons/input/inputwindowsource.cc @@ -27,7 +27,7 @@ THE SOFTWARE. #if __WIN32__ namespace Input { - __ImplementClass(Input::InputWindowSource, 'WDIS', Win32Input::Win32InputWindowSource); + __ImplementClass(Input::InputWindowSource, 'WDIS', Win32Input::Win32InputWebWindowSource); } #elif __ANDROID__ namespace Input diff --git a/Engine/addons/input/inputwindowsource.h b/Engine/addons/input/inputwindowsource.h index 0158b9e..b177412 100644 --- a/Engine/addons/input/inputwindowsource.h +++ b/Engine/addons/input/inputwindowsource.h @@ -28,10 +28,10 @@ THE SOFTWARE. #if __WIN32__ -#include "input/win32/win32inputwindowsource.h" +#include "input/win32/win32inputwebwindowsource.h" namespace Input { - class InputWindowSource : public Win32Input::Win32InputWindowSource + class InputWindowSource : public Win32Input::Win32InputWebWindowSource { __DeclareClass(InputWindowSource); }; diff --git a/Engine/addons/input/mobileinputevent.h b/Engine/addons/input/mobileinputevent.h index d15988b..a89e4b4 100644 --- a/Engine/addons/input/mobileinputevent.h +++ b/Engine/addons/input/mobileinputevent.h @@ -27,7 +27,7 @@ THE SOFTWARE. namespace Input { - class MoibleInputEvent +class MoibleInputEvent { public: @@ -43,6 +43,7 @@ public: }; MoibleInputEvent(); + virtual ~MoibleInputEvent(); /// set event type void SetType(Type t); @@ -59,6 +60,10 @@ inline MoibleInputEvent::MoibleInputEvent() : m_Type(InvalidType) { +} +inline MoibleInputEvent::~MoibleInputEvent() +{ + } inline void MoibleInputEvent::SetType(Type t) diff --git a/Engine/addons/input/mobilekeyboardevent.h b/Engine/addons/input/mobilekeyboardevent.h new file mode 100644 index 0000000..93fe64b --- /dev/null +++ b/Engine/addons/input/mobilekeyboardevent.h @@ -0,0 +1,106 @@ +/**************************************************************************** +Copyright (c) 2011-2013,WebJet Business Division,CYOU + +http://www.genesis-3d.com.cn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#ifndef __mobilekeyboardevent_H__ +#define __mobilekeyboardevent_H__ + +#include "input/mobileinputevent.h" +#include "inputkey.h" +#include "inputchar.h" + +namespace Input +{ +class MobileKeyboardEvent : public Input::MoibleInputEvent +{ +public: + + enum MotionType + { + MOTION_EVENT_KEY_DOWN = 0, + MOTION_EVENT_KEY_UP, + MOTION_EVENT_CHAR, + }; + + MobileKeyboardEvent(); + + ~MobileKeyboardEvent(); + +public: + + void SetMotionType(const MotionType type); + const MotionType GetMotionType() const; + void SetKeycode(InputKey::Code keyc); + InputKey::Code GetKeycode(); + void SetChar(Char& keyc); + Char GetChar(); + + + +protected: + MotionType m_MotionType; + InputKey::Code keyCode; + Char character; + + +}; + +inline MobileKeyboardEvent::MobileKeyboardEvent() +{ + +} + +inline MobileKeyboardEvent::~MobileKeyboardEvent() +{ + +} + +inline void MobileKeyboardEvent::SetMotionType(const MotionType type) +{ + m_MotionType = type; +} + +inline const MobileKeyboardEvent::MotionType MobileKeyboardEvent::GetMotionType() const +{ + return m_MotionType; +} + +inline void MobileKeyboardEvent::SetKeycode(InputKey::Code keyc) +{ + keyCode = keyc; +} +inline InputKey::Code MobileKeyboardEvent::GetKeycode() +{ + return keyCode; +} +inline void MobileKeyboardEvent::SetChar(Char& keyc) +{ + character = keyc; +} +inline Char MobileKeyboardEvent::GetChar() +{ + return character; +} + +} + +#endif \ No newline at end of file diff --git a/Engine/addons/input/osx/osxinputsource.cc b/Engine/addons/input/osx/osxinputsource.cc index 1c27166..94dc648 100644 --- a/Engine/addons/input/osx/osxinputsource.cc +++ b/Engine/addons/input/osx/osxinputsource.cc @@ -29,6 +29,7 @@ THE SOFTWARE. #include "input/osx/osxtouchevent.h" #include "graphicsystem/GraphicSystem.h" #include "input/inputmobileconfig.h" +#include "input/mobilekeyboardevent.h" namespace OSXInput { @@ -98,12 +99,56 @@ int OSXInputSource::OnOSXProc(MoibleInputEvent* pEvent) break; case MoibleInputEvent::INPUT_EVENT_TYPE_KEY: + { + OnKeyboardEvent(pEvent); + } break; } return 0; } - + void OSXInputSource::OnKeyboardEvent(const Input::MoibleInputEvent* pEvent) + { + //put event to eventProcessList + if ( !pEvent ) + { + return; + } + Input::MoibleInputEvent* punCEvent = const_cast(pEvent); + Input::MobileKeyboardEvent* pkeyEvent = dynamic_cast( punCEvent ); + if ( !pkeyEvent ) + { + return; + } + Input::InputEvent inputEvent; + switch(pkeyEvent->GetMotionType()) + { + case Input::MobileKeyboardEvent::MOTION_EVENT_KEY_DOWN: + { + inputEvent.SetType(Input::InputEvent::KeyDown); + inputEvent.SetKey(pkeyEvent->GetKeycode()); + } + break; + case Input::MobileKeyboardEvent::MOTION_EVENT_KEY_UP: + { + inputEvent.SetType(Input::InputEvent::KeyUp); + inputEvent.SetKey(pkeyEvent->GetKeycode()); + } + break; + case Input::MobileKeyboardEvent::MOTION_EVENT_CHAR: + { + inputEvent.SetType(Input::InputEvent::Character); + inputEvent.SetChar(pkeyEvent->GetChar()); + } + break; + default: + break; + + } + + m_InputEventList.Append(inputEvent); + + } void OSXInputSource::OnTouchEvent(const MobileTouchEvent* pEvent) { const MobileTouchEvent::MotionType actionType = pEvent->GetMotionType(); diff --git a/Engine/addons/input/osx/osxinputsource.h b/Engine/addons/input/osx/osxinputsource.h index 1a7df5d..57c5dad 100644 --- a/Engine/addons/input/osx/osxinputsource.h +++ b/Engine/addons/input/osx/osxinputsource.h @@ -69,6 +69,8 @@ protected: void OnTouchMove(const Input::MobileTouchEvent* pEvent); void OnTouch(const Input::MobileTouchEvent* pEvent, const int type); + + void OnKeyboardEvent(const Input::MoibleInputEvent* pEvent); protected: Util::Array m_InputEventList; diff --git a/Engine/addons/input/win32/win32inputwebwindowsource.cc b/Engine/addons/input/win32/win32inputwebwindowsource.cc index 2095a7b..3955b40 100644 --- a/Engine/addons/input/win32/win32inputwebwindowsource.cc +++ b/Engine/addons/input/win32/win32inputwebwindowsource.cc @@ -35,7 +35,7 @@ namespace Win32Input __ImplementClass(Win32Input::Win32InputWebWindowSource, 'WWWI', Input::InputSource ); - int _virtualKeyToText(UINT _virtualKey) + int Win32InputWebWindowSource::VirtualKeyToText(UINT _virtualKey) { static WCHAR deadKey = 0; @@ -212,7 +212,7 @@ namespace Win32Input //inputEvent.SetType(InputEvent::KeyDown); //inputEvent.SetKey(keyCode); //mInputEventList.Append(inputEvent); - SetKeyDown(mInputEventList, inputEvent, keyCode, _virtualKeyToText((UINT)wParam)); + SetKeyDown(mInputEventList, inputEvent, keyCode, VirtualKeyToText((UINT)wParam)); return 0; } } @@ -574,6 +574,8 @@ namespace Win32Input case VK_OEM_6: return Input::InputKey::RightBracket; case VK_OEM_7: return Input::InputKey::Quote; + case VK_PROCESSKEY: return Input::InputKey::InvalidKey; //输入法消息。 + case '0': return Input::InputKey::Key0; case '1': return Input::InputKey::Key1; case '2': return Input::InputKey::Key2; diff --git a/Engine/addons/input/win32/win32inputwebwindowsource.h b/Engine/addons/input/win32/win32inputwebwindowsource.h index ef46cc1..1f49393 100644 --- a/Engine/addons/input/win32/win32inputwebwindowsource.h +++ b/Engine/addons/input/win32/win32inputwebwindowsource.h @@ -101,7 +101,7 @@ namespace Win32Input { return mInputEventList; } - + static int VirtualKeyToText(UINT _virtualKey); protected: void mouseMove(const Math::float2& absMousePos); diff --git a/Engine/addons/materialmaker/GenesisMakeMaterial.cc b/Engine/addons/materialmaker/GenesisMakeMaterial.cc index 9a2f42f..42e2b9f 100644 --- a/Engine/addons/materialmaker/GenesisMakeMaterial.cc +++ b/Engine/addons/materialmaker/GenesisMakeMaterial.cc @@ -141,18 +141,22 @@ namespace GenesisMaterialMaker #endif for (SizeT i = 0; i < m_matParamList.Size(); ++i) { + if(m_matParamList[i]->GetType() == Graphic::eMaterialParamTexture2D) { static_cast(m_matParamList[i])->SetHandle(tex2DHandle); + static_cast(m_matParamList[i])->SetStringValue("sys:white.jpg"); } #if __WIN32__ && RENDERDEVICE_D3D9 else if (m_matParamList[i]->GetType() == Graphic::eMaterialParamTexture3D) { static_cast(m_matParamList[i])->SetHandle(tex3DHandle); + static_cast(m_matParamList[i])->SetStringValue("sys:Random3D.dds"); } else if(m_matParamList[i]->GetType() == Graphic::eMaterialParamTextureCUBE) { static_cast(m_matParamList[i])->SetHandle(texCubeHandle); + static_cast(m_matParamList[i])->SetStringValue("sys:whitecube.dds"); } #endif } diff --git a/Engine/addons/materialmaker/parser/GenesisShaderBison.cpp b/Engine/addons/materialmaker/parser/GenesisShaderBison.cpp index df01ea2..a3c4ea8 100644 --- a/Engine/addons/materialmaker/parser/GenesisShaderBison.cpp +++ b/Engine/addons/materialmaker/parser/GenesisShaderBison.cpp @@ -1558,7 +1558,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 72 "GenesisShaderBison.ycc" - { //n_printf("init genesisshader\n"); + { //n_debuglog("init genesisshader\n"); g_GenesisMaterial->SetName((yyvsp[(2) - (2)].str)); delete[] (yyvsp[(2) - (2)].str); ResetParserParams(); @@ -1570,7 +1570,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 78 "GenesisShaderBison.ycc" - { //n_printf("in genesisshader,left\n"); + { //n_debuglog("in genesisshader,left\n"); } break; @@ -1578,7 +1578,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 80 "GenesisShaderBison.ycc" - { //n_printf("from PropertySection to genesisshader\n"); + { //n_debuglog("from PropertySection to genesisshader\n"); } break; @@ -1586,7 +1586,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 82 "GenesisShaderBison.ycc" - { //n_printf("out genesisshader,right\n"); + { //n_debuglog("out genesisshader,right\n"); g_GenesisMaterial->AddMaterial(*g_curGenesisMakeMaterial); delete g_curGenesisMakeMaterial; g_curGenesisMakeMaterial = 0; @@ -1597,7 +1597,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 87 "GenesisShaderBison.ycc" - {//n_printf("init PropertySection\n"); + {//n_debuglog("init PropertySection\n"); } break; @@ -1605,7 +1605,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 89 "GenesisShaderBison.ycc" - {//n_printf("in ParameterSection,left\n"); + {//n_debuglog("in ParameterSection,left\n"); } break; @@ -1613,7 +1613,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 91 "GenesisShaderBison.ycc" - {//n_printf("from ParameterSection to PropertySection\n"); + {//n_debuglog("from ParameterSection to PropertySection\n"); } break; @@ -1621,7 +1621,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 93 "GenesisShaderBison.ycc" - { //n_printf("out ParameterSection,right\n"); + { //n_debuglog("out ParameterSection,right\n"); } break; @@ -1630,7 +1630,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 95 "GenesisShaderBison.ycc" { g_curGenesisMakeMaterial->SetRenderQueue(Graphic::RenderQueue::FromString((yyvsp[(3) - (3)].str))); - //n_printf("in PropertySection,setrenderqueue:%s\n", Util::String($3).AsCharPtr()); + //n_debuglog("in PropertySection,setrenderqueue:%s\n", Util::String($3).AsCharPtr()); } break; @@ -1638,7 +1638,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 98 "GenesisShaderBison.ycc" - { //n_printf("in TechniqueSection,left\n"); + { //n_debuglog("in TechniqueSection,left\n"); g_curGenesisMakeTechnique = new GenesisMakeTechnique(); } break; @@ -1647,7 +1647,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 101 "GenesisShaderBison.ycc" - {//n_printf("from TechniqueSection to PropertySection\n"); + {//n_debuglog("from TechniqueSection to PropertySection\n"); } break; @@ -1655,7 +1655,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 103 "GenesisShaderBison.ycc" - { //n_printf("in TechniqueSection,left\n"); + { //n_debuglog("in TechniqueSection,left\n"); g_curGenesisMakeTechnique = new GenesisMakeTechnique(); g_curGenesisMakeTechnique->SetName((yyvsp[(3) - (4)].str)); } @@ -1665,7 +1665,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 107 "GenesisShaderBison.ycc" - {//n_printf("from TechniqueSection to PropertySection\n"); + {//n_debuglog("from TechniqueSection to PropertySection\n"); } break; @@ -1673,7 +1673,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 109 "GenesisShaderBison.ycc" - {//n_printf("init ParameterSection\n"); + {//n_debuglog("init ParameterSection\n"); } break; @@ -1705,7 +1705,13 @@ yyreduce: g_curMatParam->SetName((yyvsp[(3) - (5)].str)); g_curMatParam->SetDesc((yyvsp[(3) - (5)].str)); g_curMatParam->SetStringValue((yyvsp[(5) - (5)].str)); - //n_printf("define texture\n"); + + if ( g_curMatParam->GetStringValue() == "#UserDefTex") + { + g_curMatParam->SetHiddenInEditor(true); + } + + //n_debuglog("define texture\n"); g_curGenesisMakeMaterial->AddMatParam(g_curMatParam); g_curMatParam = NULL; @@ -1755,7 +1761,13 @@ yyreduce: g_curMatParam->SetName((yyvsp[(3) - (6)].str)); g_curMatParam->SetDesc((yyvsp[(4) - (6)].str)); g_curMatParam->SetStringValue((yyvsp[(6) - (6)].str)); - //n_printf("define texture\n"); + + if ( g_curMatParam->GetStringValue() == "#UserDefTex") + { + g_curMatParam->SetHiddenInEditor(true); + } + + //n_debuglog("define texture\n"); g_curGenesisMakeMaterial->AddMatParam(g_curMatParam); g_curMatParam = NULL; @@ -1813,6 +1825,18 @@ yyreduce: g_curMatParam->SetName((yyvsp[(3) - (6)].str)); g_curMatParam->SetDesc((yyvsp[(4) - (6)].str)); g_curMatParam->SetStringValue((yyvsp[(6) - (6)].str)); + + if ( + Util::String::MatchPattern(g_curMatParam->GetName(), "*Color*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*color*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*emissive*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*specular*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*diffuse*") + ) + { + g_curMatParam->SetUseForColor(true); + } + g_curGenesisMakeMaterial->AddMatParam(g_curMatParam); g_curMatParam = NULL; @@ -1828,6 +1852,17 @@ yyreduce: g_curMatParam->SetDesc((yyvsp[(3) - (5)].str)); g_curMatParam->SetStringValue((yyvsp[(5) - (5)].str)); + if ( + Util::String::MatchPattern(g_curMatParam->GetName(), "*Color*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*color*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*emissive*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*specular*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*diffuse*") + ) + { + g_curMatParam->SetUseForColor(true); + } + g_curGenesisMakeMaterial->AddMatParam(g_curMatParam); g_curMatParam = NULL; } @@ -1865,7 +1900,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 248 "GenesisShaderBison.ycc" - { //n_printf("init TechniqueSection\n"); + { //n_debuglog("init TechniqueSection\n"); } break; @@ -1873,7 +1908,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 250 "GenesisShaderBison.ycc" - { //n_printf("from PassSection to TechniqueSection\n"); + { //n_debuglog("from PassSection to TechniqueSection\n"); } break; @@ -1881,7 +1916,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 252 "GenesisShaderBison.ycc" - { //n_printf("out TechniqueSection,right\n"); + { //n_debuglog("out TechniqueSection,right\n"); g_curGenesisMakeMaterial->AddTechnique(*g_curGenesisMakeTechnique); delete g_curGenesisMakeTechnique; g_curGenesisMakeTechnique = 0; @@ -1892,7 +1927,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 258 "GenesisShaderBison.ycc" - { //n_printf("init PassSection\n"); + { //n_debuglog("init PassSection\n"); } break; @@ -1909,7 +1944,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 263 "GenesisShaderBison.ycc" - { //n_printf("init Pass\n"); + { //n_debuglog("init Pass\n"); } break; @@ -1917,7 +1952,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 265 "GenesisShaderBison.ycc" - { //n_printf("in PassSection,left\n"); + { //n_debuglog("in PassSection,left\n"); } break; @@ -1926,7 +1961,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 268 "GenesisShaderBison.ycc" - { //n_printf("from codeSection to PassSection\n"); + { //n_debuglog("from codeSection to PassSection\n"); } break; @@ -1935,7 +1970,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 270 "GenesisShaderBison.ycc" { - //n_printf("out PassSection,right\n"); + //n_debuglog("out PassSection,right\n"); g_curGenesisMakeTechnique->AddPass(*g_curMakePass); delete g_curMakePass; g_curMakePass = 0; @@ -1947,7 +1982,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 277 "GenesisShaderBison.ycc" { - n_printf("in PassSection,left\n"); + n_debuglog("in PassSection,left\n"); g_curMakePass = new GenesisMakePass(); g_curMakePass->SetName("NoName"); } @@ -1958,7 +1993,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 282 "GenesisShaderBison.ycc" { - n_printf("in PassSection,left\n"); + n_debuglog("in PassSection,left\n"); g_curMakePass = new GenesisMakePass(); g_curMakePass->SetName((yyvsp[(2) - (2)].str)); } @@ -1968,7 +2003,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 288 "GenesisShaderBison.ycc" - { //n_printf("in codeSection\n"); + { //n_debuglog("in codeSection\n"); } break; @@ -1976,7 +2011,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 290 "GenesisShaderBison.ycc" - { //n_printf("from shadertype,to StateSection\n"); + { //n_debuglog("from shadertype,to StateSection\n"); } break; @@ -1984,7 +2019,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 292 "GenesisShaderBison.ycc" - { //n_printf("from shadertype,to shadertype\n"); + { //n_debuglog("from shadertype,to shadertype\n"); } break; @@ -1994,7 +2029,7 @@ yyreduce: #line 294 "GenesisShaderBison.ycc" { g_curMakePass->SetBuiltInMacro((yyvsp[(4) - (5)].str)); - n_printf("set builtinMacro\n"); + n_debuglog("set builtinMacro\n"); } break; @@ -2004,7 +2039,7 @@ yyreduce: #line 298 "GenesisShaderBison.ycc" { g_curMakePass->SetCustumMacro((yyvsp[(4) - (5)].str)); - n_printf("set builtinMacro\n"); + n_debuglog("set builtinMacro\n"); } break; @@ -2012,7 +2047,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 303 "GenesisShaderBison.ycc" - { //n_printf("in StateSection\n"); + { //n_debuglog("in StateSection\n"); } break; @@ -2023,7 +2058,7 @@ yyreduce: { g_rsDesc = RenderBase::RenderStateDesc::Create(); g_rsDesc->Setup(); - //n_printf("Create StateSection\n");//n_printf("init StateSection\n"); + //n_debuglog("Create StateSection\n");//n_debuglog("init StateSection\n"); } break; @@ -2041,7 +2076,7 @@ yyreduce: { g_curMakePass->SetRenderStateDesc(g_rsDesc); g_rsDesc = 0; - //n_printf("from RenderStateSetup,to shadertype\n"); + //n_debuglog("from RenderStateSetup,to shadertype\n"); } break; @@ -2049,7 +2084,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 317 "GenesisShaderBison.ycc" - { //n_printf("in RenderStateSetup\n"); + { //n_debuglog("in RenderStateSetup\n"); } break; @@ -2090,7 +2125,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 334 "GenesisShaderBison.ycc" - { //n_printf("set depthtest complete \n"); + { //n_debuglog("set depthtest complete \n"); } break; @@ -2109,7 +2144,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 341 "GenesisShaderBison.ycc" - { //n_printf("set blendmode complete \n"); + { //n_debuglog("set blendmode complete \n"); } break; @@ -2117,7 +2152,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 343 "GenesisShaderBison.ycc" - { //n_printf("set alphatest complete \n"); + { //n_debuglog("set alphatest complete \n"); } break; @@ -2125,7 +2160,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 345 "GenesisShaderBison.ycc" - { //n_printf("set samplerstate complete \n"); + { //n_debuglog("set samplerstate complete \n"); } break; @@ -2242,7 +2277,7 @@ yyreduce: { g_curGenesisMakeGPUProgram = new GenesisMakeGPUProgram(); g_curGenesisMakeGPUProgram->SetShaderType((yyvsp[(2) - (2)].str)); - //n_printf("in shaderType,SetShaderType\n"); + //n_debuglog("in shaderType,SetShaderType\n"); delete[] (yyvsp[(2) - (2)].str); } break; @@ -2251,7 +2286,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 415 "GenesisShaderBison.ycc" - { //n_printf("in shaderType,left\n"); + { //n_debuglog("in shaderType,left\n"); } break; @@ -2259,7 +2294,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 417 "GenesisShaderBison.ycc" - { //n_printf("from DeviceTypeSetup to shaderType\n"); + { //n_debuglog("from DeviceTypeSetup to shaderType\n"); } break; @@ -2273,7 +2308,7 @@ yyreduce: delete g_curGenesisMakeGPUProgram; g_curGenesisMakeGPUProgram = NULL; } - //n_printf("out shaderType,right\n"); + //n_debuglog("out shaderType,right\n"); } break; @@ -2281,7 +2316,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 428 "GenesisShaderBison.ycc" - { n_printf("in DeviceTypeSetup\n");} + { n_debuglog("in DeviceTypeSetup\n");} break; case 66: @@ -2290,7 +2325,7 @@ yyreduce: #line 429 "GenesisShaderBison.ycc" { g_curGenesisMakeGPUProgram->SetDeviceType((yyvsp[(3) - (3)].str)); - n_printf("in DeviceTypeSetup\n"); + n_debuglog("in DeviceTypeSetup\n"); delete[] (yyvsp[(3) - (3)].str); } break; @@ -2299,7 +2334,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 434 "GenesisShaderBison.ycc" - { n_printf("in DeviceTypeSetup,left\n"); + { n_debuglog("in DeviceTypeSetup,left\n"); } break; @@ -2307,7 +2342,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 436 "GenesisShaderBison.ycc" - { n_printf("from SubGPUProgramSetup to DeviceTypeSetup\n"); + { n_debuglog("from SubGPUProgramSetup to DeviceTypeSetup\n"); } break; @@ -2315,7 +2350,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 438 "GenesisShaderBison.ycc" - { n_printf("out DeviceTypeSetup,right\n"); + { n_debuglog("out DeviceTypeSetup,right\n"); g_curMakePass->AddShaderProgram(*g_curGenesisMakeGPUProgram); } break; @@ -2324,14 +2359,14 @@ yyreduce: /* Line 1455 of yacc.c */ #line 441 "GenesisShaderBison.ycc" - { n_printf("in empty SubGPUProgramSetup\n");} + { n_debuglog("in empty SubGPUProgramSetup\n");} break; case 71: /* Line 1455 of yacc.c */ #line 442 "GenesisShaderBison.ycc" - { n_printf("in SubGPUProgramSetup\n"); + { n_debuglog("in SubGPUProgramSetup\n"); } break; @@ -2339,7 +2374,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 444 "GenesisShaderBison.ycc" - { n_printf("in SubGPUProgramSetup,left\n"); + { n_debuglog("in SubGPUProgramSetup,left\n"); g_curGenesisSubGPUProgram = new GenesisSubGPUProgram(); g_curGenesisSubGPUProgram->SetShaderMask((yyvsp[(3) - (5)].str)); } @@ -2349,7 +2384,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 448 "GenesisShaderBison.ycc" - { n_printf("from CodeBlock to SubGPUProgramSetup\n"); + { n_debuglog("from CodeBlock to SubGPUProgramSetup\n"); } break; @@ -2357,7 +2392,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 450 "GenesisShaderBison.ycc" - { n_printf("out SubGPUProgramSetup,right\n"); + { n_debuglog("out SubGPUProgramSetup,right\n"); g_curGenesisMakeGPUProgram->AddSubGpuProgram(*g_curGenesisSubGPUProgram); if(g_curGenesisSubGPUProgram != NULL) { @@ -2371,7 +2406,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 459 "GenesisShaderBison.ycc" - { n_printf("in CodeBlock\n"); + { n_debuglog("in CodeBlock\n"); } break; @@ -2381,7 +2416,7 @@ yyreduce: #line 461 "GenesisShaderBison.ycc" { g_curGenesisSubGPUProgram->SetShaderCode((yyvsp[(3) - (3)].str)); - n_printf("in CodeBlock,AddGPUProgram\n"); + n_debuglog("in CodeBlock,AddGPUProgram\n"); delete[] (yyvsp[(3) - (3)].str); } break; @@ -2395,7 +2430,7 @@ yyreduce: g_curShaderParameter->SetRegister((yyvsp[(3) - (5)].num)); g_curShaderParameter->SetName((yyvsp[(4) - (5)].str)); g_curGenesisSubGPUProgram->AddParam(*g_curShaderParameter); - n_printf("bind texture\n"); delete[] (yyvsp[(4) - (5)].str); + n_debuglog("bind texture\n"); delete[] (yyvsp[(4) - (5)].str); delete g_curShaderParameter; g_curShaderParameter = 0; } @@ -2410,7 +2445,7 @@ yyreduce: g_curShaderParameter->SetRegister((yyvsp[(3) - (5)].num)); g_curShaderParameter->SetName((yyvsp[(4) - (5)].str)); g_curGenesisSubGPUProgram->AddParam(*g_curShaderParameter); - //n_printf("setparam matrix register\n"); delete[] $4; + //n_debuglog("setparam matrix register\n"); delete[] $4; delete g_curShaderParameter; g_curShaderParameter = 0; } @@ -2425,7 +2460,7 @@ yyreduce: g_curShaderParameter->SetRegister((yyvsp[(3) - (5)].num)); g_curShaderParameter->SetName((yyvsp[(4) - (5)].str)); g_curGenesisSubGPUProgram->AddParam(*g_curShaderParameter); - //n_printf("setparam vector register\n"); delete[] $4; + //n_debuglog("setparam vector register\n"); delete[] $4; delete g_curShaderParameter; g_curShaderParameter = 0; } @@ -2440,7 +2475,7 @@ yyreduce: g_curShaderParameter->SetRegister((yyvsp[(3) - (5)].num)); g_curShaderParameter->SetName((yyvsp[(4) - (5)].str)); g_curGenesisSubGPUProgram->AddParam(*g_curShaderParameter); - //n_printf("setparam float register\n"); delete[] $4; + //n_debuglog("setparam float register\n"); delete[] $4; delete g_curShaderParameter; g_curShaderParameter = 0; } @@ -2666,7 +2701,7 @@ yyreturn: int yyerror (const char *s) { - n_printf("GenesisShader Error: %s At line:%d\n",s,Genesislineno); + n_debuglog("GenesisShader Error: %s At line:%d\n",s,Genesislineno); return 0; } diff --git a/Engine/addons/materialmaker/parser/GenesisShaderBison.ycc b/Engine/addons/materialmaker/parser/GenesisShaderBison.ycc index 4906152..9ab76c0 100644 --- a/Engine/addons/materialmaker/parser/GenesisShaderBison.ycc +++ b/Engine/addons/materialmaker/parser/GenesisShaderBison.ycc @@ -132,6 +132,11 @@ ParameterSection:/* empty */ {//n_printf("init ParameterSection\n"); g_curMatParam->SetName($3); g_curMatParam->SetDesc($3); g_curMatParam->SetStringValue($5); + + if ( g_curMatParam->GetStringValue() == "#UserDefTex") + { + g_curMatParam->SetHiddenInEditor(true); + } //n_printf("define texture\n"); g_curGenesisMakeMaterial->AddMatParam(g_curMatParam); g_curMatParam = NULL; @@ -176,6 +181,12 @@ ParameterSection:/* empty */ {//n_printf("init ParameterSection\n"); g_curMatParam->SetName($3); g_curMatParam->SetDesc($4); g_curMatParam->SetStringValue($6); + + if ( g_curMatParam->GetStringValue() == "#UserDefTex") + { + g_curMatParam->SetHiddenInEditor(true); + } + //n_printf("define texture\n"); g_curGenesisMakeMaterial->AddMatParam(g_curMatParam); g_curMatParam = NULL; @@ -216,6 +227,18 @@ ParameterSection:/* empty */ {//n_printf("init ParameterSection\n"); g_curMatParam->SetName($3); g_curMatParam->SetDesc($4); g_curMatParam->SetStringValue($6); + + if ( + Util::String::MatchPattern(g_curMatParam->GetName(), "*Color*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*color*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*emissive*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*specular*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*diffuse*") + ) + { + g_curMatParam->SetUseForColor(true); + } + g_curGenesisMakeMaterial->AddMatParam(g_curMatParam); g_curMatParam = NULL; @@ -224,6 +247,17 @@ ParameterSection:/* empty */ {//n_printf("init ParameterSection\n"); g_curMatParam->SetName($3); g_curMatParam->SetDesc($3); g_curMatParam->SetStringValue($5); + + if ( + Util::String::MatchPattern(g_curMatParam->GetName(), "*Color*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*color*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*emissive*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*specular*") + || Util::String::MatchPattern(g_curMatParam->GetName(), "*diffuse*") + ) + { + g_curMatParam->SetUseForColor(true); + } g_curGenesisMakeMaterial->AddMatParam(g_curMatParam); g_curMatParam = NULL; diff --git a/Engine/addons/myguiengine/include/MyGUI_DDContainer.h b/Engine/addons/myguiengine/include/MyGUI_DDContainer.h index 7ab4a0b..7e266b7 100644 --- a/Engine/addons/myguiengine/include/MyGUI_DDContainer.h +++ b/Engine/addons/myguiengine/include/MyGUI_DDContainer.h @@ -130,7 +130,7 @@ namespace MyGUI virtual void updateDropItems(); virtual void updateDropItemsState(const DDWidgetState& _state); - void mouseDrag(MouseButton _id); + bool mouseDrag(MouseButton _id);// expand by genesis-3d void mouseButtonReleased(MouseButton _id); void mouseButtonPressed(MouseButton _id); diff --git a/Engine/addons/myguiengine/include/MyGUI_EditBox.h b/Engine/addons/myguiengine/include/MyGUI_EditBox.h index ed931bb..b601b11 100644 --- a/Engine/addons/myguiengine/include/MyGUI_EditBox.h +++ b/Engine/addons/myguiengine/include/MyGUI_EditBox.h @@ -282,7 +282,8 @@ namespace MyGUI void notifyMouseDrag(Widget* _sender, int _left, int _top, MouseButton _id); void notifyMouseButtonDoubleClick(Widget* _sender); - void notifyScrollChangePosition(ScrollBar* _sender, size_t _position); + void notifyScrollChangePosition(ScrollBar* _sender, int _position);// expand by genesis-3d + void notifyMouseWheel(Widget* _sender, int _rel); // 芯斜薪芯胁谢械薪懈械 锌褉械写褋褌邪胁谢械薪懈褟 diff --git a/Engine/addons/myguiengine/include/MyGUI_InputManager.h b/Engine/addons/myguiengine/include/MyGUI_InputManager.h index a9381a9..6b2f95c 100644 --- a/Engine/addons/myguiengine/include/MyGUI_InputManager.h +++ b/Engine/addons/myguiengine/include/MyGUI_InputManager.h @@ -143,6 +143,7 @@ namespace MyGUI /*internal:*/ void _resetMouseFocusWidget(); + void _forceChangeMouseFocus(Widget* _focusNew, int _absx, int _absy, int _absz);// expand by genesis-3d private: // 褍写邪谢褟械屑 写邪薪薪褘泄 胁懈写卸械褌 懈蟹 胁褋械褏 胁芯蟹屑芯卸薪褘褏 屑械褋褌 @@ -158,6 +159,8 @@ namespace MyGUI // 褋斜褉邪褋褘胁邪械褌 泻谢邪胁懈褕褍 锌芯胁褌芯褉械薪懈褟 void resetKey(); + bool changeMouseFocus(Widget* item, Widget* old_mouse_focus, int _absx, int _absy, int _absz);// expand by genesis-3d + private: // 胁懈写卸械褌褘 泻芯褌芯褉褘屑 锌褉懈薪邪写谢械卸懈褌 褎芯泻褍褋 Widget* mWidgetMouseFocus; diff --git a/Engine/addons/myguiengine/include/MyGUI_ItemBox.h b/Engine/addons/myguiengine/include/MyGUI_ItemBox.h index d840ba8..a2a1149 100644 --- a/Engine/addons/myguiengine/include/MyGUI_ItemBox.h +++ b/Engine/addons/myguiengine/include/MyGUI_ItemBox.h @@ -47,6 +47,20 @@ namespace MyGUI public: ItemBox(); + //------------------------------------------------------------------------------// + // expand by genesis-3d + /** Show VScroll when text size larger than EditBox */ + void setVScrollVisible(bool _value); + /** Get Show VScroll flag */ + bool isVScrollVisible() const; + + /** Show HScroll when text size larger than EditBox */ + void setHScrollVisible(bool _value); + /** Get Show HScroll flag */ + bool isHScrollVisible() const; + //------------------------------------------------------------------------------// + + //------------------------------------------------------------------------------// // 屑邪薪懈锌褍谢褟褑懈懈 邪泄褌械屑邪屑懈 @@ -202,6 +216,10 @@ namespace MyGUI virtual void _resetContainer(bool _update); protected: + virtual void onClientDragBegin(Widget* _sender, int _left, int _top, MouseButton _id);// expand by genesis-3d + virtual void onClientDragEnd(Widget* _sender);// expand by genesis-3d + virtual void onClientDrag(Widget* _sender, int _left, int _top, MouseButton _id);// expand by genesis-3d + virtual void initialiseOverride(); virtual void shutdownOverride(); @@ -223,7 +241,7 @@ namespace MyGUI void notifyKeyButtonPressed(Widget* _sender, KeyCode _key, Char _char); void notifyKeyButtonReleased(Widget* _sender, KeyCode _key); - void notifyScrollChangePosition(ScrollBar* _sender, size_t _index); + void notifyScrollChangePosition(ScrollBar* _sender, int _index);// expand by genesis-3d void notifyMouseWheel(Widget* _sender, int _rel); void notifyRootMouseChangeFocus(Widget* _sender, bool _focus); void notifyMouseButtonDoubleClick(Widget* _sender); @@ -263,7 +281,28 @@ namespace MyGUI private: size_t calcIndexByWidget(Widget* _widget); - + // ------------------------------------------------------------------------- + // expand by genesis-3d + float defualtSpeed() const; + void notifyScrollBarPress(Widget* _sender, int _left, int _top, MouseButton _id);// expand by genesis-3d + void pushContentPosition(); + bool headEmpty() const; + bool tailEmpty() const; + void checkScrollState(); + void scrollStop(); + void scrollOverflow(float time); + void scrollForceOverflow(float time); + void scrollInertia(float time); + void notifyTick(float time); + void preDrag(); + int dragOperator(int _current, int _length, int _sizeItem); + int getStartIndex() const; + void updateContentPosition(const IntPoint& _point); + void testSpeed(); + void resetCounter(); + void dragMove(float move); + void finalSpeed(); + // ------------------------------------------------------------------------- void requestItemSize(); virtual IntSize getContentSize(); @@ -318,6 +357,20 @@ namespace MyGUI Widget* mItemDrag; IntPoint mPointDragOffset; + float mPreCoord;// expand by genesis-3d + int mPreMouse;// expand by genesis-3d + + float mTimeCounter;// expand by genesis-3d + float mMoveCounter;// expand by genesis-3d + float mScrollSpeed;// expand by genesis-3d + enum + { + ScrollStop, + ScrollOverflow, + ScrollForceOverflow, + ScrollInertia, + } mScrollState;// expand by genesis-3d + bool mAlignVert; diff --git a/Engine/addons/myguiengine/include/MyGUI_ListBox.h b/Engine/addons/myguiengine/include/MyGUI_ListBox.h index 3bbb0ad..859bcb1 100644 --- a/Engine/addons/myguiengine/include/MyGUI_ListBox.h +++ b/Engine/addons/myguiengine/include/MyGUI_ListBox.h @@ -259,7 +259,7 @@ namespace MyGUI void onMouseWheel(int _rel); void onKeyButtonPressed(KeyCode _key, Char _char); - void notifyScrollChangePosition(ScrollBar* _sender, size_t _rel); + void notifyScrollChangePosition(ScrollBar* _sender, int _rel);// expand by genesis-3d void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id); void notifyMouseDoubleClick(Widget* _sender); void notifyMouseWheel(Widget* _sender, int _rel); diff --git a/Engine/addons/myguiengine/include/MyGUI_ScrollBar.h b/Engine/addons/myguiengine/include/MyGUI_ScrollBar.h index 2686c86..bd66996 100644 --- a/Engine/addons/myguiengine/include/MyGUI_ScrollBar.h +++ b/Engine/addons/myguiengine/include/MyGUI_ScrollBar.h @@ -28,7 +28,8 @@ namespace MyGUI { - typedef delegates::CMultiDelegate2 EventHandle_ScrollBarPtrSizeT; + //typedef delegates::CMultiDelegate2 EventHandle_ScrollBarPtrSizeT; old code + typedef delegates::CMultiDelegate2 EventHandle_ScrollBarPtrSizeT;// expand by genesis-3d class MYGUI_EXPORT ScrollBar : public Widget, @@ -49,10 +50,10 @@ namespace MyGUI /** Get scroll range */ size_t getScrollRange() const; - /** Set scroll position (value from 0 to range - 1) */ - void setScrollPosition(size_t _value); - /** Get scroll position (value from 0 to range - 1) */ - size_t getScrollPosition() const; + + void setScrollPosition(int _value, bool _force = false);// expand by genesis-3d + + int getScrollPosition() const; /** Set scroll page @param _value Tracker step when buttons pressed @@ -105,6 +106,12 @@ namespace MyGUI /** @copydoc Widget::setCoord(int _left, int _top, int _width, int _height) */ void setCoord(int _left, int _top, int _width, int _height); + // expand by genesis-3d ------------------------------------------- + void setLimitRange(bool _value); + bool getLimitRange() const; + // ---------------------------------------------------------------- + + /*events:*/ /** Event : scroll tracker position changed.\n signature : void method(MyGUI::ScrollBar* _sender, size_t _position)\n @@ -118,8 +125,9 @@ namespace MyGUI virtual void initialiseOverride(); virtual void shutdownOverride(); + void updatePreActionOffset();// expand by genesis-3d void updateTrack(); - void TrackMove(int _left, int _top); + void TrackMove(int _left, int _top);// expand by genesis-3d virtual void onMouseWheel(int _rel); @@ -148,15 +156,19 @@ namespace MyGUI size_t mSkinRangeStart; size_t mSkinRangeEnd; - size_t mScrollRange; - size_t mScrollPosition; - size_t mScrollPage; // 薪邪 褋泻芯谢褜泻芯 锌械褉械褖械谢泻懈胁邪褌褜, 锌褉懈 褖械谢褔泻械 薪邪 泻薪芯锌泻械 - size_t mScrollViewPage; // 薪邪 褋泻芯谢褜泻芯 锌械褉械褖械谢泻懈胁邪褌褜, 锌褉懈 褖械谢褔泻械 锌芯 锌芯谢芯褋械 + int mScrollRange; + //size_t mScrollPosition; old + int mScrollPosition; + + int mScrollPage; // 薪邪 褋泻芯谢褜泻芯 锌械褉械褖械谢泻懈胁邪褌褜, 锌褉懈 褖械谢褔泻械 薪邪 泻薪芯锌泻械 + int mScrollViewPage; // 薪邪 褋泻芯谢褜泻芯 锌械褉械褖械谢泻懈胁邪褌褜, 锌褉懈 褖械谢褔泻械 锌芯 锌芯谢芯褋械 int mMinTrackSize; bool mMoveToClick; bool mVerticalAlignment; + + bool mLimitRange;// expand by genesis-3d }; } // namespace MyGUI diff --git a/Engine/addons/myguiengine/include/MyGUI_ScrollView.h b/Engine/addons/myguiengine/include/MyGUI_ScrollView.h index b59d0cf..a8e4e49 100644 --- a/Engine/addons/myguiengine/include/MyGUI_ScrollView.h +++ b/Engine/addons/myguiengine/include/MyGUI_ScrollView.h @@ -90,7 +90,7 @@ namespace MyGUI void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id); void notifyMouseReleased(Widget* _sender, int _left, int _top, MouseButton _id); - void notifyScrollChangePosition(ScrollBar* _sender, size_t _position); + void notifyScrollChangePosition(ScrollBar* _sender, int _position);// expand by genesis-3d void notifyMouseWheel(Widget* _sender, int _rel); void updateView(); diff --git a/Engine/addons/myguiengine/include/MyGUI_ScrollViewBase.h b/Engine/addons/myguiengine/include/MyGUI_ScrollViewBase.h index 483e726..cf661a6 100644 --- a/Engine/addons/myguiengine/include/MyGUI_ScrollViewBase.h +++ b/Engine/addons/myguiengine/include/MyGUI_ScrollViewBase.h @@ -54,8 +54,18 @@ namespace MyGUI virtual Align getContentAlign(); virtual void eraseContent(); - protected: + void bindDrag();// expand by genesis-3d + bool dragClent(int _left, int _top, MouseButton _id);// expand by genesis-3d + bool isDraging() const;// expand by genesis-3d + void notifyClentPress(Widget* _sender, int _left, int _top, MouseButton _id);// expand by genesis-3d + void notifyClentRelease(Widget* _sender, int _left, int _top, MouseButton _id);// expand by genesis-3d + void notifyClentDrag(Widget* _sender, int _left, int _top, MouseButton _id);// expand by genesis-3d + void notifyClentLostFocus(Widget* _sender, Widget* _newFocus);// expand by genesis-3d + virtual void onClientDragBegin(Widget* _sender, int _left, int _top, MouseButton _id);// expand by genesis-3d + virtual void onClientDragEnd(Widget* _sender);// expand by genesis-3d + virtual void onClientDrag(Widget* _sender, int _left, int _top, MouseButton _id);// expand by genesis-3d + ScrollBar* mVScroll; ScrollBar* mHScroll; Widget* mClient; @@ -66,6 +76,9 @@ namespace MyGUI size_t mVRange; size_t mHRange; + // expand by genesis-3d + bool mDraging; + //---------------------------- // 懈蟹屑械薪褟械褌褋褟 谢懈 褋芯写械褉卸懈屑芯械 锌褉懈 褉械褋邪泄蟹械 bool mChangeContentByResize; }; diff --git a/Engine/addons/myguiengine/src/MyGUI_Canvas.cpp b/Engine/addons/myguiengine/src/MyGUI_Canvas.cpp index 8644457..028e424 100644 --- a/Engine/addons/myguiengine/src/MyGUI_Canvas.cpp +++ b/Engine/addons/myguiengine/src/MyGUI_Canvas.cpp @@ -298,7 +298,18 @@ namespace MyGUI void Canvas::_setUVSet(const FloatRect& _rect) { if (nullptr != getSubWidgetMain()) - getSubWidgetMain()->_setUVSet(_rect); + { + if (VertexColourType::ColourABGR == RenderManager::getInstancePtr()->getVertexFormat()) + { + FloatRect glrect(_rect.left, 1.0f - _rect.top, _rect.right, 1.0f - _rect.bottom); + getSubWidgetMain()->_setUVSet(glrect); + } + else + { + getSubWidgetMain()->_setUVSet(_rect); + } + + } } bool Canvas::isLocked() const diff --git a/Engine/addons/myguiengine/src/MyGUI_DDContainer.cpp b/Engine/addons/myguiengine/src/MyGUI_DDContainer.cpp index 85b9e9a..4c15aa2 100644 --- a/Engine/addons/myguiengine/src/MyGUI_DDContainer.cpp +++ b/Engine/addons/myguiengine/src/MyGUI_DDContainer.cpp @@ -94,10 +94,10 @@ namespace MyGUI } } - void DDContainer::mouseDrag(MouseButton _id) + bool DDContainer::mouseDrag(MouseButton _id)// expand by genesis-3d { if (MouseButton::Left != _id) - return; + return false;// expand by genesis-3d // 薪褍卸薪芯 谢懈 芯斜薪芯胁懈褌褜 写邪薪薪褘械 bool update = false; @@ -121,14 +121,17 @@ namespace MyGUI else { // 褋斜褉邪褋褘胁邪械屑 褎芯泻褍褋 屑褘褕懈 (薪械 芯斜褟蟹邪褌械谢褜薪芯) - InputManager::getInstance().resetMouseCaptureWidget(); + + // expand by genesis-3d + // reset or not logic move to item box + //InputManager::getInstance().resetMouseCaptureWidget(); } } // 写褉芯锌 薪械 薪褍卸械薪 if (!mNeedDrop) { - return; + return false;// expand by genesis-3d } // 写械谢邪械屑 蟹邪锌褉芯褋, 薪邪写 泻械屑 薪邪褕邪 屑褘褕邪 @@ -138,7 +141,8 @@ namespace MyGUI updateDropItems(); // 械褋谢懈 褉邪胁薪芯, 蟹薪邪褔懈褌 褍卸械 褋锌褉邪褕懈胁邪谢懈 - if (mOldDrop == item) return; + if (mOldDrop == item) + return true;// expand by genesis-3d mOldDrop = item; // 褋斜褉邪褋褘胁邪械屑 褋褌邪褉褍褞 锌芯写褋胁械褌泻褍 @@ -209,6 +213,7 @@ namespace MyGUI updateDropItemsState(data); eventChangeDDState(this, state); + return true;// expand by genesis-3d } void DDContainer::endDrop(bool _reset) diff --git a/Engine/addons/myguiengine/src/MyGUI_EditBox.cpp b/Engine/addons/myguiengine/src/MyGUI_EditBox.cpp index 02d386a..919873c 100644 --- a/Engine/addons/myguiengine/src/MyGUI_EditBox.cpp +++ b/Engine/addons/myguiengine/src/MyGUI_EditBox.cpp @@ -1628,8 +1628,12 @@ namespace MyGUI return Base::getTextSize(); } - void EditBox::notifyScrollChangePosition(ScrollBar* _sender, size_t _position) + void EditBox::notifyScrollChangePosition(ScrollBar* _sender, int _position)// expand by genesis-3d { + if (_position < 0)// expand by genesis-3d + { + _position = 0; + } if (mClientText == nullptr) return; diff --git a/Engine/addons/myguiengine/src/MyGUI_InputManager.cpp b/Engine/addons/myguiengine/src/MyGUI_InputManager.cpp index 1fe34ab..5316bda 100644 --- a/Engine/addons/myguiengine/src/MyGUI_InputManager.cpp +++ b/Engine/addons/myguiengine/src/MyGUI_InputManager.cpp @@ -151,6 +151,11 @@ namespace MyGUI return isFocus; } + return changeMouseFocus(item, old_mouse_focus, _absx, _absy, _absz); + } + + bool InputManager::changeMouseFocus(Widget* item, Widget* old_mouse_focus, int _absx, int _absy, int _absz) + { if (item) { // 锌芯写薪懈屑邪械屑褋褟 写芯 褉褍褌邪 @@ -474,6 +479,11 @@ namespace MyGUI } } + void InputManager::_forceChangeMouseFocus(Widget* _focusNew, int _absx, int _absy, int _absz) + { + changeMouseFocus(_focusNew, mWidgetMouseFocus, _absx, _absy, _absz); + } + // 褍写邪谢褟械屑 写邪薪薪褘泄 胁懈写卸械褌 懈蟹 胁褋械褏 胁芯蟹屑芯卸薪褘褏 屑械褋褌 void InputManager::_unlinkWidget(Widget* _widget) { diff --git a/Engine/addons/myguiengine/src/MyGUI_ItemBox.cpp b/Engine/addons/myguiengine/src/MyGUI_ItemBox.cpp index e3b28a5..cdee0af 100644 --- a/Engine/addons/myguiengine/src/MyGUI_ItemBox.cpp +++ b/Engine/addons/myguiengine/src/MyGUI_ItemBox.cpp @@ -31,6 +31,16 @@ namespace MyGUI { + static const float gDragBias = 3.0f; + static const float gCriticalForceOverflow = 0.1f; + static const float gSpeedTime = 0.1f; + static const float gSpeedDown = 0.25f; + static const float gOverflowTime = 0.2f; + static const float gDefualSpeedWeight = 0.5f; + static const float gTinyTime = 0.001f; + static const float gCriticalSpeed = 2.0f; + static const float gSpeedLerpWeight = 0.8f; + ItemBox::ItemBox() : mCountItemInLine(0), @@ -43,7 +53,12 @@ namespace MyGUI mIndexRefuse(ITEM_NONE), mIsFocus(false), mItemDrag(nullptr), - mAlignVert(true) + mAlignVert(true), + mPreCoord(0.0f), + mTimeCounter(0.0f), + mScrollSpeed(0.0f), + mMoveCounter(0.0f), + mScrollState(ScrollStop) { mChangeContentByResize = true; } @@ -83,23 +98,40 @@ namespace MyGUI // 锌芯写锌懈褋褘胁邪械屑 泻谢懈械薪褌 写谢褟 写褉邪谐褝薪写褉芯锌邪 if (mClient != nullptr) + { mClient->_setContainer(this); + } requestItemSize(); - updateScrollSize(); updateScrollPosition(); + + // expand by genesis-3d + Gui::getInstancePtr()->eventFrameStart += newDelegate(this, &ItemBox::notifyTick); + bindDrag(); + if (mHScroll != nullptr) + { + mHScroll->setLimitRange(true); + mHScroll->eventMouseButtonPressed += newDelegate(this, & ItemBox::notifyScrollBarPress); + } + + if (mVScroll != nullptr) + { + mVScroll->setLimitRange(true); + mVScroll->eventMouseButtonPressed += newDelegate(this, & ItemBox::notifyScrollBarPress); + } + } void ItemBox::shutdownOverride() { + Gui::getInstancePtr()->eventFrameStart -= newDelegate(this, &ItemBox::notifyTick);// expand by genesis-3d mVScroll = nullptr; mHScroll = nullptr; mClient = nullptr; Base::shutdownOverride(); } - void ItemBox::setPosition(const IntPoint& _point) { Base::setPosition(_point); @@ -151,24 +183,41 @@ namespace MyGUI count_visible = (_getClientWidget()->getWidth() / mSizeItem.width) + 2; } - size_t start = (mFirstVisibleIndex * mCountItemInLine); - size_t count = (count_visible * mCountItemInLine) + start; + int start = getStartIndex(); + int count = (count_visible * mCountItemInLine) + (mFirstVisibleIndex * mCountItemInLine);//start; - size_t index = 0; - for (size_t pos = start; pos < count; ++pos, ++index) + int bias = 0;// expand by genesis-3d + if (mFirstVisibleIndex < 0)// expand by genesis-3d + { + if (mAlignVert) + { + bias = -mFirstVisibleIndex * mSizeItem.height; + } + else + { + bias = -mFirstVisibleIndex * mSizeItem.width; + } + start = 0; + } + + int index = 0; + for (int pos = start; pos < count; ++pos, ++index) { // 写邪谢褜褕械 薪械褌 邪泄褌械屑芯胁 - if (pos >= mItemsInfo.size()) break; + if (pos >= (int)mItemsInfo.size()) + { + break; + } Widget* item = getItemWidget(index); if (mAlignVert) { item->setPosition(((int)index % mCountItemInLine) * mSizeItem.width - mContentPosition.left, - (((int)index / mCountItemInLine) * mSizeItem.height) - mFirstOffsetIndex); + (((int)index / mCountItemInLine) * mSizeItem.height) - mFirstOffsetIndex + bias); } else { - item->setPosition((((int)index / mCountItemInLine) * mSizeItem.width) - mFirstOffsetIndex, + item->setPosition((((int)index / mCountItemInLine) * mSizeItem.width) - mFirstOffsetIndex + bias, ((int)index % mCountItemInLine) * mSizeItem.height - mContentPosition.top); } @@ -184,7 +233,7 @@ namespace MyGUI } // 胁褋械 胁懈写卸械褌褘 械褖械 械褋褌褜, 褌芯 懈褏 薪邪写芯 斜褘 褋泻褉褘褌褜 - while (index < mVectorItems.size()) + while (index < (int)mVectorItems.size()) { mVectorItems[index]->setVisible(false); index ++; @@ -251,7 +300,7 @@ namespace MyGUI // 褋斜褉邪褋褘胁邪械屑 褋褌邪褉褍褞 锌芯写褋胁械褌泻褍 if (mIndexActive != ITEM_NONE) { - size_t start = (size_t)(mFirstVisibleIndex * mCountItemInLine); + size_t start = (size_t)getStartIndex(); size_t index = mIndexActive; mIndexActive = ITEM_NONE; @@ -319,7 +368,7 @@ namespace MyGUI mIndexAccept = (_set && _accept ) ? _index : ITEM_NONE; mIndexRefuse = (_set && !_accept) ? _index : ITEM_NONE; - size_t start = (size_t)(mFirstVisibleIndex * mCountItemInLine); + size_t start = (size_t)getStartIndex(); if ((_index >= start) && (_index < (start + mVectorItems.size()))) { IBDrawItemInfo data(_index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false); @@ -332,7 +381,7 @@ namespace MyGUI MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "ItemBox::setItemData"); mItemsInfo[_index].data = _data; - size_t start = (size_t)(mFirstVisibleIndex * mCountItemInLine); + size_t start = (size_t)getStartIndex(); if ((_index >= start) && (_index < (start + mVectorItems.size()))) { IBDrawItemInfo data(_index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, true, false); @@ -421,7 +470,7 @@ namespace MyGUI { MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "ItemBox::redrawItemAt"); - size_t start = (size_t)(mFirstVisibleIndex * mCountItemInLine); + size_t start = (size_t)getStartIndex(); if ((_index >= start) && (_index < (start + mVectorItems.size()))) { IBDrawItemInfo data(_index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, true, false); @@ -434,7 +483,7 @@ namespace MyGUI MYGUI_ASSERT_RANGE_AND_NONE(_index, mItemsInfo.size(), "ItemBox::setIndexSelected"); if (_index == mIndexSelect) return; - size_t start = (size_t)(mFirstVisibleIndex * mCountItemInLine); + size_t start = (size_t)getStartIndex(); // 褋斜褉邪褋褘胁邪械屑 褋褌邪褉芯械 胁褘写械谢械薪懈械 if (mIndexSelect != ITEM_NONE) @@ -604,14 +653,25 @@ namespace MyGUI void ItemBox::notifyMouseDrag(Widget* _sender, int _left, int _top, MouseButton _id) { - mouseDrag(_id); + // expand by genesis-3d + if(mouseDrag(_id)) + { + } + else if (dragClent(_left, _top, _id)) + { + } + else + { + InputManager::getInstance().resetMouseCaptureWidget(); + } + } void ItemBox::notifyMouseButtonPressed(Widget* _sender, int _left, int _top, MouseButton _id) { - mouseButtonPressed(_id); - - if ( MouseButton::Left == _id) + DDContainer::mouseButtonPressed(_id); + scrollStop(); + if ( MouseButton::Left == _id) { size_t old = mIndexSelect; @@ -645,6 +705,11 @@ namespace MyGUI { bool needEvent = !mStartDrop; mouseButtonReleased(_id); + if (!isDraging()) + { + preDrag(); + checkScrollState(); + } if (needEvent) eventNotifyItem(this, IBNotifyItemData(getIndexByWidget(_sender), IBNotifyItemData::MouseReleased, _left, _top, _id)); @@ -652,6 +717,11 @@ namespace MyGUI void ItemBox::notifyRootMouseChangeFocus(Widget* _sender, bool _focus) { + if (isDraging()) + { + return; + } + size_t index = calcIndexByWidget(_sender); if (_focus) { @@ -660,10 +730,15 @@ namespace MyGUI // 褋斜褉邪褋褘胁邪械屑 褋褌邪褉褘泄 if (mIndexActive != ITEM_NONE) { - size_t old_index = mIndexActive; + int old_index = (int)mIndexActive; mIndexActive = ITEM_NONE; IBDrawItemInfo data(old_index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false); - requestDrawItem(this, mVectorItems[old_index - (mFirstVisibleIndex * mCountItemInLine)], data); + int index = old_index - getStartIndex();// expand by genesis-3d + if (0 <= index && index < (int)mVectorItems.size()) + { + requestDrawItem(this, mVectorItems[old_index - getStartIndex()], data); + } + } mIndexActive = index; @@ -714,7 +789,7 @@ namespace MyGUI } } - void ItemBox::notifyScrollChangePosition(ScrollBar* _sender, size_t _index) + void ItemBox::notifyScrollChangePosition(ScrollBar* _sender, int _index) { if (_sender == mVScroll) { @@ -730,6 +805,15 @@ namespace MyGUI void ItemBox::notifyMouseWheel(Widget* _sender, int _rel) { + if (mDraging)// expand by genesis-3d + { + return; + } + if (ScrollStop != mScrollState)// expand by genesis-3d + { + scrollStop(); + } + if (mAlignVert) { if (mContentSize.height <= 0) return; @@ -787,7 +871,455 @@ namespace MyGUI if (nullptr != mHScroll) mHScroll->setScrollPosition(mContentPosition.left); } - void ItemBox::setContentPosition(const IntPoint& _point) + //------------------------------------------------------------------------------// + // expand by genesis-3d + + void ItemBox::setVScrollVisible(bool _value) + { + mVisibleVScroll = _value; + updateScrollSize(); + updateScrollPosition(); + } + + int ItemBox::getStartIndex() const + { + if (mFirstVisibleIndex > 0) + { + return mFirstVisibleIndex * mCountItemInLine; + } + else + { + return 0; + } + } + + void ItemBox::setHScrollVisible(bool _value) + { + mVisibleHScroll = _value; + updateScrollSize(); + updateScrollPosition(); + } + + bool ItemBox::isVScrollVisible() const + { + return mVisibleVScroll; + } + + bool ItemBox::isHScrollVisible() const + { + return mVisibleHScroll; + } + inline float __lerp(float x, float y, float scale) + { + return x + (y - x) * scale; + } + + inline float __abs(float x) + { + if (x < 0) + { + return -x; + } + return x; + } + + inline float __dragLerp(float overflow, float length, float preCoord, float currentCoord) + { + float scale = overflow / (float)length; + if (scale >= 1.0f) + { + return preCoord; + } + return __lerp(currentCoord, preCoord, scale); + } + + float ItemBox::defualtSpeed() const + { + float len = mAlignVert ? (float)mSizeItem.height : (float)mSizeItem.width; + return len * gDefualSpeedWeight; + } + + bool ItemBox::headEmpty() const + { + return (mPreCoord < 0.0f); + } + + bool ItemBox::tailEmpty() const + { + float sizeItem = mAlignVert ? (float)mSizeItem.height : (float)mSizeItem.width; + float clientSize = mAlignVert ? (float)mClient->getHeight() : (float)mClient->getWidth(); + float button = clientSize - (sizeItem * mCountLines - mPreCoord); + return (button > 0.0f); //button empty. + } + + int ItemBox::dragOperator(int _current, int _length, int _sizeItem) + { + float bias = (float)(_current - mPreMouse); // mouse move. + if (bias > gDragBias || gDragBias < -bias) + { + resetCurrentActiveItem(); + } + + float out = mPreCoord - bias; // new content pos. + if (out < 0.0f)// headEmpty. + { + if (bias > 0.0f) + { + out = __dragLerp(-out, (float)_length, mPreCoord, out); + } + } + else + { + float button = _length - (_sizeItem * mCountLines - out); + if (button > 0.0f) //tailEmpty. + { + if (bias < 0.0f) + { + out = __dragLerp(button, (float)_length, mPreCoord, out); + } + } + } + + dragMove(out - mPreCoord); + + mPreCoord = out; + mPreMouse = _current; + return (int)out; + + } + + void ItemBox::onClientDragBegin(Widget* _sender, int _left, int _top, MouseButton _id) + { + preDrag(); + ScrollViewBase::onClientDragBegin(_sender, _left, _top, _id); + } + + void ItemBox::onClientDragEnd(Widget* _sender) + { + checkScrollState(); + ScrollViewBase::onClientDragEnd(_sender); + } + + void ItemBox::onClientDrag(Widget* _sender, int _left, int _top, MouseButton _id) + { + if (MouseButton::Left == _id) + { + if (mAlignVert) + { + mContentPosition.top = dragOperator(_top, mClient->getHeight(), mSizeItem.height); + } + else + { + mContentPosition.left = dragOperator(_left, mClient->getWidth(), mSizeItem.width); + } + updateContentPosition(mContentPosition); + + if (nullptr != mVScroll) mVScroll->setScrollPosition(mContentPosition.top, true); + if (nullptr != mHScroll) mHScroll->setScrollPosition(mContentPosition.left, true); + } + } + + void ItemBox::notifyScrollBarPress(Widget* _sender, int _left, int _top, MouseButton _id) + { + if (ScrollInertia == mScrollState && _id == MouseButton::Left) + { + scrollStop(); + } + } + + void ItemBox::pushContentPosition() + { + if (mAlignVert) + { + mContentPosition.top = (int)mPreCoord; + } + else + { + mContentPosition.left = (int)mPreCoord; + } + + updateContentPosition(mContentPosition); + + if (nullptr != mVScroll) mVScroll->setScrollPosition(mContentPosition.top, true); + if (nullptr != mHScroll) mHScroll->setScrollPosition(mContentPosition.left, true); + } + + void ItemBox::finalSpeed() + { + if (mTimeCounter > gSpeedTime) + { + testSpeed(); + } + else if (mTimeCounter > gTinyTime) + { + float speed = mMoveCounter / gSpeedTime; + float mini = speed * gSpeedLerpWeight; + mScrollSpeed = __lerp(mScrollSpeed, speed, gSpeedLerpWeight * (mTimeCounter / gSpeedTime)); + if (__abs(mScrollSpeed) < __abs(mini)) + { + mScrollSpeed = mini; + } + } + else + { + resetCounter(); + } + } + + void ItemBox::resetCounter() + { + mTimeCounter = 0.0f; + mMoveCounter = 0.0f; + } + + void ItemBox::testSpeed() + { + float speed = mMoveCounter / gSpeedTime; + mScrollSpeed = __lerp(mScrollSpeed, speed, gSpeedLerpWeight); + + resetCounter(); + } + + void ItemBox::dragMove(float move) + { + mMoveCounter += move; + } + void ItemBox::checkScrollState() + { + finalSpeed(); + resetCounter(); + + if (headEmpty()) + { + mScrollState = ScrollOverflow; + } + else + { + if (tailEmpty()) + { + mScrollState = ScrollOverflow; + } + else + { + float defualt_speed = defualtSpeed(); + if (-defualt_speed < mScrollSpeed && mScrollSpeed < defualt_speed) + { + mScrollState = ScrollStop; + mScrollSpeed = 0.0f; + } + else + { + mScrollState = ScrollInertia; + } + + } + } + } + + void ItemBox::preDrag() + { + const IntPoint& point = InputManager::getInstance().getLastPressedPosition(MouseButton::Left); + if (mAlignVert) + { + mPreCoord = (float)mContentPosition.top; + mPreMouse = point.top; + } + else + { + mPreCoord = (float)mContentPosition.left; + mPreMouse = point.left; + } + scrollStop(); + } + + void ItemBox::scrollStop() + { + resetCounter(); + mScrollSpeed = 0.0f; + mScrollState = ScrollStop; + } + + void ItemBox::scrollOverflow(float time) + { + mTimeCounter += time; + if (headEmpty()) + { + if (mTimeCounter < gOverflowTime) + { + float coord = mPreCoord; + mPreCoord = __lerp(mPreCoord, 0, mTimeCounter / gOverflowTime); + pushContentPosition(); + mPreCoord = coord; + } + else + { + mPreCoord = 0; + pushContentPosition(); + scrollStop(); + } + } + else + { + float sizeItem = mAlignVert ? (float)mSizeItem.height : (float)mSizeItem.width; + float clientSize = mAlignVert ? (float)mClient->getHeight() : (float)mClient->getWidth(); + float head = (sizeItem * mCountLines) - clientSize; + if (head < 0.0f) + { + head = 0.0f; + } + + if (mTimeCounter < gOverflowTime) + { + float coord = mPreCoord; + mPreCoord = __lerp(mPreCoord, head, mTimeCounter / gOverflowTime); + pushContentPosition(); + mPreCoord = coord; + } + else + { + mPreCoord = head; + pushContentPosition(); + scrollStop(); + + } + } + + } + + void ItemBox::scrollForceOverflow(float time) + { + mTimeCounter += time; + if (mTimeCounter > gOverflowTime) + { + time = gOverflowTime - (mTimeCounter - time); + mPreCoord += mScrollSpeed * time; + resetCounter(); + mScrollState = ScrollOverflow; + } + else + { + mPreCoord += mScrollSpeed * time; + float clientSize = mAlignVert ? (float)mClient->getHeight() : (float)mClient->getWidth(); + float limit = clientSize * gCriticalForceOverflow; + if (mPreCoord < -limit) + { + mPreCoord = -limit; + resetCounter(); + mScrollState = ScrollOverflow; + } + else + { + float sizeItem = mAlignVert ? (float)mSizeItem.height : (float)mSizeItem.width; + + float head = (sizeItem * mCountLines) - clientSize; + if (mPreCoord - head > limit) + { + mPreCoord = head + limit; + } + } + + } + pushContentPosition(); + } + + void ItemBox::scrollInertia(float time) + { + float weight = 1.0f - mTimeCounter * gSpeedDown; + if (weight > 0.0f) + { + float speed = mScrollSpeed * weight; + if (-gCriticalSpeed < speed && speed < gCriticalSpeed) + { + scrollStop(); + } + else + { + mTimeCounter += time; + mPreCoord += speed * time; + + pushContentPosition(); + + if (headEmpty()) + { + mScrollState = ScrollForceOverflow; + mScrollSpeed = speed; + resetCounter(); + } + else if (tailEmpty()) + { + mScrollState = ScrollForceOverflow; + mScrollSpeed = speed; + resetCounter(); + } + } + + } + + } + + void ItemBox::notifyTick(float time) + { + if (isDraging()) + { + mTimeCounter += time; + if (mTimeCounter > gSpeedTime) + { + testSpeed(); + } + } + else + { + switch(mScrollState) + { + case ScrollInertia: + { + scrollInertia(time); + break; + } + case ScrollForceOverflow: + { + scrollForceOverflow(time); + break; + } + case ScrollOverflow: + { + scrollOverflow(time); + break; + } + default: + break; + } + } + + } + + inline int _offset_check(int a, int b) + { + if (a < 0) + { + int t = (-a) % b; + return b - t; + } + else + { + return a % b; + } + } + + inline int _index_check(int a, int b) + { + if (a < 0) + { + return (int)(a / (float)b) - 1; + } + else + { + return a / b; + } + } + //------------------------------------------------------------------------------// + + void ItemBox::updateContentPosition(const IntPoint& _point) { mContentPosition = _point; @@ -795,19 +1327,24 @@ namespace MyGUI if (mAlignVert) { - mFirstVisibleIndex = mContentPosition.top / mSizeItem.height; - mFirstOffsetIndex = mContentPosition.top % mSizeItem.height; + mFirstVisibleIndex = _index_check(mContentPosition.top , mSizeItem.height); // expand by genesis-3d + mFirstOffsetIndex = _offset_check(mContentPosition.top , mSizeItem.height); // expand by genesis-3d } else { - mFirstVisibleIndex = mContentPosition.left / mSizeItem.width; - mFirstOffsetIndex = mContentPosition.left % mSizeItem.width; + mFirstVisibleIndex = _index_check(mContentPosition.left , mSizeItem.width); // expand by genesis-3d + mFirstOffsetIndex = _offset_check(mContentPosition.left , mSizeItem.width); // expand by genesis-3d } _updateAllVisible(old != mFirstVisibleIndex); _resetContainer(true); } + void ItemBox::setContentPosition(const IntPoint& _point) + { + updateContentPosition(_point); + } + void ItemBox::redrawAllItems() { _updateAllVisible(true); @@ -820,7 +1357,7 @@ namespace MyGUI size_t ItemBox::calcIndexByWidget(Widget* _widget) { - return *_widget->_getInternalData() + (mFirstVisibleIndex * mCountItemInLine); + return *_widget->_getInternalData() + getStartIndex(); } IntSize ItemBox::getContentSize() @@ -922,6 +1459,14 @@ namespace MyGUI { if (_key == "VerticalAlignment") setVerticalAlignment(utility::parseValue(_value)); + else if (_key == "HScrollVisible") + { + setHScrollVisible(utility::parseValue(_value)); + } + else if (_key == "VScrollVisible") + { + setVScrollVisible(utility::parseValue(_value)); + } else { Base::setPropertyOverride(_key, _value); diff --git a/Engine/addons/myguiengine/src/MyGUI_ListBox.cpp b/Engine/addons/myguiengine/src/MyGUI_ListBox.cpp index 7d2bc03..01430ee 100644 --- a/Engine/addons/myguiengine/src/MyGUI_ListBox.cpp +++ b/Engine/addons/myguiengine/src/MyGUI_ListBox.cpp @@ -238,8 +238,12 @@ namespace MyGUI _resetContainer(true); } - void ListBox::notifyScrollChangePosition(ScrollBar* _sender, size_t _position) + void ListBox::notifyScrollChangePosition(ScrollBar* _sender, int _position)// expand by genesis-3d { + if (_position < 0)// expand by genesis-3d + { + _position = 0; + } _setScrollView(_position); _sendEventChangeScroll(_position); } diff --git a/Engine/addons/myguiengine/src/MyGUI_ScrollBar.cpp b/Engine/addons/myguiengine/src/MyGUI_ScrollBar.cpp index f908e7f..d0e43af 100644 --- a/Engine/addons/myguiengine/src/MyGUI_ScrollBar.cpp +++ b/Engine/addons/myguiengine/src/MyGUI_ScrollBar.cpp @@ -45,7 +45,8 @@ namespace MyGUI mScrollViewPage(0), mMinTrackSize(0), mMoveToClick(false), - mVerticalAlignment(true) + mVerticalAlignment(true), + mLimitRange(true) { } @@ -147,7 +148,13 @@ namespace MyGUI mWidgetTrack->setVisible(true); // 懈 芯斜薪芯胁谢褟械屑 锌芯蟹懈褑懈褞 - pos = (int)(((size_t)(pos - getTrackSize()) * mScrollPosition) / (mScrollRange - 1) + mSkinRangeStart); + //pos = (int)(((size_t)(pos - getTrackSize()) * mScrollPosition) / (mScrollRange - 1) + mSkinRangeStart); old code + + // expand by genesis-3d + int bias = (pos - getTrackSize()) * mScrollPosition; + int result = (int)(bias / (float)(mScrollRange - 1)); + pos = result + mSkinRangeStart; + // --------------------------------------------------------------------------------- mWidgetTrack->setPosition(mWidgetTrack->getLeft(), pos); if (nullptr != mWidgetFirstPart) @@ -179,7 +186,13 @@ namespace MyGUI mWidgetTrack->setVisible(true); // 懈 芯斜薪芯胁谢褟械屑 锌芯蟹懈褑懈褞 - pos = (int)(((size_t)(pos - getTrackSize()) * mScrollPosition) / (mScrollRange - 1) + mSkinRangeStart); + //pos = (int)(((size_t)(pos - getTrackSize()) * mScrollPosition) / (mScrollRange - 1) + mSkinRangeStart); old code + + // expand by genesis-3d + int bias = (pos - getTrackSize()) * mScrollPosition; + int result = (int)(bias / (float)(mScrollRange - 1)); + pos = result + mSkinRangeStart; + // --------------------------------------------------------------------------------- mWidgetTrack->setPosition(pos, mWidgetTrack->getTop()); if (nullptr != mWidgetFirstPart) @@ -196,7 +209,27 @@ namespace MyGUI } } - void ScrollBar::TrackMove(int _left, int _top) + void ScrollBar::updatePreActionOffset() + { + mPreActionOffset.left = mWidgetTrack->getLeft(); + mPreActionOffset.top = mWidgetTrack->getTop(); + } + + void ScrollBar::setLimitRange(bool _value) + { + mLimitRange = _value; + } + + bool ScrollBar::getLimitRange() const + { + return mLimitRange; + } + + // ---------------------------------------------------------------------- + + + + void ScrollBar::TrackMove(int _left, int _top)// expand by genesis-3d { if (mWidgetTrack == nullptr) return; @@ -206,11 +239,19 @@ namespace MyGUI if (mVerticalAlignment) { // 褉邪褋褔懈褌褘胁邪械屑 锌芯蟹懈褑懈褞 胁懈写卸械褌邪 - int start = mPreActionOffset.top + (_top - point.top); - if (start < (int)mSkinRangeStart) - start = (int)mSkinRangeStart; - else if (start > (getTrackPlaceLength() - (int)mSkinRangeEnd - mWidgetTrack->getHeight())) - start = (getTrackPlaceLength() - (int)mSkinRangeEnd - mWidgetTrack->getHeight()); + //int start = mPreActionOffset.top + (_top - point.top); // old code. + + // expand by genesis-3d + int bias = (_top - point.top); + int start = (mPreActionOffset.top + bias); + // ----------------------------------- + if (mLimitRange)// expand by genesis-3d + { + if (start < (int)mSkinRangeStart) + start = (int)mSkinRangeStart; + else if (start > (getTrackPlaceLength() - (int)mSkinRangeEnd - mWidgetTrack->getHeight())) + start = (getTrackPlaceLength() - (int)mSkinRangeEnd - mWidgetTrack->getHeight()); + } if (mWidgetTrack->getTop() != start) mWidgetTrack->setPosition(mWidgetTrack->getLeft(), start); @@ -221,23 +262,34 @@ namespace MyGUI pos = pos * (int)(mScrollRange - 1) / (getLineSize() - getTrackSize()); // 锌褉芯胁械褉褟械屑 薪邪 胁褘褏芯写褘 懈 懈蟹屑械薪械薪懈褟 - if (pos < 0) - pos = 0; - else if (pos >= (int)mScrollRange) - pos = (int)mScrollRange - 1; - if (pos == (int)mScrollPosition) - return; + if (mLimitRange)// expand by genesis-3d + { + if (pos < 0) + pos = 0; + else if (pos >= (int)mScrollRange) + pos = (int)mScrollRange - 1; + if (pos == (int)mScrollPosition) + return; + } mScrollPosition = pos; } else { // 褉邪褋褔懈褌褘胁邪械屑 锌芯蟹懈褑懈褞 胁懈写卸械褌邪 - int start = mPreActionOffset.left + (_left - point.left); - if (start < (int)mSkinRangeStart) - start = (int)mSkinRangeStart; - else if (start > (getTrackPlaceLength() - (int)mSkinRangeEnd - mWidgetTrack->getWidth())) - start = (getTrackPlaceLength() - (int)mSkinRangeEnd - mWidgetTrack->getWidth()); + //int start = mPreActionOffset.left + (_left - point.left);// old code. + + // expand by genesis-3d + int bias = (_left - point.left); + int start = (mPreActionOffset.left + bias); + // ----------------------------------- + if (mLimitRange)// expand by genesis-3d + { + if (start < (int)mSkinRangeStart) + start = (int)mSkinRangeStart; + else if (start > (getTrackPlaceLength() - (int)mSkinRangeEnd - mWidgetTrack->getWidth())) + start = (getTrackPlaceLength() - (int)mSkinRangeEnd - mWidgetTrack->getWidth()); + } if (mWidgetTrack->getLeft() != start) mWidgetTrack->setPosition(IntPoint(start, mWidgetTrack->getTop())); @@ -248,12 +300,16 @@ namespace MyGUI pos = pos * (int)(mScrollRange - 1) / (getLineSize() - getTrackSize()); // 锌褉芯胁械褉褟械屑 薪邪 胁褘褏芯写褘 懈 懈蟹屑械薪械薪懈褟 - if (pos < 0) - pos = 0; - else if (pos >= (int)mScrollRange) - pos = (int)mScrollRange - 1; - if (pos == (int)mScrollPosition) - return; + + if (mLimitRange)// expand by genesis-3d + { + if (pos < 0) + pos = 0; + else if (pos >= (int)mScrollRange) + pos = (int)mScrollRange - 1; + if (pos == (int)mScrollPosition) + return; + } mScrollPosition = pos; } @@ -354,8 +410,7 @@ namespace MyGUI } else if (_sender == mWidgetTrack) { - mPreActionOffset.left = _sender->getLeft(); - mPreActionOffset.top = _sender->getTop(); + updatePreActionOffset();// expand by genesis-3d } } @@ -380,13 +435,19 @@ namespace MyGUI updateTrack(); } - void ScrollBar::setScrollPosition(size_t _position) + void ScrollBar::setScrollPosition(int _position, bool _force) { if (_position == mScrollPosition) return; + if (mLimitRange && !_force) + { + if (_position < 0) + _position = 0; + + if (_position >= mScrollRange) + _position = 0; + } - if (_position >= mScrollRange) - _position = 0; mScrollPosition = _position; updateTrack(); @@ -500,7 +561,7 @@ namespace MyGUI return mScrollRange; } - size_t ScrollBar::getScrollPosition() const + int ScrollBar::getScrollPosition() const { return mScrollPosition; } diff --git a/Engine/addons/myguiengine/src/MyGUI_ScrollView.cpp b/Engine/addons/myguiengine/src/MyGUI_ScrollView.cpp index bbe9a80..b7d48ce 100644 --- a/Engine/addons/myguiengine/src/MyGUI_ScrollView.cpp +++ b/Engine/addons/myguiengine/src/MyGUI_ScrollView.cpp @@ -103,8 +103,12 @@ namespace MyGUI updateView(); } - void ScrollView::notifyScrollChangePosition(ScrollBar* _sender, size_t _position) + void ScrollView::notifyScrollChangePosition(ScrollBar* _sender, int _position)// expand by genesis-3d { + if (_position < 0)// expand by genesis-3d + { + _position = 0; + } if (mRealClient == nullptr) return; diff --git a/Engine/addons/myguiengine/src/MyGUI_ScrollViewBase.cpp b/Engine/addons/myguiengine/src/MyGUI_ScrollViewBase.cpp index 45c63c7..aea6d7c 100644 --- a/Engine/addons/myguiengine/src/MyGUI_ScrollViewBase.cpp +++ b/Engine/addons/myguiengine/src/MyGUI_ScrollViewBase.cpp @@ -23,6 +23,7 @@ #include "MyGUI_Precompiled.h" #include "MyGUI_ScrollViewBase.h" #include "MyGUI_ScrollBar.h" +#include "MyGUI_InputManager.h" namespace MyGUI { @@ -35,7 +36,8 @@ namespace MyGUI mVisibleVScroll(true), mVRange(0), mHRange(0), - mChangeContentByResize(false) + mChangeContentByResize(false), + mDraging(false) { } @@ -53,7 +55,8 @@ namespace MyGUI IntSize viewSize = getViewSize(); // 胁械褉褌懈泻邪谢褜薪褘泄 泻芯薪褌械薪褌 薪械 锌芯屑械褖邪械褌褋褟 - if (contentSize.height > viewSize.height) + //if (contentSize.height > viewSize.height) old code. + if (contentSize.height > viewSize.height && mVisibleVScroll) // expand by genesis-3d { if (mVScroll != nullptr) { @@ -141,7 +144,8 @@ namespace MyGUI // 谐芯褉懈蟹芯薪褌邪谢褜薪褘泄 泻芯薪褌械薪褌 薪械 锌芯屑械褖邪械褌褋褟 - if (contentSize.width > viewSize.width) + //if (contentSize.width > viewSize.width) old code. + if (contentSize.width > viewSize.width && mVisibleHScroll) // expand by genesis-3d { if (mHScroll != nullptr) { @@ -364,4 +368,77 @@ namespace MyGUI { } + + void ScrollViewBase::bindDrag() + { + if (mClient != nullptr) + { + mClient->eventMouseDrag += newDelegate(this, &ScrollViewBase::notifyClentDrag); + mClient->eventMouseButtonPressed += newDelegate(this, &ScrollViewBase::notifyClentPress); + mClient->eventMouseButtonReleased += newDelegate(this, &ScrollViewBase::notifyClentRelease); + mClient->eventMouseLostFocus += newDelegate(this, &ScrollViewBase::notifyClentLostFocus); + } + } + + + bool ScrollViewBase::dragClent(int _left, int _top, MouseButton _id) + { + if (MouseButton::Left == _id) + { + if (mClient) + { + InputManager::getInstancePtr()->_forceChangeMouseFocus(mClient, _left, _top, 0); + mClient->eventMouseButtonPressed(mClient, _left, _top, _id); + return true; + } + } + return false; + } + + bool ScrollViewBase::isDraging() const + { + return mDraging; + } + + void ScrollViewBase::notifyClentPress(Widget* _sender, int _left, int _top, MouseButton _id) + { + onClientDragBegin(_sender, _left, _top, _id); + } + + void ScrollViewBase::notifyClentDrag(Widget* _sender, int _left, int _top, MouseButton _id) + { + onClientDrag(_sender, _left, _top, _id); + } + + void ScrollViewBase::notifyClentLostFocus(Widget* _sender, Widget* _newFocus) + { + if (mDraging) + { + onClientDragEnd(_sender); + } + } + + void ScrollViewBase::notifyClentRelease(Widget* _sender, int _left, int _top, MouseButton _id) + { + if (mDraging) + { + onClientDragEnd(_sender); + } + } + + void ScrollViewBase::onClientDrag(Widget* _sender, int _left, int _top, MouseButton _id) + { + + } + + void ScrollViewBase::onClientDragBegin(Widget* _sender, int _left, int _top, MouseButton _id) + { + mDraging = true; + } + + void ScrollViewBase::onClientDragEnd(Widget* _sender) + { + mDraging = false; + } + } // namespace MyGUI diff --git a/Engine/addons/myguiplatforms/include/MyGUI_GenesisPlatform.h b/Engine/addons/myguiplatforms/include/MyGUI_GenesisPlatform.h index 0fe79ef..d0336d6 100644 --- a/Engine/addons/myguiplatforms/include/MyGUI_GenesisPlatform.h +++ b/Engine/addons/myguiplatforms/include/MyGUI_GenesisPlatform.h @@ -66,16 +66,14 @@ namespace MyGUI delete mInputManager; } - void initialise( const std::string& _group, const std::string& _logName = MYGUI_PLATFORM_LOG_FILENAME) + void initialise(int bufferWidth, int bufferHeight, const std::string& _group, const std::string& _logName = MYGUI_PLATFORM_LOG_FILENAME) { - assert(!mIsInitialise); mIsInitialise = true; - mRenderManager->setResolution(0, 0); + mRenderManager->initialise(0, 0, bufferWidth, bufferHeight); if (!_logName.empty()) LogManager::getInstance().createDefaultSource(_logName); - mRenderManager->initialise(); mDataManager->initialise(_group); } diff --git a/Engine/addons/myguiplatforms/include/MyGUI_GenesisRenderManager.h b/Engine/addons/myguiplatforms/include/MyGUI_GenesisRenderManager.h index ee2ac24..3af57dd 100644 --- a/Engine/addons/myguiplatforms/include/MyGUI_GenesisRenderManager.h +++ b/Engine/addons/myguiplatforms/include/MyGUI_GenesisRenderManager.h @@ -33,8 +33,11 @@ THE SOFTWARE. #include "MyGUI_IVertexBuffer.h" #include "MyGUI_RenderManager.h" -#include "graphicsystem/GraphicSystem.h" -#include "RenderSystem.h" + +namespace Graphic +{ + class Material; +} namespace MyGUI { @@ -48,7 +51,7 @@ namespace MyGUI public: GenesisRenderManager(); virtual ~GenesisRenderManager(); - void initialise(); + void initialise(int width, int height, int bufferWidth, int bufferHeight); void shutdown(); static GenesisRenderManager& getInstance(); @@ -89,20 +92,17 @@ namespace MyGUI virtual bool checkTexture(ITexture* _texture); #endif - void setResolution(int width, int height);//0 means auto. - - void setResolution(const IntSize& size);//0 means auto. + void setResolution(int width, int height, int bufferWidth, int bufferHeight);//0 means auto. const IntSize& getResolution() const; bool autoResolutionWidth() const; bool autoResolutionHeight() const; - void windowResized(); - void windowResized(int w, int h); - void deviceReseted(); + void windowResized(int bufferWidth, int bufferHeight); + void deviceReseted(int bufferWidth, int bufferHeight); - void renderGUI(); + void renderGUI(float time); bool getManualRender(); @@ -116,7 +116,7 @@ namespace MyGUI private: - void resetViewSize(int w, int h); + void resetViewSize(int bufferWidth, int bufferHeight); void destroyAllResources(); void updateRenderInfo(); @@ -140,7 +140,6 @@ namespace MyGUI void _checkShader(); void _beforeDraw(); GPtr m_shader; - //GPtr m_renderState; RenderBase::GPUProgramHandle* m_shaderHandle; static Util::String s_resourcePath; diff --git a/Engine/addons/myguiplatforms/include/MyGUI_GenesisTexture.h b/Engine/addons/myguiplatforms/include/MyGUI_GenesisTexture.h index 8cf3f00..1a1956a 100644 --- a/Engine/addons/myguiplatforms/include/MyGUI_GenesisTexture.h +++ b/Engine/addons/myguiplatforms/include/MyGUI_GenesisTexture.h @@ -38,6 +38,11 @@ THE SOFTWARE. #include "core/singleton.h" #include "util/array.h" +namespace Resources +{ + class TextureResInfo; +} + namespace MyGUI { @@ -96,15 +101,13 @@ namespace MyGUI size_t mNumElemBytes; ITextureInvalidateListener* mListener; - typedef unsigned char Byte; size_t m_width; size_t m_height; TextureBuffer m_texStream; - RenderBase::TextureHandle m_texHandle; - static Util::String s_resourcePath; + GPtr m_texRes; bool m_bManualCreate; - + static Util::String s_resourcePath; }; inline GenesisTexture::TextureBuffer& GenesisTexture::GetBuffer() @@ -112,11 +115,6 @@ namespace MyGUI return m_texStream; } - inline RenderBase::TextureHandle GenesisTexture::GetTextureHandle() const - { - return m_texHandle; - } - class GenesisTextureMgr : public Core::RefCounted { diff --git a/Engine/addons/myguiplatforms/include/MyGUI_GenesisVertexBufferManager.h b/Engine/addons/myguiplatforms/include/MyGUI_GenesisVertexBufferManager.h index 2036419..dd88811 100644 --- a/Engine/addons/myguiplatforms/include/MyGUI_GenesisVertexBufferManager.h +++ b/Engine/addons/myguiplatforms/include/MyGUI_GenesisVertexBufferManager.h @@ -53,7 +53,7 @@ namespace MyGUI public: void AddVertexBuffer(GenesisVertexBuffer* const& pBuffer); - + void RemoveVertexBuffer(GenesisVertexBuffer* const& pBuffer); void ResetAllBuffers() const; private: diff --git a/Engine/addons/myguiplatforms/src/MyGUI_GenesisRTTexture.cpp b/Engine/addons/myguiplatforms/src/MyGUI_GenesisRTTexture.cpp index 9716e72..d1dea82 100644 --- a/Engine/addons/myguiplatforms/src/MyGUI_GenesisRTTexture.cpp +++ b/Engine/addons/myguiplatforms/src/MyGUI_GenesisRTTexture.cpp @@ -28,6 +28,9 @@ THE SOFTWARE. ****************************************************************************/ #include "stdneb.h" #include + +#include "graphicsystem/GraphicSystem.h" + #include "MyGUI_GenesisRTTexture.h" #include "MyGUI_GenesisRenderManager.h" diff --git a/Engine/addons/myguiplatforms/src/MyGUI_GenesisRenderManager.cpp b/Engine/addons/myguiplatforms/src/MyGUI_GenesisRenderManager.cpp index 65998c4..307d8b1 100644 --- a/Engine/addons/myguiplatforms/src/MyGUI_GenesisRenderManager.cpp +++ b/Engine/addons/myguiplatforms/src/MyGUI_GenesisRenderManager.cpp @@ -27,18 +27,21 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "stdneb.h" +#include "graphicsystem/GraphicSystem.h" +#include "rendersystem/RenderSystem.h" +#include "materialmaker/parser/GenesisShaderParser.h" +#include "foundation/io/ioserver.h" + #include "MyGUI_GenesisDataManager.h" #include "MyGUI_GenesisRenderManager.h" #include "MyGUI_GenesisTexture.h" #include "MyGUI_GenesisVertexBuffer.h" #include "MyGUI_LogManager.h" #include "MyGUI_GenesisDiagnostic.h" -#include "MyGUI_Timer.h" #include "MyGUI_Gui.h" #include "MyGUI_GenesisInput.h" -#include "materialmaker/parser/GenesisShaderParser.h" -#include "foundation/io/ioserver.h" + #include "MyGUI_GenesisVertexBufferManager.h" #include "MyGUI_GenesisTexture.h" @@ -81,14 +84,14 @@ namespace MyGUI m_shader = NULL; } - void GenesisRenderManager::initialise() + void GenesisRenderManager::initialise(int width, int height, int bufferWidth, int bufferHeight) { mIsInitialise = true; - windowResized(); _checkShader(); m_VertexMgr = MyGUI::GenesisVertexBufferMgr::Create(); m_TextureMgr = MyGUI::GenesisTextureMgr::Create(); + setResolution(width, height, bufferWidth, bufferHeight); } void GenesisRenderManager::shutdown() @@ -124,11 +127,11 @@ namespace MyGUI delete _buffer; } - void GenesisRenderManager::resetViewSize(int w, int h) + void GenesisRenderManager::resetViewSize(int bufferWidth, int bufferHeight) { if (0 == mResolutionConfig.width) { - mCurrentResolution.width = w; + mCurrentResolution.width = bufferWidth; } else { @@ -137,7 +140,7 @@ namespace MyGUI if (0 == mResolutionConfig.height) { - mCurrentResolution.height = h; + mCurrentResolution.height = bufferHeight; } else { @@ -146,36 +149,22 @@ namespace MyGUI GenesisInputManager::getInstancePtr()->_setScreenSize((float)mCurrentResolution.width, (float)mCurrentResolution.height); } - void GenesisRenderManager::setResolution(int width, int height) + void GenesisRenderManager::setResolution(int width, int height, int bufferWidth, int bufferHeight) { mResolutionConfig.set(width, height); - windowResized(); + windowResized(bufferWidth, bufferHeight); } - void GenesisRenderManager::setResolution(const IntSize& size) + void GenesisRenderManager::windowResized(int bufferWidth, int bufferHeight) { - mResolutionConfig = size; - windowResized(); - } - - void GenesisRenderManager::windowResized() - { - const RenderBase::DisplayMode& dm = GraphicSystem::Instance()->GetMainViewPortWindow()->GetDisplayMode(); - resetViewSize(dm.GetWidth(), dm.GetHeight()); + resetViewSize(bufferWidth, bufferHeight); updateRenderInfo(); onResizeView(mCurrentResolution); } - void GenesisRenderManager::windowResized(int w, int h) + void GenesisRenderManager::deviceReseted(int bufferWidth, int bufferHeigh) { - resetViewSize(w, h); - updateRenderInfo(); - onResizeView(mCurrentResolution); - } - - void GenesisRenderManager::deviceReseted() - { - windowResized(); + windowResized(bufferWidth, bufferHeigh); m_VertexMgr->ResetAllBuffers(); m_TextureMgr->ReLoadManualTextures(); @@ -327,20 +316,13 @@ namespace MyGUI return mCountBatch; } - void GenesisRenderManager::renderGUI() + void GenesisRenderManager::renderGUI(float time) { Gui* gui = Gui::getInstancePtr(); if (gui == nullptr || nullptr == m_shaderHandle) return; - static Timer timer; - static unsigned long last_time = timer.getMilliseconds(); - unsigned long now_time = timer.getMilliseconds(); - unsigned long time = now_time - last_time; - - onFrameEvent((float)((double)(time) / (double)1000)); - - last_time = now_time; + onFrameEvent(time); _beforeDraw(); diff --git a/Engine/addons/myguiplatforms/src/MyGUI_GenesisTexture.cpp b/Engine/addons/myguiplatforms/src/MyGUI_GenesisTexture.cpp index e3775df..845479c 100644 --- a/Engine/addons/myguiplatforms/src/MyGUI_GenesisTexture.cpp +++ b/Engine/addons/myguiplatforms/src/MyGUI_GenesisTexture.cpp @@ -93,7 +93,7 @@ namespace MyGUI : mName(_name) , mGroup(_group) , mRenderTarget(nullptr) - , m_texHandle(NULL) + , m_texRes(NULL) , m_width(0) , m_height(0) , mNumElemBytes(0) @@ -130,25 +130,23 @@ namespace MyGUI void GenesisTexture::destroy() { - - //[zhongdaohuan 2012/12/12] 濡傛灉杩欎釜texture鏄敱render target鍒涘缓鐨勶紝閭d箞锛岃繖涓猼exture鐨勫彞鏌勫簲璇ョ敱render target绫绘潵绠$悊銆 - //鐜板湪鐨則erender target杩樹笉鑳界敱mygui鑷繁鍒涘缓锛屾墍浠ユ墍鏈塺ender target閮芥槸婧愪簬mygui澶栭儴锛 - //鎵浠ョ幇鍦ㄤ笉浼氬洜mygui鑰屽紩鍙戝唴瀛樻硠婕忛棶棰橈紝濡傛灉浠ュ悗mygui鍐呴儴鑷繁涔熷彲浠ュ垱寤簉ender target锛岄偅涔堬紝杩欓噷鐨勯昏緫搴旇閲嶆柊璇勪及銆 if (nullptr == mRenderTarget) { if (m_bManualCreate) { - if (m_texHandle.IsValid()) + if (m_texRes->GetHandle()) { - GraphicSystem::Instance()->RemoveTexture(m_texHandle); - m_texHandle = NULL; + GraphicSystem::Instance()->RemoveTexture(m_texRes->GetHandle()); + m_texRes = NULL; } } GenesisTextureMgr::Instance()->RemoveManualTexture(this); } m_texStream = NULL; + m_texRes = NULL; mRenderTarget = nullptr; + m_bManualCreate = false; mNumElemBytes = 0; mOriginalFormat = PixelFormat::Unknow; mOriginalUsage = TextureUsage::Default; @@ -358,14 +356,15 @@ namespace MyGUI tex->SetStream( m_texStream.upcast() ); m_texStream->Close(); //m_texStream->SetAccessMode( IO::Stream::ReadAccess ); - m_texHandle = Graphic::GraphicSystem::Instance()->CreateTexture(tex); - + RenderBase::TextureHandle handle = Graphic::GraphicSystem::Instance()->CreateTexture(tex); + m_texRes = Resources::TextureResInfo::Create(); + m_texRes->SetHandle(handle); GenesisTextureMgr::Instance()->AddManualTexture(this); m_bManualCreate = true; } else { - m_texHandle = NULL; + m_texRes = NULL; m_width = 0; m_height = 0; mOriginalUsage = TextureUsage::Default; @@ -499,10 +498,9 @@ namespace MyGUI m_texStream = NULL;*/ - GPtr tri = Resources::ResourceManager::Instance()->CreateTextureInfo(url, 0); - m_texHandle = tri->GetHandle(); + m_texRes = Resources::ResourceManager::Instance()->CreateTextureInfo(url, 0); RenderBase::TEXTURE_DESC texDesc; - GraphicSystem::Instance()->GetTextureDesc(m_texHandle, texDesc); + GraphicSystem::Instance()->GetTextureDesc(m_texRes->GetHandle(), texDesc); m_width = texDesc.width; m_height = texDesc.height; @@ -518,15 +516,31 @@ namespace MyGUI GenesisRTTexture* wjRt = static_cast(mRenderTarget); const GPtr& rendetToTexture = wjRt->getRenderToTexture(); const GPtr& renderTarget = rendetToTexture->GetRenderTarget(); - - m_width = renderTarget->GetWidth(); m_height = renderTarget->GetHeight(); mOriginalUsage = TextureUsage::RenderTarget; setFormat(FormatWjToMyGui(renderTarget->GetColorBufferFormat())); - m_texHandle = rendetToTexture->GetTextureHandle(); + + m_texRes = NULL; + m_bManualCreate = false; } + RenderBase::TextureHandle GenesisTexture::GetTextureHandle() const + { + if (m_texRes.isvalid()) + { + return m_texRes->GetHandle(); + } + if (mRenderTarget) + { + GenesisRTTexture* wjRt = static_cast(mRenderTarget); + const GPtr& rendetToTexture = wjRt->getRenderToTexture(); + return rendetToTexture->GetTextureHandle(); + } + return NULL; + } + + void GenesisTexture::setFormat(PixelFormat format) { mOriginalFormat = format; diff --git a/Engine/addons/myguiplatforms/src/MyGUI_GenesisVertexBuffer.cpp b/Engine/addons/myguiplatforms/src/MyGUI_GenesisVertexBuffer.cpp index 6ed09ee..ec2663d 100644 --- a/Engine/addons/myguiplatforms/src/MyGUI_GenesisVertexBuffer.cpp +++ b/Engine/addons/myguiplatforms/src/MyGUI_GenesisVertexBuffer.cpp @@ -49,6 +49,7 @@ namespace MyGUI GenesisVertexBuffer::~GenesisVertexBuffer() { destroyVertexBuffer(); + GenesisVertexBufferMgr::Instance()->RemoveVertexBuffer(this); } bool _createVertexComponent(Util::Array& vertexComponents) diff --git a/Engine/addons/myguiplatforms/src/MyGUI_GenesisVertexBufferManager.cpp b/Engine/addons/myguiplatforms/src/MyGUI_GenesisVertexBufferManager.cpp index b335593..4cd6941 100644 --- a/Engine/addons/myguiplatforms/src/MyGUI_GenesisVertexBufferManager.cpp +++ b/Engine/addons/myguiplatforms/src/MyGUI_GenesisVertexBufferManager.cpp @@ -55,6 +55,16 @@ namespace MyGUI } } + void GenesisVertexBufferMgr::RemoveVertexBuffer( GenesisVertexBuffer* const& pBuffer ) + { + IndexT res = m_AllVertexBuffers.FindIndex(pBuffer); + + if (res != InvalidIndex) + { + m_AllVertexBuffers.EraseIndex(res); + } + } + void GenesisVertexBufferMgr::ResetAllBuffers() const { SizeT nCount = m_AllVertexBuffers.Size(); diff --git a/Engine/addons/particles/affectors/particleColorAffector.cc b/Engine/addons/particles/affectors/particleColorAffector.cc index 3358e8a..7090621 100644 --- a/Engine/addons/particles/affectors/particleColorAffector.cc +++ b/Engine/addons/particles/affectors/particleColorAffector.cc @@ -42,6 +42,7 @@ namespace Particles ColorAffector::ColorAffector(void) : ParticleAffector(),mMinAlpha(0.0f),mMaxAlpha(1.0f),mTimeAlpha(false) , mColorCtlType(CCT_GRADCURVE) { + mAffectType = AT_Color; mMinMaxColorA.SetCurveState(Math::MinMaxCurve::Scalar); mMinMaxColorR.SetCurveState(Math::MinMaxCurve::Scalar); mMinMaxColorG.SetCurveState(Math::MinMaxCurve::Scalar); @@ -74,7 +75,7 @@ namespace Particles return; Math::Color32 clr; - float percent = (particle->mTotalTimeToLive - particle->mTimeToLive)/particle->mTotalTimeToLive; + float percent = particle->mTimeFraction; float randomSid = Math::n_rand(0.0f,1.0f); clr.r = Math::n_scalartoByte(mMinMaxColorR.Calculate(percent,randomSid)); diff --git a/Engine/addons/particles/affectors/particleGravityAffector.cc b/Engine/addons/particles/affectors/particleGravityAffector.cc index 802fdf2..5a5adc9 100644 --- a/Engine/addons/particles/affectors/particleGravityAffector.cc +++ b/Engine/addons/particles/affectors/particleGravityAffector.cc @@ -38,7 +38,7 @@ namespace Particles //----------------------------------------------------------------------- GravityAffector::GravityAffector() : ParticleAffector() { - + mAffectType = AT_Gravity; mName = "GravityAffector"; } //----------------------------------------------------------------------- @@ -46,7 +46,7 @@ namespace Particles { if(!GetEnable()) return; - float percent = (particle->mTotalTimeToLive - particle->mTimeToLive)/particle->mTotalTimeToLive; + float percent = particle->mTimeFraction; Math::float3 gravityDir(mMinMaxPosX.Calculate(percent,particle->mRandom0) , mMinMaxPosY.Calculate(percent,particle->mRandom1) @@ -59,7 +59,7 @@ namespace Particles float gravity = mMinMaxGravity.Calculate(percent,particle->mRandom3); Math::scalar _curTime = (Math::scalar)mParentSystem->GetCurrentFrameTime(); - particle->mDirection += gravity * gravityDir * _curTime * _calculateAffectSpecialisationFactor(particle); + particle->mDirection += gravity * gravityDir * _curTime; } //------------------------------------------------------------------------------- diff --git a/Engine/addons/particles/affectors/particleLimitAffector.cc b/Engine/addons/particles/affectors/particleLimitAffector.cc index 483a155..6eef8ca 100644 --- a/Engine/addons/particles/affectors/particleLimitAffector.cc +++ b/Engine/addons/particles/affectors/particleLimitAffector.cc @@ -37,6 +37,7 @@ namespace Particles LimitAffector::LimitAffector(void) : ParticleAffector() , mSeparateAxis(false) { + mAffectType = AT_Limit; mName = "LimitAffector"; mLimitX.SetScalar(0.0f); mLimitY.SetScalar(0.0f); @@ -53,7 +54,7 @@ namespace Particles if (particle) { - float curTime = (particle->mTotalTimeToLive - particle->mTimeToLive)/particle->mTotalTimeToLive; + float curTime = particle->mTimeFraction; //mAxisX float limitX = mLimitX.Calculate(curTime,particle->mRandom0); diff --git a/Engine/addons/particles/affectors/particleLinearForceAffector.cc b/Engine/addons/particles/affectors/particleLinearForceAffector.cc index ef755e2..4c8fe5c 100644 --- a/Engine/addons/particles/affectors/particleLinearForceAffector.cc +++ b/Engine/addons/particles/affectors/particleLinearForceAffector.cc @@ -39,7 +39,7 @@ namespace Particles , mSpaceCoord(SCT_LOCAL) { mName = "LinearForceAffector"; - mAffectType = AT_INCREASE; + mAffectType = AT_Force; } //----------------------------------------------------------------------- void LinearForceAffector::_preProcessParticles() @@ -54,8 +54,7 @@ namespace Particles if (mTimeSinceLastUpdate >= mTimeStep) { - float percent = (particle->mTotalTimeToLive - particle->mTimeToLive)/particle->mTotalTimeToLive; - + float percent = particle->mTimeFraction; Math::float3 forceVec(mForceVectorX.Calculate(percent,particle->mRandom0) , mForceVectorY.Calculate(percent,particle->mRandom1), @@ -63,7 +62,6 @@ namespace Particles if ( mSpaceCoord == SCT_WORLD ) { - forceVec = forceVec.transformVector(Math::matrix44::inverse(mParentSystem->GetWorldMatrix())); } @@ -106,6 +104,13 @@ namespace Particles pMarcro->TurnOn(ShaderProgramCompiler::ShaderMarcro::m_sParticleForce); } //-------------------------------------------------------------------------------- + const Math::float3 LinearForceAffector::_getEndPos(const Math::float3& pos,const Math::float3 speed,float time) + { + Math::float3 endPos; + endPos = pos + speed*time + 0.5*mShaderParam*time*time; + return endPos; + } + //-------------------------------------------------------------------------------- Math::MinMaxCurve* LinearForceAffector::getMinMaxCurve(ParticleCurveType pct) { switch(pct) diff --git a/Engine/addons/particles/affectors/particleLinearForceAffector.h b/Engine/addons/particles/affectors/particleLinearForceAffector.h index 0c086d4..0c132a2 100644 --- a/Engine/addons/particles/affectors/particleLinearForceAffector.h +++ b/Engine/addons/particles/affectors/particleLinearForceAffector.h @@ -63,6 +63,8 @@ namespace Particles void SetShaderParam(); void InitShaderParam(); void SetShaderMask(const GPtr& pMarcro); + inline const Math::float3& GetShaderParam() const; + const Math::float3 _getEndPos(const Math::float3& pos,const Math::float3 speed,float time); protected: Math::float3 mScaledVector; ForceApplication mForceApplication; @@ -124,6 +126,11 @@ namespace Particles { mSpaceCoord = sct; } + //-------------------------------------------------------------------------------- + inline const Math::float3& LinearForceAffector::GetShaderParam() const + { + return mShaderParam; + } } diff --git a/Engine/addons/particles/affectors/particleMovementAffector.cc b/Engine/addons/particles/affectors/particleMovementAffector.cc index ee68c91..761c256 100644 --- a/Engine/addons/particles/affectors/particleMovementAffector.cc +++ b/Engine/addons/particles/affectors/particleMovementAffector.cc @@ -36,6 +36,7 @@ namespace Particles //----------------------------------------------------------------------- MovementAffector::MovementAffector() : ParticleAffector() { + mAffectType = AT_Movement; mMinMaxSpeed.SetScalar( 1.0f ); mName = "MovementAffector"; } @@ -44,7 +45,7 @@ namespace Particles { if(!GetEnable()) return; - float percent = (particle->mTotalTimeToLive - particle->mTimeToLive)/particle->mTotalTimeToLive; + float percent = particle->mTimeFraction; Math::float3 GravityPos(mMinMaxPosX.Calculate(percent,particle->mRandom0) , mMinMaxPosY.Calculate(percent,particle->mRandom1) @@ -79,6 +80,19 @@ namespace Particles pMarcro->TurnOn(ShaderProgramCompiler::ShaderMarcro::m_sParticleMovement); } //-------------------------------------------------------------------------------- + const Math::float3 MovementAffector::_getEndPos(const Math::float3& pos,const Math::float3 speed,float time) + { + Math::float3 endPos = pos; + Math::float3 aimPos; + aimPos.setFromFloat4(mShaderParam); + Math::float3 dir = aimPos - pos; + dir.normalise(); + dir *= mShaderParam.w(); + endPos += dir*time; + + return endPos; + } + //-------------------------------------------------------------------------------- Math::MinMaxCurve* MovementAffector::getMinMaxCurve(ParticleCurveType pct) { switch(pct) diff --git a/Engine/addons/particles/affectors/particleMovementAffector.h b/Engine/addons/particles/affectors/particleMovementAffector.h index a03726a..9b3ca8a 100644 --- a/Engine/addons/particles/affectors/particleMovementAffector.h +++ b/Engine/addons/particles/affectors/particleMovementAffector.h @@ -43,6 +43,7 @@ namespace Particles void SetShaderParam(); void InitShaderParam(); void SetShaderMask(const GPtr& pMarcro); + const Math::float3 _getEndPos(const Math::float3& pos,const Math::float3 speed,float time); protected: Math::MinMaxCurve mMinMaxSpeed; diff --git a/Engine/addons/particles/affectors/particleScaleAffector.cc b/Engine/addons/particles/affectors/particleScaleAffector.cc index 43f6ae7..7d59737 100644 --- a/Engine/addons/particles/affectors/particleScaleAffector.cc +++ b/Engine/addons/particles/affectors/particleScaleAffector.cc @@ -37,7 +37,7 @@ namespace Particles ScaleAffector::ScaleAffector(void) : ParticleAffector() , mIsAxialScale(false) { - + mAffectType = AT_Scale; mScaleX.SetScalar(1.0f); mScaleY.SetScalar(1.0f); mScaleZ.SetScalar(1.0f); @@ -50,7 +50,7 @@ namespace Particles { if( !GetEnable()) return; - float percent = (particle->mTotalTimeToLive - particle->mTimeToLive)/particle->mTotalTimeToLive; + float percent = particle->mTimeFraction; Math::float3 particleSize(mScaleX.Calculate(percent,particle->mRandom0), mScaleY.Calculate(percent,particle->mRandom1), diff --git a/Engine/addons/particles/affectors/particleTextureAnimatorAffector.cc b/Engine/addons/particles/affectors/particleTextureAnimatorAffector.cc index c0d2961..a6b1421 100644 --- a/Engine/addons/particles/affectors/particleTextureAnimatorAffector.cc +++ b/Engine/addons/particles/affectors/particleTextureAnimatorAffector.cc @@ -51,8 +51,20 @@ namespace Particles mTexStart(0), mTexEnd(1) { + mAffectType = AT_Texture; mName = "TextureAnimatorAffector"; mMinMaxTexAnimation.SetCurveState(Math::MinMaxCurve::Curve); + Util::Array _list; + Util::Array _type; + _list.Append(Math::float2(0,0)); + _type.Append(true); + _type.Append(true); + _list.Append(Math::float2(0.5,0.5)); + _list.Append(Math::float2(0.5,0.5)); + _list.Append(Math::float2(1,1)); + _type.Append(true); + _type.Append(true); + mMinMaxTexAnimation.SetCurveFromArray(_list,_type); } //-------------------------------------------------------------------------------- void TextureAnimatorAffector::_onActivate(void) @@ -125,7 +137,7 @@ namespace Particles if(!mEnable) return; - float percent = (particle->mTotalTimeToLive - particle->mTimeToLive)/particle->mTotalTimeToLive; + float percent = particle->mTimeFraction; float time = mCycles * percent; float texCoordIndex = 0; diff --git a/Engine/addons/particles/affectors/particleTextureRotatorAffector.cc b/Engine/addons/particles/affectors/particleTextureRotatorAffector.cc index 2ef1cda..49ca3a5 100644 --- a/Engine/addons/particles/affectors/particleTextureRotatorAffector.cc +++ b/Engine/addons/particles/affectors/particleTextureRotatorAffector.cc @@ -36,6 +36,7 @@ namespace Particles //----------------------------------------------------------------------- TextureRotatorAffector::TextureRotatorAffector(void) : ParticleAffector() { + mAffectType = AT_Rotation; mName = "TextureRotatorAffector"; } //------------------------------------------------------------------------ @@ -49,7 +50,7 @@ namespace Particles if(!GetEnable()) return; - float percent = (particle->mTotalTimeToLive - particle->mTimeToLive)/particle->mTotalTimeToLive; + float percent = particle->mTimeFraction; float rotatorAngularVelocity = mMinMaxRotation.Calculate(percent,particle->mRandom0); diff --git a/Engine/addons/particles/affectors/particleVortexAffector.cc b/Engine/addons/particles/affectors/particleVortexAffector.cc index 7f0cb6d..dd22f61 100644 --- a/Engine/addons/particles/affectors/particleVortexAffector.cc +++ b/Engine/addons/particles/affectors/particleVortexAffector.cc @@ -38,6 +38,7 @@ namespace Particles //----------------------------------------------------------------------- VortexAffector::VortexAffector(void) : ParticleAffector() { + mAffectType = AT_Vortex; mName = "VortexAffector"; } //------------------------------------------------------------------------ @@ -49,7 +50,7 @@ namespace Particles { if(!GetEnable()) return; - float percent = (particle->mTotalTimeToLive - particle->mTimeToLive)/particle->mTotalTimeToLive; + float percent = particle->mTimeFraction; Math::vector normal(mMinMaxNormalX.Calculate(percent,particle->mRandom0), mMinMaxNormalY.Calculate(percent,particle->mRandom1), mMinMaxNormalZ.Calculate(percent,particle->mRandom2) ); diff --git a/Engine/addons/particles/emitters/particleModelEmitter.cc b/Engine/addons/particles/emitters/particleModelEmitter.cc index 5ff0f59..389707d 100644 --- a/Engine/addons/particles/emitters/particleModelEmitter.cc +++ b/Engine/addons/particles/emitters/particleModelEmitter.cc @@ -59,16 +59,15 @@ namespace Particles mParentSystem->SetLoadEmitterMesh(false); } mMeshName = name; +#ifdef __GENESIS_EDITOR__ // edtior use + mRealMeshName = name; +#endif mMeshRes = NULL; mVertList.Clear(); } //-------------------------------------------------------------------------------- void ModelEmitter::SetMeshRes(void* resource) { - if (mParentSystem) - { - mParentSystem->SetLoadEmitterMesh(false); - } mMeshRes = resource; } //----------------------------------------------------------------------- @@ -84,7 +83,9 @@ namespace Particles if (mVertList.IsEmpty()) { Resources::MeshRes* meshres = (Resources::MeshRes*)mMeshRes; - +#ifdef __GENESIS_EDITOR__ // edtior use + mRealMeshName = meshres->GetResourceId().AsString(); +#endif const Resources::NormalData::value_type* normals = meshres->GetVertexData(); const Resources::PositionData::value_type* verteies = meshres->GetVertexData(); diff --git a/Engine/addons/particles/emitters/particleModelEmitter.h b/Engine/addons/particles/emitters/particleModelEmitter.h index d9b1b7c..cd15bc2 100644 --- a/Engine/addons/particles/emitters/particleModelEmitter.h +++ b/Engine/addons/particles/emitters/particleModelEmitter.h @@ -51,7 +51,11 @@ namespace Particles void SetMeshEmitType(MeshEmitType); MeshEmitType GetMeshEmitType(void) const; - +#ifdef __GENESIS_EDITOR__ // edtior use + const Util::String& GetRealMeshName(void) const; + protected: + Util::String mRealMeshName; +#endif protected: Util::String mMeshName; void* mMeshRes; @@ -59,6 +63,7 @@ namespace Particles Util::Array mVertList; + public: // @ISerialization::GetVersion. when change storage, must add SerializeSVersion count virtual Serialization::SVersion GetVersion() const; @@ -94,7 +99,13 @@ namespace Particles { return mEmitType; } - +#ifdef __GENESIS_EDITOR__ // edtior use + //-------------------------------------------------------------------------------- + inline const Util::String& ModelEmitter::GetRealMeshName(void) const + { + return mRealMeshName; + } +#endif } #endif diff --git a/Engine/addons/particles/particle_fwd_decl.h b/Engine/addons/particles/particle_fwd_decl.h index a959329..0d5a948 100644 --- a/Engine/addons/particles/particle_fwd_decl.h +++ b/Engine/addons/particles/particle_fwd_decl.h @@ -49,7 +49,7 @@ namespace Particles Math::float3 mNormal; Math::float2 mTexCoord; }; - struct SimpleGPUParticleVertex { + struct SpriteGPUParticleVertex { Math::Color32 mColor; Math::float3 mPosition; Math::float3 mNormal; @@ -57,6 +57,14 @@ namespace Particles float mSize; }; + struct BoardGPUParticleVertex { + Math::Color32 mColor; + Math::float4 mTangent; + Math::float3 mPosition; + Math::float3 mNormal; + Math::float2 mTexCoord; + }; + enum ColorContrlType{CCT_CONST, CCT_RND_CONST, CCT_GRADCURVE, CCT_RND_GRADCURVE}; enum SpaceCoordType{SCT_LOCAL, SCT_WORLD, SCT_CAMERA}; @@ -192,7 +200,7 @@ namespace Particles inline IndexT GenerateRandomSeed(void* p) { - return ( (IndexT)p ) & 0xFFFF; + return ( (intptr_t)p ) & 0xFFFF; } // From Ogre: rotation of a vector by a quaternion diff --git a/Engine/addons/particles/particleaffector.cc b/Engine/addons/particles/particleaffector.cc index 9dca091..61792e2 100644 --- a/Engine/addons/particles/particleaffector.cc +++ b/Engine/addons/particles/particleaffector.cc @@ -36,7 +36,7 @@ namespace Particles : mParentSystem(NULL) , mIsActive(false) , mName("Affector") - , mAffectType(ParticleAffector::AT_DEFAULT) + , mAffectType(ParticleAffector::UnKnown) , mEnable(true) { @@ -100,40 +100,6 @@ namespace Particles { particle->mPosition += (particle->mDirection * (Math::scalar)mParentSystem->GetCurrentFrameTime() ); } - //------------------------------------------------------------------------ - Math::scalar ParticleAffector::_calculateAffectSpecialisationFactor (Particle* particle) - { - switch (mAffectType) - { - case AT_DEFAULT: - return 1.0f; - break; - case AT_INCREASE: - { - if(particle) - return particle->mTimeFraction; - else - return 1.0f; - } - break; - case AT_DECREASE: - { - if (particle) - { - return 1.0f - particle->mTimeFraction; - } - else - { - return 1.0f; - } - } - break; - - default: - return 1.0f; - break; - } - } //-------------------------------------------------------------------------------- Math::MinMaxCurve* ParticleAffector::getMinMaxCurve(ParticleCurveType pct) { diff --git a/Engine/addons/particles/particleaffector.h b/Engine/addons/particles/particleaffector.h index ba43255..da077b7 100644 --- a/Engine/addons/particles/particleaffector.h +++ b/Engine/addons/particles/particleaffector.h @@ -38,9 +38,17 @@ namespace Particles enum AffectType { - AT_DEFAULT, - AT_INCREASE, - AT_DECREASE + AT_Color, + AT_Gravity, + AT_Limit, + AT_Force, + AT_Movement, + AT_Scale, + AT_Texture, + AT_Rotation, + AT_Vortex, + + UnKnown }; @@ -90,10 +98,9 @@ namespace Particles virtual void InitShaderParam(); virtual void SetShaderMask(const GPtr& pMarcro); - Math::scalar _calculateAffectSpecialisationFactor (Particle* particle); - virtual Math::MinMaxCurve* getMinMaxCurve(ParticleCurveType pct); virtual void _switchParticleType(bool _isMobile); + virtual const Math::float3 _getEndPos(const Math::float3& pos,const Math::float3 speed,float time); protected: ParticleSystem* mParentSystem; Util::String mName; @@ -185,6 +192,11 @@ namespace Particles { //empty } + //------------------------------------------------------------------------ + inline const Math::float3 ParticleAffector::_getEndPos(const Math::float3& pos,const Math::float3 speed,float time) + { + return pos; + } } diff --git a/Engine/addons/particles/particleaffectorserialization.cc b/Engine/addons/particles/particleaffectorserialization.cc index 56e997c..3be5fdb 100644 --- a/Engine/addons/particles/particleaffectorserialization.cc +++ b/Engine/addons/particles/particleaffectorserialization.cc @@ -48,6 +48,11 @@ namespace Particles Load_2(obj,pReader); return; } + else if(3 == ver) + { + Load_3(obj,pReader); + return; + } n_error(" %s Load unknown version.\n", obj->GetClassName().AsCharPtr() ); } //------------------------------------------------------------------------ @@ -59,7 +64,7 @@ namespace Particles int specialisation; pReader->SerializeInt( s_AffectSpecialisation , specialisation); - obj->SetAffectType((ParticleAffector::AffectType)specialisation); + //obj->SetAffectType((ParticleAffector::AffectType)specialisation); } void Load_2(ParticleAffector* obj, SerializeReader* pReader) { @@ -68,12 +73,21 @@ namespace Particles obj->SetEnable(active); Load_1(obj,pReader); } + void Load_3(ParticleAffector* obj, SerializeReader* pReader) + { + bool active; + pReader->SerializeBool(s_AffectorEnable,active); + obj->SetEnable(active); + + Util::String name; + pReader->SerializeString( s_AffectorName, name ); + obj->SetName( name ); + } //------------------------------------------------------------------------ void Save( const ParticleAffector* obj, SerializeWriter* pWriter ) { pWriter->SerializeBool(s_AffectorEnable,obj->GetEnable()); pWriter->SerializeString( s_AffectorName, obj->GetName() ); - pWriter->SerializeInt( s_AffectSpecialisation, (int)obj->GetAffectType()); } }; @@ -81,7 +95,7 @@ namespace Particles // @ISerialization::GetVersion. when change storage, must add SerializeVersion count SVersion ParticleAffector::GetVersion() const { - return 2; + return 3; } //------------------------------------------------------------------------ diff --git a/Engine/addons/particles/particleemitter.h b/Engine/addons/particles/particleemitter.h index 0ae7b0e..eafae8d 100644 --- a/Engine/addons/particles/particleemitter.h +++ b/Engine/addons/particles/particleemitter.h @@ -111,6 +111,7 @@ namespace Particles float GetGPUParticleRate(); //for gpu particles; float GetGPUParticleLife(); + void Reset(); private: bool mShapeVisible; public: @@ -332,6 +333,10 @@ namespace Particles { return mMinMaxLiveTime.Calculate(0,Math::n_rand(0.0f,1.0f)); } + inline void ParticleEmitter::Reset() + { + mRemainder = 0; + } } #endif // __particleemitter_H__ diff --git a/Engine/addons/particles/particlesystem.cc b/Engine/addons/particles/particlesystem.cc index 8d84ab0..b2d24eb 100644 --- a/Engine/addons/particles/particlesystem.cc +++ b/Engine/addons/particles/particlesystem.cc @@ -45,7 +45,7 @@ namespace Particles const Timing::Time ParticleSystem::MinFrameTime(0.000001); const float ParticleSystem::MinUpdateTime(0.033f); const float ParticleSystem::MaxUpdateTime(0.33f); - const float ParticleSystem::UpdateFactor(0.5f); + const float ParticleSystem::UpdateFactor(0.002f); //------------------------------------------------------------------------ ParticleSystem::ParticleSystem() : mIsActive(false) @@ -199,9 +199,10 @@ namespace Particles mNeedUpdate = false; mUpdateTarget = true; Timing::Time time = App::GameTime::Instance()->GetFrameTime(); - double curFrame = GameTime::Instance()->GetTime(); if(mIsPlaying) - mMobileTime = curFrame; + { + mMobileTime += time; + } Timing::Time total = time; //==================================================================================== @@ -212,7 +213,7 @@ namespace Particles #endif if(bNeedLimitRate) { - _fpsControl(); + //_fpsControl(); mCurrentTimeForFps += time; if(mCurrentTimeForFps < mspf) { @@ -306,7 +307,7 @@ namespace Particles { mIsPlaying = false; mIsStop = true; - + Reset(); } @@ -375,6 +376,7 @@ namespace Particles mLastUpdateFrameIndex = -1; ParticleSystemDataChanged(); _resetPool(mQuota); + mEmitter->Reset(); } //------------------------------------------------------------------------ @@ -865,7 +867,7 @@ namespace Particles } return delayTime; } - void ParticleSystem::SetupGPUParticles(SimpleGPUParticleVertex* particleVertex,int quato) + void ParticleSystem::SetupSpriteGPUParticles(SpriteGPUParticleVertex* particleVertex,int quato) { float rate = mEmitter->GetGPUParticleRate(); float life = mEmitter->GetGPUParticleLife(); @@ -877,6 +879,8 @@ namespace Particles if(mIsPreLoop && mIsPlaying) _time -= life; Math::Color32 _color; + Math::bbox _box; + _box.begin_extend(); while (totalPar < quato) { mEmitter->_emit(particle,(float)mDuration*totalPar/quato); @@ -887,7 +891,80 @@ namespace Particles particleVertex[totalPar].mTexCoord.set(_time,particle->mTotalTimeToLive); _time += rateFps; totalPar ++; + + _box.extend(Math::point( + particle->mPosition.x(),particle->mPosition.y(),particle->mPosition.z())); + Math::float3 endPos; + endPos = _getEndPos(particle->mPosition,particle->mDirection,life); + _box.extend(Math::point( + endPos.x(),endPos.y(),endPos.z())); } + _box.end_extend(); + _box.pmax += Math::point( + particle->mSize.x()*0.5f,particle->mSize.y()*0.5f,particle->mSize.z()*0.5f); + _box.pmin -= Math::point( + particle->mSize.x()*0.5f,particle->mSize.y()*0.5f,particle->mSize.z()*0.5f); + SetLocalBoundingBox(_box); + delete particle; + } + void ParticleSystem::SetupBoardGPUParticles(BoardGPUParticleVertex* particleVertex,ushort* indicies,int quato) + { + float rate = mEmitter->GetGPUParticleRate(); + float life = mEmitter->GetGPUParticleLife(); + mDuration = life; + float rateFps = 1.0f/rate; + int totalPar = 0; + Particle* particle = new Particle(); + float _time = (float)mDelayTime; + if(mIsPreLoop && mIsPlaying) + _time = -life; + mMobileTime = 0; + Math::Color32 _color; + Math::bbox _box; + float halfSize = 0; + _box.begin_extend(); + while (totalPar < quato) + { + mEmitter->_emit(particle,(float)mDuration*totalPar/quato); + halfSize = 0.5f*particle->mSize.x(); + particleVertex[4*totalPar].mColor = particle->mColor.HexARGB(); + particleVertex[4*totalPar].mPosition = particle->mPosition; + particleVertex[4*totalPar].mTangent.set(-halfSize,halfSize,0,0); + particleVertex[4*totalPar].mNormal = particle->mDirection; + particleVertex[4*totalPar].mTexCoord.set(_time,particle->mTotalTimeToLive); + + particleVertex[4*totalPar+1] = particleVertex[4*totalPar]; + particleVertex[4*totalPar+1].mTangent.set(-halfSize,-halfSize,0,1); + + particleVertex[4*totalPar+2] = particleVertex[4*totalPar]; + particleVertex[4*totalPar+2].mTangent.set(halfSize,-halfSize,1,1); + + particleVertex[4*totalPar+3] = particleVertex[4*totalPar]; + particleVertex[4*totalPar+3].mTangent.set(halfSize,halfSize,1,0); + + indicies[6*totalPar] = 4*totalPar; + indicies[6*totalPar+1] = 4*totalPar + 1; + indicies[6*totalPar+2] = 4*totalPar + 2; + indicies[6*totalPar+3] = 4*totalPar + 2; + indicies[6*totalPar+4] = 4*totalPar + 3; + indicies[6*totalPar+5] = 4*totalPar ; + + _time += rateFps; + totalPar ++; + + _box.extend(Math::point( + particle->mPosition.x(),particle->mPosition.y(),particle->mPosition.z())); + Math::float3 endPos; + endPos = _getEndPos(particle->mPosition,particle->mDirection,life); + _box.extend(Math::point( + endPos.x(),endPos.y(),endPos.z())); + } + _box.end_extend(); + _box.pmax += Math::point( + particle->mSize.x()*0.5f,particle->mSize.y()*0.5f,particle->mSize.z()*0.5f); + _box.pmin -= Math::point( + particle->mSize.x()*0.5f,particle->mSize.y()*0.5f,particle->mSize.z()*0.5f); + SetLocalBoundingBox(_box); delete particle; } void ParticleSystem::ParticleSystemDataChanged() @@ -910,7 +987,7 @@ namespace Particles Math::bbox box = GetBoundingBox(); Math::float4 boxSizeVec = box.pmax - box.pmin; float boxSize = boxSizeVec.x()*boxSizeVec.x()+boxSizeVec.y()*boxSizeVec.y()+boxSizeVec.z()*boxSizeVec.z(); - + Graphic::Camera* pMainCam = Graphic::GraphicSystem::Instance()->GetSceneDefaultCamera(); if(pMainCam == NULL) return; @@ -964,5 +1041,17 @@ namespace Particles mAffectors[index]->SetShaderMask(pMarcro); } } + //-------------------------------------------------------------------------------- + const Math::float3 ParticleSystem::_getEndPos(const Math::float3& pos,const Math::float3 speed,float time) + { + ParticleAffectorPtr affector = NULL; + Math::float3 endPos = pos + speed*time; + for ( IndexT index = 0; index < mAffectors.Size(); ++index) + { + affector = mAffectors[index]; + endPos = affector->_getEndPos(pos,speed,time); + } + return endPos; + } } diff --git a/Engine/addons/particles/particlesystem.h b/Engine/addons/particles/particlesystem.h index 917dd77..63fb53a 100644 --- a/Engine/addons/particles/particlesystem.h +++ b/Engine/addons/particles/particlesystem.h @@ -205,7 +205,8 @@ namespace Particles void SetUpdateUnVis(bool _update); const bool GetUpdateUnVis() const; void _NeedUpdate(); - void SetupGPUParticles(SimpleGPUParticleVertex* particleVertex,int quato); + void SetupSpriteGPUParticles(SpriteGPUParticleVertex* particleVertex,int quato); + void SetupBoardGPUParticles(BoardGPUParticleVertex* particleVertex,ushort* indicies,int quato); bool _NeedUpdateBox(); void ParticleSystemDataChanged(); void SetShaderParam(); @@ -229,6 +230,7 @@ namespace Particles void _repeatUpdate(float); void _techUpdate(Timing::Time frameTime,IndexT frameIndex ); void _fpsControl(); + const Math::float3 _getEndPos(const Math::float3& pos,const Math::float3 speed,float time); protected: bool mIsActive; bool mPlayOnAwake; diff --git a/Engine/addons/particles/particlesystemserialization.cc b/Engine/addons/particles/particlesystemserialization.cc index 53f71f5..ddc7078 100644 --- a/Engine/addons/particles/particlesystemserialization.cc +++ b/Engine/addons/particles/particlesystemserialization.cc @@ -25,6 +25,7 @@ THE SOFTWARE. #include "particles/particlesystem.h" #include "particles/particletechnique.h" + namespace Particles { using namespace Serialization; @@ -183,7 +184,6 @@ namespace Particles pReader->SerializeBool(s_PlayOnAwake, playOnAwake ); #if __EDIT_STATUS__ obj->SetPlayOnAwake( playOnAwake, EditStatus::IsPlayingGame() ); - #else obj->SetPlayOnAwake( playOnAwake); #endif @@ -207,8 +207,8 @@ namespace Particles bool playOnAwake; pReader->SerializeBool(s_PlayOnAwake, playOnAwake ); -#ifdef __GENESIS_EDITOR__ - obj->SetPlayOnAwake( playOnAwake); +#if __EDIT_STATUS__ + obj->SetPlayOnAwake( playOnAwake, EditStatus::IsPlayingGame() ); #else obj->SetPlayOnAwake( playOnAwake, true ); #endif @@ -277,8 +277,8 @@ namespace Particles bool playOnAwake; pReader->SerializeBool(s_PlayOnAwake, playOnAwake ); -#ifdef __GENESIS_EDITOR__ - obj->SetPlayOnAwake( playOnAwake); +#if __EDIT_STATUS__ + obj->SetPlayOnAwake( playOnAwake, EditStatus::IsPlayingGame() ); #else obj->SetPlayOnAwake( playOnAwake, true ); #endif @@ -350,8 +350,8 @@ namespace Particles bool playOnAwake; pReader->SerializeBool(s_PlayOnAwake, playOnAwake ); -#ifdef __GENESIS_EDITOR__ - obj->SetPlayOnAwake( playOnAwake); +#if __EDIT_STATUS__ + obj->SetPlayOnAwake( playOnAwake, EditStatus::IsPlayingGame() ); #else obj->SetPlayOnAwake( playOnAwake, true ); #endif @@ -518,8 +518,8 @@ namespace Particles bool playOnAwake = parSystem->GetPlayOnAwake(); -#ifdef __GENESIS_EDITOR__ - SetPlayOnAwake(playOnAwake); +#if __EDIT_STATUS__ + SetPlayOnAwake( playOnAwake, EditStatus::IsPlayingGame() ); #else SetPlayOnAwake(playOnAwake, true); #endif diff --git a/Engine/addons/particles/particletarget.cc b/Engine/addons/particles/particletarget.cc index ce12069..e9ad142 100644 --- a/Engine/addons/particles/particletarget.cc +++ b/Engine/addons/particles/particletarget.cc @@ -217,7 +217,7 @@ namespace Particles vbd2.Setup(needCount, sizeof(ParticleVertexData), RenderBase::BufferData::Dynamic,RenderBase::PrimitiveTopology::TriangleList, false); } - void ParticleTarget::_initSimpleGPUVertexBuffer(Graphic::VertexBufferData2& vbd2, SizeT needCount) + void ParticleTarget::_initSpriteGPUVertexBuffer(Graphic::VertexBufferData2& vbd2, SizeT needCount) { Util::Array& verDeclare = vbd2.GetVertexComponents(); verDeclare.Append( VertexComponent(VertexComponent::Color,0, VertexComponent::ColorBGRA) ); @@ -225,9 +225,9 @@ namespace Particles verDeclare.Append( VertexComponent(VertexComponent::Normal,0, VertexComponent::Float3) ); verDeclare.Append( VertexComponent(VertexComponent::TexCoord, 0, VertexComponent::Float2) ); verDeclare.Append( VertexComponent(VertexComponent::Size, 0, VertexComponent::Float) ); - vbd2.Setup(needCount, sizeof(SimpleGPUParticleVertex), RenderBase::BufferData::Dynamic,RenderBase::PrimitiveTopology::PointList, false); + vbd2.Setup(needCount, sizeof(SpriteGPUParticleVertex), RenderBase::BufferData::Dynamic,RenderBase::PrimitiveTopology::PointList, false); } - void ParticleTarget::_initAffectGPUVertexBuffer(Graphic::VertexBufferData2& vbd2, SizeT needCount) + void ParticleTarget::_initBoardGPUVertexBuffer(Graphic::VertexBufferData2& vbd2, SizeT needCount) { Util::Array& verDeclare = vbd2.GetVertexComponents(); verDeclare.Append( VertexComponent(VertexComponent::Color,0, VertexComponent::ColorBGRA) ); @@ -235,8 +235,7 @@ namespace Particles verDeclare.Append( VertexComponent(VertexComponent::Position,0, VertexComponent::Float3) ); verDeclare.Append( VertexComponent(VertexComponent::Normal,0, VertexComponent::Float3) ); verDeclare.Append( VertexComponent(VertexComponent::TexCoord, 0, VertexComponent::Float2) ); - verDeclare.Append( VertexComponent(VertexComponent::Size, 0, VertexComponent::Float) ); - vbd2.Setup(needCount, sizeof(SimpleGPUParticleVertex), RenderBase::BufferData::Dynamic,RenderBase::PrimitiveTopology::PointList, false); + vbd2.Setup(needCount, sizeof(BoardGPUParticleVertex), RenderBase::BufferData::Static,RenderBase::PrimitiveTopology::TriangleList, false); } void ParticleTarget::_initVertexBufferData(Graphic::IndexBufferData2& ibd2, SizeT needCount) { diff --git a/Engine/addons/particles/particletarget.h b/Engine/addons/particles/particletarget.h index 0f9250d..e4fd7aa 100644 --- a/Engine/addons/particles/particletarget.h +++ b/Engine/addons/particles/particletarget.h @@ -349,8 +349,8 @@ namespace Particles virtual void _RotatorParticle(Particle* particle, ParticleVertexData* particleVertex); virtual Math::MinMaxCurve* getMinMaxCurve(ParticleCurveType pct); void _initVertexBufferData(Graphic::VertexBufferData2& vbd2, SizeT needCount); - void _initSimpleGPUVertexBuffer(Graphic::VertexBufferData2& vbd2, SizeT needCount); - void _initAffectGPUVertexBuffer(Graphic::VertexBufferData2& vbd2, SizeT needCount); + void _initSpriteGPUVertexBuffer(Graphic::VertexBufferData2& vbd2, SizeT needCount); + void _initBoardGPUVertexBuffer(Graphic::VertexBufferData2& vbd2, SizeT needCount); void _initVertexBufferData(Graphic::IndexBufferData2& ibd2, SizeT needCount); protected: void restActiveElemCount(); diff --git a/Engine/addons/particles/targets/particleGPUTarget.cc b/Engine/addons/particles/targets/particleGPUTarget.cc index 67be897..6d0a9ae 100644 --- a/Engine/addons/particles/targets/particleGPUTarget.cc +++ b/Engine/addons/particles/targets/particleGPUTarget.cc @@ -63,16 +63,44 @@ namespace Particles mPrimDirty = true; return; } - Graphic::VertexBufferData2 vbd2; - Graphic::DynamicBuffer dvb; - _initSimpleGPUVertexBuffer(vbd2, quato); - dvb.SetSize(quato*sizeof(SimpleGPUParticleVertex)); - SimpleGPUParticleVertex* particleVertex = dvb.GetBufferPtr(); - mParentSystem->SetupGPUParticles(particleVertex,quato); mParentSystem->InitShaderParam(); + + Graphic::VertexBufferData2 vbd2; + Graphic::IndexBufferData2 ibd2; + /* + _initSpriteGPUVertexBuffer(vbd2, quato); + dvb.SetSize(quato*sizeof(SpriteGPUParticleVertex)); + SpriteGPUParticleVertex* particleVertex = dvb.GetBufferPtr(); + mParentSystem->SetupSpriteGPUParticles(particleVertex,quato); mPrimitiveHandle = Graphic::GraphicSystem::Instance()->CreatePrimitiveHandle(&vbd2); mActiveVertexCount = quato; Graphic::GraphicSystem::Instance()->UpdatePrimitiveHandle(mPrimitiveHandle, &dvb); + mPrimDirty = true; + mNeedPrimitive = false; + */ + + mActiveVertexCount = 4*quato; + mActiveIndexCount = 6*quato; + + vbd2.Setup(mActiveVertexCount,sizeof(BoardGPUParticleVertex), + RenderBase::BufferData::Static,RenderBase::PrimitiveTopology::TriangleList,true); + + ibd2.Setup(mActiveIndexCount, RenderBase::BufferData::Static, RenderBase::IndexBufferData::Int16, true); + + BoardGPUParticleVertex* particleVertex = vbd2.GetBufferPtr(); + ushort* indicies = ibd2.GetBufferPtr(); + + mParentSystem->SetupBoardGPUParticles(particleVertex,indicies,quato); + + _initBoardGPUVertexBuffer(vbd2,mActiveVertexCount); + + if(mPrimitiveHandle.IsValid()) + { + Graphic::GraphicSystem::Instance()->RemovePrimitive(mPrimitiveHandle); + } + mPrimitiveHandle = Graphic::GraphicSystem::Instance()->CreatePrimitiveHandle(&vbd2,&ibd2); + + mPrimDirty = true; mNeedPrimitive = false; } diff --git a/Engine/addons/resource/imageresloader.cc b/Engine/addons/resource/imageresloader.cc index f627793..9ce2f3b 100644 --- a/Engine/addons/resource/imageresloader.cc +++ b/Engine/addons/resource/imageresloader.cc @@ -27,6 +27,8 @@ THE SOFTWARE. #include "ETC_Header.h" #include "foundation/io/filestream.h" #include "foundation/io/memorystream.h" +#include "rendersystem/base/GraphicCardCapability.h" +#include "rendersystem/RenderSystem.h" // must define FREEIMAGE_LIB when use FreeImage as static lib #define FREEIMAGE_LIB @@ -136,8 +138,8 @@ namespace Resources //#else FreeImage_Initialise(false); - n_printf("FreeImage version: %s Info: %s \n", FreeImage_GetVersion(), FreeImage_GetCopyrightMessage()); - n_printf("FreeImage Supported formats: \n"); + n_debuglog("FreeImage version: %s Info: %s \n", FreeImage_GetVersion(), FreeImage_GetCopyrightMessage()); + n_debuglog("FreeImage Supported formats: \n"); for (int iType = 0; iType < FreeImage_GetFIFCount(); ++iType) { @@ -159,7 +161,7 @@ namespace Resources Util::String strType = strArray[index]; strType.ToUpper(); - n_printf( " %s", strType.AsCharPtr() ); + n_debuglog( " %s", strType.AsCharPtr() ); if ( InvalidIndex == mExtReg.FindIndex( strType ) ) { @@ -167,7 +169,7 @@ namespace Resources } } } - n_printf("\n"); + n_debuglog("\n"); // Set error handler FreeImage_SetOutputMessage(FreeImageLoadErrorHandler); @@ -261,6 +263,7 @@ namespace Resources { n_assert( mStream.isvalid() && pImage.isvalid() ); +#if RENDERDEVICE_D3D9 // check if dds if ( stream->GetSize() >= 4 ) { @@ -278,6 +281,33 @@ namespace Resources // prepare check other stream->Seek(0, IO::Stream::Begin ); } +#endif + +#if RENDERDEVICE_OPENGLES + const RenderBase::GraphicCardCapability& caps = RenderBase::RenderSystem::Instance()->GetGraphicCardCapability(); + if (caps.mS3TC) + { + // check if dds + if ( stream->GetSize() >= 4 ) + { + //Read first byte to identify format + uint32 magic; + stream->Read(&magic,sizeof(uint32) ); + FlipEndian(&magic, sizeof(uint32), 1); + + if ( DDS_MAGIC == magic ) + { + stream->Seek(0, IO::Stream::Begin ); + return LoadDXT(stream, pImage ); + } + + // prepare check other + stream->Seek(0, IO::Stream::Begin ); + } + } + +#endif + // check if PVRTC if ( stream->GetSize() >= sizeof(PVRTCTexHeader) ) diff --git a/Engine/addons/resource/physxmaterialloader.cc b/Engine/addons/resource/physxmaterialloader.cc index 101aee0..03a14b5 100644 --- a/Engine/addons/resource/physxmaterialloader.cc +++ b/Engine/addons/resource/physxmaterialloader.cc @@ -86,7 +86,10 @@ namespace Resources bool ret = LoadPhysXMaterialResByVersion(pRes,pReader,version); - + if(pRes->GetMat()) + { + pRes->SetMat(NULL); + } //pReader->EndFileSerialize(); return ret; } diff --git a/Engine/addons/shadercompiler/ShaderTemplate/ShaderJoint.cc b/Engine/addons/shadercompiler/ShaderTemplate/ShaderJoint.cc index 5cd9ae9..48dd395 100644 --- a/Engine/addons/shadercompiler/ShaderTemplate/ShaderJoint.cc +++ b/Engine/addons/shadercompiler/ShaderTemplate/ShaderJoint.cc @@ -148,7 +148,7 @@ void ShaderJoint::_ParseVsOutput(const CommonShaderSetting* pCommon, const Shadi } - Util::String testCode = includeContent + m_sJointedSource + g_sSimpleLight; + Util::String testCode = "#define D3D9\n" + includeContent + m_sJointedSource + g_sSimpleLight; testCode += "float4 psMain (" + m_CustomFunc.paramInputType + " p) : COLOR\n"; testCode += "{\n"; diff --git a/Engine/addons/soundsystem/SoundSystemDSPOpenAL.cc b/Engine/addons/soundsystem/SoundSystemDSPOpenAL.cc index 98b7064..910b97e 100644 --- a/Engine/addons/soundsystem/SoundSystemDSPOpenAL.cc +++ b/Engine/addons/soundsystem/SoundSystemDSPOpenAL.cc @@ -52,6 +52,9 @@ namespace Sound //------------------------------------------------------------------------------ bool SoundSystemDSPOpenAL::setParameter( int index, float value , bool integer) { + if(!CheckDspSupport()) + return false; + if ( m_type != AL_FILTER_LOWPASS ) { if (integer) @@ -75,6 +78,9 @@ namespace Sound //------------------------------------------------------------------------------ bool SoundSystemDSPOpenAL::setParameters( int index, float* pan) { + if(!CheckDspSupport()) + return false; + alEffectfv( m_uiFilter, index, pan); return true; } @@ -82,11 +88,15 @@ namespace Sound //------------------------------------------------------------------------------ bool SoundSystemDSPOpenAL::init(ALuint type) { + if(!CheckDspSupport()) + return false; + // Clear AL Error State alGetError(); ALboolean result = ALFWIsEFXSupported(); - n_assert(result == AL_TRUE); + if( result == AL_FALSE ) + return false; alGenAuxiliaryEffectSlots(1, &m_uiEffectSlot); if ( alGetError() != AL_NO_ERROR ) @@ -143,6 +153,9 @@ namespace Sound //------------------------------------------------------------------------------ bool SoundSystemDSPOpenAL::uninit() { + if(!CheckDspSupport()) + return false; + if ( alIsFilter(m_uiFilter) ) alDeleteFilters( 1, &m_uiFilter ); @@ -159,6 +172,9 @@ namespace Sound bool SoundSystemDSPOpenAL::apply( SoundSystemSource* sss, int sendIndex) { + if(!CheckDspSupport()) + return false; + m_sendIndex = sendIndex; if(sss) @@ -204,6 +220,9 @@ namespace Sound bool SoundSystemDSPOpenAL::unapply( SoundSystemSource* sss ) { + if(!CheckDspSupport()) + return false; + if(sss) { ALuint uiSource = NULL; @@ -222,5 +241,16 @@ namespace Sound return false; } + + bool SoundSystemDSPOpenAL::CheckDspSupport() + { + ALCcontext* pContext = alcGetCurrentContext(); + ALCdevice* pDevice = alcGetContextsDevice(pContext); + + if(!alcIsExtensionPresent(pDevice, (ALCchar*)ALC_EXT_EFX_NAME)) + return false; + + return true; + } } #endif // __USE_AUDIO__ || __GENESIS_EDITOR__ \ No newline at end of file diff --git a/Engine/addons/soundsystem/SoundSystemDSPOpenAL.h b/Engine/addons/soundsystem/SoundSystemDSPOpenAL.h index 0bac0e6..307e220 100644 --- a/Engine/addons/soundsystem/SoundSystemDSPOpenAL.h +++ b/Engine/addons/soundsystem/SoundSystemDSPOpenAL.h @@ -52,6 +52,8 @@ namespace Sound int GetSendIndex() { return m_sendIndex; } protected: + bool CheckDspSupport(); + ALuint m_type; ALuint m_uiEffectSlot; // effect slot ALuint m_uiFilter; // filter diff --git a/Engine/addons/soundsystem/SoundSystemOpenAL.cc b/Engine/addons/soundsystem/SoundSystemOpenAL.cc index 1566f1c..95a31fd 100644 --- a/Engine/addons/soundsystem/SoundSystemOpenAL.cc +++ b/Engine/addons/soundsystem/SoundSystemOpenAL.cc @@ -485,8 +485,8 @@ namespace Sound bool SoundSystemOpenAL::createDSPByType( ALuint type, GPtr& dsp ) { dsp = SoundSystemDSPOpenAL::Create(); - dsp->init(type); - return true; + bool result = dsp->init(type); + return result; } } diff --git a/Engine/addons/sprite/spritemesh.h b/Engine/addons/sprite/spritemesh.h index 12f6ccb..c04edf1 100644 --- a/Engine/addons/sprite/spritemesh.h +++ b/Engine/addons/sprite/spritemesh.h @@ -24,7 +24,7 @@ THE SOFTWARE. #ifndef __SPRITE_MESH_H__ #define __SPRITE_MESH_H__ #include "foundation/core/refcounted.h" -#include "foundation/Util/array.h" +#include "foundation/util/array.h" #include "foundation/math/size.h" #include "foundation/math/float3.h" #include "foundation/math/color.h" diff --git a/Engine/addons/stdneb.h b/Engine/addons/stdneb.h index 40d99cf..679d785 100644 --- a/Engine/addons/stdneb.h +++ b/Engine/addons/stdneb.h @@ -32,7 +32,7 @@ THE SOFTWARE. #elif __PS3__ #include "core/ps3/precompiled.h" #elif __OSX__ -#include "core/OSX/precompiled.h" +#include "core/osx/precompiled.h" #elif __ANDROID__ #include "core/android/precompiled.h" #else diff --git a/Engine/addons/terrainsystem/TerrainDataSource.cc b/Engine/addons/terrainsystem/TerrainDataSource.cc index c723332..9194745 100644 --- a/Engine/addons/terrainsystem/TerrainDataSource.cc +++ b/Engine/addons/terrainsystem/TerrainDataSource.cc @@ -950,29 +950,45 @@ namespace Terrain } void TerrainDataSource::GetColorMapData(Math::Color32* buffer,const int xStart /* = 0 */,const int yStart /* = 0 */,const int width /* = -1 */,const int height /* = -1 */) { - if(GetImagesData(mColorMap,xStart,yStart,width,height,buffer,COLOR32)) - return; - memset (buffer, 0, width * height * sizeof(Math::Color32)); + if (mColorMap.isvalid()) + { + if(GetImagesData(mColorMap,xStart,yStart,width,height,buffer,COLOR32)) + return; + } + else + { + memset (buffer, 0, width * height * sizeof(Math::Color32)); + } } void TerrainDataSource::GetColorMapData(Math::ColorF* buffer,const int xStart /* = 0 */,const int yStart /* = 0 */,const int width /* = -1 */,const int height /* = -1 */) { - if(GetImagesData(mColorMap,xStart,yStart,width,height,buffer,COLORF)) - return; - memset (buffer, 0, width * height * sizeof(Math::ColorF)); + if (mColorMap.isvalid()) + { + if(GetImagesData(mColorMap,xStart,yStart,width,height,buffer,COLORF)) + return; + } + else + { + memset (buffer, 0, width * height * sizeof(Math::ColorF)); + } } void TerrainDataSource::SetColorMapData(Math::ColorF* buffer,const int xStart /* = 0 */,const int yStart /* = 0 */,const int width /* = -1 */,const int height /* = -1 */) { - SetImagesData(mColorMap,xStart,yStart,width,height,buffer,COLORF); - if (mColorMap) + if (mColorMap.isvalid()) + { + SetImagesData(mColorMap,xStart,yStart,width,height,buffer,COLORF); + Graphic::GraphicSystem::Instance()->UpdateTexture(mColorMap->GetHandle(), &_UpdateTextureFunction, mColorMap); - //RefreshBasemap(xStart,yStart,width,height); + } } void TerrainDataSource::SetColorMapData(Math::Color32* buffer,const int xStart /* = 0 */,const int yStart /* = 0 */,const int width /* = -1 */,const int height /* = -1 */) { - SetImagesData(mColorMap,xStart,yStart,width,height,buffer,COLOR32); - if (mColorMap) + if (mColorMap.isvalid()) + { + SetImagesData(mColorMap,xStart,yStart,width,height,buffer,COLOR32); + Graphic::GraphicSystem::Instance()->UpdateTexture(mColorMap->GetHandle(), &_UpdateTextureFunction, mColorMap); - //RefreshBasemap(xStart,yStart,width,height); + } } //------------------------------------------------------------------------------ //other unclassify methods @@ -1053,10 +1069,29 @@ namespace Terrain height = texture->GetHeight() - yStart; } - n_assert( xStart >= 0 && xStart < texture->GetWidth() && "xStart is invalid" ); - n_assert( yStart >= 0 && yStart < texture->GetHeight() && "yStart is invalid" ); - n_assert( width >= 1 && width + xStart <= texture->GetWidth() && "width is invalid"); - n_assert( height >= 1 && height + yStart <= texture->GetHeight() && "height is invalid"); + if( !(xStart >= 0 && xStart < texture->GetWidth()) ) + { + n_warning("This operation is invalid"); + return false; + } + + if( !(yStart >= 0 && yStart < texture->GetHeight()) ) + { + n_warning("This operation is invalid"); + return false; + } + + if( !(width >= 1 && width + xStart <= texture->GetWidth()) ) + { + n_warning("This operation is invalid"); + return false; + } + + if( !(height >= 1 && height + yStart <= texture->GetHeight()) ) + { + n_warning("This operation is invalid"); + return false; + } if (datatype == COLORF) { diff --git a/Engine/addons/vegetation/VegetationObejct.h b/Engine/addons/vegetation/VegetationObejct.h index d2e5f39..ac0210c 100644 --- a/Engine/addons/vegetation/VegetationObejct.h +++ b/Engine/addons/vegetation/VegetationObejct.h @@ -190,6 +190,12 @@ namespace Vegetation Util::FixedArray& GetIndices(); void GetReferenceResourceId(Util::Array& list) const; +#ifdef __GENESIS_EDITOR__ + void SetEditorVisible(bool bVis); + + bool IsVisible() const; +#endif + protected: void _onActive(void); void _onDeactive(void); @@ -238,6 +244,9 @@ namespace Vegetation friend class VegetationServer; +#ifdef __GENESIS_EDITOR__ + bool m_bEditorVis; +#endif }; //-------------------------------------------------------------------------------- @@ -353,6 +362,18 @@ namespace Vegetation { return m_indices; } + +#ifdef __GENESIS_EDITOR__ + inline void VegetationObject::SetEditorVisible(bool bVis) + { + m_bEditorVis = bVis; + } + + inline bool VegetationObject::IsVisible() const + { + return m_bEditorVis; + } +#endif } #endif //__VEGETATION_OBJECT_H__ diff --git a/Engine/app/CMakeLists.txt b/Engine/app/CMakeLists.txt index 5721782..e4feb04 100644 --- a/Engine/app/CMakeLists.txt +++ b/Engine/app/CMakeLists.txt @@ -254,6 +254,7 @@ SET ( SCRIPTFEATURE_HEADER_FILES scriptfeature/script_root_instance.h scriptfeature/script_IAP_instance.h scriptfeature/script_render_buffer_filter.h + scriptfeature/script_app.h ) @@ -273,6 +274,7 @@ SET ( SCRIPTFEATURE_SOURCE_FILES scriptfeature/script_root_instance.cc scriptfeature/script_IAP_instance.cc scriptfeature/script_render_buffer_filter.cc + scriptfeature/script_app.cc ) #scriptfeature inc folder @@ -393,8 +395,13 @@ SET ( GUIFEATURE_FILES guifeature/guievent.cc guifeature/FontFeature.h guifeature/FontFeature.cc - - + +) +SET ( JNI_FILES + Jni/imejni.h + Jni/imejni.cc + Jni/jnihelper.h + Jni/jnihelper.cc ) SET ( GUIBIND_FILES guibind/scriptbind_gui.cc @@ -669,6 +676,11 @@ SOURCE_GROUP( FILES ${GUIFEATURE_FILES} ) +SOURCE_GROUP( + "Jni" + FILES + ${JNI_FILES} +) SOURCE_GROUP( "GuiBind" FILES @@ -815,6 +827,7 @@ ADD_LIBRARY( ${SPRITEBACTH_FILES} ${GUIFEATURE_FILES} ${GUIBIND_FILES} + ${JNI_FILES} ) #Organize projects into folders diff --git a/Engine/app/Jni/Jnihelper.cc b/Engine/app/Jni/Jnihelper.cc new file mode 100644 index 0000000..4cb8775 --- /dev/null +++ b/Engine/app/Jni/Jnihelper.cc @@ -0,0 +1,181 @@ +/**************************************************************************** +Copyright (c) 2011-2013,WebJet Business Division,CYOU + +http://www.genesis-3d.com.cn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#if __ANDROID__ +#include "stdneb.h" +#include "jnihelper.h" +#include +#include "players/GenesisA/simplegameapplication.h" + +namespace App +{ + ////////////////////////////////////////////////////////////////////////// + // java vm helper function + ////////////////////////////////////////////////////////////////////////// + + static bool getEnv(JNIEnv **env) + { + bool bRet = true; + *env = Genesis::DemoPublishGameApplication::Instance()->GetJNIEvn(); + return bRet; + } + bool JniHelper::GetEnv(JNIEnv **env) + { + return getEnv(env); + } + + static jclass getClassID_(const char *className, JNIEnv *env) + { + JNIEnv *pEnv = env; + jclass ret = 0; + + do + { + if (! pEnv) + { + if (! getEnv(&pEnv)) + { + break; + } + } + + ret = pEnv->FindClass(className); + if (! ret) + { + n_warning("Failed to find class of %s", className); + break; + } + } while (0); + + return ret; + } + + static bool getStaticMethodInfo_(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) + { + jmethodID methodID = 0; + JNIEnv *pEnv = 0; + bool bRet = false; + + do + { + if (! getEnv(&pEnv)) + { + break; + } + + jclass classID = getClassID_(className, pEnv); + + methodID = pEnv->GetStaticMethodID(classID, methodName, paramCode); + if (! methodID) + { + n_warning("Failed to find static method id of %s", methodName); + break; + } + + methodinfo.classID = classID; + methodinfo.env = pEnv; + methodinfo.methodID = methodID; + + bRet = true; + } while (0); + + return bRet; + } + + static bool getMethodInfo_(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) + { + jmethodID methodID = 0; + JNIEnv *pEnv = 0; + bool bRet = false; + + do + { + if (! getEnv(&pEnv)) + { + break; + } + + jclass classID = getClassID_(className, pEnv); + + methodID = pEnv->GetMethodID(classID, methodName, paramCode); + if (! methodID) + { + n_warning("Failed to find method id of %s", methodName); + break; + } + + methodinfo.classID = classID; + methodinfo.env = pEnv; + methodinfo.methodID = methodID; + + bRet = true; + } while (0); + + return bRet; + } + + static std::string jstring2string_(jstring jstr) + { + if (jstr == NULL) + { + return ""; + } + + JNIEnv *env = 0; + + if (! getEnv(&env)) + { + return 0; + } + + const char* chars = env->GetStringUTFChars(jstr, NULL); + std::string ret(chars); + env->ReleaseStringUTFChars(jstr, chars); + + return ret; + } +////////////////////////////////////////////////////////////// + + + +jclass JniHelper::GetClassID(const char *className, JNIEnv *env) +{ + return getClassID_(className, env); +} + +bool JniHelper::GetStaticMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) +{ + return getStaticMethodInfo_(methodinfo, className, methodName, paramCode); +} + +bool JniHelper::GetMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) +{ + return getMethodInfo_(methodinfo, className, methodName, paramCode); +} + +std::string JniHelper::jstring2string(jstring str) +{ + return jstring2string_(str); +} +} +#endif diff --git a/Engine/app/Jni/Jnihelper.h b/Engine/app/Jni/Jnihelper.h new file mode 100644 index 0000000..2fd3956 --- /dev/null +++ b/Engine/app/Jni/Jnihelper.h @@ -0,0 +1,56 @@ +/**************************************************************************** +Copyright (c) 2011-2013,WebJet Business Division,CYOU + +http://www.genesis-3d.com.cn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#ifndef __JNI_HELPER_H__ +#define __JNI_HELPER_H__ +#if __ANDROID__ +#include +#include + +namespace App +{ + + +typedef struct JniMethodInfo_ +{ + JNIEnv * env; + jclass classID; + jmethodID methodID; +} JniMethodInfo; + +class JniHelper +{ +public: + static bool GetEnv(JNIEnv **env); + static jclass GetClassID(const char *className, JNIEnv *env=0); + static bool GetStaticMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode); + static bool GetMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode); + static std::string jstring2string(jstring str); + +private: + +}; + +} +#endif +#endif // __JNI_HELPER_H__ diff --git a/Engine/app/Jni/imejni.cc b/Engine/app/Jni/imejni.cc new file mode 100644 index 0000000..bea17d2 --- /dev/null +++ b/Engine/app/Jni/imejni.cc @@ -0,0 +1,67 @@ +/**************************************************************************** +Copyright (c) 2011-2013,WebJet Business Division,CYOU + +http://www.genesis-3d.com.cn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#if __ANDROID__ +#include "imejni.h" +#include +#include +#include "Jnihelper.h" + +namespace App +{ + + static char* s_classname= "org/genesis/lib/GenesisGLSurfaceView"; + + void IMEJni::ShowKeyboardJNI(int bOpen) + { + if (bOpen) + { + IMEJni::OpenKeyboardJNI(); + } + else + { + IMEJni::CloseKeyboardJNI(); + } + } + + void IMEJni::OpenKeyboardJNI() + { + JniMethodInfo t; + + if (JniHelper::GetStaticMethodInfo(t, s_classname, "openIMEKeyboard", "()V")) { + t.env->CallStaticVoidMethod(t.classID, t.methodID); + t.env->DeleteLocalRef(t.classID); + } + } + + void IMEJni::CloseKeyboardJNI() + { + JniMethodInfo t; + + if (JniHelper::GetStaticMethodInfo(t, s_classname, "closeIMEKeyboard", "()V")) { + t.env->CallStaticVoidMethod(t.classID, t.methodID); + t.env->DeleteLocalRef(t.classID); + } + } +} +#endif \ No newline at end of file diff --git a/Engine/app/Jni/imejni.h b/Engine/app/Jni/imejni.h new file mode 100644 index 0000000..f8a9856 --- /dev/null +++ b/Engine/app/Jni/imejni.h @@ -0,0 +1,39 @@ +/**************************************************************************** +Copyright (c) 2011-2013,WebJet Business Division,CYOU + +http://www.genesis-3d.com.cn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#ifndef __IME_JNI_H__ +#define __IME_JNI_H__ + +namespace App +{ + class IMEJni + { + public: + static void ShowKeyboardJNI(int bOpen); + static void OpenKeyboardJNI(); + static void CloseKeyboardJNI(); + }; + +} + +#endif // __IME_JNI_H__ diff --git a/Engine/app/appframework/actor.cc b/Engine/app/appframework/actor.cc index 628d5c2..f293d37 100644 --- a/Engine/app/appframework/actor.cc +++ b/Engine/app/appframework/actor.cc @@ -52,6 +52,7 @@ __ImplementClass(App::Actor, 'GACT', Core::RefCounted); uint Actor::s_fastIdCounter = 0; const GPtr Actor::NullActor; +const ActorPropertySet ActorPropertySet::s_defaultVal; //------------------------------------------------------------------------------ /** */ @@ -61,6 +62,7 @@ Actor::Actor() : mActivated(false), mActiveControl(false), mTemplateName(""), + mModelName(""), mIsLinkTemplate(false), mLayerID(eSL_Defualt), mTagID(1), @@ -79,7 +81,6 @@ Actor::Actor() : #ifdef __GENESIS_EDITOR__ mQueryMask(0), mFrozen(false), - mLocked(false), #endif mEditorFlag(0), mPriority(ResourcePriority::Undefinition) @@ -159,9 +160,23 @@ Actor::_Destory(bool forceShutDown ) //------------------------------------------------------------------------ void Actor::SetLayerID(LayerID id) { + if (id == mLayerID) + return; + n_assert(id < 32); n_assert(0 <= id); mLayerID = id; + +#if __USE_PHYSX__ || __GENESIS_EDITOR__ + //从脚本设置的话,需要更新物理形状的groupId + GPtr com = FindComponent(); + if(com.isvalid() && com->GetEntity()->IsValid()) + { + com->GetEntity()->SetGroupID(id); + } +#endif + + IndexT i; for (i = 0; i < this->mComponents.Size(); ++i) { @@ -1055,7 +1070,16 @@ Actor::AttachComponent(const GPtr& prop) { n_assert(0 != prop); - this->mComponents.Append(prop); + //修复bug252 脚本组件应当放在最后 + SizeT len = mComponents.Size(); + if (len > 0 && mComponents[len-1]->IsA(ScriptComponent::RTTI)) + { + mComponents.Insert(len-1, prop); + } + else + { + mComponents.Append(prop); + } prop->_SetActor(this); prop->SetupAllResource(); if ( IsActive()) @@ -1372,7 +1396,7 @@ void Actor::SetActiveStateForTemplate() } //------------------------------------------------------------------------ -void Actor::CopyFrom( const GPtr& pSource, bool includePrivateProperty, bool isTemplate , bool needRecurVFL ) +void Actor::CopyFrom( const GPtr& pSource,const ActorPropertySet& actorPropertySet, bool includePrivateProperty, bool isTemplate , bool needRecurVFL ) { //#ifdef _DEBUG // mCopyedActor = 1; @@ -1437,7 +1461,7 @@ void Actor::CopyFrom( const GPtr& pSource, bool includePrivateProperty, b mChildren[i] = pNewChild; } n_assert( mChildren[i].isvalid() ); - mChildren[i]->CopyFrom( pSourceChild, true , isTemplate , needRecurVFL); // Dest Child is just Create, Copy All from Source Child + mChildren[i]->CopyFrom( pSourceChild,ActorPropertySet::s_defaultVal, true , isTemplate , needRecurVFL); // Dest Child is just Create, Copy All from Source Child } } @@ -1455,52 +1479,85 @@ void Actor::CopyFrom( const GPtr& pSource, bool includePrivateProperty, b AttachComponent( pDestCom ); } } - //更新 新加入的Component的显示属性 - SetVisible(pSource->GetVisible(), needRecurVFL); -#ifdef __GENESIS_EDITOR__ - SetFrozen(pSource->GetFrozen(), needRecurVFL); - SetLocked(pSource->GetLocked(), needRecurVFL); -#endif - SetLocalBoundingBox(pSource->GetLocalBoundingBox()); - SetTemplateName( pSource->GetTemplateName() ); + _CopyFrom_MustProperty(pSource,needRecurVFL); if ( includePrivateProperty ) { // copy actor property, just serialization's property need copy //SetVisible(pSource->GetVisible()); + _CopyFrom_IncludeProperty(pSource,actorPropertySet); - if ( pSource->GetActiveControl() ) - Active(); - else - Deactive(); - SetName( pSource->GetName() ); - SetLinkTemplate( pSource->IsLinkTemplate() ); - SetLayerID( pSource->GetLayerID() ); - SetTagID( pSource->GetTagID() ); - SetTransform( pSource->GetPosition(), pSource->GetRotation(), pSource->GetScale() ); - // for templatedActors - SetTmpActiveState( pSource->IsActive() ); -#ifdef __GENESIS_EDITOR__ - SetQueryMask(pSource->GetQueryMask()); -#endif - SetEditorFlag( pSource->GetEditorFlag() ); } if (isTemplate) { - SetLayerID( pSource->GetLayerID() ); - SetTagID( pSource->GetTagID() ); - SetTransform( this->GetPosition(), this->GetRotation(), this->GetScale() ); - SetTmpActiveState( pSource->IsActive() ); -#ifdef __GENESIS_EDITOR__ - SetQueryMask(pSource->GetQueryMask()); -#endif - SetEditorFlag( pSource->GetEditorFlag() ); + _CopyFrom_CommonProperty(pSource,actorPropertySet); } } +//------------------------------------------------------------------------ +void Actor::_CopyFrom_MustProperty( const GPtr& pSource, bool needRecurVFL) +{ + //更新 新加入的Component的显示属性 + SetVisible(pSource->GetVisible(), needRecurVFL); +#ifdef __GENESIS_EDITOR__ + SetFrozen(pSource->GetFrozen(), needRecurVFL); +#endif + SetLocalBoundingBox(pSource->GetLocalBoundingBox()); + SetTemplateName( pSource->GetTemplateName() ); + SetModelName(pSource->GetModelName()); +} +//------------------------------------------------------------------------ +void Actor::_CopyFrom_IncludeProperty( const GPtr& pSource,const ActorPropertySet& actorPropertySet) +{ + if ( pSource->GetActiveControl() ) + Active(); + else + Deactive(); + + bool bRootTemplateActor = actorPropertySet.TestFlag(ActorPropertySet::logic_exclusive_RootActorName) && + this->GetTemplateName().IsValid() && + (!this->GetParent() || this->GetParent() && !this->GetParent()->GetTemplateName().IsValid()); + + if ( !bRootTemplateActor ) + { + SetName( pSource->GetName() ); + } + + + SetLinkTemplate( pSource->IsLinkTemplate() ); + _CopyFrom_CommonProperty(pSource,actorPropertySet); + if ( actorPropertySet.TestFlag(ActorPropertySet::logic_exclusive_pos_rot) ) + { + SetTransform( this->GetPosition(), this->GetRotation(), pSource->GetScale() ); + } + else + { + SetTransform( pSource->GetPosition(), pSource->GetRotation(), pSource->GetScale() ); + } + SetPriority(pSource->GetPriority()); +} +//------------------------------------------------------------------------ +void Actor::_CopyFrom_TemplateProperty( const GPtr& pSource,const ActorPropertySet& actorPropertySet) +{ + _CopyFrom_CommonProperty(pSource,actorPropertySet); + SetTransform( this->GetPosition(), this->GetRotation(), this->GetScale() ); +} + +//------------------------------------------------------------------------ +void Actor::_CopyFrom_CommonProperty( const GPtr& pSource,const ActorPropertySet& actorPropertySet) +{ + SetLayerID( pSource->GetLayerID() ); + SetTagID( pSource->GetTagID() ); + + SetTmpActiveState( pSource->IsActive() ); +#ifdef __GENESIS_EDITOR__ + SetQueryMask(pSource->GetQueryMask()); +#endif + SetEditorFlag( pSource->GetEditorFlag() ); +} //------------------------------------------------------------------------ void Actor::SetPriority( const Resources::Priority priority ) @@ -1632,15 +1689,33 @@ Actor::FindChildIndex(FastId id) const } //------------------------------------------------------------------------ const GPtr& -Actor::FindChild(FastId id) const +Actor::FindChild(FastId id, bool includeGrandson) const { - IndexT findIndex = FindChildIndex(id); - return GetChild( findIndex ); + SizeT count = mChildren.Size(); + for ( IndexT index = 0; index < count; ++index ) + { + if ( mChildren[index]->GetFastId() == id ) + { + return mChildren[index]; + } + } + if (includeGrandson) + { + for ( IndexT index = 0; index < count; ++index ) + { + const GPtr& result = mChildren[index]->FindChild(id, includeGrandson); + if (result.isvalid()) + { + return result; + } + } + } + return NullActor; } //------------------------------------------------------------------------ const GPtr& -Actor::FindChildByTag(App::TagID id) const +Actor::FindChildByTag(App::TagID id, bool includeGrandson) const { // @todo may be need optimize, eg. Binary Search SizeT count = mChildren.Size(); @@ -1651,10 +1726,21 @@ Actor::FindChildByTag(App::TagID id) const return mChildren[index]; } } + if (includeGrandson) + { + for ( IndexT index = 0; index < count; ++index ) + { + const GPtr& result = mChildren[index]->FindChildByTag(id, includeGrandson); + if (result.isvalid()) + { + return result; + } + } + } return NullActor; } //------------------------------------------------------------------------ -void Actor::FindChildrenByTag(const App::TagID id,Util::Array< GPtr >& actors) const +void Actor::FindChildrenByTag(const App::TagID id,Util::Array< GPtr >& actors, bool includeGrandson) const { SizeT count = mChildren.Size(); for ( IndexT index = 0; index < count; ++index ) @@ -1663,10 +1749,14 @@ void Actor::FindChildrenByTag(const App::TagID id,Util::Array< GPtr >& ac { actors.Append(mChildren[index]); } + if (includeGrandson) + { + mChildren[index]->FindChildrenByTag(id, actors, includeGrandson); + } } } const GPtr& - Actor::FindChild(const Util::String& name) const + Actor::FindChild(const Util::String& name, bool includeGrandson) const { // @todo may be need optimize, eg. Binary Search SizeT count = mChildren.Size(); @@ -1677,12 +1767,24 @@ const GPtr& return mChildren[index]; } } + + if (includeGrandson) + { + for ( IndexT index = 0; index < count; ++index ) + { + const GPtr& result = mChildren[index]->FindChild(name, includeGrandson); + if (result.isvalid()) + { + return result; + } + } + } return NullActor; } //------------------------------------------------------------------------ const GPtr& -Actor::FindChild(const Util::Guid& guid) const +Actor::FindChild(const Util::Guid& guid, bool includeGrandson) const { // @todo may be need optimize, eg. Binary Search SizeT count = mChildren.Size(); @@ -1693,6 +1795,18 @@ Actor::FindChild(const Util::Guid& guid) const return mChildren[index]; } } + + if (includeGrandson) + { + for ( IndexT index = 0; index < count; ++index ) + { + const GPtr& result = mChildren[index]->FindChild(guid, includeGrandson); + if (result.isvalid()) + { + return result; + } + } + } return NullActor; } @@ -1784,27 +1898,12 @@ Actor::_DirtyWorldTransform() // dirty child GPtr children; -#ifdef __GENESIS_EDITOR__ - bool bLocked = false; -#endif + SizeT numActor = mChildren.Size(); for ( IndexT i = 0; i < numActor; ++i ) { children = mChildren[i]; - -#ifdef __GENESIS_EDITOR__ - /*子actor处于锁定状态时,其世界坐标不应该跟着父actor的变换而变换, - 但其局部坐标发生了变化,所以要更新局部坐标*/ - bLocked = children->GetLocked(); - if ( bLocked ) - { - const Actor *parent = children->GetParent(); - children->SetLockedActorLocalTransform(parent); - continue; - } -#endif - children->_DirtyWorldTransform(); } } @@ -1884,29 +1983,8 @@ Actor::SaveTerrainFile(void) const } //------------------------------------------------------------------------------ #ifdef __GENESIS_EDITOR__ -void Actor::SetLocked(bool bLocked , bool needRecursive/* = true*/) -{ - mLocked = bLocked; - if (needRecursive) - { - SizeT count = mChildren.Size(); - for ( IndexT index = 0; index < count; ++index ) - { - mChildren[index]->SetLocked(bLocked); - } - } -} -//------------------------------------------------------------------------------ -void Actor::SetLockedActorTransformRecursive(const GPtr& pSource) -{ - n_assert(pSource); - SetTransform(pSource->GetPosition(),pSource->GetRotation(),pSource->GetScale()); - SizeT count = mChildren.Size(); - for ( IndexT index = 0; index < count; ++index ) - { - mChildren[index]->SetLockedActorTransformRecursive(pSource->GetChild(index)); - } -} + + //------------------------------------------------------------------------------ void Actor::SetFrozen(bool bFrozen , bool needRecursive/* = true*/) { @@ -1923,7 +2001,7 @@ void Actor::SetFrozen(bool bFrozen , bool needRecursive/* = true*/) #endif //------------------------------------------------------------------------------ void Actor::SetVisible( bool bVisible , bool needRecursive /*= true*/ ) -{ +{ mVisible = bVisible; if ( NULL != FindComponent() ) @@ -1934,8 +2012,12 @@ void Actor::SetVisible( bool bVisible , bool needRecursive /*= true*/ ) { GPtr renderCom = coms[i].downcast(); n_assert(renderCom.isvalid()); - +#ifdef __GENESIS_EDITOR__ + renderCom->SetEditorVisible(bVisible); +#else renderCom->SetVisible(bVisible); +#endif + } } @@ -1950,7 +2032,11 @@ void Actor::SetVisible( bool bVisible , bool needRecursive /*= true*/ ) { continue; } +#ifdef __GENESIS_EDITOR__ + vegeRenderCom->SetEditorVisible(bVisible); +#else vegeRenderCom->SetVisible(bVisible); +#endif } } if (needRecursive) @@ -1963,6 +2049,7 @@ void Actor::SetVisible( bool bVisible , bool needRecursive /*= true*/ ) } //暂未处理其它component对显示隐藏属性的响应,如相机、灯光、声音、粒子 return; + } //------------------------------------------------------------------------------ bool Actor::GetVisible() const @@ -1985,32 +2072,7 @@ bool Actor::IsChildOfAnimationActor() } return false; } -//------------------------------------------------------------------------ -/*设置锁定actor的局部坐标时是不需要调_DirtyWorldTransform()函数的,因为 -锁定物体的局部坐标是因为父物体位置改变造成的,其本身的空间方位根本没有发生变化。*/ -#ifdef __GENESIS_EDITOR__ -void Actor::SetLockedActorLocalTransform( const Actor *parent ) -{ - if ( parent ) - { - const Math::matrix44 &parentWT = parent->GetWorldTransform(); - Math::matrix44 inversepw = Math::matrix44::inverse(parentWT); - const Math::matrix44 &worldTransform = GetWorldTransform(); - mLocaTrans = Math::matrix44::multiply( inversepw , worldTransform ); - mLocaTrans.setrow3( Math::float4(0.0f,0.0f,0.0f,1.0f)); - mLocaTrans.decompose( mLocalScale, mLocalRotation, mLocalPosition ); - return; - } - else - { - mLocalPosition = mWorldPosition; - mLocalRotation = mWorldRotation; - mLocalScale = mWorldScale; - mLocaTrans = mWorldTrans; - } -} -#endif //------------------------------------------------------------------------------ #if NEBULA3_ENABLE_PROFILING //------------------------------------------------------------------------ diff --git a/Engine/app/appframework/actor.h b/Engine/app/appframework/actor.h index 5739d6e..e078891 100644 --- a/Engine/app/appframework/actor.h +++ b/Engine/app/appframework/actor.h @@ -69,7 +69,7 @@ namespace App enum SysLayerID { eSL_Defualt = 0,//RenderLayer::eRLDefault - eSL_Debug = 31,//RenderLayer::eRLDebug + eSL_Assist = 31,//RenderLayer::eSL_Assist }; @@ -87,7 +87,40 @@ namespace App } Actor* parent; }; + class ActorPropertySet + { + public: + enum FlagProperty + { + logic_exclusive_pos_rot = 1 << 0, + logic_exclusive_RootActorName = 1 << 1 + }; + const static ActorPropertySet s_defaultVal; + ActorPropertySet():m_Flags(0) + { + } + ~ActorPropertySet(){}; + bool TestFlag(FlagProperty eFlag) const + { + return (eFlag & m_Flags) != 0; + } + void SetFlag(FlagProperty eFlag,bool bVal) + { + if ( bVal ) + { + m_Flags |= eFlag; + } + else + { + m_Flags &= (~eFlag); + } + } + private: + uint m_Flags; + + + }; // Modified From Nebula3's Entity(Actor) and Property(Component). MayBe It's Good for Radon Labs. // But I think It's too Difficult to Understand Nebula3's Design for Newer. For Example: Property in DB Storage , So Many Thread, So Many Details Hidden in Addon... // Actor: Manage RelationShip And Component. TODO: Add TinyActor For Object With No Game Logic. @@ -176,15 +209,15 @@ namespace App const GPtr& GetChild(IndexT i) const; // find actor by FastID - const GPtr& FindChild(FastId id) const; + const GPtr& FindChild(FastId id, bool includeGrandson = true) const; - const GPtr& FindChildByTag(App::TagID id) const; + const GPtr& FindChildByTag(App::TagID id, bool includeGrandson = true) const; - void FindChildrenByTag(const App::TagID tagID,Util::Array< GPtr >& actors) const; + void FindChildrenByTag(const App::TagID tagID,Util::Array< GPtr >& actors, bool includeGrandson = true) const; - const GPtr& FindChild(const Util::Guid& guid) const; + const GPtr& FindChild(const Util::Guid& guid, bool includeGrandson = true) const; - const GPtr& FindChild(const Util::String& name) const; + const GPtr& FindChild(const Util::String& name, bool includeGrandson = true) const; // find child actor index in child list IndexT FindChildIndex(FastId id) const; @@ -351,7 +384,9 @@ namespace App // if includePrivateProperty is true, the actor's property( like transform, layerID,...) , components and child actor will copy // if needRecurVFL is false, the actor's visible,frozen,lock states will affect its children. // after copy, the actor is deactive. should manu active if need - virtual void CopyFrom( const GPtr& pSource, bool includePrivateProperty , bool isTemplate = false , bool needRecurVFL = true); + virtual void CopyFrom( const GPtr& pSource,const ActorPropertySet& actorPropertySet, bool includePrivateProperty , bool isTemplate = false , bool needRecurVFL = true); + + //virtual void CopyFromTemplateRes(Resources::ResourceId resID);' @@ -386,6 +421,13 @@ namespace App void _UpdateWolrdTransform() const; void _UpdateLocalTransform() const; + void _CopyFrom_MustProperty( const GPtr& pSource, bool needRecurVFL); + void _CopyFrom_IncludeProperty( const GPtr& pSource,const ActorPropertySet& actorPropertySet); + void _CopyFrom_TemplateProperty( const GPtr& pSource,const ActorPropertySet& actorPropertySet); + void _CopyFrom_CommonProperty( const GPtr& pSource,const ActorPropertySet& actorPropertySet); + + + void _CheckActive(); @@ -434,20 +476,14 @@ namespace App void SetEulerRotation(const Math::vector & rot); void SetFrozen( bool bFrozen , bool needRecursive = true ); - void SetLocked( bool bLocked , bool needRecursive = true ); bool GetFrozen() { return mFrozen; } - bool GetLocked() { return mLocked; } - //only called after copy,pSource is the actor used for copyfrom source - void SetLockedActorTransformRecursive(const GPtr& pSource); - protected: - void SetLockedActorLocalTransform( const Actor *parent ); + Math::vector mEulerAngle; uint mQueryMask; bool mFrozen; - bool mLocked; #endif public: enum EditorFlag @@ -464,6 +500,8 @@ namespace App //return true if this actor is a child of one actor that has a animation component bool IsChildOfAnimationActor(); + void SetModelName(const Util::String& name) { mModelName = name; } + const Util::String& GetModelName(void) const { return mModelName; } protected:// date uint mEditorFlag; @@ -519,6 +557,8 @@ namespace App bool mVisible; Resources::Priority mPriority; + Util::String mModelName; + //GPtr mTemplateResInfo; friend class ActorManager; diff --git a/Engine/app/appframework/actormanager.cc b/Engine/app/appframework/actormanager.cc index b36b192..1c34a81 100644 --- a/Engine/app/appframework/actormanager.cc +++ b/Engine/app/appframework/actormanager.cc @@ -235,7 +235,7 @@ namespace App GPtr pActor = CreateActor(); n_assert( pActor ); - pActor->CopyFrom( pTemplate, true, false, false); + pActor->CopyFrom( pTemplate,ActorPropertySet::s_defaultVal, true, false, false); /*因为pTemplate一定是非激活状态,所以在复制完成之后要根据字典中保存的状态信息对pActor进行设置*/ index = mTemplateActors.FindIndex( actorTemplateName ); if (mTemplateActors.ValueAtIndex(index).activeFlag) @@ -277,7 +277,7 @@ namespace App return false; } - pDestActor->CopyFrom( pTemplate, includePrivateProperty ); + pDestActor->CopyFrom( pTemplate,ActorPropertySet::s_defaultVal, includePrivateProperty ); /*因为pTemplate一定是非激活状态,所以在复制完成之后要根据字典中保存的状态信息对pActor进行设置*/ index = mTemplateActors.FindIndex( actorTemplateName ); if (mTemplateActors.ValueAtIndex(index).activeFlag) @@ -297,30 +297,18 @@ namespace App const Util::String g_SingleTemplateExt = ".template"; bool ActorManager::SaveSingleTemplate( const Util::String& actorTemplateName, GPtr& pSource, int iFileType, bool updateSource) { - if ( iFileType<0 || - iFileType>=Serialization::FT_NUM ) + if ( !CheckSaveTemplate(pSource,iFileType) ) { return false; } //Util::String templateName = g_SingleTemplateURI + actorTemplateName.ExtractFileName(); Util::String templateName = actorTemplateName; - bool bHasInstance = Serialization::SerializationServer::HasInstance(); - if ( !pSource || - !bHasInstance ) - { - return false; - } - GPtr pTemplate = Actor::Create(); - pTemplate->CopyFrom(pSource, true, false, false); -#ifdef __GENESIS_EDITOR__ - pTemplate->SetFrozen(false,false); - pTemplate->SetLocked(false,false); -#endif - // template must deactive and link false - RecursionUnLinkTemplate(pTemplate); // 递归断开连接。避免嵌套 - pTemplate->SetTemplateName( templateName ); + SetTemplateActorProperty(pTemplate,pSource,ActorPropertySet::s_defaultVal); + pTemplate->SetTemplateName( templateName ); + + if (updateSource) { //update the template name of pSource @@ -328,8 +316,37 @@ namespace App pSource->SetTemplateName( templateName ); } + if (!WriteTemplateFile(templateName,pTemplate,iFileType)) + { + return false; + } + + UpdateTemplateCache(templateName,pTemplate,iFileType); + + return true; + } + //------------------------------------------------------------------------ + bool ActorManager::CheckSaveTemplate(GPtr& pSource, int iFileType) + { + if ( iFileType<0 || + iFileType>=Serialization::FT_NUM ) + { + return false; + } + + bool bHasInstance = Serialization::SerializationServer::HasInstance(); + if ( !pSource || + !bHasInstance ) + { + return false; + } + return true; + } + //------------------------------------------------------------------------ + bool ActorManager::WriteTemplateFile( const Util::String& actorTemplateName, GPtr& pTemplate,int iFileType) + { Serialization::SerializationServer* serialize = Serialization::SerializationServer::Instance(); - + Util::String filePath = actorTemplateName; Serialization::FileType eFileType = static_cast( iFileType ); @@ -344,9 +361,30 @@ namespace App pTemplate->Deactive(true); return false; } + return true; + } + //------------------------------------------------------------------------ + void ActorManager::SetTemplateActorProperty(GPtr& pTemplate,GPtr& pSource, const ActorPropertySet& actorPropertySet) + { + pTemplate->CopyFrom(pSource,actorPropertySet, true, false, false); +#ifdef __GENESIS_EDITOR__ + pTemplate->SetFrozen(false,false); +#endif + + // template must deactive and link false + RecursionUnLinkTemplate(pTemplate); // 递归断开连接。避免嵌套 + + + } + + //------------------------------------------------------------------------ + void ActorManager::UpdateTemplateCache(const Util::String& templateName, GPtr& pTemplate,int iFileType) + { /*在将actor保存为模板时,即使ator之前并非由模板创建,在模板缓冲中也有可能存在同名的模板, 所以序列化完成之后要更新模板缓冲*/ + + Serialization::FileType eFileType = static_cast( iFileType ); IndexT index = mTemplateActors.FindIndex( templateName ); TemplateInfo templateInfo(pTemplate, eFileType); /*使用pTemplate创建完templateInfo后,pTemplate的激活状态已经保存在templateInfo中, @@ -360,11 +398,9 @@ namespace App { mTemplateActors.Add(templateName, templateInfo); } - - return true; } //------------------------------------------------------------------------ - void ActorManager::UpdateTemplatedActors( GPtr& pActor ) + void ActorManager::UpdateTemplatedActors( GPtr& pActor, const ActorPropertySet& actorPropertySet) { const GPtr pRootActor(this->_GetMainSceneRootActor()); const Util::String templateName = pActor->GetTemplateName().AsString(); @@ -389,14 +425,74 @@ namespace App LoadSingleTemplate( templateName ,iFileType); } - SaveSingleTemplate(templateName, pActor, iFileType); - RecursionUpdateTemplate(pActor, pRootActor, templateName); + + //SaveSingleTemplate(templateName, pActor, iFileType); + + + if ( CheckSaveTemplate(pActor,iFileType) ) + { + + GPtr pTemplate = Actor::Create(); + SetTemplateActorProperty(pTemplate,pActor,actorPropertySet); + pTemplate->SetTemplateName( templateName ); + + Util::String templateActorName = pActor->GetName(); + if ( actorPropertySet.TestFlag(ActorPropertySet::logic_exclusive_RootActorName) ) + { + IndexT index = mTemplateActors.FindIndex( templateName ); + if ( InvalidIndex != index ) + { + templateActorName = mTemplateActors.ValueAtIndex( index ).m_ptr->GetName(); + } + } + + pTemplate->SetName(templateActorName); + + + + + if (WriteTemplateFile(templateName,pTemplate,iFileType)) + { + UpdateTemplateCache(templateName,pTemplate,iFileType); + } + } + + + + + + //update actors created by template + RecursionUpdateTemplate(pActor, pRootActor, templateName,actorPropertySet); } } + //------------------------------------------------------------------------ + void ActorManager::CopyFrom_PositionRotation(const GPtr& pDest,const GPtr& pSource) + { + //// first copy child + //{ + // SizeT count = pSource->GetChildCount(); + + // for ( IndexT i = 0; i < count; ++i) + // { + // const GPtr& pSourceChild = pSource->GetChild(i); + // n_assert( pSourceChild.isvalid() ); + + // + // if(pSourceChild->GetRtti() == pDest->GetChild(i)->GetRtti() ) + // { + // CopyFrom_PositionRotation(pDest->GetChild(i),pSourceChild); + // } + // + // } + //} + //// copy property + //pDest->SetTransform( pSource->GetPosition(), pSource->GetRotation(), pDest->GetScale() ); + } + //------------------------------------------------------------------------ void ActorManager::RecursionUpdateTemplate(const GPtr& sourceActor,const GPtr& destActor, - const Util::String& actorTemplateName) + const Util::String& actorTemplateName, const ActorPropertySet& actorPropertySet) { if ( sourceActor.isvalid() && destActor.isvalid() && sourceActor.get() != destActor.get()) { @@ -404,7 +500,10 @@ namespace App { //因为在actor的CopyFrom函数中会将actor自己Deactive掉,所以要将active状态保存,拷贝完成后恢复 bool bIsActive = destActor->IsActive(); - destActor->CopyFrom( sourceActor, false,false, false); + Util::String templateRootActorName = destActor->GetName(); + destActor->CopyFrom( sourceActor,actorPropertySet, true,false, false); + destActor->SetName(templateRootActorName); + destActor->SetScale(sourceActor->GetScale()); if (bIsActive) { @@ -420,7 +519,7 @@ namespace App SizeT count = destActor->GetChildCount(); for ( IndexT index = 0; index < count; ++index ) { - RecursionUpdateTemplate( sourceActor, destActor->GetChild(index), actorTemplateName); + RecursionUpdateTemplate( sourceActor, destActor->GetChild(index), actorTemplateName,actorPropertySet); } } } @@ -557,6 +656,20 @@ namespace App return NULL; } + //------------------------------------------------------------------------ + const Util::Array< GPtr > ActorManager::FindActiveActorByModelName(const Util::String& modelName) const + { + ActorArray array; + for (SizeT i = mActiveActors.Size()-1; i >=0; --i) + { + if(mActiveActors.ValueAtIndex(i)->GetModelName() == modelName) + { + array.Append(mActiveActors.ValueAtIndex(i)); + } + } + return array; + } + IndexT ActorManager::FindActiveActorIndex(App::Actor::FastId fastID) const { return mActiveActors.FindIndex(fastID); diff --git a/Engine/app/appframework/actormanager.h b/Engine/app/appframework/actormanager.h index bbfb638..efb9916 100644 --- a/Engine/app/appframework/actormanager.h +++ b/Engine/app/appframework/actormanager.h @@ -149,6 +149,13 @@ namespace App // 将某个Actor保存为模板,*.template. bool SaveSingleTemplate( const Util::String& actorTemplateName, GPtr& pSource, int iFileType ,bool updateSource = false ); + void SetTemplateActorProperty(GPtr& pTemplate,GPtr& pSource, const ActorPropertySet& actorPropertySet); + bool WriteTemplateFile( const Util::String& actorTemplateName, GPtr& pTemplate,int iFileType ); + bool CheckSaveTemplate(GPtr& pSource, int iFileType); + void CopyFrom_PositionRotation(const GPtr& pDest,const GPtr& pSource); + + void UpdateTemplateCache(const Util::String& templateName, GPtr& pTemplate,int iFileType); + // 读取单个模板文件。 *.template GPtr LoadSingleTemplate( const Util::String& actorTemplateName ,Serialization::FileType& fileType); @@ -157,9 +164,9 @@ namespace App void RecursionUnLinkTemplate( const GPtr& pActor); //更新templatedactors - void UpdateTemplatedActors( GPtr& pActor ); + void UpdateTemplatedActors( GPtr& pActor , const ActorPropertySet& actorPropertySet); //迭代更新templatedactors - void RecursionUpdateTemplate(const GPtr& sourceActor,const GPtr& destActor, const Util::String& actorTemplateName); + void RecursionUpdateTemplate(const GPtr& sourceActor,const GPtr& destActor, const Util::String& actorTemplateName, const ActorPropertySet& actorPropertySet); bool GetTemplateActiveFlag(const Util::String& actorTemplateName, bool& bActiveFlag); @@ -179,6 +186,9 @@ namespace App // find active actor by Name Actor* FindActiveActorByName(const Util::String& name) const; + // find active actor by Model name + const Util::Array< GPtr > FindActiveActorByModelName(const Util::String& modelName) const; + // find actor index in active list IndexT FindActiveActorIndex(App::Actor::FastId fastID) const; diff --git a/Engine/app/appframework/actorserialization.cc b/Engine/app/appframework/actorserialization.cc index d3b9144..7416c10 100644 --- a/Engine/app/appframework/actorserialization.cc +++ b/Engine/app/appframework/actorserialization.cc @@ -72,6 +72,11 @@ namespace App Load_7(pReader); return; } + else if( 8 == ver) + { + Load_8(pReader); + return; + } n_error(" SceneSerialization::Load unknonw version " ); } @@ -82,6 +87,7 @@ namespace App void Load_5( AppReader* pReader ); void Load_6( AppReader* pReader); void Load_7( AppReader* pReader); + void Load_8( AppReader* pReader); void Save( AppWriter* pWriter ); protected: const Actor* mObject; @@ -104,6 +110,7 @@ namespace App const char* s_ActorResourcePriority = "ActorResourcePriority"; const char* s_ActorEditorStaticFlag = "ActorEditorStaticFlag"; const char* s_ActorVisable = "ActorVisable"; + const char* s_ActorModelName = "ActorModelName"; //------------------------------------------------------------------------ void ActorSerialization::Load_1(AppReader* pSerialize) { @@ -689,7 +696,7 @@ namespace App pSerialize->SerializeInt( s_ActorLayerID, pActor->GetLayerID() ); pSerialize->SerializeInt( s_ActorTagID, pActor->GetTagID() ); pSerialize->SerializeInt( s_ActorEditorStaticFlag, pActor->GetEditorFlag() ); - pSerialize->SerializeBool( s_ActorVisable, pActor->GetVisible() ); + pSerialize->SerializeBool( s_ActorVisable, true ); pSerialize->SerializeFloat4( s_ActorPosition, pActor->mLocalPosition); Math::quaternion qRot = pActor->GetRotation(); @@ -733,7 +740,20 @@ namespace App { // do nothing. we can deSerialization from actor template } + + pSerialize->SerializeString(s_ActorModelName, pActor->GetModelName()); } + + void ActorSerialization::Load_8(AppReader* pReader) + { + Load_7(pReader); + + Actor* pActor = const_cast( mObject ); + Util::String modelName; + pReader->SerializeString( s_ActorModelName, modelName ); + pActor->SetModelName( modelName ); + } + } namespace App @@ -742,7 +762,7 @@ namespace App // @ISerialization::GetVersion. when change storage, must add SerializeVersion count Version Actor::GetVersion() const { - return 7; //当前版本号为7 + return 8; //当前版本号为8 } //------------------------------------------------------------------------ diff --git a/Engine/app/appframework/gameapplication.cc b/Engine/app/appframework/gameapplication.cc index 2443f99..d9c6510 100644 --- a/Engine/app/appframework/gameapplication.cc +++ b/Engine/app/appframework/gameapplication.cc @@ -100,6 +100,8 @@ GameApplication::GameApplication() , mQuit(false) , mDeviceState(DS_Normal) , m_pShaderFactory(NULL) + , mOpenSceneDirty(false) + , mCloseSceneDirty(false) { __ConstructThreadSingleton; _RegisterDynamicClass(); @@ -355,55 +357,75 @@ GameApplication::Run() #if __NEBULA3_HTTP__ this->mHttpServerProxy->HandlePendingRequests(); #endif - - - ////this->mCoreServer->Trigger(); - //trigger our game server, which triggers all game features - - switch (mDeviceState) - { - case DS_Lost: + if (mOpenSceneDirty) { - mGraphicsFeature->OnDeviceLost(); - mDeviceState = DS_Losted; + openScene(mOpenSceneName); + ActorManager::Instance()->ForceGC(); + mOpenSceneDirty = false; } - break; - case DS_Losted: + switch (mDeviceState) { - if (mGraphicsFeature->CheckReset()) + case DS_Lost: { - mDeviceState = DS_Reset; + mGraphicsFeature->OnDeviceLost(); + mDeviceState = DS_Losted; } - this->mCoreServer->Trigger(); - mGameServer->OnFrameWithoutGraphics(); + break; + case DS_Losted: + { + if (mGraphicsFeature->CheckReset()) + { + mDeviceState = DS_Reset; + } + this->mCoreServer->Trigger(); + mGameServer->OnFrameWithoutGraphics(); + } + break; + case DS_Reset: + { + mGraphicsFeature->OnDeviceReset(); + mDeviceState = DS_Normal; + } + break; + case DS_Normal: + { + this->mCoreServer->Trigger(); + mGameServer->OnFrame(); + } + break; + default: + break; } - break; - case DS_Reset: + if (mCloseSceneDirty) { - mGraphicsFeature->OnDeviceReset(); - mDeviceState = DS_Normal; + closeScene(mCloseSceneName); + ActorManager::Instance()->ForceGC(); + mCloseSceneDirty = false; } - break; - case DS_Normal: - { - this->mCoreServer->Trigger(); - mGameServer->OnFrame(); - } - break; - default: - break; - } - PROFILE_PRESENT(); } //------------------------------------------------------------------------------ -bool GameApplication::OpenScene(const Util::String& sSceneName, bool create) +bool GameApplication::OpenScene(const Util::String& sceneName, bool force) { n_assert(IsOpen()); + if (force) + { + return openScene(sceneName); + } + else + { + mOpenSceneName = sceneName; + mOpenSceneDirty = true; + return true; + } +} + +bool GameApplication::openScene(const Util::String& sceneName) +{ App::SceneScheduleManager* pSceneSchedule = App::SceneScheduleManager::Instance(); - return pSceneSchedule->OpenScene(sSceneName, create); + return pSceneSchedule->OpenScene(sceneName, false); } //------------------------------------------------------------------------------ void GameApplication::OnStopped() @@ -456,18 +478,27 @@ const GPtr& GameApplication::GetCurrentScene() const } //------------------------------------------------------------------------------ -bool GameApplication::CloseScene(const Util::String& sSceneName) +bool GameApplication::closeScene(const Util::String& sceneName) { - //现在只支持单场景。 App::SceneScheduleManager* pSceneSchedule = App::SceneScheduleManager::Instance(); - if(sSceneName == pSceneSchedule->GetMainScene()->GetName()) + return pSceneSchedule->CloseScene(sceneName); +} + +bool GameApplication::CloseScene( const Util::String& sceneName, bool force ) +{ + n_assert(IsOpen()); + if (force) { - CloseAllScenes(); + return closeScene(sceneName); + } + else + { + mCloseSceneName = sceneName; + mCloseSceneDirty = true; return true; } - return false; - } + //------------------------------------------------------------------------ void GameApplication::CloseAllScenes() { diff --git a/Engine/app/appframework/gameapplication.h b/Engine/app/appframework/gameapplication.h index 8dc09ed..3f604c3 100644 --- a/Engine/app/appframework/gameapplication.h +++ b/Engine/app/appframework/gameapplication.h @@ -95,9 +95,10 @@ public: virtual bool IsQuit(); /// open a scence - virtual bool OpenScene(const Util::String& sSceneName, bool create = false); + virtual bool OpenScene(const Util::String& sceneName, bool force = true); /// close a scence - virtual bool CloseScene(const Util::String& sSceneName); + virtual bool CloseScene(const Util::String& sceneName, bool force = true); + /// called when the game stopped virtual void OnStopped(); /// called when the game resumed @@ -180,6 +181,8 @@ protected: void exitGui(); + bool openScene(const Util::String& sceneName); + bool closeScene(const Util::String& sceneName); /// loading scene logo virtual void displayLOGO(); @@ -248,6 +251,11 @@ protected: Util::String mFileServicePath; //Packet Pipe Util::String mPipeName; + + Util::String mOpenSceneName; + + Util::String mCloseSceneName; + ////是否使用本地资源 bool mUseLocalRes; //是否调试脚本 @@ -258,6 +266,8 @@ protected: bool mbUseFileService; bool mQuit; bool mUseWeb; + bool mOpenSceneDirty; + bool mCloseSceneDirty; void* mWinHandle; IO::AssignRegistry* mAssignRegistry; diff --git a/Engine/app/appframework/profiletool.cc b/Engine/app/appframework/profiletool.cc index 70c0902..c19e803 100644 --- a/Engine/app/appframework/profiletool.cc +++ b/Engine/app/appframework/profiletool.cc @@ -246,7 +246,7 @@ namespace App mStatTexts[Stat_Explain].textID = mgr->AppendDrawText(0, 0,"Control: F9", mStatVisArray[SV_Base]); #endif - mStatTexts[Stat_Fps].textID = mgr->AppendDrawText(0, 0,"Fps:", mStatVisArray[SV_Base]); + mStatTexts[Stat_Fps].textID = mgr->AppendDrawText(0, 0,"FPS:", mStatVisArray[SV_Base]); mStatTexts[Stat_Triangles].textID = mgr->AppendDrawText(0, 0,"Triangles:", mStatVisArray[SV_Base]); mStatTexts[Stat_Vertices].textID = mgr->AppendDrawText(0, 0,"Vertices:", mStatVisArray[SV_Base]); diff --git a/Engine/app/appframework/scene.cc b/Engine/app/appframework/scene.cc index 50886ae..0b2453b 100644 --- a/Engine/app/appframework/scene.cc +++ b/Engine/app/appframework/scene.cc @@ -36,7 +36,7 @@ namespace App RootActor::RootActor() :mScene(NULL) { - mName.Format("__scene_name_%d",(int)this); + mName.Format("__scene_name_%d",(intptr_t)this); SetTagID(0xffffffff); } @@ -103,7 +103,8 @@ namespace App if(apply) { PhysicsServer::Instance()->SetGravity(mEnvironment.graivty); - PhysicsServer::Instance()->SetSleepThreshold(mEnvironment.sleepVel); + //屏蔽睡眠动量 + //PhysicsServer::Instance()->SetSleepThreshold(mEnvironment.sleepVel); PhysicsServer::Instance()->SetMaxAngularVelocity(mEnvironment.maxAngular); PhysicsServer::Instance()->SetDefaultMaterial(mEnvironment.defaultMat); if(mEnvironment.layerIDArray.Size() == 32) @@ -173,13 +174,17 @@ namespace App void Scene::AddActor( GPtr& pActor ) { - //当导入角色动画等原本就有层级结构的Actor时,就不能把他们挂在最顶层的mRoot上 - if (pActor->GetParent()) + if (pActor.isvalid()) { - return; + //当导入角色动画等原本就有层级结构的Actor时,就不能把他们挂在最顶层的mRoot上 + if (pActor->GetParent()) + { + return; + } + n_assert( mRoot.isvalid() ); + mRoot->AddChild( pActor ); } - n_assert( mRoot.isvalid() ); - mRoot->AddChild( pActor ); + } //------------------------------------------------------------------------ void @@ -208,6 +213,7 @@ namespace App } mRoot = RootActor::Create(); + mRoot->SetLayerID(App::eSL_Assist); mRoot->SetScene(this); mRoot->Active(false); } diff --git a/Engine/app/appframework/sceneserialization.cc b/Engine/app/appframework/sceneserialization.cc index f7b35bc..e0d87d4 100644 --- a/Engine/app/appframework/sceneserialization.cc +++ b/Engine/app/appframework/sceneserialization.cc @@ -29,7 +29,7 @@ THE SOFTWARE. #include "physXfeature/physicsCore/PhysicsServer.h" #include "graphicsystem/GraphicObjectManager.h" #include "Material/MaterialManager.h" -#include "lightmap/lightmapSetting.h" +#include "Lightmap/lightmapSetting.h" #include "addons/shadercompiler/ShadercompilerConfig.h" namespace App @@ -519,11 +519,11 @@ namespace App } //// 没找到合适的地方,先放这儿了 - GPtr& manager = GraphicObjectManager::Instance()->GetMaterialInstanceManager(); + /*GPtr& manager = GraphicObjectManager::Instance()->GetMaterialInstanceManager(); if ( manager ) { - manager->SaveMaterial(); - } + manager->SaveMaterial(); + }*/ } diff --git a/Engine/app/basegamefeature/managers/sceneschedulemanager.cc b/Engine/app/basegamefeature/managers/sceneschedulemanager.cc index 30a7542..dd9a04e 100644 --- a/Engine/app/basegamefeature/managers/sceneschedulemanager.cc +++ b/Engine/app/basegamefeature/managers/sceneschedulemanager.cc @@ -30,7 +30,7 @@ THE SOFTWARE. #include "serialization/serializeserver.h" #include "vegetationfeature/vegetationfeature.h" #include "appframework/actormanager.h" -#include "lightmap/lightmapSetting.h" +#include "Lightmap/lightmapSetting.h" #include "profilesystem/ProfileSystem.h" namespace App @@ -246,7 +246,7 @@ namespace App { mMainScene = NULL; } - mScenesDelayDel.Append(*it); + mScenesDelayDel.Append(*it);//只为了拿着智能指针的引用,防止触发析构,析构应该在下一帧再开始。 mScenes.Erase(it); return true; } diff --git a/Engine/app/basegamefeature/managers/timesource.cc b/Engine/app/basegamefeature/managers/timesource.cc index da9ca8d..8f2e7f6 100644 --- a/Engine/app/basegamefeature/managers/timesource.cc +++ b/Engine/app/basegamefeature/managers/timesource.cc @@ -33,7 +33,7 @@ __ImplementClass(GameTime,'GTSG',App::TimeSource); __ImplementImageSingleton(GameTime); using namespace Timing; -#define WRAPTIME 100.0f +#define WRAPTIME 5.0f //------------------------------------------------------------------------ GameTime::GameTime() { @@ -102,7 +102,7 @@ TimeSource::UpdateTime(Time frameTime) if (this->mWrapTime > WRAPTIME) { - this->mWrapTime -= WRAPTIME; + this->mWrapTime = 0.0f; } } } diff --git a/Engine/app/graphicfeature/components/animationcomponent.cc b/Engine/app/graphicfeature/components/animationcomponent.cc index 269c4c3..dd42dd2 100644 --- a/Engine/app/graphicfeature/components/animationcomponent.cc +++ b/Engine/app/graphicfeature/components/animationcomponent.cc @@ -240,12 +240,12 @@ namespace App int keyValuePairIndex_Anim = m_UsedBonesIndex.FindIndex(m_CurrentAnimName); int keyValuePairIndex_Actor = 0;; - if(keyValuePairIndex_Anim != -1) + if(keyValuePairIndex_Anim != InvalidIndex) { keyValuePairIndex_Actor = m_UsedBonesIndex[m_CurrentAnimName].FindIndex(pActor); } - if(keyValuePairIndex_Actor == -1 || keyValuePairIndex_Anim == -1) + if(keyValuePairIndex_Actor == InvalidIndex || keyValuePairIndex_Anim == InvalidIndex) { bool ret = true; for (IndexT iClip = 0; iClip < m_Animation->GetAnimClipCount(); ++iClip) @@ -253,6 +253,13 @@ namespace App ret &= FindUsedBones(m_Animation->GetAnimClips()[iClip], NULL, pActor); } + IndexT animIndex = m_UsedBonesIndex.FindIndex(m_CurrentAnimName); + if( InvalidIndex == animIndex ) + return false; + IndexT actorIndex = m_UsedBonesIndex[m_CurrentAnimName].FindIndex(pActor); + if( InvalidIndex == actorIndex ) + return false; + return ret; } @@ -287,31 +294,39 @@ namespace App } } - float GetRatioInView(Math::vector objWorldPos, Math::bbox box) + float GetRatioInView(Math::vector objWorldPos, Math::bbox box, const App::Actor* actor) { Math::float4 boxSizeVec = box.pmax - box.pmin; float boxSize = boxSizeVec.x()*boxSizeVec.x()+boxSizeVec.y()*boxSizeVec.y()+boxSizeVec.z()*boxSizeVec.z(); float minViewSize = 400000000; - const Graphic::RenderSceneList& sceneList = Graphic::GraphicSystem::Instance()->GetRenderSceneList(); - for(IndexT i = 0; i < sceneList.Size() ; i++) + + if(!actor) { - const Graphic::RenderScene::CameraList& cameraList = sceneList[i]->GetCameraList(); - for(IndexT cameraIndex = 0; cameraIndex < cameraList.Size(); cameraIndex++) + return boxSize/minViewSize; + } + + const Graphic::RenderScene* renderScene = actor->GetRenderScene(); + if(!renderScene) + { + return boxSize/minViewSize; + } + + const Graphic::RenderScene::CameraList& cameraList = renderScene->GetCameraList(); + for(IndexT cameraIndex = 0; cameraIndex < cameraList.Size(); cameraIndex++) + { + if(cameraList[cameraIndex]) { - if(cameraList[cameraIndex]) - { - Math::vector cameraLocalPos = cameraList[cameraIndex]->GetTransform().get_position() - objWorldPos; - float dis = cameraLocalPos.x()*cameraLocalPos.x()+cameraLocalPos.y()*cameraLocalPos.y()+cameraLocalPos.z()*cameraLocalPos.z(); + Math::vector cameraLocalPos = cameraList[cameraIndex]->GetTransform().get_position() - objWorldPos; + float dis = cameraLocalPos.x()*cameraLocalPos.x()+cameraLocalPos.y()*cameraLocalPos.y()+cameraLocalPos.z()*cameraLocalPos.z(); - float zNear = cameraList[cameraIndex]->GetCameraSetting().GetZNear(); - float zFar = cameraList[cameraIndex]->GetCameraSetting().GetZFar(); - float farWidth = cameraList[cameraIndex]->GetCameraSetting().GetFarWidth(); - float farHeight = cameraList[cameraIndex]->GetCameraSetting().GetFarHeight(); - float viewSize = dis/((zFar-zNear)*(zFar-zNear))*(farWidth*farWidth + farHeight*farHeight); + float zNear = cameraList[cameraIndex]->GetCameraSetting().GetZNear(); + float zFar = cameraList[cameraIndex]->GetCameraSetting().GetZFar(); + float farWidth = cameraList[cameraIndex]->GetCameraSetting().GetFarWidth(); + float farHeight = cameraList[cameraIndex]->GetCameraSetting().GetFarHeight(); + float viewSize = dis/((zFar-zNear)*(zFar-zNear))*(farWidth*farWidth + farHeight*farHeight); - minViewSize = Math::n_min(viewSize,minViewSize); - } + minViewSize = Math::n_min(viewSize,minViewSize); } } @@ -433,15 +448,15 @@ namespace App //Use bbox size and camera distance to change animation's update rate bool bNeedLimitRate = true; -//#ifdef __GENESIS_EDITOR__ // edtior didn`t use +#ifdef __GENESIS_EDITOR__ // edtior didn`t use bNeedLimitRate = false; -//#endif +#endif if(!bNeedLimitRate) return; Math::bbox box = mActor->GetWorldBoundingBoxWithChild(); - float ratioInView = GetRatioInView(mActor->GetWorldPosition(), box); + float ratioInView = GetRatioInView(mActor->GetWorldPosition(), box, mActor); float MINTIME = 0.033f; float MAXTIME = 0.33f; @@ -542,8 +557,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return false; } @@ -686,8 +699,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return; } @@ -742,8 +753,6 @@ namespace App { n_warning("there is no '%s' animation! \n", animName.Value()); - m_bHasAnyErrors = true; - return; } @@ -898,8 +907,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return false; } } @@ -942,8 +949,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return false; } } @@ -1074,8 +1079,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return false; } } @@ -1156,8 +1159,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return false; } } @@ -1202,8 +1203,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return false; } } @@ -1246,8 +1245,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return; } } @@ -1320,8 +1317,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return; } } @@ -1363,8 +1358,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return; } } @@ -1454,8 +1447,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return; } } @@ -1499,8 +1490,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return; } } @@ -1566,8 +1555,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return; } } @@ -1609,8 +1596,6 @@ namespace App { n_warning("there is no '%s' animation! \n", name.Value()); - m_bHasAnyErrors = true; - return; } } @@ -1956,6 +1941,9 @@ namespace App } this->SetDefaultAnimName(pSource->GetDefaultAnimName()); + + Util::Array< GPtr > skelTree = pSource->GetSkelTreeData(); + this->SetSkelTree(skelTree); } bool AnimationComponent::IsAllResourceLoaded() @@ -2099,8 +2087,16 @@ namespace App if (index != InvalidIndex) { - usedboneIndex.Add(iNode, index); - SkelPairs.Erase(index); + + if(SkelPairs.Contains(index)) + { + usedboneIndex.Add(iNode, index); + SkelPairs.Erase(index); + } + else + { + n_warning("Skeleton has error, may contains duplicate name"); + } } } diff --git a/Engine/app/graphicfeature/components/cameracomponent.cc b/Engine/app/graphicfeature/components/cameracomponent.cc index efec2b3..4825088 100644 --- a/Engine/app/graphicfeature/components/cameracomponent.cc +++ b/Engine/app/graphicfeature/components/cameracomponent.cc @@ -393,7 +393,7 @@ void CameraComponent::SetUseSkyBox(bool useSkyBox) { if (m_camera.isvalid()) { - return m_camera->HasDepthMap(); + return m_camera->IsRenderDepthMap(); } return false; } diff --git a/Engine/app/graphicfeature/components/cameracomponent.h b/Engine/app/graphicfeature/components/cameracomponent.h index 9ef0895..356b6d9 100644 --- a/Engine/app/graphicfeature/components/cameracomponent.h +++ b/Engine/app/graphicfeature/components/cameracomponent.h @@ -174,6 +174,12 @@ public: bool GetRenderShadowMap() const; +#if __GENESIS_EDITOR__ + void SetCameraTarget(const Graphic::Camera::CameraTarget bTarget); + + Graphic::Camera::CameraTarget GetCameraTarget() const; +#endif + protected: friend class CameraComponentSerialization; @@ -450,6 +456,21 @@ CameraComponent::SetLightLitTexture(const GPtr& rtt) m_camera->SetLightLitMap(rtt); } +#if __GENESIS_EDITOR__ +inline void CameraComponent::SetCameraTarget(const Graphic::Camera::CameraTarget bTarget) +{ + m_camera->SetCameraTarget(bTarget); +} + +inline Graphic::Camera::CameraTarget CameraComponent::GetCameraTarget() const +{ + return m_camera->GetCameraTarget(); +} + +#endif + }; // namespace GraphicsFeature //------------------------------------------------------------------------------ + + #endif //__CAMERACOMPONENT_H__ diff --git a/Engine/app/graphicfeature/components/locatercomponent.cc b/Engine/app/graphicfeature/components/locatercomponent.cc index 9bac61c..293d49d 100644 --- a/Engine/app/graphicfeature/components/locatercomponent.cc +++ b/Engine/app/graphicfeature/components/locatercomponent.cc @@ -80,6 +80,19 @@ namespace App { Super::_OnBeginFrame(); + + } + + + void LocaterComponent::_OnFrame() + { + Super::_OnFrame(); + } + + void LocaterComponent::_OnEndFrame() + { + Super::_OnEndFrame(); + GPtr parentActor = mActor->GetParent(); if(!parentActor.isvalid()) @@ -109,6 +122,15 @@ namespace App mAttachedSkelIndex = animationComponent->GetNodeIndex(mAttachedSkelName); } + //If both name and index cannot find, just return + if( mAttachedSkelIndex == InvalidIndex) + { + Math::matrix44 tempNodeTrans = Math::matrix44::identity(); + bool ret = animationComponent->GetNodeTransform(mAttachedSkelName, tempNodeTrans); + if(!ret) + return; + } + if(m_bNeedSetup) { mLastAnimTrans = Math::matrix44::identity(); @@ -130,7 +152,7 @@ namespace App Math::matrix44 actorTrans = mActor->GetTransform(); - if(!firstLoaded) + if(!firstLoaded && !animationComponent->IsAnyAnimationPlaying()) { Math::matrix44 NodeTransInv = Math::matrix44::inverse(mLastAnimTrans); mRelativeTrans = Math::matrix44::multiply(NodeTransInv,actorTrans); @@ -143,17 +165,7 @@ namespace App mLastAnimTrans = NodeTrans; } - } - - void LocaterComponent::_OnFrame() - { - Super::_OnFrame(); - } - - void LocaterComponent::_OnEndFrame() - { - Super::_OnEndFrame(); } void LocaterComponent::SetupLocater() diff --git a/Engine/app/graphicfeature/components/mesh2drendercomponent.cc b/Engine/app/graphicfeature/components/mesh2drendercomponent.cc index e41bb34..09936be 100644 --- a/Engine/app/graphicfeature/components/mesh2drendercomponent.cc +++ b/Engine/app/graphicfeature/components/mesh2drendercomponent.cc @@ -157,8 +157,9 @@ namespace App } void Mesh2dRenderComponent::OnActivate() - { - if (mVisible) + { + + if (mVisible) { _AttachRenderObject(); }; @@ -168,7 +169,8 @@ namespace App void Mesh2dRenderComponent::OnDeactivate() { - if (IsActive() && mVisible) + + if (IsActive() && mVisible) { _DeattachRenderObject(); } @@ -177,6 +179,10 @@ namespace App void Mesh2dRenderComponent::SetVisible(bool bVis) { + if ( bVis == mVisible ) + { + return; + } mVisible = bVis; if (IsActive()) { @@ -190,13 +196,29 @@ namespace App } } } + +#ifdef __GENESIS_EDITOR__ + void Mesh2dRenderComponent::SetEditorVisible(bool bVis) + { + Super::SetEditorVisible(bVis); + if (IsActive()) + { + mScreenObject->SetEditorVisible(bVis); + + } + } +#endif + void Mesh2dRenderComponent::SetTargetCamera(CameraComponent* camera) { - if (IsActive() && mVisible) + + if (IsActive() && mVisible) { _DeattachRenderObject(); } mTargetCamera = camera;//必须在中间 + + if (IsActive() && mVisible) { _AttachRenderObject(); @@ -333,7 +355,8 @@ namespace App void Mesh2dRenderComponent::OnDestroy() { - if (IsActive() && mVisible) + + if (IsActive() && mVisible) { _DeattachRenderObject(); } @@ -427,7 +450,8 @@ namespace App } mMeshType = meshInfo.mMeshType; SetMaterialByShaderID(0, sDefaultShaderID, false); - if (IsActive() && mVisible) + + if (IsActive() && mVisible) { _DeattachRenderObject(); } @@ -454,7 +478,8 @@ namespace App //SetShaderID(0, sDefaultShaderID); n_assert( GraphicSystem::HasInstance() ); - if (IsActive() && mVisible) + + if (IsActive() && mVisible) { _DeattachRenderObject(); } diff --git a/Engine/app/graphicfeature/components/mesh2drendercomponent.h b/Engine/app/graphicfeature/components/mesh2drendercomponent.h index 30828b5..2040e61 100644 --- a/Engine/app/graphicfeature/components/mesh2drendercomponent.h +++ b/Engine/app/graphicfeature/components/mesh2drendercomponent.h @@ -264,6 +264,10 @@ namespace App //************************************ static void SetActorTransform(GPtr& actor, const Math::float2& pos, const Math::float3& scales, const Math::float4& axis, float angle); +#ifdef __GENESIS_EDITOR__ + virtual void SetEditorVisible(bool bVis); +#endif + protected: /// @Component::OnActivate called from Actor::ActivateComponents() diff --git a/Engine/app/graphicfeature/components/meshrendercomponent.cc b/Engine/app/graphicfeature/components/meshrendercomponent.cc index bbd4b00..2510b67 100644 --- a/Engine/app/graphicfeature/components/meshrendercomponent.cc +++ b/Engine/app/graphicfeature/components/meshrendercomponent.cc @@ -75,6 +75,7 @@ namespace App } else { + if (!mMeshLoading && mVisible) { _AttachRenderObject(); @@ -93,7 +94,8 @@ namespace App //------------------------------------------------------------------------ void MeshRenderComponent::OnDeactivate() { - if (IsActive() && mVisible) + + if (IsActive() && mVisible) { _DeattachRenderObject(); } @@ -192,6 +194,10 @@ namespace App void MeshRenderComponent::SetVisible(bool bVis) { + if ( bVis == mVisible ) + { + return; + } Super::SetVisible(bVis); if (IsActive()) { @@ -205,6 +211,22 @@ namespace App } } } +#ifdef __GENESIS_EDITOR__ + void MeshRenderComponent::SetEditorVisible(bool bVis) + { + Super::SetEditorVisible(bVis); + + if (IsActive()) + { + if (mRenderObject.isvalid()) + { + mRenderObject->SetEditorVisible(bVis); + + } + } + + } +#endif void MeshRenderComponent::_AttachRenderObject() { if (mRenderObject.isvalid()) @@ -234,7 +256,9 @@ namespace App void MeshRenderComponent::_OnMeshDirty(bool bDeleteRenderObject) { + if (bDeleteRenderObject || (IsActive() && mVisible) ) + { _DeattachRenderObject(); } @@ -257,9 +281,16 @@ namespace App mActor->_UpdateLocalBBox(); //mActor->SetLocalBoundingBox(mPrimitiveResInfo->GetRes().downcast()->GetBoundingBox()); _BuildRenderRes(); + if ( IsActive() && mVisible) { _AttachRenderObject(); +#ifdef __GENESIS_EDITOR__ + if ( mRenderObject.isvalid() ) + { + mRenderObject->SetEditorVisible(m_bEidtorVis); + } +#endif } mPrimitive = mPrimitiveResInfo->GetHandle(); mMeshLoading = false; diff --git a/Engine/app/graphicfeature/components/meshrendercomponent.h b/Engine/app/graphicfeature/components/meshrendercomponent.h index 5561fce..160fa14 100644 --- a/Engine/app/graphicfeature/components/meshrendercomponent.h +++ b/Engine/app/graphicfeature/components/meshrendercomponent.h @@ -125,6 +125,12 @@ namespace App virtual void SetReceiveShadow( bool bReceiveShadow ); virtual bool GetReceiveShadow(); + +#ifdef __GENESIS_EDITOR__ + virtual void SetEditorVisible(bool bVis); +#endif + + protected: typedef MeshRenderObject RenderObjectType; typedef GPtr MeshRenderObjectPtr; @@ -194,6 +200,7 @@ namespace App bool m_bUsedForResHotLoad; Util::Dictionary mDeattachedMatList; + }; inline diff --git a/Engine/app/graphicfeature/components/projectorcomponent.cc b/Engine/app/graphicfeature/components/projectorcomponent.cc index 501d539..6c98bcb 100644 --- a/Engine/app/graphicfeature/components/projectorcomponent.cc +++ b/Engine/app/graphicfeature/components/projectorcomponent.cc @@ -211,7 +211,7 @@ void ProjectorRenderComponent::_UpdateProjector() GPtr renderObj = renderObjs[i]; // skip the subRenderObject such as axis_X etc - if ( renderObj->GetLayerID() == eSL_Debug ) + if ( renderObj->GetLayerID() == eSL_Assist ) continue; GPtr meshRenderObj = renderObj.downcast(); diff --git a/Engine/app/graphicfeature/components/rendercomponent.cc b/Engine/app/graphicfeature/components/rendercomponent.cc index ff2621f..7dab527 100644 --- a/Engine/app/graphicfeature/components/rendercomponent.cc +++ b/Engine/app/graphicfeature/components/rendercomponent.cc @@ -49,6 +49,9 @@ namespace App ,m_bAllTexLoaded(true) ,mVisible(true) ,m_bShaderMask(true) +#ifdef __GENESIS_EDITOR__ + ,m_bEidtorVis(true) +#endif { //empty } @@ -594,7 +597,12 @@ namespace App //-------------------------------------------------------------------------------- void RenderComponent::SetVisible( bool bVisible) { + if ( bVisible == mVisible ) + { + return ; + } mVisible = bVisible; + } //------------------------------------------------------------------------------ bool RenderComponent::GetVisible() @@ -809,5 +817,15 @@ namespace App } Super::GetReferenceResourceId(list); } - + //------------------------------------------------------------------------ +#ifdef __GENESIS_EDITOR__ + void RenderComponent::SetEditorVisible(bool bVis) + { + m_bEidtorVis = bVis; + } + bool RenderComponent::IsEditorVisible() + { + return m_bEidtorVis; + } +#endif } diff --git a/Engine/app/graphicfeature/components/rendercomponent.h b/Engine/app/graphicfeature/components/rendercomponent.h index 4eff280..2ccbddf 100644 --- a/Engine/app/graphicfeature/components/rendercomponent.h +++ b/Engine/app/graphicfeature/components/rendercomponent.h @@ -199,6 +199,12 @@ namespace App /// modify shader parameters void _AddTextureParam( IndexT iSubMesh, const ShaderParamString& paramName, const Resources::ResourceId& _texID, Resources::Priority priority = Resources::ResourcePriority::TextureDefault); void _ClearTextureParam( IndexT iSubMesh ); + +#ifdef __GENESIS_EDITOR__ + virtual void SetEditorVisible(bool bVis); + virtual bool IsEditorVisible(); +#endif + protected: friend class RenderComponentSerialization; /// get shader constant param value,used for serialization @@ -258,6 +264,11 @@ namespace App bool mVisible; bool m_bShaderMask; + +#ifdef __GENESIS_EDITOR__ + bool m_bEidtorVis; +#endif + }; //--------------------------------------------------------------------------- inline bool RenderComponent::IsAllTexLoaded() diff --git a/Engine/app/graphicfeature/components/screenmeshrenderobject.cc b/Engine/app/graphicfeature/components/screenmeshrenderobject.cc index 407242a..555ec3a 100644 --- a/Engine/app/graphicfeature/components/screenmeshrenderobject.cc +++ b/Engine/app/graphicfeature/components/screenmeshrenderobject.cc @@ -40,6 +40,10 @@ namespace App } void ScreenMeshRenderObject::Render(const Renderable* renderable, RenderPassType passType, const Material* customizedMaterial) { +#ifdef __GENESIS_EDITOR__ + if (!IsEditorVisible()) + return; +#endif n_assert(renderable); Mesh2dRenderComponent* mesh2dRC = getOwner(); diff --git a/Engine/app/graphicfeature/components/simpleskycomponent.cc b/Engine/app/graphicfeature/components/simpleskycomponent.cc index 2f87afe..a0b1c62 100644 --- a/Engine/app/graphicfeature/components/simpleskycomponent.cc +++ b/Engine/app/graphicfeature/components/simpleskycomponent.cc @@ -25,6 +25,7 @@ THE SOFTWARE. #include "simpleskycomponent.h" #include "appframework/actor.h" #include "resource/meshres.h" +#include "graphicsystem/Material/materialinstance.h" namespace App { @@ -36,7 +37,9 @@ SimpleSkyComponent::SimpleSkyComponent(): m_skyTex2(NULL), m_skyTex3(NULL), m_skyTex4(NULL), - m_skyTex5(NULL) + m_skyTex5(NULL), + m_skyFogLowest(0.0f), + m_skyFogHighest(0.5f) { } @@ -119,12 +122,17 @@ void SimpleSkyComponent::updateScale( Graphic::Camera* camera ) float nw = camera->GetCameraSetting().GetNearWidth(); float nz = camera->GetCameraSetting().GetZNear(); - - float scale = Math::n_max(nh,nw); - scale = Math::n_max(nz,scale)/75; - mActor->SetScale(Math::vector(scale,scale,scale)); + scale = Math::n_max(nz,scale)/50; + Math::matrix44 _mscale; + _mscale.scale(Math::float4(scale,scale,scale,1.0f)); + Math::matrix44 trans = camera->GetCameraSetting().GetViewTransform(); + trans.set_position(Math::float4(0.0f,0.0f,0.0f,1.0f)); + Math::matrix44 rot = Math::matrix44::rotationx(-90); + trans = Math::matrix44::multiply(trans,rot); + trans = Math::matrix44::multiply(trans,_mscale); + mActor->SetTransform(trans); } //----------------------------------------------------------------- @@ -134,27 +142,27 @@ void SimpleSkyComponent:: SetSkyTexByNum( int num, Util::String& tex ) { case 0: m_skyTex0 = tex; - SetTexture(0, "_diffuseMap", m_skyTex0);//, 0);// + SetTexture(0, "_diffuseMap", m_skyTex0); break; case 1: m_skyTex1 = tex; - SetTexture(1, "_diffuseMap", m_skyTex1);//, 0); + SetTexture(1, "_diffuseMap", m_skyTex1); break; case 2: m_skyTex2 = tex; - SetTexture(2, "_diffuseMap", m_skyTex2);//, 0); + SetTexture(2, "_diffuseMap", m_skyTex2); break; case 3: m_skyTex3 = tex; - SetTexture(3, "_diffuseMap", m_skyTex3);//, 0); + SetTexture(3, "_diffuseMap", m_skyTex3); break; case 4: m_skyTex4 = tex; - SetTexture(4, "_diffuseMap", m_skyTex4);//, 0); + SetTexture(4, "_diffuseMap", m_skyTex4); break; case 5: m_skyTex5 = tex; - SetTexture(5, "_diffuseMap", m_skyTex5);//, 0); + SetTexture(5, "_diffuseMap", m_skyTex5); break; default: break; @@ -190,6 +198,33 @@ const Util::String SimpleSkyComponent::GetSkyTexByNum( int num ) return temp; } //------------------------------------------------------------------------------ +float SimpleSkyComponent::GetSkyFogLowest() +{ + return m_skyFogLowest; +} +float SimpleSkyComponent::GetSkyFogHighest() +{ + return m_skyFogHighest; +} +void SimpleSkyComponent::SetSkyFogLowest(IndexT iSubMesh, const ShaderParamString& paramName,float low) +{ + m_skyFogLowest = low; + GPtr& mat = GetMaterial(iSubMesh); + if ( mat ) + { + mat->SetConstantParam(paramName,low); + } +} +void SimpleSkyComponent::SetSkyFogHighest(IndexT iSubMesh, const ShaderParamString& paramName,float high) +{ + m_skyFogHighest = high; + GPtr& mat = GetMaterial(iSubMesh); + if ( mat ) + { + mat->SetConstantParam(paramName,high); + } +} +//------------------------------------------------------------------------------ void SimpleSkyComponent::SetMaterialID( IndexT iSubMesh, const Resources::ResourceId& matID,const bool bCopy/* = false*/,Resources::Priority p ) { //skybox's setmaterial should be null @@ -198,7 +233,6 @@ void SimpleSkyComponent::SetMaterialID( IndexT iSubMesh, const Resources::Resour //------------------------------------------------------------------------------ void SimpleSkyComponent::GetReferenceResourceId(Util::Array& list) const { - list.Append(Resources::ReferenceResource(mMeshInfo.meshID, Resources::RR_Unknown)); list.Append(Resources::ReferenceResource(m_skyTex0, Resources::RR_Texture)); diff --git a/Engine/app/graphicfeature/components/simpleskycomponent.h b/Engine/app/graphicfeature/components/simpleskycomponent.h index 12d4893..ba1c7c0 100644 --- a/Engine/app/graphicfeature/components/simpleskycomponent.h +++ b/Engine/app/graphicfeature/components/simpleskycomponent.h @@ -27,6 +27,7 @@ THE SOFTWARE. #include "meshrendercomponent.h" #include "graphicsystem/Camera/Camera.h" + namespace App { class SimpleSkyComponent : public App::MeshRenderComponent @@ -94,6 +95,10 @@ public: public: void SetSkyTexByNum( int num, Util::String& tex ); const Util::String GetSkyTexByNum( int num ); + float GetSkyFogLowest(); + float GetSkyFogHighest(); + void SetSkyFogLowest(IndexT iSubMesh, const ShaderParamString& paramName,float low); + void SetSkyFogHighest(IndexT iSubMesh, const ShaderParamString& paramName,float high); protected: Util::String m_skyTex0; Util::String m_skyTex1; @@ -101,6 +106,8 @@ protected: Util::String m_skyTex3; Util::String m_skyTex4; Util::String m_skyTex5; + float m_skyFogLowest; + float m_skyFogHighest; }; } diff --git a/Engine/app/graphicfeature/components/simpleskycomponentserialization.cc b/Engine/app/graphicfeature/components/simpleskycomponentserialization.cc index 388a880..243e7bc 100644 --- a/Engine/app/graphicfeature/components/simpleskycomponentserialization.cc +++ b/Engine/app/graphicfeature/components/simpleskycomponentserialization.cc @@ -48,12 +48,18 @@ namespace App Load_3(pReader); return; } + if (ver == 4) + { + Load_4(pReader); + return; + } n_error(" SimpleSkyComponentSerialization::Load unknown version " ); } void Load_2( AppReader* pReader ); void Load_3( AppReader* pReader ); + void Load_4( AppReader* pReader ); void Save( AppWriter* pWriter ); protected: @@ -66,6 +72,8 @@ namespace App const char* s_sky3 = "simpleSky3"; const char* s_sky4 = "simpleSky4"; const char* s_sky5 = "simpleSky5"; + const char* s_foglow = "skyfoglow"; + const char* s_foghigh = "skyfoghigh"; void SimpleSkyComponentSerialization::Load_2( AppReader* pReader ) { @@ -105,24 +113,45 @@ namespace App pReader->SerializeString( s_sky5, skyTex ); pSky->SetSkyTexByNum(5,skyTex); } + void SimpleSkyComponentSerialization::Load_4(AppReader* pReader) + { + n_assert( mObject ); + SimpleSkyComponent* pSky = const_cast(mObject); + n_assert(pSky); + + Load_3(pReader); + float low,high; + pReader->SerializeFloat(s_foglow,low); + pReader->SerializeFloat(s_foghigh,high); + for (int i = 0; i < 6; ++i) + { + pSky->SetSkyFogLowest(i,"_skyFogLow",low); + pSky->SetSkyFogHighest(i,"_skyFogHigh",high); + } + + } void SimpleSkyComponentSerialization::Save(App::AppWriter *pWriter) { n_assert(mObject); n_assert(pWriter); SimpleSkyComponent* pSky = const_cast(mObject); - //add by wangyanqing,2013.9.26 + //2013.9.26 pWriter->SerializeString( s_sky0, pSky->GetSkyTexByNum(0) ); pWriter->SerializeString( s_sky1, pSky->GetSkyTexByNum(1) ); pWriter->SerializeString( s_sky2, pSky->GetSkyTexByNum(2) ); pWriter->SerializeString( s_sky3, pSky->GetSkyTexByNum(3) ); pWriter->SerializeString( s_sky4, pSky->GetSkyTexByNum(4) ); pWriter->SerializeString( s_sky5, pSky->GetSkyTexByNum(5) ); + //2014.5.8 + pWriter->SerializeFloat( s_foglow, pSky->GetSkyFogLowest() ); + pWriter->SerializeFloat( s_foghigh, pSky->GetSkyFogHighest() ); } Version SimpleSkyComponent::GetVersion() const { //return 2; - return 3;//add by wangyanqing,2013.9.26 + //return 3; + return 4;//2014.5.8 } void SimpleSkyComponent::Load( Version ver, AppReader* pReader, const Serialization::SerializationArgs* args ) diff --git a/Engine/app/graphicfeature/components/skeletoncomponent.cpp b/Engine/app/graphicfeature/components/skeletoncomponent.cpp index bb1600f..232fec1 100644 --- a/Engine/app/graphicfeature/components/skeletoncomponent.cpp +++ b/Engine/app/graphicfeature/components/skeletoncomponent.cpp @@ -28,6 +28,7 @@ THE SOFTWARE. #include "graphicfeature/graphicsfeature.h" #include "graphicfeature/graphicsfeatureprotocol.h" #include "resource/resourceserver.h" +#include "serialization/serializeserver.h" namespace App { @@ -121,6 +122,90 @@ namespace App } +#ifdef __GENESIS_EDITOR__ + bool IsModelContainSkelInfo(const GPtr& rootActor, const Resources::ResourceId& skelId) + { + Util::String modelName = rootActor->GetModelName(); + + if(modelName == "") + return true; + + GPtr pStream = IO::MemoryStream::Create(); + n_assert( pStream ); + + GPtr readStreamMsg = IO::ReadStream::Create(); + n_assert( readStreamMsg ); + + IO::AssignRegistry* pAssignRegistry = IO::AssignRegistry::Instance(); + + IO::URI resolvedPath = pAssignRegistry->ResolveAssigns(modelName); + if(!resolvedPath.IsValid()) + return true; + + Util::String resPath = resolvedPath.LocalPath(); + + Serialization::SerializationServer* serialize = Serialization::SerializationServer::Instance(); + GPtr pReader = serialize->OpenReadFile( resPath,Serialization::FT_DEFAULT ); + if ( pReader ) + { + try + { + GPtr actor; + actor = pReader->SerializeObject(); + + if (!actor.isvalid()) + { + serialize->CloseReadFile(pReader); + return false; + } + + bool result = false; + // 临时代码:model文件里只有一个actor关节一个子actor + if (actor->GetChildCount() != 0) + { + for(int i=0; iGetChildCount(); i++) + { + GPtr targetActor = NULL; + targetActor = actor->GetChild(i); + if (!targetActor.isvalid()) + { + continue; + } + GPtr com = targetActor->FindComponent(SkeletonComponent::RTTI); + if (!com.isvalid()) + { + continue; + } + + GPtr skelCom = com.downcast(); + + const Resources::ResourceId& skelResId = skelCom->GetSkeletonID(); + + if(skelCom->GetSkeletonID() == skelId) + { + result = true; + break; + } + } + } + + actor->Deactive(true); + actor->Destory(true); + actor = NULL; + + serialize->CloseReadFile(pReader); + return result; + } + catch(...) + { + serialize->CloseReadFile(pReader); + } + } + + return false; + } +#endif + void SkeletonComponent::SetAnimSkelTree() { //Find animation data @@ -138,6 +223,15 @@ namespace App const GPtr& skeletonRes = GetSkeleton(); if (skeletonRes.isvalid() && !skeletonRes->IsSkelTreeEmpty()) { + +#ifdef __GENESIS_EDITOR__ + if(!IsModelContainSkelInfo(actorParent, GetSkeletonID())) + { + m_bSkeletonDirty = false; + return; + } +#endif + pAnimationCom->SetSkelTree(skeletonRes->GetSkelTree()); pAnimationCom->SetSkelTree(skeletonRes->GetSkelTreeArray()); diff --git a/Engine/app/graphicfeature/components/spritebaserendercomponent.cc b/Engine/app/graphicfeature/components/spritebaserendercomponent.cc index d922856..2d23d77 100644 --- a/Engine/app/graphicfeature/components/spritebaserendercomponent.cc +++ b/Engine/app/graphicfeature/components/spritebaserendercomponent.cc @@ -70,7 +70,8 @@ namespace App _BuildSimpleRenderObject(); } mRenderObject->SetTransform(mActor->GetWorldTransform()); - if (mVisible) + + if (mVisible) { _AttachRenderObject(); } @@ -138,6 +139,10 @@ namespace App void SpriteBaseRenderComponent::SetVisible(bool bVis) { + if ( bVis == mVisible ) + { + return; + } Super::SetVisible(bVis); if (IsActive()) { @@ -152,6 +157,17 @@ namespace App } } +#ifdef __GENESIS_EDITOR__ + void SpriteBaseRenderComponent::SetEditorVisible(bool bVis) + { + Super::SetEditorVisible(bVis); + if (IsActive()) + { + mRenderObject->SetEditorVisible(bVis); + + } + } +#endif void SpriteBaseRenderComponent::_AttachRenderObject() { diff --git a/Engine/app/graphicfeature/components/spritebaserendercomponent.h b/Engine/app/graphicfeature/components/spritebaserendercomponent.h index ac110a0..a677060 100644 --- a/Engine/app/graphicfeature/components/spritebaserendercomponent.h +++ b/Engine/app/graphicfeature/components/spritebaserendercomponent.h @@ -81,6 +81,10 @@ namespace App bool Intersect(const Math::Ray& worldRay, Math::scalar& fout, Math::scalar fTolerance = N_TINY); +#ifdef __GENESIS_EDITOR__ + virtual void SetEditorVisible(bool bVis); +#endif + protected: /// @Component::OnActivate called from Actor::ActivateComponents() virtual void OnActivate(); diff --git a/Engine/app/graphicfeature/graphicsfeature.cc b/Engine/app/graphicfeature/graphicsfeature.cc index 2532a91..bd5a209 100644 --- a/Engine/app/graphicfeature/graphicsfeature.cc +++ b/Engine/app/graphicfeature/graphicsfeature.cc @@ -207,30 +207,12 @@ namespace App Camera* camera = mGraphicSystem->GetSceneDefaultCamera(); if(camera) { - CameraComponent* cc = static_cast(camera->GetOwner()); + CameraComponent* cc = dynamic_cast(camera->GetOwner()); if (cc) { return GPtr(cc->GetActor()); } } - - /*const Graphic::CameraList& list = mGraphicSystem->GetCameraList(); - for (SizeT i = list.Size() - 1; i >= 0; --i) - { - Camera* camera = list[i]; - if (camera && (NULL == camera->GetTargetWindow() || Graphic::VPT_MAIN == camera->GetTargetWindow()->GetType())) - { - CameraComponent* cc = static_cast(camera->GetOwner()); - if (cc) - { - Actor* a = cc->GetActor(); - if (a->GetLayerID() != eSL_Debug) - { - return GPtr(a); - } - } - } - }*/ return GPtr(); } diff --git a/Engine/app/guibind/scriptbind_itembox.cc b/Engine/app/guibind/scriptbind_itembox.cc index eaba365..6e169a5 100644 --- a/Engine/app/guibind/scriptbind_itembox.cc +++ b/Engine/app/guibind/scriptbind_itembox.cc @@ -30,7 +30,31 @@ THE SOFTWARE. namespace App { //using namespace MyGUI; - void ICallReg_ScriptGUI_ItemBox( void ); + void ICall_ICallReg_ScriptGUI_ItemBox( void ); + + static void ICall_setVisibleVScroll(gconstpointer itembox_ptr, bool _value) + { + MyGUI::ItemBox* itembox = static_cast(itembox_ptr); + itembox->setVScrollVisible(_value); + } + + static bool ICall_isVisibleVScroll(gconstpointer itembox_ptr) + { + MyGUI::ItemBox* itembox = static_cast(itembox_ptr); + return itembox->isVScrollVisible(); + } + + static void ICall_setVisibleHScroll(gconstpointer itembox_ptr, bool _value) + { + MyGUI::ItemBox* itembox = static_cast(itembox_ptr); + itembox->setHScrollVisible(_value); + } + + static bool ICall_isVisibleHScroll(gconstpointer itembox_ptr) + { + MyGUI::ItemBox* itembox = static_cast(itembox_ptr); + return itembox->isHScrollVisible(); + } static void ICall_addItem(gconstpointer itembox_ptr, MonoObject* item_ptr_cs) { @@ -44,56 +68,47 @@ namespace App itembox->removeAllItems(); } - static uint ICall_getItemCount(gconstpointer itembox_ptr) { MyGUI::ItemBox* itembox = static_cast(itembox_ptr); return itembox->getItemCount(); } - static void ICall_insertItemAt(gconstpointer itembox_ptr, uint index, MonoObject* item) { MyGUI::ItemBox* itembox = static_cast(itembox_ptr); itembox->insertItemAt(index, item); } - static void ICall_removeItemAt(gconstpointer itembox_ptr, uint index) { MyGUI::ItemBox* itembox = static_cast(itembox_ptr); itembox->removeItemAt(index); } - static void ICall_redrawItemAt(gconstpointer itembox_ptr, uint index) { MyGUI::ItemBox* itembox = static_cast(itembox_ptr); itembox->redrawItemAt(index); } - static void ICall_redrawAllItems(gconstpointer itembox_ptr) { MyGUI::ItemBox* itembox = static_cast(itembox_ptr); itembox->redrawAllItems(); } - - static uint ICall_getIndexSelected(gconstpointer itembox_ptr) { MyGUI::ItemBox* itembox = static_cast(itembox_ptr); return itembox->getIndexSelected(); } - static void ICall_setIndexSelected(gconstpointer itembox_ptr, uint index) { MyGUI::ItemBox* itembox = static_cast(itembox_ptr); itembox->setIndexSelected(index); } - static void ICall_clearIndexSelected(gconstpointer itembox_ptr) { @@ -101,20 +116,17 @@ namespace App itembox->clearIndexSelected(); } - static void ICall_setItemDataAt(gconstpointer itembox_ptr, uint index, MonoObject* data) { MyGUI::ItemBox* itembox = static_cast(itembox_ptr); itembox->setItemDataAt(index, data); } - static void ICall_clearItemDataAt(gconstpointer itembox_ptr, uint index) { MyGUI::ItemBox* itembox = static_cast(itembox_ptr); itembox->clearItemDataAt(index); } - static void ICall_setVerticalAlignment(gconstpointer itembox_ptr, mono_bool value) { @@ -163,12 +175,17 @@ namespace App ,{ "ScriptGUI.ItemBox::ICall_removeAllItems", (void*)&ICall_removeAllItems} ,{ "ScriptGUI.ItemBox::ICall_redrawItemAt", (void*)&ICall_redrawItemAt} ,{ "ScriptGUI.ItemBox::ICall_redrawAllItems", (void*)&ICall_redrawAllItems} - ,{ "ScriptGUI.ItemBox::ICall_getIndexSelected", (void*)&ICall_getIndexSelected} + ,{ "ScriptGUI.ItemBox::ICall_getIndexSelected", (void*)&ICall_getIndexSelected} ,{ "ScriptGUI.ItemBox::ICall_setIndexSelected", (void*)&ICall_setIndexSelected} ,{ "ScriptGUI.ItemBox::ICall_clearIndexSelected", (void*)&ICall_clearIndexSelected} ,{ "ScriptGUI.ItemBox::ICall_setItemDataAt", (void*)&ICall_setItemDataAt} ,{ "ScriptGUI.ItemBox::ICall_clearItemDataAt", (void*)&ICall_clearItemDataAt} + ,{ "ScriptGUI.ItemBox::ICall_setVisibleVScroll", (void*)&ICall_setVisibleVScroll} + ,{ "ScriptGUI.ItemBox::ICall_isVisibleVScroll", (void*)&ICall_isVisibleVScroll} + ,{ "ScriptGUI.ItemBox::ICall_setVisibleHScroll", (void*)&ICall_setVisibleHScroll} + ,{ "ScriptGUI.ItemBox::ICall_isVisibleHScroll", (void*)&ICall_isVisibleHScroll} + ,{ "ScriptGUI.ItemBox::ICall_setVerticalAlignment", (void*)&ICall_setVerticalAlignment} ,{ "ScriptGUI.ItemBox::ICall_getVerticalAlignment", (void*)&ICall_getVerticalAlignment} ,{ "ScriptGUI.ItemBox::ICall_getIndexByWidget", (void*)&ICall_getIndexByWidget} diff --git a/Engine/app/guifeature/androidguiinputhandler.cc b/Engine/app/guifeature/androidguiinputhandler.cc index a175f58..f997117 100644 --- a/Engine/app/guifeature/androidguiinputhandler.cc +++ b/Engine/app/guifeature/androidguiinputhandler.cc @@ -118,6 +118,21 @@ namespace Input } } break; + case InputEvent::KeyUp: + { + ret |= gui_input->injectKeyRelease(App::GUIServer::KeyCodeWJtoMyGUI(inputEvent.GetKey())); + } + break; + case InputEvent::KeyDown: + { + ret |= gui_input->injectKeyPress(App::GUIServer::KeyCodeWJtoMyGUI(inputEvent.GetKey()), inputEvent.GetChar()); + } + break; + case InputEvent::Character: + { + ret |= gui_input->injectKeyPress(MyGUI::KeyCode::None, (MyGUI::Char)inputEvent.GetChar()); + } + break; default: break; } diff --git a/Engine/app/guifeature/guiserver.cc b/Engine/app/guifeature/guiserver.cc index 6043a85..20bfc66 100644 --- a/Engine/app/guifeature/guiserver.cc +++ b/Engine/app/guifeature/guiserver.cc @@ -26,6 +26,7 @@ THE SOFTWARE. #include "guiserver.h" #include "graphicsystem/GraphicSystem.h" #include "addons/myguiplatforms/include/MyGUI_GenesisPlatform.h" +#include "basegamefeature/managers/timesource.h" #include "guifeature/gui.h" #include "guiroot.h" @@ -112,23 +113,18 @@ namespace App void GUIServer::OnWindowResized() { n_assert(IsOpen()); - if (m_targetWindow) - { - const RenderBase::DisplayMode& dm = m_targetWindow->GetDisplayMode(); - m_platform->getRenderManagerPtr()->windowResized(dm.GetWidth(), dm.GetHeight()); + MyGUI::IntSize size = GUIServer::GetScreenSize(); - } - else - { - m_platform->getRenderManagerPtr()->windowResized(); - } + m_platform->getRenderManagerPtr()->windowResized(size.width, size.height); + m_guiRoot.WinSizeChange(); } void GUIServer::OnDeviceReseted() { n_assert(IsOpen()); - m_platform->getRenderManagerPtr()->deviceReseted(); + MyGUI::IntSize size = GUIServer::GetScreenSize(); + m_platform->getRenderManagerPtr()->deviceReseted(size.width, size.height); } void GUIServer::InitGuiRootScript() @@ -155,6 +151,25 @@ namespace App return MyGUI::IntSize(dm.GetWidth(), dm.GetHeight());//s } + void GUIServer::SetResolution(const MyGUI::IntSize& size) + { + MyGUI::IntSize buffer = GUIServer::GetScreenSize(); + MyGUI::GenesisRenderManager::getInstancePtr()->setResolution(size.width, size.height, buffer.width, buffer.height); + } + const MyGUI::IntSize& GUIServer::GetResolution() + { + return MyGUI::GenesisRenderManager::getInstancePtr()->getResolution(); + } + bool GUIServer::AutoResolutionWidth() + { + return MyGUI::GenesisRenderManager::getInstancePtr()->autoResolutionWidth(); + } + bool GUIServer::AutoResolutionHeight() + { + return MyGUI::GenesisRenderManager::getInstancePtr()->autoResolutionHeight(); + } + + bool GUIServer::StartTick(bool start) { //也可以注册到,MyGUI::Gui::getInstance().eventFrameStart @@ -348,7 +363,8 @@ namespace App uilog += "\\gui.log"; } #endif - m_platform->initialise("General", uilog); + MyGUI::IntSize buffer = GUIServer::GetScreenSize(); + m_platform->initialise(buffer.width, buffer.height, "General", uilog); m_gui = n_new(Gui); m_gui->initialise(m_coreFile.AsCharPtr()); @@ -378,7 +394,7 @@ namespace App if (vpw->GetNeedUpdate()) { Graphic::GraphicSystem::Instance()->SetCurrentTargetWindow(vpw, RenderBase::RenderTarget::ClearNone); - GetPlatform()->getRenderManagerPtr()->renderGUI(); + GetPlatform()->getRenderManagerPtr()->renderGUI((float)App::GameTime::Instance()->GetFrameTime()); } } diff --git a/Engine/app/guifeature/guiserver.h b/Engine/app/guifeature/guiserver.h index 05f80c0..8be206e 100644 --- a/Engine/app/guifeature/guiserver.h +++ b/Engine/app/guifeature/guiserver.h @@ -81,6 +81,12 @@ namespace App bool GetVisible(); void SetVisible(bool visible); + void SetResolution(const MyGUI::IntSize& size);//0 means auto. + const MyGUI::IntSize& GetResolution(); + bool AutoResolutionWidth(); + bool AutoResolutionHeight(); + + EventHandle_BeforeDrawVoid eventBeforeDrawUI; static MyGUI::KeyCode KeyCodeWJtoMyGUI(Input::InputKey::Code key); diff --git a/Engine/app/guifeature/guiutility.cc b/Engine/app/guifeature/guiutility.cc index 02f0e38..596c52e 100644 --- a/Engine/app/guifeature/guiutility.cc +++ b/Engine/app/guifeature/guiutility.cc @@ -545,10 +545,11 @@ namespace App _sendEvent(_sender, &arg); } - void GuiUtility::onScrollChangePosition(MyGUI::ScrollBar* scroll_bar, size_t position) + void GuiUtility::onScrollChangePosition(MyGUI::ScrollBar* scroll_bar, int position) { ScrollChangePositionEventArg arg; arg.EventType = EventType::ScrollChangePosition; + arg.Position = position; _sendEvent(scroll_bar, &arg); diff --git a/Engine/app/guifeature/guiutility.h b/Engine/app/guifeature/guiutility.h index 3f6f04b..0095219 100644 --- a/Engine/app/guifeature/guiutility.h +++ b/Engine/app/guifeature/guiutility.h @@ -368,7 +368,7 @@ namespace App private: static MyGUI::Widget* getRootWidget(MyGUI::Widget* widget); - static void onScrollChangePosition(MyGUI::ScrollBar* scroll_bar, size_t position); + static void onScrollChangePosition(MyGUI::ScrollBar* scroll_bar, int position); // --------------------------------------- widget event ------------------------------------------------ static void onMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new); diff --git a/Engine/app/guifeature/imejni.cc b/Engine/app/guifeature/imejni.cc new file mode 100644 index 0000000..7210c72 --- /dev/null +++ b/Engine/app/guifeature/imejni.cc @@ -0,0 +1,72 @@ +/**************************************************************************** +Copyright (c) 2011-2013,WebJet Business Division,CYOU + +http://www.genesis-3d.com.cn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#if __ANDROID__ +#include "imejni.h" +#include +#include + +namespace App +{ + + static char* s_classname= "org/genesis/lib/GenesisGLSurfaceView"; + + void ShowKeyboardJNI(int bOpen) + { + if (bOpen) + { + OpenKeyboardJNI(); + } + else + { + CloseKeyboardJNI(); + } + } + + void OpenKeyboardJNI() + { + JniMethodInfo t; + + if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxGLSurfaceView", "openIMEKeyboard", "()V")) { + t.env->CallStaticVoidMethod(t.classID, t.methodID); + t.env->DeleteLocalRef(t.classID); + } + jclass jcls = static_cast(cls); + jmethodID jmth = static_cast(methodID); + jvalue* jargs = Utility_CreateCppArrFromMonoArr(args); + JNIEnv* jevn = DemoPublishGameApplication::Instance()->GetJNIEvn(); + + long ret = jevn->functions->CallStaticLongMethodA(jevn,jcls,jmth,jargs); + } + + void CloseKeyboardJNI() + { + JniMethodInfo t; + + if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxGLSurfaceView", "closeIMEKeyboard", "()V")) { + t.env->CallStaticVoidMethod(t.classID, t.methodID); + t.env->DeleteLocalRef(t.classID); + } + } +} +#endif \ No newline at end of file diff --git a/Engine/app/guifeature/osxguiinputhandler.cpp b/Engine/app/guifeature/osxguiinputhandler.cpp index e0d949e..d20bd65 100644 --- a/Engine/app/guifeature/osxguiinputhandler.cpp +++ b/Engine/app/guifeature/osxguiinputhandler.cpp @@ -112,6 +112,21 @@ namespace Input } } break; + case InputEvent::KeyUp: + { + ret |= gui_input->injectKeyRelease(App::GUIServer::KeyCodeWJtoMyGUI(inputEvent.GetKey())); + } + break; + case InputEvent::KeyDown: + { + ret |= gui_input->injectKeyPress(App::GUIServer::KeyCodeWJtoMyGUI(inputEvent.GetKey()), inputEvent.GetChar()); + } + break; + case InputEvent::Character: + { + ret |= gui_input->injectKeyPress(MyGUI::KeyCode::None, (MyGUI::Char)inputEvent.GetChar()); + } + break; default: break; } diff --git a/Engine/app/guifeature/scriptgui.cc b/Engine/app/guifeature/scriptgui.cc index 61621e2..ce2a0ff 100644 --- a/Engine/app/guifeature/scriptgui.cc +++ b/Engine/app/guifeature/scriptgui.cc @@ -25,9 +25,98 @@ THE SOFTWARE. #include "scriptgui.h" #include "guiserver.h" #include "graphicsystem/GraphicSystem.h" -#include "myguiplatforms/include/MyGUI_GenesisRenderManager.h" +#include "guiutility.h" +#include "Jni/imejni.h" +#if __OSX__ +#include "OCAndCPlusInterface.h" +#endif namespace App { + MyGUI::Widget* ScriptGui::s_pCurFocusEditBox = NULL; + void ScriptGui::SetFocusedEditboxCaption(const MyGUI::UString& data) + { + if (s_pCurFocusEditBox) { + MyGUI::EditBox* pEditBox = dynamic_cast(s_pCurFocusEditBox); + pEditBox->setCaption(data); + } + + } + void ScriptGui::recursiveGetEditBoxWidget(MyGUI::VectorWidgetPtr& outVec,MyGUI::Widget* pWidget) + { + if ( !pWidget ) + { + return; + } + //itself + if ( pWidget->isType() ) + { + outVec.push_back(pWidget); + } + //children + size_t nSize = pWidget->getChildCount(); + for ( size_t i = 0; i < nSize; i++ ) + { + MyGUI::Widget* pChildWidget = pWidget->getChildAt(i); + recursiveGetEditBoxWidget(outVec,pChildWidget); + } + } + void ScriptGui::_ShowKeyboard(bool bShow) + { +#if __ANDROID__ + // call to java by the way jni + IMEJni::ShowKeyboardJNI(bShow); +#elif __OSX__ + // call to object c by the way ThirdLibIosSenderListener interface + if (bShow) { + MyGUI::EditBox* pEditBox = dynamic_cast(s_pCurFocusEditBox); + MyGUI::UString ustr = pEditBox->getCaption(); + pEditBox->setCaption(""); + const char* cstr = ustr.asUTF8_c_str(); + OCAndCPlusInterface::showKeyboard(bShow,cstr); + } else { + OCAndCPlusInterface::showKeyboard(bShow,NULL); + } + + +#else + n_warning("not implement this platform!"); +#endif + } + template + void _reg_event(MyGUI::Widget* widget, EventType::_type event_type, bool advise, Delegate& _delegate, Function& _function); + void ScriptGui::_OnKeySetFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new) + { + s_pCurFocusEditBox = _sender; + //show keyboard + //if ( _new && _new->isType() ) + //{ //old focus is editbox,don't need show keyboard + // return; + //} + _ShowKeyboard(true); + } + void ScriptGui::_OnKeyLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _old) + { + if ( _sender == s_pCurFocusEditBox ) + { + s_pCurFocusEditBox = NULL; + } + //hide keyboard + //if ( _old && _old->isType() ) + //{// new focus is editbox,don't need hide keyboard + // return; + //} + _ShowKeyboard(false); + } + void ScriptGui::_InternalRegisterEditBoxGetLostFocus(MyGUI::Widget*pWidget) + { + if ( !pWidget ) + { + return; + } + _reg_event(pWidget, EventType::KeySetFocus, true, pWidget->eventKeySetFocus, _OnKeySetFocus); + _reg_event(pWidget, EventType::KeyLostFocus, true, pWidget->eventKeyLostFocus, _OnKeyLostFocus); + + } MyGUI::Widget* ScriptGui::loadLayout(MyGUI::Widget* parent, const std::string& file_name) { MyGUI::LayoutManager* lm = MyGUI::LayoutManager::getInstancePtr(); @@ -41,6 +130,20 @@ namespace App "", static_cast(parent)); + //interal register event +#if __ANDROID__ || __OSX__ + MyGUI::VectorWidgetPtr allEditBox; + for ( MyGUI::VectorWidgetPtr::iterator it = insts.begin(); it != insts.end(); it++ ) + { + recursiveGetEditBoxWidget(allEditBox,*it); + } + for ( MyGUI::VectorWidgetPtr::iterator it = allEditBox.begin(); it != allEditBox.end(); it++ ) + { + _InternalRegisterEditBoxGetLostFocus(*it); + } +#endif + + if (1 == insts.size()) { return insts.at(0); @@ -74,18 +177,18 @@ namespace App void ScriptGui::setResolution(const MyGUI::IntSize& size) { - MyGUI::GenesisRenderManager::getInstancePtr()->setResolution(size); + GUIServer::Instance()->SetResolution(size); } const MyGUI::IntSize& ScriptGui::getResolution() { - return MyGUI::GenesisRenderManager::getInstancePtr()->getResolution(); + return GUIServer::Instance()->GetResolution(); } bool ScriptGui::autoResolutionWidth() { - return MyGUI::GenesisRenderManager::getInstancePtr()->autoResolutionWidth(); + return GUIServer::Instance()->AutoResolutionWidth(); } bool ScriptGui::autoResolutionHeight() { - return MyGUI::GenesisRenderManager::getInstancePtr()->autoResolutionHeight(); + return GUIServer::Instance()->AutoResolutionHeight(); } } \ No newline at end of file diff --git a/Engine/app/guifeature/scriptgui.h b/Engine/app/guifeature/scriptgui.h index 55189b5..d0e0b83 100644 --- a/Engine/app/guifeature/scriptgui.h +++ b/Engine/app/guifeature/scriptgui.h @@ -29,6 +29,9 @@ namespace App class ScriptGui { public: + static MyGUI::Widget* s_pCurFocusEditBox; + static void SetFocusedEditboxCaption(const MyGUI::UString& data); + static MyGUI::Widget* loadLayout(MyGUI::Widget* parent, const std::string& file_name); static void destroyWidget(MyGUI::Widget* widget); static MyGUI::Widget* findWidget(MyGUI::Widget* parent, const std::string& widget_name); @@ -39,6 +42,12 @@ namespace App static const MyGUI::IntSize& getResolution(); static bool autoResolutionWidth(); static bool autoResolutionHeight(); + static void recursiveGetEditBoxWidget(MyGUI::VectorWidgetPtr& outVec,MyGUI::Widget*pWidget); + private: + static void _InternalRegisterEditBoxGetLostFocus(MyGUI::Widget*pWidget); + static void _OnKeySetFocus(MyGUI::Widget* _sender, MyGUI::Widget* _old); + static void _OnKeyLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _old); + static void _ShowKeyboard(bool bShow); }; } diff --git a/Engine/app/inputfeature/inputfeature.cc b/Engine/app/inputfeature/inputfeature.cc index 19a16e3..85023cc 100644 --- a/Engine/app/inputfeature/inputfeature.cc +++ b/Engine/app/inputfeature/inputfeature.cc @@ -153,5 +153,14 @@ InputFeature::OnEndFrame() // clear the input of this frame m_inputServer->EndFrame(); } - +//------------------------------------------------------------------------------ +/** +*/ +void +InputFeature::OnResetEvent() +{ + InputEvent inputEvent; + inputEvent.SetType(InputEvent::Reset); + m_inputServer->PutEvent( inputEvent ); +} } // namespace Game diff --git a/Engine/app/inputfeature/inputfeature.h b/Engine/app/inputfeature/inputfeature.h index 881a524..aa13954 100644 --- a/Engine/app/inputfeature/inputfeature.h +++ b/Engine/app/inputfeature/inputfeature.h @@ -63,6 +63,8 @@ namespace App /// @Feature::OnEndFrame called at the end of the feature trigger cycle virtual void OnEndFrame(); + void OnResetEvent(); + void AttachInputSource(GPtr input); void RemoveInputSource(GPtr input); diff --git a/Engine/app/particlefeature/components/particlerendercomponent.cc b/Engine/app/particlefeature/components/particlerendercomponent.cc index 9a75813..6d17f15 100644 --- a/Engine/app/particlefeature/components/particlerendercomponent.cc +++ b/Engine/app/particlefeature/components/particlerendercomponent.cc @@ -76,6 +76,7 @@ namespace App , mShowSimpleShape(false) , mSelectTech(0) , mTemplateName("sys:Mesh.template") + , mCurCamera(NULL) { mMeshInfo.dirty = false; mMeshInfo.meshID = "sys:box.mesh"; @@ -252,7 +253,7 @@ namespace App LoadEmitterMesh(); BuildRenderData(); - + mParticleSystem->SetParticleFPS(_fpsControl()); Super::_OnBeginFrame(); } @@ -458,6 +459,10 @@ namespace App void ParticleRenderComponent::SetVisible(bool bVis) { + if ( bVis == mVisible ) + { + return; + } mVisible = bVis; if (IsActive()) { @@ -471,6 +476,16 @@ namespace App } } } +#ifdef __GENESIS_EDITOR__ + void ParticleRenderComponent::SetEditorVisible(bool bVis) + { + Super::SetEditorVisible(bVis); + if (IsActive()) + { + mRenderObject->SetEditorVisible(bVis); + } + } +#endif void ParticleRenderComponent::OnRenderSceneChanged() { @@ -482,7 +497,8 @@ namespace App void ParticleRenderComponent::_AttachRenderObject() { - if(!mVisible) + + if(!mVisible) return; if (mRenderObject.isvalid()) { @@ -622,13 +638,7 @@ namespace App }//end: for ( IndexT index = 0; index < mRenderDates.Size(); ++index ) if(mParticleSystem->_NeedUpdateBox()) { - Math::bbox box; - box.begin_extend(); - Math::bbox particleBox = mParticleSystem->GetBoundingBox(); - box.extend(particleBox); - box.end_extend(); - - mRenderObject->SetBoundingBox(box); + mRenderObject->SetBoundingBox(mParticleSystem->GetBoundingBox()); } } //------------------------------------------------------------------------ @@ -677,6 +687,8 @@ namespace App if ( partType == ParticleTarget::Mesh ) { + if(mMeshInfo.dirty || !mIsBuild) + return; GPtr entityTar = pTarget.downcast(); mMats.AppendArray( entityTar->GetMatrixList()); @@ -809,7 +821,7 @@ namespace App //------------------------------------------------------------------------ void ParticleRenderComponent::SetMeshID(const Resources::ResourceId& meshID, Resources::Priority priority ) { - if( mMeshInfo.meshID != meshID ) + //if( mMeshInfo.meshID != meshID ) //热加载 { if (mActor && mActor->PriorityDefinition()) { @@ -819,6 +831,7 @@ namespace App mMeshInfo.priority = priority; mMeshInfo.dirty = true; } + } //------------------------------------------------------------------------ void ParticleRenderComponent::SetTemplateID( const Resources::ResourceId& templateID ) @@ -830,5 +843,49 @@ namespace App { return mTemplateName; } + //------------------------------------------------------------------------- + SizeT ParticleRenderComponent::_fpsControl() + { + Math::bbox box = mParticleSystem->GetBoundingBox(); + Math::float4 boxSizeVec = box.pmax - box.pmin; + float boxSize = boxSizeVec.x()*boxSizeVec.x()+boxSizeVec.y()*boxSizeVec.y()+boxSizeVec.z()*boxSizeVec.z(); + float minViewSize = 400000000; + + if(!mActor) + { + return (SizeT)(minViewSize); + } + + const Graphic::RenderScene* renderScene = mActor->GetRenderScene(); + if(!renderScene) + { + return (SizeT)(minViewSize); + } + + const Graphic::RenderScene::CameraList& cameraList = renderScene->GetCameraList(); + for(IndexT cameraIndex = 0; cameraIndex < cameraList.Size(); cameraIndex++) + { + if(cameraList[cameraIndex]) + { + Math::vector cameraLocalPos = cameraList[cameraIndex]->GetTransform().get_position() - mActor->GetWorldPosition(); + float dis = cameraLocalPos.x()*cameraLocalPos.x()+cameraLocalPos.y()*cameraLocalPos.y()+cameraLocalPos.z()*cameraLocalPos.z(); + + float zNear = cameraList[cameraIndex]->GetCameraSetting().GetZNear(); + float zFar = cameraList[cameraIndex]->GetCameraSetting().GetZFar(); + float farWidth = cameraList[cameraIndex]->GetCameraSetting().GetFarWidth(); + float farHeight = cameraList[cameraIndex]->GetCameraSetting().GetFarHeight(); + float viewSize = dis/((zFar-zNear)*(zFar-zNear))*(farWidth*farWidth + farHeight*farHeight); + + minViewSize = Math::n_min(viewSize,minViewSize); + } + } + float ratioInView = minViewSize/boxSize; + float MINTIME = 0.033f; + float MAXTIME = 0.33f; + float updateTime = MINTIME + (MAXTIME-MINTIME) * ratioInView * ParticleSystem::UpdateFactor; + updateTime = updateTime>MAXTIME?MAXTIME:updateTime; + + return (SizeT)(1.0/updateTime); + } } diff --git a/Engine/app/particlefeature/components/particlerendercomponent.h b/Engine/app/particlefeature/components/particlerendercomponent.h index 7bcde59..2083bfd 100644 --- a/Engine/app/particlefeature/components/particlerendercomponent.h +++ b/Engine/app/particlefeature/components/particlerendercomponent.h @@ -122,6 +122,11 @@ namespace App void NeedUpdate(); Graphic::Camera* _getCurrentCamera() const; void SetShaderMask(); + +#ifdef __GENESIS_EDITOR__ + virtual void SetEditorVisible(bool bVis); +#endif + protected: typedef ParticleRenderObject RenderObjectType; typedef GPtr ParticleRenderObjectPtr; @@ -168,6 +173,7 @@ namespace App void _DeattachRenderObject(); void _updateTarget(Graphic::Camera* camera); + SizeT _fpsControl(); protected: Graphic::Camera* mCurCamera; @@ -239,6 +245,9 @@ namespace App const Resources::ResourceId& ParticleRenderComponent::GetEmitMeshID( void ) const { + const Resources::ResourceId& resID = ""; + if(!mEmitMeshRes.isvalid()) + return resID; return mEmitMeshRes->GetResID(); } //------------------------------------------------------------------------ diff --git a/Engine/app/particlefeature/components/particlerenderobject.cc b/Engine/app/particlefeature/components/particlerenderobject.cc index 224754a..c9da3ce 100644 --- a/Engine/app/particlefeature/components/particlerenderobject.cc +++ b/Engine/app/particlefeature/components/particlerenderobject.cc @@ -83,9 +83,18 @@ namespace App if(renderData->mPartType == ParticleTarget::GPU) { gModleMaterix = particleRC->GetActor()->GetWorldTransform(); - Math::matrix44 vp = particleRC->_getCurrentCamera()->GetViewProjTransform(); + Graphic::Camera* camera = particleRC->_getCurrentCamera(); + const Math::float4& upVector4 = camera->GetTransform().get_yaxis(); + const Math::float4& cameraPos4 = camera->GetTransform().get_position(); + const Math::float4& derivedPos4 = particleRC->GetActor()->GetWorldPosition(); + Math::float4 dirVec4 = cameraPos4 - derivedPos4; + Math::float4 rightVec4 = Math::float4::cross3(upVector4,dirVec4); + + Math::matrix44 vp = camera->GetViewProjTransform(); gModleMaterix = Math::matrix44::multiply(vp,gModleMaterix); particleRC->GetParticleSystem()->SetShaderParam(); + pGMP->SetVectorParam(eGShaderParticleUpVec,Math::float4::normalize(upVector4)); + pGMP->SetVectorParam(eGShaderParticleRightVec,Math::float4::normalize(rightVec4)); } if (renderData->mPartType == ParticleTarget::Mesh || renderData->mPartType == ParticleTarget::Decal) diff --git a/Engine/app/physXfeature/physicsCore/PhysicsCapsuleShape.cc b/Engine/app/physXfeature/physicsCore/PhysicsCapsuleShape.cc index 689924d..bf10b35 100644 --- a/Engine/app/physXfeature/physicsCore/PhysicsCapsuleShape.cc +++ b/Engine/app/physXfeature/physicsCore/PhysicsCapsuleShape.cc @@ -247,9 +247,10 @@ namespace App { _scale = m_ActorScale.z(); } - Math::scalar tempHeight = m_Height * _scale; - Math::scalar realRadius = _GetRealRadius(); - return Math::n_max(tempHeight - 2 * realRadius, 0.01f); + return Math::n_max(Math::n_abs(m_Height * _scale), 0.01f); +// Math::scalar tempHeight = m_Height * _scale; +// Math::scalar realRadius = _GetRealRadius(); +// return Math::n_max(tempHeight - 2 * realRadius, 0.01f); } Math::scalar PhysicsCapsuleShape::_GetRealRadius() diff --git a/Engine/app/physXfeature/physicsCore/PhysicsDynamic.cc b/Engine/app/physXfeature/physicsCore/PhysicsDynamic.cc index 2a05f05..e643704 100644 --- a/Engine/app/physXfeature/physicsCore/PhysicsDynamic.cc +++ b/Engine/app/physXfeature/physicsCore/PhysicsDynamic.cc @@ -536,13 +536,14 @@ namespace App { return 0.01f; } + bool _needUpdate = false; + SizeT _invalidShapeCount = 0; for ( int i=0; iIsValid() ) + if ( !m_arrPhysicsShapePtr[i]->IsValid()) { - //m_pPxActor->setMass(0.01f); - //return 0.01f; + _invalidShapeCount++; continue; } if ( m_arrPhysicsShapePtr[i]->IsMassUpdate() ) @@ -555,6 +556,11 @@ namespace App { UpdateEntityMass(); } + + if (_invalidShapeCount == m_arrPhysicsShapePtr.Size()) + { + m_pPxActor->setMass(0.01f); + } return m_pPxActor->getMass(); } diff --git a/Engine/app/physXfeature/physicsCore/PhysicsEntity.cc b/Engine/app/physXfeature/physicsCore/PhysicsEntity.cc index dba40cf..aaa8530 100644 --- a/Engine/app/physXfeature/physicsCore/PhysicsEntity.cc +++ b/Engine/app/physXfeature/physicsCore/PhysicsEntity.cc @@ -126,6 +126,8 @@ namespace App } if ( GetRigidActor() ) { + LayerID actorLayerId = m_pComponent->GetActor()->GetLayerID(); + SetGroupID(actorLayerId); _pShape->CreatePxShape(GetRigidActor(),m_eGroup); UpdateEntityMass(); } diff --git a/Engine/app/physXfeature/physicsCore/PhysicsRole.cc b/Engine/app/physXfeature/physicsCore/PhysicsRole.cc index 432e093..b2d393b 100644 --- a/Engine/app/physXfeature/physicsCore/PhysicsRole.cc +++ b/Engine/app/physXfeature/physicsCore/PhysicsRole.cc @@ -530,7 +530,7 @@ namespace App { if ( m_pController && m_pController->getActor() ) { - /*Math::vector f4Axis(0.f,0.f,1.f); + Math::vector f4Axis(0.f,0.f,1.f); Math::scalar sRadian = (Math::scalar)(0.5f*PI); Math::quaternion _tempRot = Math::quaternion::rotationaxis(f4Axis,sRadian); _tempRot = Math::quaternion::multiply(quat,_tempRot); @@ -538,12 +538,12 @@ namespace App _pos.q.x = _tempRot.x(); _pos.q.y = _tempRot.y(); _pos.q.z = _tempRot.z(); - _pos.q.w = _tempRot.w();*/ - Math::vector dir = quat * Math::vector(0.0f,1.0f,0.0f); - PxVec3 pDir(dir.x(),dir.y(),dir.z()); - pDir.normalize(); - m_pController->setUpDirection(pDir); - //m_pController->getActor()->setGlobalPose(_pos); + _pos.q.w = _tempRot.w(); + //Math::vector dir = quat * Math::vector(0.0f,1.0f,0.0f); + //PxVec3 pDir(dir.x(),dir.y(),dir.z()); + //pDir.normalize(); + //m_pController->setUpDirection(pDir); + m_pController->getActor()->setGlobalPose(_pos); } } diff --git a/Engine/app/scriptbind/autogen/scriptbind_PhysicsBodyComponent_register.h b/Engine/app/scriptbind/autogen/scriptbind_PhysicsBodyComponent_register.h index 816060f..7102480 100644 --- a/Engine/app/scriptbind/autogen/scriptbind_PhysicsBodyComponent_register.h +++ b/Engine/app/scriptbind/autogen/scriptbind_PhysicsBodyComponent_register.h @@ -32,7 +32,7 @@ namespace App static void ICall_PhysicsBodyComponent_GetAngularVelocity(MonoObject* self, Math::float3& velocity); - static void ICall_PhysicsBodyComponent_SetLinearDamping(MonoObject* self, float scalar); + static void ICall_PhysicsBodyComponent_SetLinearDamping(MonoObject* self, float scalar); static float ICall_PhysicsBodyComponent_GetLinearDamping(MonoObject* pMonoObj); @@ -82,14 +82,6 @@ namespace App static void ICall_PhysicsBodyComponent_AddForce(MonoObject* self, Math::float3& force, PhysicsDynamic::ForceType forcetype, mono_bool bWakeUp); - static void ICall_PhysicsBodyComponent_AddForceAtPos(MonoObject* self, Math::float3& force, Math::float3& pos,PhysicsDynamic::ForceType forcetype, mono_bool bWakeUp); - - static void ICall_PhysicsBodyComponent_AddForceAtLocalPos(MonoObject* self, Math::float3& force, Math::float3& pos, PhysicsDynamic::ForceType forcetype, mono_bool bWakeUp); - - static void ICall_PhysicsBodyComponent_AddLocalForceAtPos(MonoObject* self, Math::float3& force, Math::float3& pos,PhysicsDynamic::ForceType forcetype, mono_bool bWakeUp); - - static void ICall_PhysicsBodyComponent_AddLocalForceAtLocalPos(MonoObject* self, Math::float3& force, Math::float3& pos,PhysicsDynamic::ForceType forcetype, mono_bool bWakeUp); - static MonoObject* ICall_PhysicsEntity_GetShapeAt(MonoObject* self, int index); static int ICall_PhysicsEntity_GetShapeCount(MonoObject* self); @@ -147,17 +139,13 @@ namespace App { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_GetConstLineVelocity",(void*)&ICall_PhysicsBodyComponent_GetConstLineVelocity}, { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_SetConstTorque", (void*)&ICall_PhysicsBodyComponent_SetConstTorque}, { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_GetConstTorque", (void*)&ICall_PhysicsBodyComponent_GetConstTorque}, - { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_SetAngularVelocity", (void*)&ICall_PhysicsBodyComponent_SetConstAngularVelocity}, - { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_GetAngularVelocity", (void*)&ICall_PhysicsBodyComponent_GetConstAngularVelocity}, + { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_SetConstAngularVelocity", (void*)&ICall_PhysicsBodyComponent_SetConstAngularVelocity}, + { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_GetConstAngularVelocity", (void*)&ICall_PhysicsBodyComponent_GetConstAngularVelocity}, { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_MovePostion", (void*)&ICall_PhysicsBodyComponent_MovePostion}, { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_RotateRotation", (void*)&ICall_PhysicsBodyComponent_RotateRotation}, { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_MoveToPostion", (void*)&ICall_PhysicsBodyComponent_MoveToPostion}, { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_RotateToRotation", (void*)&ICall_PhysicsBodyComponent_RotateToRotation}, { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_AddForce", (void*)&ICall_PhysicsBodyComponent_AddForce}, - { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_AddForceAtPos", (void*)&ICall_PhysicsBodyComponent_AddForceAtPos}, - { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_AddForceAtLocalPos", (void*)&ICall_PhysicsBodyComponent_AddForceAtLocalPos}, - { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_AddLocalForceAtPos", (void*)&ICall_PhysicsBodyComponent_AddLocalForceAtPos}, - { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsBodyComponent_AddLocalForceAtLocalPos",(void*)&ICall_PhysicsBodyComponent_AddLocalForceAtLocalPos}, { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsEntity_GetShapeAt", (void*)&ICall_PhysicsEntity_GetShapeAt}, { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsEntity_GetShapeCount", (void*)&ICall_PhysicsEntity_GetShapeCount}, { "ScriptRuntime.PhysicsBodyComponent::ICall_PhysicsRole_IsOnGround", (void*)&ICall_PhysicsRole_IsOnGround }, diff --git a/Engine/app/scriptbind/scriptbind_actor.cc b/Engine/app/scriptbind/scriptbind_actor.cc index f632958..6e7dbd4 100644 --- a/Engine/app/scriptbind/scriptbind_actor.cc +++ b/Engine/app/scriptbind/scriptbind_actor.cc @@ -206,8 +206,8 @@ namespace App static void ICall_Actor_SetParent( MonoObject* pMonoObj, MonoObject* pParent ) { ScriptObjWrapper self( pMonoObj ); - ScriptObjWrapper parent( pParent ); - self->SetParent( parent.GetCppObjPtr() ); + Actor* parent = ScriptObjToCppPointer(pParent); + self->SetParent( parent ); } //------------------------------------------------------------------------ static SizeT ICall_Actor_GetChildCount( MonoObject* pMonoObj ) @@ -255,10 +255,8 @@ namespace App static void ICall_Actor_AddChild( MonoObject* pMonoObj, MonoObject* pChildObj ) { ScriptObjWrapper self( pMonoObj ); - - ScriptObjWrapper child( pChildObj ); - GPtr pChildPtr( child.GetCppObjPtr() ); - + Actor* child = ScriptObjToCppPointer(pChildObj); + GPtr pChildPtr( child ); self->AddChild( pChildPtr ); } //------------------------------------------------------------------------ @@ -420,8 +418,9 @@ namespace App if(pPEC == NULL) return; ScriptObjWrapper self( pMonoObj ); - ScriptObjWrapper com(pPEC); - GPtr pCom = static_cast( com.GetCppObjPtr() ); + + Component* com = ScriptObjToCppPointer(pPEC); + GPtr pCom = static_cast( com ); self->RemoveComponent( pCom ); } //------------------------------------------------------------------------ diff --git a/Engine/app/scriptbind/scriptbind_animation_component.cc b/Engine/app/scriptbind/scriptbind_animation_component.cc index c6e62e1..71ccd5b 100644 --- a/Engine/app/scriptbind/scriptbind_animation_component.cc +++ b/Engine/app/scriptbind/scriptbind_animation_component.cc @@ -130,16 +130,17 @@ namespace App static void ICall_AnimationComponent_AddAttachedActor( MonoObject* pMonoObj, MonoObject* pActor, MonoString* pMonoString) { ScriptObjWrapper self( pMonoObj ); - ScriptObjWrapper actor( pActor ); + + Actor* actor = ScriptObjToCppPointer(pActor); Util::String skelName = Utility_MonoStringToCppString( pMonoString ); - self->AddAttachedActor(actor.GetCppObjPtr(),skelName); + self->AddAttachedActor(actor,skelName); } //------------------------------------------------------------------------ static void ICall_AnimationComponent_RemoveAttachedActor( MonoObject* pMonoObj, MonoObject* pActor) { ScriptObjWrapper self( pMonoObj ); - ScriptObjWrapper actor( pActor ); - self->RemoveAttachedActor(actor.GetCppObjPtr()); + Actor* actor = ScriptObjToCppPointer(pActor); + self->RemoveAttachedActor(actor); } //------------------------------------------------------------------------ diff --git a/Engine/app/scriptbind/scriptbind_application.cc b/Engine/app/scriptbind/scriptbind_application.cc index 5575a75..cbd8d8e 100644 --- a/Engine/app/scriptbind/scriptbind_application.cc +++ b/Engine/app/scriptbind/scriptbind_application.cc @@ -43,7 +43,7 @@ namespace App { String scence_name; Utility_MonoStringToCppString(sceneResID, scence_name); - return Utility_MonoBool(GameApplication::Instance()->OpenScene(scence_name) ); + return Utility_MonoBool(GameApplication::Instance()->OpenScene(scence_name, false) ); } @@ -53,7 +53,7 @@ namespace App Utility_MonoStringToCppString(sceneResID, scence_name); return Utility_MonoBool( - GameApplication::Instance()->CloseScene(scence_name) ); + GameApplication::Instance()->CloseScene(scence_name,false) ); } static void ICall_Application_Quit() @@ -72,7 +72,7 @@ namespace App const GPtr& pScene = GameApplication::Instance()->GetCurrentScene(); if ( pScene.isvalid() ) { - return CppObjectToScriptObj( *pScene ); + return CppPointerToScriptObj( pScene.get_unsafe() ); } else { diff --git a/Engine/app/scriptbind/scriptbind_camera.cc b/Engine/app/scriptbind/scriptbind_camera.cc index 0e44abb..ae08e7f 100644 --- a/Engine/app/scriptbind/scriptbind_camera.cc +++ b/Engine/app/scriptbind/scriptbind_camera.cc @@ -70,9 +70,9 @@ namespace App static void ICall_Camera_SetRenderToTexture(MonoObject* pMonoObj ,MonoObject* pRenderToTexture) { ScriptObjWrapper self( pMonoObj ); - ScriptObjWrapper renderToTexture( pRenderToTexture ); - - self->SetRenderToTexture( renderToTexture.GetCppObjPtr() ); + + Graphic::RenderToTexture* renderToTexture = ScriptObjToCppPointer(pRenderToTexture); + self->SetRenderToTexture( renderToTexture ); } static void ICall_Camera_SetRenderDepth( MonoObject* pMonoObj,mono_bool bRenderDepth) @@ -189,9 +189,9 @@ namespace App static void ICall_Camera_SetLightLitTexture(MonoObject* pMonoObj ,MonoObject* pRenderToTexture) { ScriptObjWrapper self( pMonoObj ); - ScriptObjWrapper renderToTexture( pRenderToTexture ); - - self->SetLightLitMap( renderToTexture.GetCppObjPtr() ); + + Graphic::RenderToTexture* renderToTexture = ScriptObjToCppPointer(pRenderToTexture); + self->SetLightLitMap( renderToTexture ); } void ICallReg_ScriptRuntime_Camera( void ) diff --git a/Engine/app/scriptbind/scriptbind_camera_component.cc b/Engine/app/scriptbind/scriptbind_camera_component.cc index 9157d4b..423b70f 100644 --- a/Engine/app/scriptbind/scriptbind_camera_component.cc +++ b/Engine/app/scriptbind/scriptbind_camera_component.cc @@ -146,9 +146,8 @@ namespace App static void ICall_CameraComponent_SetRenderToTexture(MonoObject* pMonoObj ,MonoObject* pRenderToTexture) { ScriptObjWrapper self( pMonoObj ); - ScriptObjWrapper renderToTexture( pRenderToTexture ); - - self->SetRenderToTexture( renderToTexture.GetCppObjPtr() ); + Graphic::RenderToTexture* renderToTexture = ScriptObjToCppPointer(pRenderToTexture); + self->SetRenderToTexture( renderToTexture ); } static void ICall_CameraComponent_SetRenderDepth( MonoObject* pMonoObj,mono_bool bRenderDepth) @@ -231,10 +230,9 @@ namespace App static void ICall_CameraComponent_SetLightLitTexture(MonoObject* pMonoObj ,MonoObject* pRenderToTexture) { - ScriptObjWrapper self( pMonoObj ); - ScriptObjWrapper renderToTexture( pRenderToTexture ); - - self->SetLightLitTexture( renderToTexture.GetCppObjPtr() ); + ScriptObjWrapper self( pMonoObj ); + Graphic::RenderToTexture* renderToTexture = ScriptObjToCppPointer(pRenderToTexture); + self->SetLightLitTexture( renderToTexture ); } } diff --git a/Engine/app/scriptbind/scriptbind_graphic_system.cc b/Engine/app/scriptbind/scriptbind_graphic_system.cc index b7f32b6..694a782 100644 --- a/Engine/app/scriptbind/scriptbind_graphic_system.cc +++ b/Engine/app/scriptbind/scriptbind_graphic_system.cc @@ -23,18 +23,20 @@ THE SOFTWARE. ****************************************************************************/ #include "stdneb.h" #include "scriptfeature/inc/script_utility.h" -#include "core/refcounted.h" -#include "foundation/util/scriptbind.h" -#include "foundation/util/string.h" -#include "graphicsystem/GraphicSystem.h" -#include "rendersystem/base/RenderDeviceTypes.h" -#include "graphicsystem/base/RenderToTexture.h" -#include "graphicsystem/base/ImageFilters.h" -#include "graphicsystem/GraphicObjectManager.h" -#include "resource/resourcemanager.h" -#include "graphicfeature/components/cameracomponent.h" -#include "graphicfeature/graphicsfeature.h" -#include "resource/resinfo.h" +//#include "core/refcounted.h" +//#include "foundation/util/scriptbind.h" +//#include "foundation/util/string.h" +//#include "graphicsystem/GraphicSystem.h" +//#include "rendersystem/base/RenderDeviceTypes.h" +//#include "graphicsystem/base/RenderToTexture.h" +//#include "graphicsystem/base/ImageFilters.h" +//#include "graphicsystem/GraphicObjectManager.h" +//#include "resource/resourcemanager.h" +//#include "graphicfeature/components/cameracomponent.h" +//#include "graphicfeature/graphicsfeature.h" +//#include "resource/resinfo.h" + +#include "scriptfeature/script_app.h" namespace App { @@ -45,67 +47,47 @@ namespace App //------------------------------------------------------------------------ static MonoObject* ICall_GraphicSystem_GetSceneCamera( ) { - CameraComponent * ret = static_cast(Graphic::GraphicSystem::Instance()->GetRenderingCamera()->GetOwner()); - return CppPointerToScriptObj(ret); + CameraComponent* cc = ScriptApp::GetSceneCamera(); + return CppPointerToScriptObj(cc); } + //------------------------------------------------------------------------ + static MonoObject* ICall_GraphicSystem_GetRenderingCamera( ) + { + CameraComponent* cc = ScriptApp::GetRenderingCamera(); + return CppPointerToScriptObj(cc); + } + //------------------------------------------------------------------------ static void ICall_GraphicSystem_RenderCamera( MonoObject* pMonoObj ) { ScriptObjWrapper self( pMonoObj ); - Graphic::GraphicSystem::Instance()->RenderCamera(self.GetCppObjPtr()); + ScriptApp::RenderCamera(self.GetCppObjPtr()); } //------------------------------------------------------------------------ static void ICall_GraphicSystem_SetRenderTarget( MonoObject* pMonoObj ,int value) { ScriptObjWrapper self( pMonoObj ); - GPtr rt = self.GetCppObjPtr(); - Graphic::GraphicSystem::Instance()->SetRenderTarget(rt,0,RenderBase::RenderTarget::ClearAll); + ScriptApp::SetRenderTarget(self.GetCppObjPtr(), value); } static int ICall_GraphicSystem_GetWidth( ) { - const RenderBase::DisplayMode& dm = Graphic::GraphicSystem::Instance()->GetMainViewPortWindow()->GetDisplayMode(); - return dm.GetWidth(); + return ScriptApp::GetWidth(); } static int ICall_GraphicSystem_GetHeight( ) { - const RenderBase::DisplayMode& dm = Graphic::GraphicSystem::Instance()->GetMainViewPortWindow()->GetDisplayMode(); - return dm.GetHeight(); - } - - - static MonoObject* ICall_GraphicSystem_GetCameraRenderToTextureByCameraType(int type) - { - GPtr glowCam = Graphic::GraphicSystem::Instance()->GetCameraByType((Graphic::CameraOrder)type); - Graphic::RenderToTexture* rtt =glowCam->GetRenderToTexture(); - return CppObjectToScriptObj(*rtt); + return ScriptApp::GetHeight(); } static MonoObject* ICall_GraphicSystem_CreateMaterial( MonoString* resID) { Util::String res; Utility_MonoStringToCppString(resID, res); - GPtr matResInfo = Resources::ResourceManager::Instance()->CreateMaterialInfo(res,0); - if ( !matResInfo.isvalid() ) - { - return NULL; - } - GPtr& mtrl = matResInfo->GetHandle(); - if ( mtrl.isvalid() ) - { - Util::String defshaderName = "defaultFallBackShader.shader"; - int len = defshaderName.Length(); - IndexT pos = res.FindStringIndex(defshaderName); - bool bRequestDefaultShader = (pos != InvalidIndex) && (res.FindStringIndex(defshaderName,(res.Length() - len) ) != InvalidIndex ); - if ( !bRequestDefaultShader && mtrl->GetName() == Graphic::Material::s_defaultFallBackMat->GetName() ) - {// request create shader is not default shader,and returned material is defaultfallback,then i think it is not exist shader at disk. - return NULL; - } - return CppObjectToScriptObj( *mtrl ); - } - return NULL; + GPtr mtrl = ScriptApp::CreateMaterial(res); + + return CppObjectToScriptObj( *mtrl ); } static void ICall_GraphicSystem_BlitImage(gpointer textureHandlePtr, MonoObject* destObj, MonoObject* matObj, int passIndex) @@ -113,8 +95,7 @@ namespace App Graphic::RenderToTexture* target = ScriptObjWrapper::Convert( destObj ); Graphic::MaterialInstance* material = ScriptObjWrapper::Convert( matObj ); RenderBase::TextureHandle* tex = static_cast(textureHandlePtr); - - Graphic::ImageFiltrationSystem::Render(tex, target, material, passIndex); + ScriptApp::BlitImage(tex, target, material, passIndex); } //------------------------------------------------------------------------ @@ -122,11 +103,11 @@ namespace App { static const InternalCallDetail s_cScriptBindInternalCallDetail[] = { { "ScriptRuntime.GraphicSystem::ICall_GraphicSystem_GetSceneCamera", (void*)&ICall_GraphicSystem_GetSceneCamera }, + { "ScriptRuntime.GraphicSystem::ICall_GraphicSystem_GetRenderingCamera", (void*)&ICall_GraphicSystem_GetRenderingCamera }, { "ScriptRuntime.GraphicSystem::ICall_GraphicSystem_RenderCamera", (void*)&ICall_GraphicSystem_RenderCamera }, { "ScriptRuntime.GraphicSystem::ICall_GraphicSystem_SetRenderTarget", (void*)&ICall_GraphicSystem_SetRenderTarget }, { "ScriptRuntime.GraphicSystem::ICall_GraphicSystem_GetWidth", (void*)&ICall_GraphicSystem_GetWidth }, { "ScriptRuntime.GraphicSystem::ICall_GraphicSystem_GetHeight", (void*)&ICall_GraphicSystem_GetHeight }, - { "ScriptRuntime.GraphicSystem::ICall_GraphicSystem_GetCameraRenderToTextureByCameraType", (void*)&ICall_GraphicSystem_GetCameraRenderToTextureByCameraType }, { "ScriptRuntime.GraphicSystem::ICall_GraphicSystem_CreateMaterial", (void*)&ICall_GraphicSystem_CreateMaterial }, { "ScriptRuntime.GraphicSystem::ICall_GraphicSystem_BlitImage", (void*)&ICall_GraphicSystem_BlitImage }, }; diff --git a/Engine/app/scriptbind/scriptbind_input.cc b/Engine/app/scriptbind/scriptbind_input.cc index 602035a..ceda51f 100644 --- a/Engine/app/scriptbind/scriptbind_input.cc +++ b/Engine/app/scriptbind/scriptbind_input.cc @@ -35,7 +35,7 @@ THE SOFTWARE. #include "input/android/androidinputserver.h" #include "input/inputtouchscreen.h" #elif defined __OSX__ -#include "input/OSX/OSXinputserver.h" +#include "input/osx/osxinputserver.h" #include "input/inputtouchscreen.h" #endif @@ -52,7 +52,9 @@ namespace App return 0; #endif const GPtr& keyboard = App::InputFeature::Instance()->GetInputServer()->GetDefaultKeyboard(); - return (mono_bool)keyboard->KeyDown((Input::InputKey::Code)iKeyCode); + + bool down = keyboard->KeyDown((Input::InputKey::Code)iKeyCode); + return (mono_bool)down; } //------------------------------------------------------------------------ static mono_bool ICall_Input_KeyUp( int iKeyCode) @@ -320,7 +322,7 @@ namespace App return mouse->GetCurrentEventCount(); } - static void ICall_Input_GetCurrentMouseButtonEvent(int index, int& code, int& event) + static void ICall_Input_GetCurrentMouseButtonEvent(int index, int& code, int& event,Math::float2& pixelPos,Math::float2& screenPos) { #ifdef __OSX__ return; @@ -332,6 +334,8 @@ namespace App Input::MouseButtonEvent mbe = mouse->GetCurrentEvent(index); code = mbe.button; event = mbe.event; + pixelPos = mbe.pixelPos; + screenPos = mbe.screenPos; } static int ICall_Input_GetCurrentTouchEventCount() @@ -348,18 +352,22 @@ namespace App #endif } - static void ICall_Input_GetCurrentTouchEvent(int index, int& id, int& event) + static void ICall_Input_GetCurrentTouchEvent(int index, int& id, int& event,Math::float2& pixelPos,Math::float2& screenPos) { #ifdef __ANDROID__ const GPtr< Input::InputTouchScreen>& touchScreen = App::InputFeature::Instance()->GetInputServer().downcast()->GetDefaultTouchScreen(); Input::TouchEvent te = touchScreen->GetCurrentEvent(index); id = te.id; event = te.event; + pixelPos = te.pixelPos; + screenPos = te.screenPos; #elif defined __OSX__ const GPtr< Input::InputTouchScreen>& touchScreen = App::InputFeature::Instance()->GetInputServer().downcast()->GetDefaultTouchScreen(); Input::TouchEvent te = touchScreen->GetCurrentEvent(index); id = te.id; event = te.event; + pixelPos = te.pixelPos; + screenPos = te.screenPos; #else //n_warning("No Implemention on WIN32 ver.\n"); id = -1; diff --git a/Engine/app/scriptbind/scriptbind_intersectWorld.cc b/Engine/app/scriptbind/scriptbind_intersectWorld.cc index be42e1a..41915e0 100644 --- a/Engine/app/scriptbind/scriptbind_intersectWorld.cc +++ b/Engine/app/scriptbind/scriptbind_intersectWorld.cc @@ -42,11 +42,10 @@ namespace App static mono_bool ICall_IntersectWorld_IntersectActor(MonoObject* monoact, const Math::Ray& ray, uint select_mark,Math::float3& outpos) { - ScriptObjWrapper pActor(monoact); - + Actor* pActor = ScriptObjToCppPointer(monoact); float dis=0.0f; AppUtil::IntersectResultList rsList; - bool ret = AppUtil::IntersectUtil::IntersectActor(ray,pActor.GetCppObjPtr(), select_mark, false, dis); + bool ret = AppUtil::IntersectUtil::IntersectActor(ray,pActor, select_mark, false, dis); outpos = ray.PointAt(dis); diff --git a/Engine/app/scriptbind/scriptbind_material.cc b/Engine/app/scriptbind/scriptbind_material.cc index b1348f7..6f5cf97 100644 --- a/Engine/app/scriptbind/scriptbind_material.cc +++ b/Engine/app/scriptbind/scriptbind_material.cc @@ -97,20 +97,6 @@ namespace App self->SetConstantParam(param_name, value); } - - static void ICall_Material_SetGlobalMatrix(int index, const Math::matrix44& value) - { - Graphic::GlobalMaterialParam* pGMP = Graphic::Material::GetGlobalMaterialParams(); - pGMP->SetMatrixParam(TypeConvert::Conver(index), value); - - } - - static void ICall_Material_SetGlobalVector(int index, const Math::float4& value) - { - Graphic::GlobalMaterialParam* pGMP = Graphic::Material::GetGlobalMaterialParams(); - pGMP->SetVectorParam(TypeConvert::Conver(index), value); - - } //------------------------------------------------------------------------ void ICallReg_ScriptRuntime_Material( void ) { @@ -122,8 +108,6 @@ namespace App { "ScriptRuntime.MaterialInstance::ICall_Material_SetValueFloat", (void*)&ICall_Material_SetValueFloat }, { "ScriptRuntime.MaterialInstance::ICall_Material_SetValueVector4", (void*)&ICall_Material_SetValueVector4 }, { "ScriptRuntime.MaterialInstance::ICall_Material_SetValueMatrix44", (void*)&ICall_Material_SetValueMatrix44 }, - { "ScriptRuntime.MaterialInstance::ICall_Material_SetGlobalMatrix", (void*)&ICall_Material_SetGlobalMatrix }, - { "ScriptRuntime.MaterialInstance::ICall_Material_SetGlobalVector", (void*)&ICall_Material_SetGlobalVector }, }; int size = sizeof(s_cScriptBindInternalCallDetail)/sizeof(InternalCallDetail); diff --git a/Engine/app/scriptbind/scriptbind_physicsbody_component.cc b/Engine/app/scriptbind/scriptbind_physicsbody_component.cc index a7b406f..bb3b09f 100644 --- a/Engine/app/scriptbind/scriptbind_physicsbody_component.cc +++ b/Engine/app/scriptbind/scriptbind_physicsbody_component.cc @@ -264,44 +264,12 @@ namespace App static void ICall_PhysicsBodyComponent_AddForce(MonoObject* pMonoObj, Math::float3& force, PhysicsDynamic::ForceType forcetype, mono_bool bWakeUp) { - ScriptObjWrapper self( pMonoObj ); + ScriptObjWrapper self( pMonoObj ); GPtr pEntity = self->GetEntity(); if(pEntity->IsA(PhysicsDynamic::RTTI)) pEntity.downcast()->AddForce(force,forcetype,Utility_MonoBool(bWakeUp)); } - static void ICall_PhysicsBodyComponent_AddForceAtPos(MonoObject* pMonoObj, Math::float3& force, Math::float3& pos,PhysicsDynamic::ForceType forcetype, mono_bool bWakeUp) - { - ScriptObjWrapper self( pMonoObj ); - GPtr pEntity = self->GetEntity(); - if(pEntity->IsA(PhysicsDynamic::RTTI)) - pEntity.downcast()->AddForceAtPos(force,pos,forcetype,Utility_MonoBool(bWakeUp)); - } - - static void ICall_PhysicsBodyComponent_AddForceAtLocalPos(MonoObject* pMonoObj, Math::float3& force, Math::float3& pos, PhysicsDynamic::ForceType forcetype, mono_bool bWakeUp) - { - ScriptObjWrapper self( pMonoObj ); - GPtr pEntity = self->GetEntity(); - if(pEntity->IsA(PhysicsDynamic::RTTI)) - pEntity.downcast()->AddForceAtLocalPos(force,pos,forcetype,Utility_MonoBool(bWakeUp)); - } - - static void ICall_PhysicsBodyComponent_AddLocalForceAtPos(MonoObject* pMonoObj, Math::float3& force, Math::float3& pos,PhysicsDynamic::ForceType forcetype, mono_bool bWakeUp) - { - ScriptObjWrapper self( pMonoObj ); - GPtr pEntity = self->GetEntity(); - if(pEntity->IsA(PhysicsDynamic::RTTI)) - pEntity.downcast()->AddLocalForceAtPos(force,pos,forcetype,Utility_MonoBool(bWakeUp)); - } - - static void ICall_PhysicsBodyComponent_AddLocalForceAtLocalPos(MonoObject* pMonoObj, Math::float3& force, Math::float3& pos,PhysicsDynamic::ForceType forcetype, mono_bool bWakeUp) - { - ScriptObjWrapper self( pMonoObj ); - GPtr pEntity = self->GetEntity(); - if(pEntity->IsA(PhysicsDynamic::RTTI)) - pEntity.downcast()->AddLocalForceAtLocalPos(force,pos,forcetype,Utility_MonoBool(bWakeUp)); - } - static MonoObject* ICall_PhysicsEntity_GetShapeAt( MonoObject* pMonoObj,int index) { ScriptObjWrapper self( pMonoObj ); diff --git a/Engine/app/scriptbind/scriptbind_render_component.cc b/Engine/app/scriptbind/scriptbind_render_component.cc index 47d525c..8a9c820 100644 --- a/Engine/app/scriptbind/scriptbind_render_component.cc +++ b/Engine/app/scriptbind/scriptbind_render_component.cc @@ -68,9 +68,7 @@ namespace App static void ICall_RenderComponent_SetMaterialInstance( MonoObject* pMonoObj, int iSubMesh, MonoObject* pMonoInstance, mono_bool bCopy) { ScriptObjWrapper self( pMonoObj ); - - ScriptObjWrapper instance( pMonoInstance); - Graphic::MaterialInstance* materialInstance = instance.GetCppObjPtr(); + Graphic::MaterialInstance* materialInstance = ScriptObjToCppPointer(pMonoInstance); bool b = Utility_MonoBool(bCopy); self->SetMaterialID( iSubMesh, materialInstance->GetMaterialID(), b); @@ -126,8 +124,7 @@ namespace App ScriptObjWrapper self( pMonoObj ); Util::String sParamName; Utility_MonoStringToCppString( pMonoStrParamName, sParamName ); - ScriptObjWrapper rtt( pMonoRTT ); - + Graphic::RenderToTexture* rtt = ScriptObjToCppPointer(pMonoRTT); self->SetTexture( iSubMesh, sParamName, rtt->GetTextureHandle()); } //-------------------------------------------------------------------------------------------------- @@ -166,8 +163,8 @@ namespace App static void ICall_RenderComponent_StandaloneRender( MonoObject* pMonoObj, MonoObject* material ) { ScriptObjWrapper self( pMonoObj ); - ScriptObjWrapper mat( material ); - GPtr pMat = mat.GetCppObjPtr(); + Graphic::Material* mat = ScriptObjToCppPointer(material); + GPtr pMat = mat; self->StandaloneRender(pMat); } //-------------------------------------------------------------------------------------------------- diff --git a/Engine/app/scriptbind/scriptbind_scene.cc b/Engine/app/scriptbind/scriptbind_scene.cc index f889403..a481758 100644 --- a/Engine/app/scriptbind/scriptbind_scene.cc +++ b/Engine/app/scriptbind/scriptbind_scene.cc @@ -93,8 +93,7 @@ namespace App static mono_bool ICall_Scene_AddActor( MonoObject* pMonoObj, MonoObject* pActor ) { ScriptObjWrapper self( pMonoObj ); - ScriptObjWrapper add( pActor ); - GPtr actorPtr(add.GetCppObjPtr()); + GPtr actorPtr(ScriptObjToCppPointer(pActor)); self->AddActor( actorPtr ); return c_iMonoBool_True; } @@ -102,8 +101,7 @@ namespace App static mono_bool ICall_Scene_RemoveActor( MonoObject* pMonoObj, MonoObject* pActor ) { ScriptObjWrapper self( pMonoObj ); - ScriptObjWrapper sub( pActor ); - GPtr actorPtr(sub.GetCppObjPtr()); + GPtr actorPtr(ScriptObjToCppPointer(pActor)); self->RemoveActor( actorPtr ); return c_iMonoBool_True; } diff --git a/Engine/app/scriptbind/scriptbind_script_component.cc b/Engine/app/scriptbind/scriptbind_script_component.cc index 0b53369..d750d0b 100644 --- a/Engine/app/scriptbind/scriptbind_script_component.cc +++ b/Engine/app/scriptbind/scriptbind_script_component.cc @@ -45,11 +45,23 @@ namespace App //return NULL; } + static int ICall_ScriptComponent_GetScriptInstanceCount(MonoObject* pMonoObj) + { + ScriptObjWrapper self( pMonoObj ); + return self->GetScriptInstanceCount(); + } + static MonoObject* ICall_ScriptComponent_GetScriptObject(MonoObject* pMonoObj, int index) + { + ScriptObjWrapper self( pMonoObj ); + return self->GetScriptObject(index); + } void ICallReg_ScriptRuntime_ScriptComponent( void ) { static const InternalCallDetail s_cScriptBindInternalCallDetail[] = { - { "ScriptRuntime.ScriptComponent::ICall_ScriptComponent_GetScriptByName", (void*)&ICall_ScriptComponent_GetScriptByName }, + { "ScriptRuntime.ScriptComponent::ICall_ScriptComponent_GetScriptByName", (void*)&ICall_ScriptComponent_GetScriptByName }, + { "ScriptRuntime.ScriptComponent::ICall_ScriptComponent_GetScriptInstanceCount", (void*)&ICall_ScriptComponent_GetScriptInstanceCount }, + { "ScriptRuntime.ScriptComponent::ICall_ScriptComponent_GetScriptObject", (void*)&ICall_ScriptComponent_GetScriptObject }, }; diff --git a/Engine/app/scriptfeature/inc/script_component.h b/Engine/app/scriptfeature/inc/script_component.h index d60d84c..b111295 100644 --- a/Engine/app/scriptfeature/inc/script_component.h +++ b/Engine/app/scriptfeature/inc/script_component.h @@ -84,7 +84,9 @@ namespace App /// get method const Util::TStringArray& GetAssemblyNames() const ; /// get method - int GetScriptCount(); + int GetScriptCount() const; + /// get method + int GetScriptInstanceCount() const; /// get a script instance by name TScriptInstancePtr& GetScriptByName( const Util::String& name ); /// get a script instance by classname @@ -92,6 +94,8 @@ namespace App /// get a ScriptInstance by index,a null pointer is return if the idx is invalid TScriptInstancePtr& GetScriptInstance( int idx ); + MonoObject* GetScriptObject(int idx); + TScriptInstancePtr& FindScriptWithEntryMethod(EEntryMethodIndex emIndex); bool OnRenderPostEffect(int index, CameraComponent* camera, Graphic::RenderToTexture* source, Graphic::RenderToTexture* destination); @@ -205,10 +209,15 @@ namespace App return m_arrAssemblyNames; } //------------------------------------------------------------------------ - inline int ScriptComponent::GetScriptCount() + inline int ScriptComponent::GetScriptCount() const { return m_arrClassNames.Size(); } + + inline int ScriptComponent::GetScriptInstanceCount() const + { + return m_arrScriptInstances.Size(); + } //------------------------------------------------------------------------ inline TScriptInstancePtr& ScriptComponent::GetScriptInstance( int idx ) { diff --git a/Engine/app/scriptfeature/inc/script_instance.h b/Engine/app/scriptfeature/inc/script_instance.h index cf3f1a7..f7b488d 100644 --- a/Engine/app/scriptfeature/inc/script_instance.h +++ b/Engine/app/scriptfeature/inc/script_instance.h @@ -31,6 +31,7 @@ THE SOFTWARE. #include "appframework/app_fwd_decl.h" //#include "app/physXfeature/PhysicsShapeComponent.h" #include "app/scriptfeature/inc/script_message.h" +#include "scriptfeature/script_root_instance.h" namespace Graphic { @@ -161,7 +162,7 @@ namespace App //------------------------------------------------------------------------ inline MonoObject* ScriptInstance::invokeScript(EEntryMethodIndex methodIndex, void** params /* = NULL */) { - if ( IsInit() ) + if ( IsInit() && ScriptRootInstance::HasInstance() ) { MonoMethod* pMethod = m_pArrEntryMethods->operator[]( methodIndex ); if ( pMethod ) diff --git a/Engine/app/scriptfeature/inc/script_utility.h b/Engine/app/scriptfeature/inc/script_utility.h index 823e34d..350c6fb 100644 --- a/Engine/app/scriptfeature/inc/script_utility.h +++ b/Engine/app/scriptfeature/inc/script_utility.h @@ -500,11 +500,11 @@ namespace App template MonoObject* CppObjectToScriptObj( T& rCppObj ) { - const Core::Rtti* pRtti = rCppObj.GetRtti(); - n_assert( NULL != pRtti ); MonoObject* pMonoObj = rCppObj.GetMonoObject(); if ( NULL == pMonoObj ) { + const Core::Rtti* pRtti = rCppObj.GetRtti(); + n_assert( NULL != pRtti ); // - create a script object MonoClass* pMonoClass = NULL; @@ -538,6 +538,17 @@ namespace App } } + template + T* ScriptObjToCppPointer(MonoObject* pScriptObj) + { + if (pScriptObj) + { + return (T*)Utility_GetCppObjectPtr( pScriptObj ); + } + return NULL; + } + + template MonoArray* Utility_CppArrToMonoArr( const Util::Array& cppArr ) { @@ -588,13 +599,15 @@ namespace App : m_pMonoObj( pMonoObj ) , m_pCppObj( NULL ) { - void* pObj = Utility_GetCppObjectPtr( pMonoObj ); - m_pCppObj = static_cast( pObj ); - n_assert( NULL!=m_pCppObj ); + if( NULL!=m_pMonoObj ) + { + void* pObj = Utility_GetCppObjectPtr( pMonoObj ); + m_pCppObj = static_cast( pObj ); + n_assert( NULL!=m_pCppObj ); + } } T* GetCppObjPtr( void ) { return m_pCppObj; } - T& operator * () const { return *m_pCppObj; } T* operator -> () const { return m_pCppObj; } bool IsValid( void ) const { return m_pMonoObj!=NULL;} diff --git a/Engine/app/scriptfeature/script_app.cc b/Engine/app/scriptfeature/script_app.cc new file mode 100644 index 0000000..14c6bfa --- /dev/null +++ b/Engine/app/scriptfeature/script_app.cc @@ -0,0 +1,119 @@ +/**************************************************************************** +Copyright (c) 2011-2013,WebJet Business Division,CYOU + +http://www.genesis-3d.com.cn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#include "stdneb.h" +#include "script_app.h" +#include "graphicsystem/GraphicSystem.h" +#include "resource/resourcemanager.h" +namespace App +{ + + static Graphic::ViewPortWindow* gVPW = NULL; + + + static Graphic::ViewPortWindow* _getViewportWindow() + { + if (gVPW) + { + return gVPW; + } + return Graphic::GraphicSystem::Instance()->GetMainViewPortWindow(); + } + + + CameraComponent* ScriptApp::GetSceneCamera() + { + return GetRenderingCamera(); + } + + CameraComponent* ScriptApp::GetRenderingCamera() + { + const Graphic::Camera* camera = Graphic::GraphicSystem::Instance()->GetRenderingCamera(); + if (camera) + { + Core::RefCounted* owner = camera->GetOwner(); + if (owner) + { + CameraComponent* cc = dynamic_cast(owner); + return cc; + } + } + return NULL; + } + + void ScriptApp::RenderCamera(Graphic::Camera* camera) + { + Graphic::GraphicSystem::Instance()->RenderCamera(camera); + } + + void ScriptApp::SetRenderTarget(Graphic::RenderToTexture* rt, int index) + { + Graphic::GraphicSystem::Instance()->SetRenderTarget(rt, index, RenderBase::RenderTarget::ClearAll); + } + + int ScriptApp::GetWidth() + { + const RenderBase::DisplayMode& dm = _getViewportWindow()->GetDisplayMode(); + return dm.GetWidth(); + } + + int ScriptApp::GetHeight() + { + const RenderBase::DisplayMode& dm = _getViewportWindow()->GetDisplayMode(); + return dm.GetHeight(); + } + + GPtr ScriptApp::CreateMaterial(const Util::String& matID) + { + GPtr matResInfo = Resources::ResourceManager::Instance()->CreateMaterialInfo(matID,0); + if ( !matResInfo.isvalid() ) + { + return NULL; + } + GPtr& mtrl = matResInfo->GetHandle(); + //if ( mtrl.isvalid() ) + //{ + // Util::String defshaderName = "defaultFallBackShader.shader"; + // int len = defshaderName.Length(); + // IndexT pos = matID.FindStringIndex(defshaderName); + // bool bRequestDefaultShader = (pos != InvalidIndex) && (matID.FindStringIndex(defshaderName,(matID.Length() - len) ) != InvalidIndex ); + // if ( !bRequestDefaultShader && mtrl->GetName() == Graphic::Material::s_defaultFallBackMat->GetName() ) + // {// request create shader is not default shader,and returned material is defaultfallback,then i think it is not exist shader at disk. + // return NULL; + // } + //} + + return mtrl; + } + + void ScriptApp::BlitImage(const RenderBase::TextureHandle* texture, const Graphic::RenderToTexture* target, const Graphic::Material* material, int passIndex) + { + Graphic::ImageFiltrationSystem::Render(texture, target, material, passIndex); + } + + + void ScriptApp::_SetTargetWindow(Graphic::ViewPortWindow* vpw) + { + gVPW = vpw; + } +} \ No newline at end of file diff --git a/Engine/app/scriptfeature/script_app.h b/Engine/app/scriptfeature/script_app.h new file mode 100644 index 0000000..745bf56 --- /dev/null +++ b/Engine/app/scriptfeature/script_app.h @@ -0,0 +1,52 @@ +/**************************************************************************** +Copyright (c) 2011-2013,WebJet Business Division,CYOU + +http://www.genesis-3d.com.cn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#ifndef __scriptapp_H__ +#define __scriptapp_H__ + +#include "graphicsystem/Material/materialinstance.h" +#include "graphicsystem/Camera/Camera.h" +#include "graphicsystem/base/RenderToTexture.h" +#include "graphicfeature/components/cameracomponent.h" +namespace App +{ + class ScriptApp + { + public: + static CameraComponent* GetSceneCamera(); + static CameraComponent* GetRenderingCamera(); + static void RenderCamera(Graphic::Camera* camera); + static void SetRenderTarget(Graphic::RenderToTexture* rt, int index); + static int GetWidth(); + static int GetHeight(); + static GPtr CreateMaterial(const Util::String& matID); + static void BlitImage(const RenderBase::TextureHandle* texture, const Graphic::RenderToTexture* target, const Graphic::Material* material, int passIndex); + + + static void _SetTargetWindow(Graphic::ViewPortWindow* vpw); + }; +} + + + +#endif //__scriptapp_H__ \ No newline at end of file diff --git a/Engine/app/scriptfeature/script_component.cc b/Engine/app/scriptfeature/script_component.cc index 6590734..31a31db 100644 --- a/Engine/app/scriptfeature/script_component.cc +++ b/Engine/app/scriptfeature/script_component.cc @@ -388,6 +388,18 @@ namespace App return nullPtr; } + MonoObject* ScriptComponent::GetScriptObject(int idx) + { + if (0 <= idx && idx < m_arrScriptInstances.Size()) + { + if (m_arrScriptInstances[idx].isvalid()) + { + return m_arrScriptInstances[idx]->GetMonoInstance(); + } + } + return NULL; + } + //------------------------------------------------------------------------ void ScriptComponent::CopyFrom( const GPtr& pComponent ) { @@ -1134,7 +1146,15 @@ namespace App #ifdef __GENESIS_EDITOR__ if ( !_pScriptInstance.isvalid() ) { - n_warning("Script instance creation failed! Please make sure that the file name is the same with the class name,and there is no compile errors!\n"); + if (NULL != mActor) + { + n_warning("Script class(%s.%s) is no found, at actor(%s).\n", m_arrNameSpaces[ii].AsCharPtr(), m_arrClassNames[ii].AsCharPtr(), mActor->GetName().AsCharPtr()); + } + else + { + n_warning("Script class(%s.%s) is no found.\n", m_arrNameSpaces[ii].AsCharPtr(), m_arrClassNames[ii].AsCharPtr()); + } + continue; } #endif diff --git a/Engine/app/scriptfeature/script_feature.cc b/Engine/app/scriptfeature/script_feature.cc index ecacca5..b6cbe59 100644 --- a/Engine/app/scriptfeature/script_feature.cc +++ b/Engine/app/scriptfeature/script_feature.cc @@ -201,7 +201,10 @@ namespace App ScriptInstances::Iterator end = scriptInstances.End(); while(it != end) { - (*it)->OnLoad(); + if ((*it).isvalid()) + { + (*it)->OnLoad(); + } ++it; } } @@ -233,7 +236,10 @@ namespace App ScriptInstances::Iterator end = scriptInstances.End(); while(it != end) { - (*it)->OnExit(); + if ((*it).isvalid()) + { + (*it)->OnExit(); + } ++it; } } diff --git a/Engine/app/scriptfeature/script_general_manager.cc b/Engine/app/scriptfeature/script_general_manager.cc index fa5f49a..8e96aba 100644 --- a/Engine/app/scriptfeature/script_general_manager.cc +++ b/Engine/app/scriptfeature/script_general_manager.cc @@ -173,7 +173,10 @@ namespace App GPtr srcStream = IO::IoServer::Instance()->ReadFile( sPath ); #endif if (!srcStream.isvalid()) + { + n_warning("Assemblie is no found: %s.", sPath.AsCharPtr()); continue; + } srcStream->SetAccessMode( IO::Stream::ReadAccess ); diff --git a/Engine/app/soundfeature/components/SoundReverbFilterComponent.cc b/Engine/app/soundfeature/components/SoundReverbFilterComponent.cc index f03f39b..34766a6 100644 --- a/Engine/app/soundfeature/components/SoundReverbFilterComponent.cc +++ b/Engine/app/soundfeature/components/SoundReverbFilterComponent.cc @@ -218,7 +218,7 @@ namespace App { bool result = false; - if ( pEFXEAXReverb ) + if ( pEFXEAXReverb ) { mDSP->setParameter(AL_EAXREVERB_DENSITY,pEFXEAXReverb->flDensity); mDSP->setParameter(AL_EAXREVERB_DIFFUSION,pEFXEAXReverb->flDiffusion); diff --git a/Engine/app/soundfeature/components/SoundSourceComponent.cc b/Engine/app/soundfeature/components/SoundSourceComponent.cc index 2ff29f3..dd2f5d8 100644 --- a/Engine/app/soundfeature/components/SoundSourceComponent.cc +++ b/Engine/app/soundfeature/components/SoundSourceComponent.cc @@ -717,8 +717,12 @@ namespace App bool SoundSource::Set3D(const bool &is3D) { n_assert(mSoundRes); + bool result = mSoundRes->Set3D(is3D); - return mSoundRes->Set3D(is3D); + if(result && Is3D()) + _OnMoveAfter(); + + return result; } //------------------------------------------------------------------------------ @@ -995,6 +999,8 @@ namespace App break; } + if(Is3D()) + _OnMoveAfter(); } //------------------------------------------------------------------------------ void SoundSource::SetPosition(uint position) diff --git a/Engine/app/spritebacth/DrawTextManager.cc b/Engine/app/spritebacth/DrawTextManager.cc index 538f04f..c82c195 100644 --- a/Engine/app/spritebacth/DrawTextManager.cc +++ b/Engine/app/spritebacth/DrawTextManager.cc @@ -263,7 +263,7 @@ namespace App // set font info SetFontSize(12); SetFontColor(Math::float4(1.f,1.f,1.f,1.f)); - //mFpsIndex = AppendDrawText(FPSPOSX,FPSPOSY,"Fps:"); + //mFpsIndex = AppendDrawText(FPSPOSX,FPSPOSY,"FPS:"); //mSecondIndex = AppendDrawText(TriVertPOSX,TriVertPOSY,"Triangles:"); //mThirdIndex = AppendDrawText(RTDrawPOSX,RTDrawPOSY,"RenderTargets:"); diff --git a/Engine/app/spritebacth/statictext.cc b/Engine/app/spritebacth/statictext.cc index 59e9cc0..34ea091 100644 --- a/Engine/app/spritebacth/statictext.cc +++ b/Engine/app/spritebacth/statictext.cc @@ -151,9 +151,9 @@ namespace App m_charInfoTable.Add(key, info); - SizeT dest_addr = (SizeT)m_buffer + (m_nextU + m_nextV * m_width);//(info.rect_int.left + info.rect_int.top * m_width); - SizeT src_addr = (SizeT)data; - SizeT end = src_addr + glyph->bitmap.width * glyph->bitmap.rows; + intptr_t dest_addr = (intptr_t)m_buffer + (m_nextU + m_nextV * m_width);//(info.rect_int.left + info.rect_int.top * m_width); + intptr_t src_addr = (intptr_t)data; + intptr_t end = src_addr + glyph->bitmap.width * glyph->bitmap.rows; while(src_addr < end) { Memory::Copy((void*)src_addr, (void*)dest_addr, glyph->bitmap.width); diff --git a/Engine/app/terrainfeature/components/TerrainRenderComponent.cc b/Engine/app/terrainfeature/components/TerrainRenderComponent.cc index 35ec118..8adf7c0 100644 --- a/Engine/app/terrainfeature/components/TerrainRenderComponent.cc +++ b/Engine/app/terrainfeature/components/TerrainRenderComponent.cc @@ -231,7 +231,9 @@ namespace App const Math::matrix44& world = mActor->GetWorldTransform(); m_TerrainWordTransform.set_position( world.get_position() ); + if(mVisible) + { //when active, need rebuild all data m_bIsHeightMapDirty = true; @@ -246,6 +248,7 @@ namespace App //------------------------------------------------------------------------------ void TerrainRenderComponent::OnDeactivate() { + if(mVisible) { _ClearRenderObjects(); @@ -258,6 +261,24 @@ namespace App return; } //------------------------------------------------------------------------------ +#ifdef __GENESIS_EDITOR__ + void TerrainRenderComponent::SetEditorVisible(bool bVis) + { + Super::SetEditorVisible(bVis); + + if (IsActive()) + { + SizeT nCount = m_RenderObjects.Size(); + + for (IndexT i = 0; i < nCount; ++i) + { + m_RenderObjects.ValueAtIndex(i)->SetEditorVisible(bVis); + } + } + + } +#endif + //------------------------------------------------------------------------------ void TerrainRenderComponent::SetVisible(bool bVisible) { if(bVisible == mVisible) @@ -441,6 +462,35 @@ namespace App } } //------------------------------------------------------------------------ + void TerrainRenderComponent::CheckMaterials() + { + for (int i = 0; i < mRenderableResUnitList.Size(); ++i) + { + const Graphic::RenderbleResUnit& unit = mRenderableResUnitList[i]; + const Graphic::Renderable* pRenderable = unit.GetRenderable(); + + if (pRenderable->GetMaterial()->GetMaterialID() == "sys:Missing_Material.material") + { + if (i == 0) + { + SetMaterialByShaderID(sBaseMapMaterialIdx, sBaseMapShaderID,true); + } + else if ( i == 1) + { + SetMaterialByShaderID(sColorMapMaterialIdx, sColorMapShderID,true); + } + else if ( i == 2) + { + SetMaterialID(i, "sys:TerrainDefault.material", false, 0); + } + else + { + SetMaterialID(i, "sys:TerrainDefaultAdd.material", false, 0); + } + } + } + } + //------------------------------------------------------------------------ void TerrainRenderComponent::_ResetRenderableMark(int index) { //mRenderableResUnitList[index].GetResInfo()->GetHandle()->SetID((Graphic::Material::ID)(Graphic::Material::ID_TerrainBegin + index)); @@ -865,7 +915,9 @@ namespace App m_TerrainDataSource->DelControlMap(controlMapCout_Before -1); } + if(mVisible) + { // delete layer related info //(these render data will be attached when rebuild LOD data) @@ -922,10 +974,6 @@ namespace App oldTilezOffset = tileOffsetValue.AsFloat4(); } - //Get old material sortID(or instanceID) to make new material has same draw order - GPtr matInstance = GetMaterial(matIdx); - uint sortId = n_min(matInstance->GetInstanceID(),matInstance->GetSort()); - //Delete old material // GPtr& pManager = App::GraphicObjectManager::Instance()->GetMaterialInstanceManager(); // pManager->RemoveMaterialInstance(matInstance->GetMaterialID()); @@ -941,10 +989,6 @@ namespace App _ModifyTerrainMaterialDir(curMatID,newMatId); Resources::ResourceManager::Instance()->ModifyMaterialInstanceID(curMatID,newMatId); - //Set sortID to new material - GPtr newMatInstance = GetMaterial(matIdx); - newMatInstance->SetSort(sortId); - // Set texture brush's uv info _SetMaterialTileOffsetParam(matIdx, sUVParamName, oldTilezOffset); @@ -959,6 +1003,13 @@ namespace App _SetMaterialTextureParam(matIdx,sControlParamName, oldControlTexID, 0); } + //Reset material sortId to make sure terrain renderobjs have right order + for(int matIndex=0;matIndex instance = GetMaterial(matIndex); + instance->SetSort(matIndex); + } + m_bIsTextureDirty = true; CheckRenderables(); @@ -1443,7 +1494,10 @@ namespace App Math::float3 ratio(terrainScale.x(),heightScale,terrainScale.y()); m_TerrainDataSource->SetTerrainRatio(ratio); + if(mVisible) + + { m_bIsHeightMapDirty = true; } @@ -1467,7 +1521,9 @@ namespace App m_TerrainDataSource->ResetHeightmpData(nextPowerOfTwo); + if(mVisible) + { // if MipMap level changed, Node and Renderable should be destroyed _ClearRenderObjects(); @@ -1504,7 +1560,9 @@ namespace App SetBaseHeight((int)settings.baseheight); // Clear data + if(mVisible) + { _ClearRenderObjects(); m_bIsHeightMapDirty = true; @@ -1648,7 +1706,10 @@ namespace App (*itor) = *lvalue; } m_TerrainDataSource->BuildHeightmpData(heightMapH,heights); + + if(mVisible) + { m_bIsHeightMapDirty = true; } diff --git a/Engine/app/terrainfeature/components/TerrainRenderComponent.h b/Engine/app/terrainfeature/components/TerrainRenderComponent.h index 464642a..6a7c0d9 100644 --- a/Engine/app/terrainfeature/components/TerrainRenderComponent.h +++ b/Engine/app/terrainfeature/components/TerrainRenderComponent.h @@ -114,6 +114,11 @@ namespace App virtual bool GetCastShadow(); virtual void SetReceiveShadow( bool bReceiveShadow ); virtual bool GetReceiveShadow(); + +#ifdef __GENESIS_EDITOR__ + virtual void SetEditorVisible(bool bVis); +#endif + protected: Resources::TextureResInfo* _GetTextureParam(IndexT index,const Graphic::ShaderParamString& shdTexKey); void _SetMaterialTextureParam(IndexT matIndex, const ShaderParamString& paramName, const Resources::ResourceId& texID, Resources::Priority priority = Resources::ResourcePriority::TextureDefault); @@ -150,6 +155,8 @@ namespace App void CheckRenderables();//called after material being setted + void CheckMaterials(); + // Get all terrain renderobject TerrainRenderComponent::TerrainRenderObjects GetAllRenderObjects(); diff --git a/Engine/app/terrainfeature/components/TerrainRenderComponentSerialization.cc b/Engine/app/terrainfeature/components/TerrainRenderComponentSerialization.cc index edcbd3f..0274a1a 100644 --- a/Engine/app/terrainfeature/components/TerrainRenderComponentSerialization.cc +++ b/Engine/app/terrainfeature/components/TerrainRenderComponentSerialization.cc @@ -208,6 +208,8 @@ namespace App pTRenderCom->GetTerrainDataSource()->SetDataSourceSetting(dataSetting); pTRenderCom->CheckRenderables(); + pTRenderCom->CheckMaterials(); + // render data const SizeT count = pTRenderCom->GetShaderCount(); @@ -504,6 +506,16 @@ namespace App pWriter->SerializeUInt(s_TerrainLMSize, mObject->GetLMSize() ); pWriter->SerializeUInt(s_TerrainLightmapMode, (uint)mObject->GetLightmapMode() ); + + for(int matIndex=0;matIndexGetMaterialCount();matIndex++) + { + GPtr instance = mObject->GetMaterial(matIndex); + if (instance) + { + Resources::ResourceManager::Instance()->SaveMaterial(instance->GetMaterialID()); + } + } + return; } diff --git a/Engine/app/terrainfeature/components/TerrainRenderObject.cc b/Engine/app/terrainfeature/components/TerrainRenderObject.cc index 18a5f6d..69eacdb 100644 --- a/Engine/app/terrainfeature/components/TerrainRenderObject.cc +++ b/Engine/app/terrainfeature/components/TerrainRenderObject.cc @@ -57,6 +57,9 @@ namespace App SetTransform(world); SetBoundingBox( node->GetLocalBoundingBox() ); SetLayerID(mOwner->GetActor()->GetLayerID()); +#ifdef __GENESIS_EDITOR__ + SetEditorVisible(mOwner->IsEditorVisible()); +#endif } void TerrainRenderObject::AddToCollection(Graphic::RenderDataCollection* collection, const Graphic::RenderConfig* renderConfig) diff --git a/Engine/app/vegetationfeature/components/vegetationrendercomponent.cc b/Engine/app/vegetationfeature/components/vegetationrendercomponent.cc index ea61866..3537832 100644 --- a/Engine/app/vegetationfeature/components/vegetationrendercomponent.cc +++ b/Engine/app/vegetationfeature/components/vegetationrendercomponent.cc @@ -53,6 +53,10 @@ namespace App //------------------------------------------------------------------------ VegetationRenderComponent::VegetationRenderComponent() :mVisible(true) + ,mAttached(false) +#ifdef __GENESIS_EDITOR__ + ,m_bEditorVis(true) +#endif { } @@ -114,7 +118,8 @@ namespace App //------------------------------------------------------------------------ void VegetationRenderComponent::OnActivate() { - if(mVisible) + + if(mVisible) { BuildRenderData(); AttachRenderObjects(); @@ -125,7 +130,11 @@ namespace App //------------------------------------------------------------------------ void VegetationRenderComponent::OnDeactivate() { +#if __GENESIS_EDITOR__ + if(m_bEditorVis) +#else if(mVisible) +#endif { DeattachRenderObjects(); DiscardRenderData(); @@ -139,8 +148,29 @@ namespace App Super::OnDestroy(); } //------------------------------------------------------------------------ +#if __GENESIS_EDITOR__ + void VegetationRenderComponent::SetEditorVisible(bool bVis) + { + m_bEditorVis = bVis; + + if (IsActive()) + { + + for (int nObj = 0; nObj < mRenderDates.Size(); ++nObj) + { + mRenderDates[nObj]->SetEditorVisible(bVis); + + } + } + } +#endif + //------------------------------------------------------------------------ void VegetationRenderComponent::SetVisible(bool bVisible) { + if ( bVisible == mVisible ) + { + return; + } mVisible = bVisible; if (IsActive()) { @@ -490,7 +520,7 @@ namespace App //------------------------------------------------------------------------ void VegetationRenderComponent::AttachRenderObjects(void) { - + mAttached = true; for (int nObj = 0; nObj < mRenderDates.Size(); ++nObj) { _AttachRenderObject(mRenderDates[nObj]); @@ -521,7 +551,7 @@ namespace App void VegetationRenderComponent::DeattachRenderObjects(void) { //TODO : foreach object - + mAttached = false; for (int nObj = 0; nObj < mRenderDates.Size(); ++nObj) { _DeattachRenderObject(mRenderDates[nObj]); diff --git a/Engine/app/vegetationfeature/components/vegetationrendercomponent.h b/Engine/app/vegetationfeature/components/vegetationrendercomponent.h index 8f9e820..d660ebb 100644 --- a/Engine/app/vegetationfeature/components/vegetationrendercomponent.h +++ b/Engine/app/vegetationfeature/components/vegetationrendercomponent.h @@ -128,6 +128,11 @@ namespace App bool CreateInstanceMap(const GPtr& obj); +#ifdef __GENESIS_EDITOR__ + virtual void SetEditorVisible(bool bVis); +#endif + + protected: /// @Component::OnActivate called from Actor::ActivateComponents() virtual void OnActivate(); @@ -175,6 +180,11 @@ namespace App Util::Array mRenderDates; bool mIsTrans; bool mVisible; + bool mAttached; + +#ifdef __GENESIS_EDITOR__ + bool m_bEditorVis; +#endif }; diff --git a/Engine/foundation/core/debug.cc b/Engine/foundation/core/debug.cc index 98419f2..bffa985 100644 --- a/Engine/foundation/core/debug.cc +++ b/Engine/foundation/core/debug.cc @@ -182,6 +182,16 @@ n_dbgout(const char *msg, ...) IO::Console::Instance()->DebugOut(msg, argList); va_end(argList); } +#if defined( DEBUG ) || defined( _DEBUG ) +void __cdecl +n_debuglog(const char *msg, ...) +{ + va_list argList; + va_start(argList, msg); + IO::Console::Instance()->Print(msg, argList); + va_end(argList); +} +#endif #endif //------------------------------------------------------------------------------ diff --git a/Engine/foundation/core/debug.h b/Engine/foundation/core/debug.h index f4a8228..8b12297 100644 --- a/Engine/foundation/core/debug.h +++ b/Engine/foundation/core/debug.h @@ -46,26 +46,32 @@ THE SOFTWARE. #if defined( DEBUG ) || defined( _DEBUG ) || defined( __WIN32__ ) -#if __ANDROID__ -#define n_printf(...) __android_log_print(ANDROID_LOG_VERBOSE, "ProjectName", __VA_ARGS__) -#define n_error(...) __android_log_print(ANDROID_LOG_ERROR, "ProjectName", __VA_ARGS__) -#define n_dbgout(...) __android_log_print(ANDROID_LOG_DEBUG, "ProjectName", __VA_ARGS__) -#define n_warning(...) __android_log_print(ANDROID_LOG_WARN, "ProjectName", __VA_ARGS__) -#define n_confirm(...) __android_log_print(ANDROID_LOG_INFO, "ProjectName", __VA_ARGS__) + #if __ANDROID__ + #define n_printf(...) __android_log_print(ANDROID_LOG_VERBOSE, "ProjectName", __VA_ARGS__) + #define n_error(...) __android_log_print(ANDROID_LOG_ERROR, "ProjectName", __VA_ARGS__) + #define n_dbgout(...) __android_log_print(ANDROID_LOG_DEBUG, "ProjectName", __VA_ARGS__) + #define n_warning(...) __android_log_print(ANDROID_LOG_WARN, "ProjectName", __VA_ARGS__) + #define n_confirm(...) __android_log_print(ANDROID_LOG_INFO, "ProjectName", __VA_ARGS__) + #define n_debuglog(...) __android_log_print(ANDROID_LOG_INFO, "ProjectName", __VA_ARGS__) + #else + void n_printf(const char *, ...) __attribute__((format(printf,1,2))); + void n_error(const char*, ...) __attribute__((format(printf,1,2))); + void n_dbgout(const char*, ...) __attribute__((format(printf,1,2))); + void n_warning(const char*, ...) __attribute__((format(printf,1,2))); + void n_confirm(const char*, ...) __attribute__((format(printf,1,2))); + #if defined( DEBUG ) || defined( _DEBUG ) + void n_debuglog(const char*, ...) __attribute__((format(printf,1,2))); + #else + #define n_debuglog(...) + #endif // _DEBUG + #endif #else -void n_printf(const char *, ...) __attribute__((format(printf,1,2))); -void n_error(const char*, ...) __attribute__((format(printf,1,2))); -void n_dbgout(const char*, ...) __attribute__((format(printf,1,2))); -void n_warning(const char*, ...) __attribute__((format(printf,1,2))); -void n_confirm(const char*, ...) __attribute__((format(printf,1,2))); -#endif -#else - -#define n_printf(...) -#define n_error(...) -#define n_dbgout(...) -#define n_warning(...) -#define n_confirm( ...) + #define n_printf(...) + #define n_error(...) + #define n_dbgout(...) + #define n_warning(...) + #define n_confirm( ...) + #define n_debuglog(...) #endif diff --git a/Engine/foundation/exception/exceptionbase.h b/Engine/foundation/exception/exceptionbase.h index 28013ee..60bd6b1 100644 --- a/Engine/foundation/exception/exceptionbase.h +++ b/Engine/foundation/exception/exceptionbase.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __EXCEPTION_H__ #define __EXCEPTION_H__ #include -#include "Util/string.h" +#include "util/string.h" namespace Exceptions { diff --git a/Engine/foundation/io/ioserver.cc b/Engine/foundation/io/ioserver.cc index 2836719..b8252e6 100644 --- a/Engine/foundation/io/ioserver.cc +++ b/Engine/foundation/io/ioserver.cc @@ -35,7 +35,7 @@ THE SOFTWARE. #include "io/archfs/archivefilesystem.h" #include "io/FileService/fileservicesystem.h" -#include "packageTool/PackageSystem.h" +#include "packagetool/PackageSystem.h" namespace IO { diff --git a/Engine/foundation/io/ioserver.h b/Engine/foundation/io/ioserver.h index 7050663..4026c58 100644 --- a/Engine/foundation/io/ioserver.h +++ b/Engine/foundation/io/ioserver.h @@ -48,8 +48,8 @@ THE SOFTWARE. #include "io/assignregistry.h" #include "io/schemeregistry.h" #include "io/iointerfaceprotocol.h" -#include "fileservice/fileservicesystem.h" -#include "packageTool/PackageSystem.h" +#include "FileService/fileservicesystem.h" +#include "packagetool/PackageSystem.h" //------------------------------------------------------------------------------ namespace IO { diff --git a/Engine/foundation/io/logfileconsolehandler.cc b/Engine/foundation/io/logfileconsolehandler.cc index dc81918..5515782 100644 --- a/Engine/foundation/io/logfileconsolehandler.cc +++ b/Engine/foundation/io/logfileconsolehandler.cc @@ -72,10 +72,14 @@ LogFileConsoleHandler::Open() fileName.Format("home:logfiles/%s_%s.txt", Core::CoreServer::Instance()->GetAppName().Value(), calString.AsCharPtr()); // open file stream - this->stream = ioServer->CreateFileStream(URI(fileName)); + this->stream = IO::IoServer::Instance()->CreateFileStream(URI(fileName)); this->textWriter = TextWriter::Create(); this->textWriter->SetStream(this->stream); this->textWriter->Open(); + + this->textWriter->WriteChar(0xef); + this->textWriter->WriteChar(0xbb); + this->textWriter->WriteChar(0xbf); } //------------------------------------------------------------------------------ diff --git a/Engine/foundation/io/textwriter.h b/Engine/foundation/io/textwriter.h index c9aebbe..d45e7b1 100644 --- a/Engine/foundation/io/textwriter.h +++ b/Engine/foundation/io/textwriter.h @@ -55,7 +55,7 @@ public: /// write a number of lines, separated by new-lines void WriteLines(const Util::Array& lines); /// generic writer method - template void Write(const T& t); + //template void Write(const T& t); }; } // namespace IO diff --git a/Engine/foundation/threading/osx/osxthread.cc b/Engine/foundation/threading/osx/osxthread.cc index 154fa0d..e499b1f 100644 --- a/Engine/foundation/threading/osx/osxthread.cc +++ b/Engine/foundation/threading/osx/osxthread.cc @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "stdneb.h" #include "osxthread.h" -#include "threading/threadruntimeinfo.h" +#include "threading/ThreadRuntimeInfo.h" namespace OSX { __ImplementClass(OSX::OSXThread, 'THRD', Core::RefCounted); diff --git a/Engine/foundation/util/localstringatomtable.cc b/Engine/foundation/util/localstringatomtable.cc index abf7659..ceb7f74 100644 --- a/Engine/foundation/util/localstringatomtable.cc +++ b/Engine/foundation/util/localstringatomtable.cc @@ -25,7 +25,7 @@ THE SOFTWARE. #include "stdneb.h" #include "util/localstringatomtable.h" -#include "threading/threadruntimeinfo.h" +#include "threading/ThreadRuntimeInfo.h" namespace Util { // 静态变量初始化顺序的原因。自行设定标识符号。 diff --git a/Engine/graphicsystem/Camera/Camera.cc b/Engine/graphicsystem/Camera/Camera.cc index 731896f..73d6c91 100644 --- a/Engine/graphicsystem/Camera/Camera.cc +++ b/Engine/graphicsystem/Camera/Camera.cc @@ -104,6 +104,9 @@ namespace Graphic ,m_quadRenderable(NULL) ,m_antiAliasQuality(RenderBase::AntiAliasQuality::None) ,m_bUseCallBack(true) +#if __GENESIS_EDITOR__ + ,m_CamTarget(GAME) +#endif { const RenderBase::DisplayMode& dm = GraphicSystem::Instance()->GetMainViewPortWindow()->GetDisplayMode(); m_setting.SetupPerspectiveFovRH(Graphic::Camera::PerspNormalFov, float(dm.GetWidth())/float(dm.GetHeight()), 1.0f, S_Camera_Far);// 0.1f diff --git a/Engine/graphicsystem/Camera/Camera.h b/Engine/graphicsystem/Camera/Camera.h index ce449ff..062e815 100644 --- a/Engine/graphicsystem/Camera/Camera.h +++ b/Engine/graphicsystem/Camera/Camera.h @@ -24,7 +24,7 @@ THE SOFTWARE. #ifndef CAMERA_H_ #define CAMERA_H_ -#include "RenderSystem/RenderSystem.h" +#include "rendersystem/RenderSystem.h" #include "Camera/CameraSetting.h" #include "base/GraphicObject.h" #include "Light/Light.h" @@ -202,6 +202,8 @@ namespace Graphic const GPtr& GetSwapTexture() const; ///set lightlit map void SetLightLitMap(const GPtr& rtt); + + bool IsRenderDepthMap() const; /// render depth map bool HasDepthMap() const; /// get depth map @@ -213,6 +215,7 @@ namespace Graphic const GPtr& GetDeferredLightMap() const; + bool IsRenderLightLitMap() const; /// render light lit map bool HasLightLitMap() const; /// get light lit map @@ -316,6 +319,20 @@ namespace Graphic void SetUseCallBack(bool bUse); bool GetUseCallBack(); + +#if __GENESIS_EDITOR__ + + enum CameraTarget + { + SCENE = 0, + GAME + }; + + void SetCameraTarget(const CameraTarget bTarget); + + CameraTarget GetCameraTarget() const; +#endif + private: void registWindowEvent(); @@ -373,6 +390,10 @@ namespace Graphic bool m_bUseBeforeDrawEvent; bool m_bUseCallBack; +#if __GENESIS_EDITOR__ + CameraTarget m_CamTarget; +#endif + }; //------------------------------------------------------------------------------ @@ -474,11 +495,16 @@ namespace Graphic return m_swapTexture; } - inline bool Camera::HasDepthMap() const + inline bool Camera::IsRenderDepthMap() const { return m_bRenderDepthMap; } + inline bool Camera::HasDepthMap() const + { + return m_bRenderDepthMap && m_depthMap.isvalid(); + } + inline const GPtr& Camera::GetDepthMap() const { return m_depthMap; @@ -499,11 +525,16 @@ namespace Graphic return m_deferredLightMap; } - inline bool Camera::HasLightLitMap() const + inline bool Camera::IsRenderLightLitMap() const { return m_bRenderLightLitMap; } + inline bool Camera::HasLightLitMap() const + { + return m_bRenderLightLitMap && m_lightLitTexture.isvalid(); + } + inline const GPtr& Camera::GetLightLitTexture() const { return m_lightLitTexture; @@ -727,6 +758,17 @@ namespace Graphic return m_bUseCallBack; } //--------------------------------------------------------------------------------- +#if __GENESIS_EDITOR__ + inline void Camera::SetCameraTarget(const CameraTarget bTarget) + { + m_CamTarget = bTarget; + } + + inline Camera::CameraTarget Camera::GetCameraTarget() const + { + return m_CamTarget; + } +#endif } diff --git a/Engine/graphicsystem/Camera/RenderPipeline/RenderData.cc b/Engine/graphicsystem/Camera/RenderPipeline/RenderData.cc index 55533ce..5eaea87 100644 --- a/Engine/graphicsystem/Camera/RenderPipeline/RenderData.cc +++ b/Engine/graphicsystem/Camera/RenderPipeline/RenderData.cc @@ -49,11 +49,15 @@ namespace Graphic const RenderData& lhs = data[lIndrex]; const RenderData& rhs = data[rIndex]; - if (lhs.renderable->GetMaterial()->GetRenderQueue().GetQueueIndex() != rhs.renderable->GetMaterial()->GetRenderQueue().GetQueueIndex()) + const MaterialInstance* lmat = lhs.renderable->GetMaterial(); + const MaterialInstance* rmat = rhs.renderable->GetMaterial(); + + if (lmat->GetRenderQueue().GetQueueIndex() != rmat->GetRenderQueue().GetQueueIndex()) { - return lhs.renderable->GetMaterial()->GetRenderQueue().GetQueueIndex() < rhs.renderable->GetMaterial()->GetRenderQueue().GetQueueIndex(); + return lmat->GetRenderQueue().GetQueueIndex() < rmat->GetRenderQueue().GetQueueIndex(); } + if (!opaque) { float lhsOrder = lhs.onwer->distance + lhs.renderable->GetSort(); @@ -65,13 +69,17 @@ namespace Graphic } } - if (lhs.renderable->GetMaterial()->GetSort() != rhs.renderable->GetMaterial()->GetSort()) + if (lmat->GetSort() != rmat->GetSort()) { - return lhs.renderable->GetMaterial()->GetSort() < rhs.renderable->GetMaterial()->GetSort(); + return lmat->GetSort() < rmat->GetSort(); } - if (lhs.renderable->GetMaterial()->GetShaderInstanceID() != rhs.renderable->GetMaterial()->GetShaderInstanceID()) + if (lmat->GetShaderInstanceID() != rmat->GetShaderInstanceID()) { - return lhs.renderable->GetMaterial()->GetShaderInstanceID() < rhs.renderable->GetMaterial()->GetShaderInstanceID(); + return lmat->GetShaderInstanceID() < rmat->GetShaderInstanceID(); + } + if (lmat->GetInstanceID() != rmat->GetInstanceID()) + { + return lmat->GetInstanceID() < rmat->GetInstanceID(); } if (opaque) @@ -115,13 +123,16 @@ namespace Graphic const RenderData& lhs = data[lIndrex]; const RenderData& rhs = data[rIndex]; - if (lhs.renderable->GetMaterial()->GetSort() != rhs.renderable->GetMaterial()->GetSort()) + const MaterialInstance* lmat = lhs.renderable->GetMaterial(); + const MaterialInstance* rmat = rhs.renderable->GetMaterial(); + + if (lmat->GetShaderInstanceID() != rmat->GetShaderInstanceID()) { - return lhs.renderable->GetMaterial()->GetSort() < rhs.renderable->GetMaterial()->GetSort(); + return lmat->GetShaderInstanceID() < rmat->GetShaderInstanceID(); } - if (lhs.renderable->GetMaterial()->GetShaderInstanceID() != rhs.renderable->GetMaterial()->GetShaderInstanceID()) + if (lmat->GetInstanceID() != rmat->GetInstanceID()) { - return lhs.renderable->GetMaterial()->GetShaderInstanceID() < rhs.renderable->GetMaterial()->GetShaderInstanceID(); + return lmat->GetInstanceID() < rmat->GetInstanceID(); } return lhs.onwer->distance < rhs.onwer->distance; diff --git a/Engine/graphicsystem/Camera/RenderPipeline/RenderPipelineManager.cc b/Engine/graphicsystem/Camera/RenderPipeline/RenderPipelineManager.cc index 6981cf0..2b57185 100644 --- a/Engine/graphicsystem/Camera/RenderPipeline/RenderPipelineManager.cc +++ b/Engine/graphicsystem/Camera/RenderPipeline/RenderPipelineManager.cc @@ -177,6 +177,21 @@ namespace Graphic if (mark) { + +#if __GENESIS_EDITOR__ + if (renderObj->IsEditorVisible() || camera->GetCameraTarget() == Camera::GAME) + { + if (mainCamera && renderObj->GetNeedCullCallBack()) + { + params.m_callBacks.Append(renderObj); + } + Math::float4 renderablePos = renderObj->GetTransform().get_position(); + Math::float4 camToObj = renderablePos - camPos; + VisibleNode& node = params.m_visibleNodes.PushBack(); + node.object = renderObj; + node.distance = Math::float4::dot3(camDir,camToObj); + } +#else if (mainCamera && renderObj->GetNeedCullCallBack()) { params.m_callBacks.Append(renderObj); @@ -186,6 +201,8 @@ namespace Graphic VisibleNode& node = params.m_visibleNodes.PushBack(); node.object = renderObj; node.distance = Math::float4::dot3(camDir,camToObj); +#endif + } } @@ -199,9 +216,19 @@ namespace Graphic uint mark = (*it)->GetRenderCullMark() & (uint)camera->GetCullMask(); if (mark) { +#if __GENESIS_EDITOR__ + if ( (*it)->IsEditorVisible() || camera->GetCameraTarget() == Camera::GAME) + { + VisibleNode& node = params.m_visibleNodes.PushBack(); + node.object = *it; + node.distance = 0; + } +#else VisibleNode& node = params.m_visibleNodes.PushBack(); node.object = *it; node.distance = 0; +#endif + } ++it; } diff --git a/Engine/graphicsystem/GraphicObjectManager.cc b/Engine/graphicsystem/GraphicObjectManager.cc index ec9ec25..69332f8 100644 --- a/Engine/graphicsystem/GraphicObjectManager.cc +++ b/Engine/graphicsystem/GraphicObjectManager.cc @@ -58,7 +58,7 @@ namespace App GPtr pRes(res); GPtr pMesh = pRes.downcast(); - uint32 updateThreadID = uint32(Thread::GetMyThreadId()); + intptr_t updateThreadID = intptr_t(Thread::GetMyThreadId()); if ( GraphicObjectManager::Instance()->m_MainThreadID == updateThreadID ) { GraphicObjectManager::Instance()->UpdataPrimitiveHandle( pMesh ); @@ -72,7 +72,7 @@ namespace App GPtr pRes(res); GPtr pImage = pRes.downcast(); - uint32 updateThreadID = uint32(Thread::GetMyThreadId()); + intptr_t updateThreadID = intptr_t(Thread::GetMyThreadId()); if ( GraphicObjectManager::Instance()->m_MainThreadID == updateThreadID ) { @@ -83,7 +83,7 @@ namespace App //------------------------------------------------------------------------ GraphicObjectManager::GraphicObjectManager() { - m_MainThreadID = uint32(Thread::GetMyThreadId()); + m_MainThreadID = intptr_t(Thread::GetMyThreadId()); __ConstructImageSingleton; } diff --git a/Engine/graphicsystem/GraphicObjectManager.h b/Engine/graphicsystem/GraphicObjectManager.h index b2eb4c3..9df0aa7 100644 --- a/Engine/graphicsystem/GraphicObjectManager.h +++ b/Engine/graphicsystem/GraphicObjectManager.h @@ -139,7 +139,7 @@ namespace App GPtr mMaterialInstanceManager; public: - uint32 m_MainThreadID; + intptr_t m_MainThreadID; }; inline GPtr& GraphicObjectManager::GetMaterialInstanceManager() { diff --git a/Engine/graphicsystem/Material/GlobalShaderParam.cc b/Engine/graphicsystem/Material/GlobalShaderParam.cc index dced97c..5dd19c4 100644 --- a/Engine/graphicsystem/Material/GlobalShaderParam.cc +++ b/Engine/graphicsystem/Material/GlobalShaderParam.cc @@ -98,6 +98,8 @@ namespace Graphic m_globalShaderParams[eGShaderParticleMovement] = GlobalShaderParam(float4(0.f,0.f,0.f,0.f),Util::String("g_ParticleMovement")); m_globalShaderParams[eGShaderParticleColor] = GlobalShaderParam(float4(1.f,1.f,1.f,1.f),Util::String("g_ParticleColor")); m_globalShaderParams[eGShaderParticleTexAnim] = GlobalShaderParam(float4(1.f,1.f,0.f,0.f),Util::String("g_ParticleTexAnim")); + m_globalShaderParams[eGShaderParticleUpVec] = GlobalShaderParam(float4(0.f,1.f,0.f,0.f),Util::String("g_ParticleUpVec")); + m_globalShaderParams[eGShaderParticleRightVec] = GlobalShaderParam(float4(1.f,0.f,0.f,0.f),Util::String("g_ParticleRightVec")); m_globalShaderParams[eGShaderMatLMTexParam] = GlobalShaderParam(float4(0.f,0.f,1.f,1.f),Util::String("g_LMTexParam")); m_globalShaderParams[eGShaderMatLMEnable] = GlobalShaderParam(float4(0.f,0.f,0.f,0.f),Util::String("g_UseLM")); diff --git a/Engine/graphicsystem/Material/GlobalShaderParam.h b/Engine/graphicsystem/Material/GlobalShaderParam.h index 46e5116..d0ff4e5 100644 --- a/Engine/graphicsystem/Material/GlobalShaderParam.h +++ b/Engine/graphicsystem/Material/GlobalShaderParam.h @@ -110,6 +110,8 @@ namespace Graphic eGShaderParticleMovement, // g_ParticleMovement; eGShaderParticleColor, // g_ParticleColor; eGShaderParticleTexAnim, // g_ParticleTexAnim; + eGShaderParticleUpVec, // g_ParticleUpVec + eGShaderParticleRightVec, // g_ParticleRightVec eGShaderMatLMTexParam, // g_LMTexParam eGShaderMatLMEnable, // g_UseLM diff --git a/Engine/graphicsystem/Material/MaterialManager.cc b/Engine/graphicsystem/Material/MaterialManager.cc index 7352133..05207b8 100644 --- a/Engine/graphicsystem/Material/MaterialManager.cc +++ b/Engine/graphicsystem/Material/MaterialManager.cc @@ -236,7 +236,18 @@ namespace Graphic IndexT index = m_graphicMaterialInstanceMap.FindIndex(matID); if(InvalidIndex == index ) { - n_assert(0); + IndexT nMissing = m_graphicMaterialInstanceMap.FindIndex("sys:Missing_Material.material"); + if (nMissing != InvalidIndex) + { + aMat = m_graphicMaterialInstanceMap.ValueAtIndex(nMissing); + } + else + { + aMat = _CreateNewMaterialInstance("sys:Missing_Material.material"); + aMat->SetMaterialID(aMat->GetMaterialID()); + m_graphicMaterialInstanceMap.Add("sys:Missing_Material.material",aMat); + n_warning("Material Missing, use default material instead!"); + } return aMat; } aMat = m_graphicMaterialInstanceMap.ValueAtIndex(index); diff --git a/Engine/graphicsystem/Material/MaterialParam.cc b/Engine/graphicsystem/Material/MaterialParam.cc index 9844602..48f2d62 100644 --- a/Engine/graphicsystem/Material/MaterialParam.cc +++ b/Engine/graphicsystem/Material/MaterialParam.cc @@ -26,6 +26,7 @@ THE SOFTWARE. namespace Graphic { + MaterialParamMatrix::MaterialParamMatrix() { m_type = eMaterialParamMatrix; diff --git a/Engine/graphicsystem/Material/MaterialParam.h b/Engine/graphicsystem/Material/MaterialParam.h index 3d81958..6268c63 100644 --- a/Engine/graphicsystem/Material/MaterialParam.h +++ b/Engine/graphicsystem/Material/MaterialParam.h @@ -43,27 +43,39 @@ namespace Graphic virtual ~MaterialParam(); void SetStringValue(const Util::String& valStr); const Util::String& GetStringValue() const; + void SetName(const Util::String& name); const Util::String& GetName() const; + void SetDesc(const Util::String& desc); const Util::String& GetDesc() const; + + void SetHiddenInEditor(bool hiddenInEditor); + const bool GetHiddenInEditor() const; + + void SetUseForColor(bool usedForColor); + const bool GetUseForColor() const; + const MaterialParameterType& GetType() const; const bool IsConstType() const; const bool IsTexType() const; - protected: + protected: MaterialParam(); Util::String m_name; Util::String m_desc; Util::String m_valueStr; MaterialParameterType m_type; + bool m_hiddenInEditor; + bool m_bUsedForColor; }; typedef Util::Array MaterialParamList; inline MaterialParam::MaterialParam() { - //empty + m_hiddenInEditor = false; + m_bUsedForColor = false; }; inline MaterialParam::~MaterialParam() @@ -91,10 +103,31 @@ namespace Graphic return m_desc; } + inline void MaterialParam::SetHiddenInEditor(bool hiddenInEditor) + { + m_hiddenInEditor = hiddenInEditor; + } + + inline const bool MaterialParam::GetHiddenInEditor() const + { + return m_hiddenInEditor; + } + + inline void MaterialParam::SetUseForColor(bool usedForColor) + { + m_bUsedForColor = usedForColor; + } + + inline const bool MaterialParam::GetUseForColor() const + { + return m_bUsedForColor; + } + inline const MaterialParameterType& MaterialParam::GetType() const { return m_type; } + inline const bool MaterialParam::IsConstType() const { return m_type >= eMaterialParamMatrix && m_type <= eMaterialParamFloat; @@ -107,7 +140,21 @@ namespace Graphic inline void MaterialParam::SetStringValue(const Util::String& valStr) { - m_valueStr = valStr; + if (m_bUsedForColor) + { + Math::float4 val = valStr.AsFloat4(); + + val.x() = Math::n_clamp(val.x(), 0.0f, 1.0f); + val.y() = Math::n_clamp(val.y(), 0.0f, 1.0f); + val.z() = Math::n_clamp(val.z(), 0.0f, 1.0f); + val.w() = Math::n_clamp(val.w(), 0.0f, 1.0f); + m_valueStr.SetFloat4(val); + } + else + { + m_valueStr = valStr; + } + } inline const Util::String& MaterialParam::GetStringValue() const @@ -149,7 +196,19 @@ namespace Graphic inline void MaterialParamVector::SetValue(const Math::float4& val) { - m_value = val; + if (m_bUsedForColor) + { + m_value.x() = Math::n_clamp(val.x(), 0.0f, 1.0f); + m_value.y() = Math::n_clamp(val.y(), 0.0f, 1.0f); + m_value.z() = Math::n_clamp(val.z(), 0.0f, 1.0f); + m_value.w() = Math::n_clamp(val.w(), 0.0f, 1.0f); + } + else + { + m_value = val; + } + + m_valueStr.SetFloat4(m_value); } inline const Math::float4& MaterialParamVector::GetValue() const diff --git a/Engine/graphicsystem/Material/materialinstance.cc b/Engine/graphicsystem/Material/materialinstance.cc index 9b5f721..3d03ea3 100644 --- a/Engine/graphicsystem/Material/materialinstance.cc +++ b/Engine/graphicsystem/Material/materialinstance.cc @@ -35,6 +35,7 @@ namespace Graphic using namespace Resources; GPtr MaterialInstance::NullMaterial(NULL); static uint sInstanceID = 1;//零位保留,表示空 + static const uint sSortDefault = 1000; static const Util::String scUserDefTex="#UserDefTex"; @@ -42,8 +43,9 @@ namespace Graphic , m_allLoaded(false) , m_isbuild(false) , m_materialID("") + , m_sort(sSortDefault) { - m_sort = sInstanceID; + //m_sort = sSortDefault; m_InstanceID = sInstanceID; ++sInstanceID; //empty @@ -200,7 +202,8 @@ namespace Graphic if (ePFR_Succeed == ret) { mp->SetValue(val); - _SetConstantParamOld(paramName, Util::String::FromFloat4(val)); + Util::String val1 = mp->GetStringValue(); + _SetConstantParamOld(paramName, val1 ); } return ret; } @@ -240,6 +243,7 @@ namespace Graphic { MaterialParamVector* mpv = static_cast(mp); mpv->SetValue(val.AsFloat4()); + val = mpv->GetStringValue(); break; } case Graphic::eMaterialParamFloat: @@ -400,9 +404,70 @@ namespace Graphic for (IndexT j = 0; j < list.Size(); ++j) { - if (matParmList[i]->GetName() == list[j]->GetName()) + if (matParmList[i]->GetName() == list[j]->GetName() + && matParmList[i]->GetType() == matParmList[i]->GetType()) { - matParmList[i]->SetStringValue(list[j]->GetStringValue()); + switch (matParmList[i]->GetType()) + { + case eMaterialParamFloat: + { + MaterialParamFloat* source = static_cast(list[j]); + MaterialParamFloat* dest = static_cast(matParmList[i]); + dest->SetValue(source->GetValue()); + dest->SetStringValue(source->GetStringValue()); + } + break; + case eMaterialParamVector: + { + MaterialParamVector* source = static_cast(list[j]); + MaterialParamVector* dest = static_cast(matParmList[i]); + dest->SetValue(source->GetValue()); + dest->SetStringValue(source->GetStringValue()); + } + break; + case eMaterialParamMatrix: + { + MaterialParamMatrix* source = static_cast(list[j]); + MaterialParamMatrix* dest = static_cast(matParmList[i]); + dest->SetValue(source->GetValue()); + dest->SetStringValue(source->GetStringValue()); + } + break; + case eMaterialParamTexture1D: + { + MaterialParamTex1D* source = static_cast(list[j]); + MaterialParamTex1D* dest = static_cast(matParmList[i]); + dest->SetHandle(source->GetHandle()); + } + break; + case eMaterialParamTexture2D: + { + MaterialParamTex2D* source = static_cast(list[j]); + MaterialParamTex2D* dest = static_cast(matParmList[i]); + dest->SetHandle(source->GetHandle()); + dest->SetStringValue(source->GetStringValue()); + } + break; + case eMaterialParamTexture3D: + { + MaterialParamTex3D* source = static_cast(list[j]); + MaterialParamTex3D* dest = static_cast(matParmList[i]); + dest->SetHandle(source->GetHandle()); + dest->SetStringValue(source->GetStringValue()); + } + break; + case eMaterialParamTextureCUBE: + { + MaterialParamTexCube* source = static_cast(list[j]); + MaterialParamTexCube* dest = static_cast(matParmList[i]); + dest->SetHandle(source->GetHandle()); + dest->SetStringValue(source->GetStringValue()); + } + break; + default: + n_error("TODO: MaterialInstance::UpdateParamList(): current material parameter is not implemented!\n"); + break; + } } } } diff --git a/Engine/graphicsystem/Renderable/RenderObject.cc b/Engine/graphicsystem/Renderable/RenderObject.cc index 0eb2a72..6eed04a 100644 --- a/Engine/graphicsystem/Renderable/RenderObject.cc +++ b/Engine/graphicsystem/Renderable/RenderObject.cc @@ -37,6 +37,9 @@ namespace Graphic , m_Projected(true) , mbReceiveShadow(false) , mbCastShadow(false) +#ifdef __GENESIS_EDITOR__ + , m_bEditorVis(true) +#endif { m_transform = matrix44::identity(); } diff --git a/Engine/graphicsystem/Renderable/RenderObject.h b/Engine/graphicsystem/Renderable/RenderObject.h index a8c39b1..78c7109 100644 --- a/Engine/graphicsystem/Renderable/RenderObject.h +++ b/Engine/graphicsystem/Renderable/RenderObject.h @@ -79,6 +79,12 @@ namespace Graphic // !!!!!!internal call!!!!! for vis manage. const GPtr& _GetVisEnt(void) const; +#ifdef __GENESIS_EDITOR__ + void SetEditorVisible(bool bVis); + + bool IsEditorVisible() const; +#endif + protected: RenderObject(); private: @@ -89,6 +95,10 @@ namespace Graphic bool m_Projected; bool mbReceiveShadow; bool mbCastShadow; +#ifdef __GENESIS_EDITOR__ + bool m_bEditorVis; +#endif + }; inline void RenderObject::SetLayerID(LayerID rl) @@ -168,6 +178,18 @@ namespace Graphic { return m_VisEnt; } + +#ifdef __GENESIS_EDITOR__ + inline void RenderObject::SetEditorVisible(bool bVis) + { + m_bEditorVis = bVis; + } + + inline bool RenderObject::IsEditorVisible() const + { + return m_bEditorVis; + } +#endif } #endif //_RENDEROBJECT_H_ \ No newline at end of file diff --git a/Engine/graphicsystem/ViewPortWindow.cc b/Engine/graphicsystem/ViewPortWindow.cc index 5635cef..82d6eef 100644 --- a/Engine/graphicsystem/ViewPortWindow.cc +++ b/Engine/graphicsystem/ViewPortWindow.cc @@ -67,12 +67,18 @@ namespace Graphic void ViewPortWindow::ApplyWindow() { - GetRenderWindow()->EndRender(); + if (GetRenderWindow()) + { + GetRenderWindow()->EndRender(); + } } void ViewPortWindow::BeginRender() { - GetRenderWindow()->BeginRender(); + if (GetRenderWindow()) + { + GetRenderWindow()->BeginRender(); + } } void ViewPortWindow::_OnChangeSize() @@ -84,7 +90,7 @@ namespace Graphic void ViewPortWindow::ApplyGlobalShaderParam() const { - Material::GetGlobalMaterialParams()->SetVectorParam(eGShaderVecScreenSize,float4(float(),float(mDisplayMode.GetHeight()),float(0.5/mDisplayMode.GetWidth()),float(0.5/mDisplayMode.GetHeight()))); + Material::GetGlobalMaterialParams()->SetVectorParam(eGShaderVecScreenSize,float4(float(mDisplayMode.GetWidth()),float(mDisplayMode.GetHeight()),float(0.5/mDisplayMode.GetWidth()),float(0.5/mDisplayMode.GetHeight()))); } void ViewPortWindow::setupBackBuffer() diff --git a/Engine/graphicsystem/base/RenderBase.h b/Engine/graphicsystem/base/RenderBase.h index 694191b..c155673 100644 --- a/Engine/graphicsystem/base/RenderBase.h +++ b/Engine/graphicsystem/base/RenderBase.h @@ -53,7 +53,7 @@ namespace Graphic eRLWater = BIT_FLAG(4), eRLCustomBegin = BIT_FLAG(6),// eRLCustomEnd = BIT_FLAG(29),// - eRLDebug = BIT_FLAG(31), + eSL_Assist = BIT_FLAG(31), eRLSYSAll = eRLDefault | eRLWater, eRLCustomAll = BIT_FLAG(6) | BIT_FLAG(7) | 0x0fffff00 | BIT_FLAG(28) | BIT_FLAG(29), diff --git a/Engine/packagetool/FileData.cc b/Engine/packagetool/FileData.cc index d6b3d53..63d1d62 100644 --- a/Engine/packagetool/FileData.cc +++ b/Engine/packagetool/FileData.cc @@ -24,7 +24,7 @@ THE SOFTWARE. #include "stdneb.h" #include "io/filestream.h" -#include "packageTool/FileData.h" +#include "packagetool/FileData.h" #include "io/ioserver.h" namespace Pack diff --git a/Engine/packagetool/FileFormat.h b/Engine/packagetool/FileFormat.h index ea6951a..75cd364 100644 --- a/Engine/packagetool/FileFormat.h +++ b/Engine/packagetool/FileFormat.h @@ -24,7 +24,7 @@ THE SOFTWARE. #ifndef __FILE_FORMAT_H__ #define __FILE_FORMAT_H__ -#include "packageTool/PackDef.h" +#include "packagetool/PackDef.h" namespace Pack { struct FileBlock diff --git a/Engine/packagetool/Package.h b/Engine/packagetool/Package.h index 63535dd..5a79ecc 100644 --- a/Engine/packagetool/Package.h +++ b/Engine/packagetool/Package.h @@ -27,9 +27,9 @@ THE SOFTWARE. #include "core/refcounted.h" #include "core/ptr.h" -#include "packageTool/FileFormat.h" -#include "packageTool/FileTable.h" -#include "packageTool/PackDef.h" +#include "packagetool/FileFormat.h" +#include "packagetool/FileTable.h" +#include "packagetool/PackDef.h" #include "io/zipfs/ziparchive.h" namespace IO { diff --git a/Engine/packagetool/PackageSystem.cc b/Engine/packagetool/PackageSystem.cc index 865e7d8..14a715b 100644 --- a/Engine/packagetool/PackageSystem.cc +++ b/Engine/packagetool/PackageSystem.cc @@ -23,8 +23,8 @@ THE SOFTWARE. ****************************************************************************/ #include "stdneb.h" -#include "packageTool/PackageSystem.h" -#include "packageTool/Package.h" +#include "packagetool/PackageSystem.h" +#include "packagetool/Package.h" namespace Pack diff --git a/Engine/packagetool/PackageSystem.h b/Engine/packagetool/PackageSystem.h index d9ef611..f38b034 100644 --- a/Engine/packagetool/PackageSystem.h +++ b/Engine/packagetool/PackageSystem.h @@ -26,7 +26,7 @@ THE SOFTWARE. #define __PACKAGESYSTEM__ #include "core/refcounted.h" #include "core/ptr.h" -#include "packageTool/PackDef.h" +#include "packagetool/PackDef.h" #include "io/stream.h" namespace Pack { diff --git a/Engine/packagetool/PackageTool.cc b/Engine/packagetool/PackageTool.cc index 659280b..d4b4c46 100644 --- a/Engine/packagetool/PackageTool.cc +++ b/Engine/packagetool/PackageTool.cc @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "stdneb.h" -#include "packageTool/PackageTool.h" +#include "packagetool/PackageTool.h" namespace Pack { diff --git a/Engine/packagetool/PackageTool.h b/Engine/packagetool/PackageTool.h index 3dc4372..3fd57ee 100644 --- a/Engine/packagetool/PackageTool.h +++ b/Engine/packagetool/PackageTool.h @@ -25,8 +25,8 @@ THE SOFTWARE. #ifndef __PACKAGETOOL__ #define __PACKAGETOOL__ -#include "packageTool/PackDef.h" -#include "packageTool/Package.h" +#include "packagetool/PackDef.h" +#include "packagetool/Package.h" #include namespace Pack diff --git a/Engine/packagetool/PackageUtil.h b/Engine/packagetool/PackageUtil.h index 1126ba3..677c342 100644 --- a/Engine/packagetool/PackageUtil.h +++ b/Engine/packagetool/PackageUtil.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __PACKAGE_UTIL_H__ #define __PACKAGE_UTIL_H__ #include -#include "packageTool/PackDef.h" +#include "packagetool/PackDef.h" namespace Pack { typedef void (*WarningCallBack)(const char* msg); diff --git a/Engine/players/GenesisA/AndroidJNILoader.cc b/Engine/players/GenesisA/AndroidJNILoader.cc index d6ad751..53568cb 100644 --- a/Engine/players/GenesisA/AndroidJNILoader.cc +++ b/Engine/players/GenesisA/AndroidJNILoader.cc @@ -32,12 +32,17 @@ THE SOFTWARE. #include "input/inputwindowsource.h" #include "input/android/androidinputsource.h" #include "input/android/androidtouchevent.h" +#include "input/mobilekeyboardevent.h" #include "rendersystem/gles/OpenGLES.h" #include #include #include "addons/shadercompiler/ShadercompilerConfig.h" +#include "app/Jni/Jnihelper.h" +#include "addons/myguiengine/include/MyGUI_UString.h" +#include "app/guifeature/scriptgui.h" + using namespace Genesis; static DemoPublishGameApplication* g_pApp = NULL; @@ -219,6 +224,9 @@ extern "C" { JNIEXPORT void JNICALL Java_org_genesis_lib_GenesisRenderer_nativeTouchesEnd(JNIEnv * env, jobject obj, jint pIDs, jfloat pXs, jfloat pYs); JNIEXPORT void JNICALL Java_org_genesis_lib_GenesisRenderer_nativeTouchesCancel(JNIEnv * env, jobject obj, jintArray pIDs, jfloatArray pXs, jfloatArray pYs); JNIEXPORT void JNICALL Java_org_genesis_lib_GenesisRenderer_nativeKeyDown(JNIEnv * env, jobject obj, jint pKeyCode); + JNIEXPORT void JNICALL Java_org_genesis_lib_GenesisRenderer_nativeInsertText(JNIEnv* env, jobject obj, jstring text); + JNIEXPORT void JNICALL Java_org_genesis_lib_GenesisRenderer_nativeDeleteBackward(JNIEnv* env, jobject thiz); + JNIEXPORT jstring JNICALL Java_org_genesis_lib_GenesisRenderer_nativeGetContentText(); }; JNIEXPORT void Java_org_genesis_lib_GenesisRenderer_nativeConfig(JNIEnv* env, jobject thiz, jstring gamedir, jstring scenename,jboolean bShader) @@ -347,4 +355,80 @@ JNIEXPORT void Java_org_genesis_lib_GenesisRenderer_nativeKeyDown(JNIEnv * env, JNIEXPORT void Java_org_genesis_lib_GenesisRenderer_nativeOnStop(JNIEnv * env, jobject obj) { LOGI("-----------------------------nativeOnStop-----------------------------"); +} +JNIEXPORT void Java_org_genesis_lib_GenesisRenderer_nativeInsertText(JNIEnv* env, jobject obj, jstring text) +{ + const char* pszText = env->GetStringUTFChars(text, NULL); + n_warning("insert text:%s",pszText); + + //jni GetStringUTFChars get string is utf8 + MyGUI::UString guiString(pszText); + std::wstring wstr = guiString.asWStr(); + + MyGUI::UString uiStr(wstr); + + App::ScriptGui::SetFocusedEditboxCaption(uiStr); + MyGUI::InputManager::getInstance().setKeyFocusWidget(nullptr); + //// first run,and then modify + //for ( IndexT i = 0; i < wstr.length(); i++ ) + //{ + // Input::MobileKeyboardEvent keyboardEvent; + // keyboardEvent.SetType(Input::MoibleInputEvent::INPUT_EVENT_TYPE_KEY); + // keyboardEvent.SetMotionType(Input::MobileKeyboardEvent::MOTION_EVENT_CHAR); + // Input::Char characterCode = (Input::Char)wstr.at(i); + // keyboardEvent.SetChar(characterCode); + + // const GPtr& pInputSource = g_pApp->GetInputSource(); + // if (pInputSource.isvalid()) + // { + // pInputSource.downcast()->OnAndroidProc(&keyboardEvent); + // } + //} + env->ReleaseStringUTFChars(text, pszText); + + +} +JNIEXPORT void Java_org_genesis_lib_GenesisRenderer_nativeDeleteBackward(JNIEnv* env, jobject thiz) +{ + + n_warning("delete backward text"); + Input::MobileKeyboardEvent keyboardEvent; + keyboardEvent.SetType(Input::MoibleInputEvent::INPUT_EVENT_TYPE_KEY); + keyboardEvent.SetMotionType(Input::MobileKeyboardEvent::MOTION_EVENT_KEY_DOWN); + keyboardEvent.SetKeycode(Input::InputKey::Back); + + const GPtr& pInputSource = g_pApp->GetInputSource(); + if (pInputSource.isvalid()) + { + pInputSource.downcast()->OnAndroidProc(&keyboardEvent); + + //send keyrelease + keyboardEvent.SetMotionType(Input::MobileKeyboardEvent::MOTION_EVENT_KEY_UP); + pInputSource.downcast()->OnAndroidProc(&keyboardEvent); + + } +} + +JNIEXPORT jstring Java_org_genesis_lib_GenesisRenderer_nativeGetContentText() +{ + n_warning("get content text"); + JNIEnv * env = 0; + if ( !App::JniHelper::GetEnv(&env) ) + { + return 0; + } + const char * pszText = "jiu shi ai ni"; + MyGUI::UString ustr = ""; + if ( App::ScriptGui::s_pCurFocusEditBox ) + { + MyGUI::EditBox* pEditBox = dynamic_cast(App::ScriptGui::s_pCurFocusEditBox); + + if ( pEditBox ) + { + ustr = pEditBox->getCaption(); + } + } + const char* strUtf8 = ustr.asUTF8_c_str(); + return env->NewStringUTF(strUtf8); + } \ No newline at end of file diff --git a/Engine/rendersystem/base/GraphicCardCapability.h b/Engine/rendersystem/base/GraphicCardCapability.h index 194b061..0373534 100644 --- a/Engine/rendersystem/base/GraphicCardCapability.h +++ b/Engine/rendersystem/base/GraphicCardCapability.h @@ -58,6 +58,7 @@ struct GraphicCardCapability bool mDepthFormat; bool mSeparateAplhaBlend; bool mStencilTwoSize; + bool mS3TC; #endif #if RENDERDEVICE_D3D9 diff --git a/Engine/rendersystem/gles/GraphicCardCapabilityGLES.cc b/Engine/rendersystem/gles/GraphicCardCapabilityGLES.cc index 4778939..7f88498 100644 --- a/Engine/rendersystem/gles/GraphicCardCapabilityGLES.cc +++ b/Engine/rendersystem/gles/GraphicCardCapabilityGLES.cc @@ -52,6 +52,7 @@ void GraphicCardCapability::DetectGraphicCardCapsGLES20() mSeparateAplhaBlend = true; mStencilTwoSize = GLESImpl::Instance()->CheckExtension("GL_OES_packed_depth_stencil"); + mS3TC = GLESImpl::Instance()->CheckExtension("GL_EXT_texture_compression_s3tc"); } #endif } \ No newline at end of file diff --git a/Engine/script/frameworklibrary/Properties/AssemblyInfo.cs b/Engine/script/frameworklibrary/Properties/AssemblyInfo.cs index 73ca421..afff928 100644 --- a/Engine/script/frameworklibrary/Properties/AssemblyInfo.cs +++ b/Engine/script/frameworklibrary/Properties/AssemblyInfo.cs @@ -33,4 +33,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.4")] +[assembly: AssemblyFileVersion("1.0.0.9")] diff --git a/Engine/script/guilibrary/GUICommon.cs b/Engine/script/guilibrary/GUICommon.cs index 79ef4bf..ea74f41 100644 --- a/Engine/script/guilibrary/GUICommon.cs +++ b/Engine/script/guilibrary/GUICommon.cs @@ -45,7 +45,7 @@ namespace ScriptGUI } } private static ExecuteResult mExecuteResult; - private static ExecuteResult setResult(ExecuteResult ret) + internal static ExecuteResult setResult(ExecuteResult ret) { mExecuteResult = ret; return ret; diff --git a/Engine/script/guilibrary/GUIWidget.cs b/Engine/script/guilibrary/GUIWidget.cs index 66bcaf9..3ed4c9b 100644 --- a/Engine/script/guilibrary/GUIWidget.cs +++ b/Engine/script/guilibrary/GUIWidget.cs @@ -1930,6 +1930,77 @@ namespace ScriptGUI public static partial class UIItemBox { + + /// + /// 璁剧疆姘村钩婊氬姩鏉℃槸鍚﹀彲瑙 + /// + /// 鐣岄潰鍚嶇О + /// 鎺т欢鍚嶇О + /// 鍊 + /// 缁撴灉 + public static ExecuteResult SetHScrollVisible(FString layout_name, FString widget_name, bool value) + { + ItemBox ib = null; + ExecuteResult ret = FindUI(layout_name, widget_name, out ib); + if (ExecuteResult.Success == ret) + { + ib.HScrollVisible = value; + } + return ret; + } + /// + /// 姘村钩婊氬姩鏉℃槸鍚﹀彲瑙 + /// + /// 鐣岄潰鍚嶇О + /// 鎺т欢鍚嶇О + /// 杩斿洖鍊 + public static bool GetHScrollVisible(FString layout_name, FString widget_name) + { + ItemBox ib = null; + ExecuteResult ret = FindUI(layout_name, widget_name, out ib); + if (ExecuteResult.Success == ret) + { + return ib.HScrollVisible; + } + return false; + } + + /// + /// 璁剧疆鍨傜洿婊氬姩鏉℃槸鍚﹀彲瑙 + /// + /// 鐣岄潰鍚嶇О + /// 鎺т欢鍚嶇О + /// 鍊 + /// 缁撴灉 + public static ExecuteResult SetVScrollVisible(FString layout_name, FString widget_name, bool value) + { + ItemBox ib = null; + ExecuteResult ret = FindUI(layout_name, widget_name, out ib); + if (ExecuteResult.Success == ret) + { + ib.VScrollVisible = value; + } + return ret; + } + + /// + /// 鍨傜洿婊氬姩鏉℃槸鍚﹀彲瑙 + /// + /// 鐣岄潰鍚嶇О + /// 鎺т欢鍚嶇О + /// 杩斿洖鍊 + public static bool GetVScrollVisible(FString layout_name, FString widget_name) + { + ItemBox ib = null; + ExecuteResult ret = FindUI(layout_name, widget_name, out ib); + if (ExecuteResult.Success == ret) + { + return ib.VScrollVisible; + } + return false; + } + + /// /// 娣诲姞椤圭洰 /// diff --git a/Engine/script/guilibrary/ItemBox.cs b/Engine/script/guilibrary/ItemBox.cs index 5eba6d0..edff902 100644 --- a/Engine/script/guilibrary/ItemBox.cs +++ b/Engine/script/guilibrary/ItemBox.cs @@ -46,7 +46,12 @@ namespace ScriptGUI /// 鍔犺浇鍚庢槸鍚﹀彲瑙 public ExecuteResult AddLayout(String file_name, bool delay_load, bool visible) { - return GUI.RegisterLayout(mParent.ParentLayout.Name, mItem.Name, mLayoutName, file_name, delay_load, visible);//sender + if (!mInit) + { + mInit = true; + return GUI.RegisterLayout(mParent.ParentLayout.Name, mItem.Name, mLayoutName, file_name, delay_load, visible);//sender + } + return GUI.setResult(ExecuteResult.False); } internal void Clear() @@ -90,6 +95,7 @@ namespace ScriptGUI private Widget mParent; private Widget mItem; private FString mLayoutName; + private bool mInit = false; } internal class ItemBox : DDContainer { @@ -427,6 +433,31 @@ namespace ScriptGUI { ICall_resetDrag(mInstance.Ptr); } + + internal bool VScrollVisible + { + get + { + return ICall_isVisibleVScroll(mInstance.Ptr); + } + set + { + ICall_setVisibleVScroll(mInstance.Ptr, value); + } + } + + internal bool HScrollVisible + { + get + { + return ICall_isVisibleHScroll(mInstance.Ptr); + } + set + { + ICall_setVisibleHScroll(mInstance.Ptr, value); + } + } + protected ItemInfo findItem(Instance inst) { ItemInfo info = null; @@ -531,7 +562,6 @@ namespace ScriptGUI [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static uint ICall_getIndexByWidget(IntPtr itembox_ptr, IntPtr widget_ptr); - [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static IntPtr ICall_getWidgetDrag(IntPtr itembox_ptr); @@ -542,7 +572,13 @@ namespace ScriptGUI extern private static new void ICall_resetDrag(IntPtr itembox_ptr); - //[MethodImplAttribute(MethodImplOptions.InternalCall)] - //extern private static void ICall_(IntPtr itembox_ptr, uint index); + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern private static void ICall_setVisibleVScroll(IntPtr itembox_ptr, bool _value); + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern private static bool ICall_isVisibleVScroll(IntPtr itembox_ptr); + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern private static void ICall_setVisibleHScroll(IntPtr itembox_ptr, bool _value); + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern private static bool ICall_isVisibleHScroll(IntPtr itembox_ptr); } } diff --git a/Engine/script/guilibrary/Properties/AssemblyInfo.cs b/Engine/script/guilibrary/Properties/AssemblyInfo.cs index a40dcd4..6fb3c72 100644 --- a/Engine/script/guilibrary/Properties/AssemblyInfo.cs +++ b/Engine/script/guilibrary/Properties/AssemblyInfo.cs @@ -33,4 +33,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.4")] +[assembly: AssemblyFileVersion("1.0.0.9")] diff --git a/Engine/script/guilibrary/ScriptGUILibrary.csproj b/Engine/script/guilibrary/ScriptGUILibrary.csproj index 252c7cb..fd6f77e 100644 --- a/Engine/script/guilibrary/ScriptGUILibrary.csproj +++ b/Engine/script/guilibrary/ScriptGUILibrary.csproj @@ -28,6 +28,7 @@ 4 True AllRules.ruleset + bin\Debug\ScriptGUILibrary.XML pdbonly @@ -38,6 +39,7 @@ 4 True AllRules.ruleset + bin\Release\ScriptGUILibrary.XML @@ -119,6 +121,7 @@ --> - xcopy $(TargetPath) $(ProjectDir)..\..\..\..\genesis_editor\bin\win32\DefaultAssets\Script /q /y + xcopy $(TargetPath) $(ProjectDir)..\..\..\..\genesis_editor\bin\win32\DefaultAssets\Script /q /y +xcopy $(TargetDir)$(TargetName).XML $(ProjectDir)..\..\..\..\genesis_editor\bin\win32\DefaultAssets\Script /q /y \ No newline at end of file diff --git a/Engine/script/runtimelibrary/GraphicSystem.cs b/Engine/script/runtimelibrary/GraphicSystem.cs index 9948d9f..65965b4 100644 --- a/Engine/script/runtimelibrary/GraphicSystem.cs +++ b/Engine/script/runtimelibrary/GraphicSystem.cs @@ -36,13 +36,23 @@ namespace ScriptRuntime /// - /// 鑾峰彇鍦烘櫙涓殑涓荤浉鏈 + /// 鑾峰緱褰撳墠姝e湪娓叉煋鐨勭浉鏈(宸茶繃鏈燂紝璇风敤GetRenderingCamera()锛屼唬鏇) /// /// 鐩告満缁勪欢 + [System.Obsolete("Please, use fuction GetRenderingCamera() instead.")] public static CameraComponent GetSceneCamera() { return ICall_GraphicSystem_GetSceneCamera(); } + /// + /// 鑾峰緱褰撳墠姝e湪娓叉煋鐨勭浉鏈 + /// + /// 鐩告満缁勪欢 + public static CameraComponent GetRenderingCamera() + { + return ICall_GraphicSystem_GetRenderingCamera(); + } + /// /// 浠ョ浉鏈轰綔涓哄弬鏁帮紝娓叉煋鍦烘櫙 /// @@ -81,15 +91,7 @@ namespace ScriptRuntime { return ICall_GraphicSystem_GetHeight(); } - /// - /// 鏍规嵁鐩告満绫诲瀷鑾峰緱鐩告満鐨凴enderToTexture - /// - /// 鐩告満绫诲瀷鍙傛暟锛屽煎彲閫:eCO_InvalidCamera,eCO_Shadow,eCO_Main,eCO_PuppetMain - /// 杩斿洖RenderToTexture - public static RenderToTexture GetCameraRenderToTextureByCameraType(int type) - { - return ICall_GraphicSystem_GetCameraRenderToTextureByCameraType(type); - } + /// /// 鏍规嵁璧勬簮ID鍒涘缓鏉愯川瀹炰緥 /// @@ -122,6 +124,9 @@ namespace ScriptRuntime [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static CameraComponent ICall_GraphicSystem_GetSceneCamera(); + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern private static CameraComponent ICall_GraphicSystem_GetRenderingCamera(); + [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static void ICall_GraphicSystem_RenderCamera(Camera render); @@ -134,9 +139,6 @@ namespace ScriptRuntime [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static int ICall_GraphicSystem_GetHeight(); - [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static RenderToTexture ICall_GraphicSystem_GetCameraRenderToTextureByCameraType(int type); - [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static MaterialInstance ICall_GraphicSystem_CreateMaterial(String resID); diff --git a/Engine/script/runtimelibrary/Input.cs b/Engine/script/runtimelibrary/Input.cs index fe25027..d7bf91b 100644 --- a/Engine/script/runtimelibrary/Input.cs +++ b/Engine/script/runtimelibrary/Input.cs @@ -309,7 +309,7 @@ namespace ScriptRuntime for (int i = 0; i < count; ++i) { MouseEvent _event = new MouseEvent(); - ICall_Input_GetCurrentMouseButtonEvent(i, out _event.button, out _event.eventType); + ICall_Input_GetCurrentMouseButtonEvent(i, out _event.button, out _event.eventType, out _event.absolutePos, out _event.relativePos); events.Add(_event); } return events.ToArray(); @@ -326,7 +326,7 @@ namespace ScriptRuntime for (int i = 0; i < count; ++i) { TouchEvent _event = new TouchEvent(); - ICall_Input_GetCurrentTouchEvent(i, out _event.id, out _event.eventType); + ICall_Input_GetCurrentTouchEvent(i, out _event.id, out _event.eventType, out _event.absolutePos, out _event.relativePos); events.Add(_event); } return events.ToArray(); @@ -397,12 +397,12 @@ namespace ScriptRuntime extern private static int ICall_Input_GetCurrentMouseButtonEventCount(); [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_Input_GetCurrentMouseButtonEvent(int index, out MouseCode code, out InputEventType _event); + extern private static void ICall_Input_GetCurrentMouseButtonEvent(int index, out MouseCode code, out InputEventType _event, out Vector2 absolutePos, out Vector2 relativePos); [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static int ICall_Input_GetCurrentTouchEventCount(); [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_Input_GetCurrentTouchEvent(int index, out int id, out InputEventType _event); + extern private static void ICall_Input_GetCurrentTouchEvent(int index, out int id, out InputEventType _event, out Vector2 absolutePos, out Vector2 relativePos); } } \ No newline at end of file diff --git a/Engine/script/runtimelibrary/InputEvent.cs b/Engine/script/runtimelibrary/InputEvent.cs index 0eb52d4..18290bd 100644 --- a/Engine/script/runtimelibrary/InputEvent.cs +++ b/Engine/script/runtimelibrary/InputEvent.cs @@ -232,6 +232,8 @@ namespace ScriptRuntime { public MouseCode button; public InputEventType eventType; + public Vector2 relativePos; + public Vector2 absolutePos; } /// @@ -241,6 +243,8 @@ namespace ScriptRuntime { public int id; public InputEventType eventType; + public Vector2 relativePos; + public Vector2 absolutePos; } } \ No newline at end of file diff --git a/Engine/script/runtimelibrary/MaterialInstance.cs b/Engine/script/runtimelibrary/MaterialInstance.cs index 32c76ed..732ae97 100644 --- a/Engine/script/runtimelibrary/MaterialInstance.cs +++ b/Engine/script/runtimelibrary/MaterialInstance.cs @@ -108,25 +108,5 @@ namespace ScriptRuntime { ICall_Material_SetValueMatrix44(this, paramName, ref value); } - - /// - /// 璁剧疆鐫鑹插櫒涓殑鍏ㄥ眬鐭╅樀鍙傛暟,姣斿鎽勫儚鏈哄彉鎹㈢煩闃 - /// - /// 鐫鑹插櫒涓殑鍏ㄥ眬鐭╅樀鍙傛暟绫诲瀷 - /// 瑕佽缃殑鐭╅樀鐨勫 - public static void SetGlobalValue(GlobalShaderMatrix index,ref Matrix44 value) - { - ICall_Material_SetGlobalMatrix(index, ref value); - } - - /// - /// 璁剧疆鐫鑹插櫒涓殑鍏ㄥ眬鍚戦噺鍙傛暟,姣斿鐜鍏 - /// - /// 鐫鑹插櫒涓殑鍏ㄥ眬鍚戦噺鍙傛暟绫诲瀷 - /// 瑕佽缃殑鍚戦噺鐨勫 - public static void SetGlobalValue(GlobalShaderVector index,ref Vector4 value) - { - ICall_Material_SetGlobalVector(index, ref value); - } } } diff --git a/Engine/script/runtimelibrary/MaterialInstance_register.cs b/Engine/script/runtimelibrary/MaterialInstance_register.cs index 6b40a1c..62a709e 100644 --- a/Engine/script/runtimelibrary/MaterialInstance_register.cs +++ b/Engine/script/runtimelibrary/MaterialInstance_register.cs @@ -50,11 +50,5 @@ namespace ScriptRuntime [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static void ICall_Material_SetTextureResource(MaterialInstance self, String paramName, String id, int priority); - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_Material_SetGlobalMatrix(GlobalShaderMatrix index, ref Matrix44 value); - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_Material_SetGlobalVector(GlobalShaderVector index, ref Vector4 value); } } diff --git a/Engine/script/runtimelibrary/PhysicsBodyComponent.cs b/Engine/script/runtimelibrary/PhysicsBodyComponent.cs index 71949fe..c390b3b 100644 --- a/Engine/script/runtimelibrary/PhysicsBodyComponent.cs +++ b/Engine/script/runtimelibrary/PhysicsBodyComponent.cs @@ -67,6 +67,41 @@ namespace ScriptRuntime ICall_PhysicsBodyComponent_SetLinearVelocity(this, ref value); } } + + /// + /// 璇诲啓灞炴э細鐗╃悊浣撳父閫熷害 + /// + public Vector3 ConstLineVelocity + { + get + { + Vector3 temp; + ICall_PhysicsBodyComponent_GetConstLineVelocity(this, out temp); + return temp; + } + set + { + ICall_PhysicsBodyComponent_SetConstLineVelocity(this, ref value); + } + } + + /// + /// 璇诲啓灞炴э細鐗╃悊浣撳父瑙掗熷害 + /// + public Vector3 ConstAngularVelocity + { + get + { + Vector3 temp; + ICall_PhysicsBodyComponent_GetConstAngularVelocity(this, out temp); + return temp; + } + set + { + ICall_PhysicsBodyComponent_SetConstAngularVelocity(this, ref value); + } + } + /// /// 璇诲啓灞炴э細鐗╃悊浣撶灛鏃惰閫熷害 /// @@ -150,7 +185,7 @@ namespace ScriptRuntime } } /// - /// 璇诲啓灞炴э細鏄惁鍙戠敓纰版挒妫娴 + /// 璇诲啓灞炴э細鏄惁鍚敤鐗╃悊妯℃嫙 /// public bool Collision { @@ -166,11 +201,11 @@ namespace ScriptRuntime /// /// 璇诲啓灞炴э細缁欑墿鐞嗕綋娣诲姞鎭掑姏 /// - public Vector4 ConstForce + public Vector3 ConstForce { get { - Vector4 temp; + Vector3 temp; ICall_PhysicsBodyComponent_GetConstForce(this, out temp); return temp; } @@ -182,11 +217,11 @@ namespace ScriptRuntime /// /// 璇诲啓灞炴э細缁欑墿鐞嗕綋娣诲姞鎭掑畾杞煩 /// - public Vector4 ConstTorque + public Vector3 ConstTorque { get { - Vector4 temp; + Vector3 temp; ICall_PhysicsBodyComponent_GetConstTorque(this, out temp); return temp; } @@ -212,7 +247,7 @@ namespace ScriptRuntime ICall_PhysicsBodyComponent_MoveToPostion(this, ref f3Pos); } /// - /// 鎸夌収缁欏畾鐨勮搴﹂夋嫨鐗╃悊浣 + /// 鎸夌収缁欏畾鐨勮搴︽棆杞墿鐞嗕綋 /// /// 鏃嬭浆瑙 public void RotationRotation(ref Quaternion rot) @@ -238,51 +273,7 @@ namespace ScriptRuntime ICall_PhysicsBodyComponent_AddForce(this, ref force, forcetype, bWakeUp); } /// - /// 鍦ㄤ笘鐣屼綅缃坊鍔犲姏 - /// - /// 鍔 - /// 鍔涚殑鏂藉姞浣嶇疆 - /// 鍔涚殑绫诲瀷 - /// 鏄惁鍞ら啋Actor - public void AddForceAtPos(Vector3 force, Vector3 pos, ForceType forcetype, bool bWakeUp) - { - ICall_PhysicsBodyComponent_AddForceAtPos(this, ref force, ref pos, forcetype, bWakeUp); - } - /// - /// 鍦ㄤ笘鐣屼綅缃坊鍔犳湰鍦板姏 - /// - /// 鍔 - /// 鍔涚殑鏂藉姞浣嶇疆 - /// 鍔涚殑绫诲瀷 - /// 鏄惁鍞ら啋Actor - public void AddLocalForceAtPos(Vector3 force, Vector3 pos, ForceType forcetype, bool bWakeUp) - { - ICall_PhysicsBodyComponent_AddLocalForceAtPos(this, ref force, ref pos, forcetype, bWakeUp); - } - /// - /// 鍦ㄦ湰鍦颁綅缃坊鍔犲姏 - /// - /// 鍔 - /// 鍔涚殑鏂藉姞浣嶇疆 - /// 鍔涚殑绫诲瀷 - /// 鏄惁鍞ら啋Actor - public void AddForceAtLocalPos(Vector3 force, Vector3 pos, ForceType forcetype, bool bWakeUp) - { - ICall_PhysicsBodyComponent_AddForceAtLocalPos(this, ref force, ref pos, forcetype, bWakeUp); - } - /// - /// 鍦ㄦ湰鍦颁綅缃坊鍔犳湰鍦板姏 - /// - /// 鍔 - /// 鍔涚殑鏂藉姞浣嶇疆 - /// 鍔涚殑绫诲瀷 - /// 鏄惁鍞ら啋Actor - public void AddLocalForceAtLocalPos(Vector3 force, Vector3 pos, ForceType forcetype, bool bWakeUp) - { - ICall_PhysicsBodyComponent_AddLocalForceAtLocalPos(this,ref force,ref pos, forcetype, bWakeUp); - } - /// - /// 鑾峰彇鎸囧畾浣嶇疆鐗╃悊褰㈢姸 + /// 鑾峰彇鎸囧畾绱㈠紩鐨勭墿鐞嗗舰鐘 /// /// 鎸囧畾浣嶇疆 /// 鐗╃悊褰㈢姸鎸囬拡 @@ -395,7 +386,7 @@ namespace ScriptRuntime } } /// - /// 璇诲啓灞炴э細瑙掕壊鎺у埗鍣ㄨ兌鍥婁綋楂樺害 + /// 璇诲啓灞炴э細瑙掕壊鎺у埗鍣ㄨ兌鍥婁綋鐨勪腑蹇 /// public Vector3 LocalCenter { diff --git a/Engine/script/runtimelibrary/PhysicsBodyComponent_register.cs b/Engine/script/runtimelibrary/PhysicsBodyComponent_register.cs index 9f6bafc..aa400b9 100644 --- a/Engine/script/runtimelibrary/PhysicsBodyComponent_register.cs +++ b/Engine/script/runtimelibrary/PhysicsBodyComponent_register.cs @@ -42,6 +42,18 @@ namespace ScriptRuntime [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static void ICall_PhysicsBodyComponent_GetAngularVelocity(PhysicsBodyComponent self, out Vector3 velocity); + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern private static void ICall_PhysicsBodyComponent_GetConstLineVelocity(PhysicsBodyComponent self, out Vector3 force); + + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern private static void ICall_PhysicsBodyComponent_SetConstLineVelocity(PhysicsBodyComponent self, ref Vector3 force); + + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern private static void ICall_PhysicsBodyComponent_SetConstAngularVelocity(PhysicsBodyComponent self, ref Vector3 torque); + + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern private static void ICall_PhysicsBodyComponent_GetConstAngularVelocity(PhysicsBodyComponent self, out Vector3 torque); + [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static void ICall_PhysicsBodyComponent_SetLinearDamping(PhysicsBodyComponent self, float scalar); @@ -79,22 +91,22 @@ namespace ScriptRuntime extern private static bool ICall_PhysicsBodyComponent_GetCollision(PhysicsBodyComponent self); [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_PhysicsBodyComponent_SetConstForce(PhysicsBodyComponent self, ref Vector4 force); + extern private static void ICall_PhysicsBodyComponent_SetConstForce(PhysicsBodyComponent self, ref Vector3 force); [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_PhysicsBodyComponent_GetConstForce(PhysicsBodyComponent self, out Vector4 force); + extern private static void ICall_PhysicsBodyComponent_GetConstForce(PhysicsBodyComponent self, out Vector3 force); [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_PhysicsBodyComponent_SetConstTorque(PhysicsBodyComponent self, ref Vector4 torque); + extern private static void ICall_PhysicsBodyComponent_SetConstTorque(PhysicsBodyComponent self, ref Vector3 torque); [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_PhysicsBodyComponent_GetConstTorque(PhysicsBodyComponent self, out Vector4 torque); + extern private static void ICall_PhysicsBodyComponent_GetConstTorque(PhysicsBodyComponent self, out Vector3 torque); [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_PhysicsBodyComponent_SetGravityCenter(PhysicsBodyComponent self, ref Vector4 pos); + extern private static void ICall_PhysicsBodyComponent_SetGravityCenter(PhysicsBodyComponent self, ref Vector3 pos); [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_PhysicsBodyComponent_GetGravityCenter(PhysicsBodyComponent self, out Vector4 pos); + extern private static void ICall_PhysicsBodyComponent_GetGravityCenter(PhysicsBodyComponent self, out Vector3 pos); [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static void ICall_PhysicsBodyComponent_MovePostion(PhysicsBodyComponent self, ref Vector3 pos); @@ -111,18 +123,6 @@ namespace ScriptRuntime [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static void ICall_PhysicsBodyComponent_AddForce(PhysicsBodyComponent self,ref Vector3 force, ForceType forcetype, bool bWakeUp); - [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_PhysicsBodyComponent_AddForceAtPos(PhysicsBodyComponent self, ref Vector3 force, ref Vector3 pos, ForceType forcetype, bool bWakeUp); - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_PhysicsBodyComponent_AddLocalForceAtPos(PhysicsBodyComponent self, ref Vector3 force, ref Vector3 pos, ForceType forcetype, bool bWakeUp); - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_PhysicsBodyComponent_AddForceAtLocalPos(PhysicsBodyComponent self, ref Vector3 force, ref Vector3 pos, ForceType forcetype, bool bWakeUp); - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern private static void ICall_PhysicsBodyComponent_AddLocalForceAtLocalPos(PhysicsBodyComponent self, ref Vector3 force, ref Vector3 pos, ForceType forcetype, bool bWakeUp); - [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static PhysicsShape ICall_PhysicsEntity_GetShapeAt(PhysicsBodyComponent self, int index); diff --git a/Engine/script/runtimelibrary/Properties/AssemblyInfo.cs b/Engine/script/runtimelibrary/Properties/AssemblyInfo.cs index 550408c..194cd24 100644 --- a/Engine/script/runtimelibrary/Properties/AssemblyInfo.cs +++ b/Engine/script/runtimelibrary/Properties/AssemblyInfo.cs @@ -33,4 +33,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.4")] +[assembly: AssemblyFileVersion("1.0.0.9")] diff --git a/Engine/script/runtimelibrary/RenderToTexture.cs b/Engine/script/runtimelibrary/RenderToTexture.cs index 1f24485..5962aa8 100644 --- a/Engine/script/runtimelibrary/RenderToTexture.cs +++ b/Engine/script/runtimelibrary/RenderToTexture.cs @@ -88,7 +88,7 @@ namespace ScriptRuntime R32F = _PixelFormat.R32F, G32R32F = _PixelFormat.G32R32F, A32B32G32R32F = _PixelFormat.A32B32G32R32F, - + A8R8G8B8 = _PixelFormat.A8R8G8B8, } public enum ClearFlag diff --git a/Engine/script/runtimelibrary/ScriptComponent.cs b/Engine/script/runtimelibrary/ScriptComponent.cs index 08a8ab8..9a897ea 100644 --- a/Engine/script/runtimelibrary/ScriptComponent.cs +++ b/Engine/script/runtimelibrary/ScriptComponent.cs @@ -49,7 +49,68 @@ namespace ScriptRuntime { return ICall_ScriptComponent_GetScriptByName(this, name); } + + /// + /// 閫氳繃绫诲悕鑾峰緱鑴氭湰瀹炰緥 + /// + /// 绫诲悕 + /// 杩斿洖鑴氭湰瀹炰緥 + public TScript GetScriptObject() + where TScript : ScriptableClass + { + int count = ICall_ScriptComponent_GetScriptInstanceCount(this); + for (int i = 0; i < count; ++i) + { + ScriptableClass sc = ICall_ScriptComponent_GetScriptObject(this, i); + if (null != sc) + { + if (sc is TScript) + { + return sc as TScript; + } + } + } + return null; + } + + /// + /// 鏄惁鎸傝浇浜嗘煇涓被鍨嬬殑鑴氭湰 + /// + /// 绫诲悕 + /// 缁撴灉 + public bool ContainScript() + { + int count = ICall_ScriptComponent_GetScriptInstanceCount(this); + for (int i = 0; i < count; ++i) + { + ScriptableClass sc = ICall_ScriptComponent_GetScriptObject(this, i); + if (null != sc) + { + if (sc is TScript) + { + return true; + } + } + } + return false; + } + + public int GetScriptObjectCount() + { + return ICall_ScriptComponent_GetScriptInstanceCount(this); + } + + public ScriptableClass GetScriptObject(int index) + { + return ICall_ScriptComponent_GetScriptObject(this, index); + } + [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static ScriptableClass ICall_ScriptComponent_GetScriptByName(ScriptComponent self, String name); + + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern private static int ICall_ScriptComponent_GetScriptInstanceCount(ScriptComponent self); + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern private static ScriptableClass ICall_ScriptComponent_GetScriptObject(ScriptComponent self, int index); } } diff --git a/Engine/script/runtimelibrary/ScriptRuntimeLibrary.csproj b/Engine/script/runtimelibrary/ScriptRuntimeLibrary.csproj index ef8a178..94f133e 100644 --- a/Engine/script/runtimelibrary/ScriptRuntimeLibrary.csproj +++ b/Engine/script/runtimelibrary/ScriptRuntimeLibrary.csproj @@ -79,7 +79,6 @@ -